bindings generator

This commit is contained in:
Alwin Berger 2025-04-25 10:16:00 +00:00
parent e1179c292d
commit ae9a4029d0
7 changed files with 29 additions and 17 deletions

View File

@ -1,6 +0,0 @@
#include <FreeRTOS.h>
#include <FreeRTOSConfig.h>
#include <task.h>
#include <list.h>
#include "../../Source/tasks.c"

View File

@ -0,0 +1,8 @@
#include <FreeRTOS.h>
#include <FreeRTOSConfig.h>
#include <task.h>
#include <list.h>
#include <queue.h>
#include "../../../Source/queue.c"
#include "../../../Source/tasks.c"

View File

@ -0,0 +1,4 @@
#![allow(non_camel_case_types,non_snake_case,non_upper_case_globals,deref_nullptr,unused)]
use serde::{Deserialize, Serialize};
/*========== Start of generated Code =============*/

View File

@ -0,0 +1,17 @@
#!/bin/sh
set -e
rm -f bindings.i bindings.rs _bindings.rs _header.rs
arm-none-eabi-gcc -E bindgen.h \
-I ../../../Source/include -I ../../../Source/portable/GCC/ARM_CM3 -I .. > bindings.i
bindgen bindings.i --ignore-functions --no-layout-tests \
--allowlist-type "TaskStatus_t|List_t|QueueHandle_t|Queue_t|TCB_t" \
-- --target=armv7a-none-eabi > _bindings.rs
while IFS= read -r line; do
echo pub type $line = "::std::os::raw::c_uint;" | sed -f transform.sed
done <<< "$(grep -oE "\*mut [A-Z:_a-z0-9]*|\*const [A-Z:a-z_]*char" _bindings.rs | sort | uniq)" > _header.rs
cat header.rs _header.rs _bindings.rs | sed -f transform.sed > bindings.rs
rm -f bindings.i _bindings.rs _header.rs

View File

@ -1,8 +0,0 @@
// Manual Types
pub type xLIST_ITEM_ptr = ::std::os::raw::c_uint;
pub type xLIST_ptr = ::std::os::raw::c_uint;
pub type ListItem_t_ptr = ::std::os::raw::c_uint;
pub type StackType_t_ptr = ::std::os::raw::c_uint;
pub type char_ptr = ::std::os::raw::c_uint;
pub type void_ptr = ::std::os::raw::c_uint;

View File

@ -1,3 +0,0 @@
while IFS= read -r line; do
echo pub type $line = "::std::os::raw::c_uint;" | sed -f transform.sed
done <<< "$(grep -oE "\*mut [A-Z:_a-z]*|\*const [A-Z:a-z_]*char" build/bindings.rs | sort | uniq)" > build/header.rs