generate better headers

This commit is contained in:
Alwin Berger 2022-02-16 15:18:15 +01:00
parent 45dec7fb56
commit 1735458d20
3 changed files with 8 additions and 3 deletions

View File

@ -134,9 +134,10 @@ ${BUILD_DIR}/bindgen.i : bindgen.h
${BUILD_DIR}/bindgen.rs : ${BUILD_DIR}/bindgen.i
bindgen --allowlist-type "List_t|TaskHandle_t|TaskStatus_t|TCB_t" ${BUILD_DIR}/bindgen.i -o ${BUILD_DIR}/bindings.rs
bindgen --no-layout-tests --allowlist-type "List_t|TaskHandle_t|TaskStatus_t|TCB_t" ${BUILD_DIR}/bindgen.i -o ${BUILD_DIR}/bindings.rs
sh write_header.sh
sed -i -f transform.sed build/bindings.rs
cat typeheader.rs build/bindings.rs > build/bindings_2.rs
cat build/header.rs build/bindings.rs > build/bindings_2.rs
# --ctypes-prefix compat_types
# bindgen --new-type-alias void --default-alias-style new_type --allowlist-type "List_t|TaskHandle_t|TaskStatus_t|TCB_t" ${BUILD_DIR}/bindgen.i -o ${BUILD_DIR}/bindings.rs

View File

@ -1,4 +1,5 @@
s@::c_ulong@::c_uint@
s@*mut ::std::os::raw::c_void@void_ptr@
s@*const ::std::os::raw::c_char@char_ptr@
s@*mut \([A-Z,_,a-z]*\),@\1_ptr,@
s@*mut \([A-Z_a-z]*\)@\1_ptr@
s@Debug, Copy, Clone@Debug, Copy, Clone, Default, Serialize, Deserialize@

View File

@ -0,0 +1,3 @@
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