Use a sed script instead of a shell script to fix up autogenerated WINGs FFI bindings #37

Merged
trurl merged 1 commits from trurl/wmaker:riir.bindgen_wings_use_sed into riir 2026-05-08 10:39:42 -04:00
3 changed files with 13 additions and 24 deletions

View File

@@ -18,7 +18,7 @@ RUST_EXTRA = \
Cargo.lock \
Cargo.toml
src/WINGsP.rs: ../WINGs/WINGsP.h ../../wrlib/wraster.h ../WINGs/WINGs.h ../WINGs/WUtil.h Makefile patch_WINGsP.sh
src/WINGsP.rs: ../WINGs/WINGsP.h ../../wrlib/wraster.h ../WINGs/WINGs.h ../WINGs/WUtil.h Makefile patch_WINGsP.sed
$(BINDGEN) ../WINGs/WINGsP.h \
--no-recursive-allowlist \
--allowlist-type "^W_.+|^WM(View|Array|DragOperationType|Point|Data|OpenPanel|SavePanel|HashTable|DraggingInfo|SelectionProcs|Rect|EventProc|Widget|Size|Pixmap|FilePanel|List|ListItem)" \
@@ -55,7 +55,8 @@ src/WINGsP.rs: ../WINGs/WINGsP.h ../../wrlib/wraster.h ../WINGs/WINGs.h ../WINGs
-o src/WINGsP.rs -- \
@PANGO_CFLAGS@ \
-I../../wrlib \
-I.. && ./patch_WINGsP.sh src/WINGsP.rs
-I.. \
&& sed -i -r -f patch_WINGsP.sed src/WINGsP.rs
Cargo.lock:
$(CARGO) build

10
WINGs/wings-rs/patch_WINGsP.sed Executable file
View File

@@ -0,0 +1,10 @@
# This file provides ad-hoc fixups to the WINGsP bindings provided by bindgen:
# - Import Xlib symbols so that everything compiles.
# - Import FFI symbols from Rust bindings and rewrites.
# - The opaque type names _XftDraw and _XftFont are replaced with void*.
# - Pango bindings aren't yet pulled into our Rust code, so PangoLayout is also demoted to void*.
1s/^/use wrlib_rs::ffi::*;\nuse wutil_rs::range::ffi::*;\nuse x11::xlib::*;\nuse crate::ffi::*;\n\n/
s/_XftDraw/::std::ffi::c_void/g
s/_XftFont/::std::ffi::c_void/g
s/PangoLayout/::std::ffi::c_void/g

View File

@@ -1,22 +0,0 @@
#!/bin/sh
# This file provides ad-hoc fixups to the WINGsP provided by bindgen:
# - Import Xlib symbols so that everything compiles.
# - The opaque type names _XftDraw and _XftFont are replaced with void*.
# - Pango bindings aren't yet pulled into our Rust code, so PangoLayout is also demoted to void*.
set -e
if [ "x$1" = "x" ]; then
echo "Usage: $(basename $0) <file to patch>"
exit 1
fi
FILE="$1"
exec sed -i -r \
-e "1s/^/use wrlib_rs::ffi::*;\nuse wutil_rs::range::ffi::*;\nuse x11::xlib::*;\nuse crate::ffi::*;\n\n/" \
-e "s/_XftDraw/::std::ffi::c_void/g" \
-e "s/_XftFont/::std::ffi::c_void/g" \
-e "s/PangoLayout/::std::ffi::c_void/g" \
"$1"