gtk-rs / gtk4-rs

Rust bindings of GTK 4
https://gtk-rs.org/gtk4-rs/
MIT License
1.87k stars 175 forks source link

[HELP] bindings not regenerating #1488

Closed werdahias closed 1 year ago

werdahias commented 1 year ago

I tried to regenerate the bindings for gdk4-wayland-sys but had no sucess so far. I copied the relevant gir files from the -dev packages in debian to the build directory and deleted the lines from the freetype2 gir file before generation so it can be run. This fails though:

...
cp /usr/share/gir-1.0/GLib-2.0.gir /<<PKGBUILDDIR>>
cp /usr/share/gir-1.0/freetype2-2.0.gir /<<PKGBUILDDIR>>
cp /usr/share/gir-1.0/GObject-2.0.gir /<<PKGBUILDDIR>>
cp /usr/share/gir-1.0/Gio-2.0.gir /<<PKGBUILDDIR>>
cp /usr/share/gir-1.0/GdkWayland-4.0.gir /<<PKGBUILDDIR>>
cp /usr/share/gir-1.0/HarfBuzz-0.0.gir /<<PKGBUILDDIR>>
cp /usr/share/gir-1.0/Gdk-4.0.gir /<<PKGBUILDDIR>>
cp /usr/share/gir-1.0/Pango-1.0.gir /<<PKGBUILDDIR>>
cp /usr/share/gir-1.0/GdkPixbuf-2.0.gir /<<PKGBUILDDIR>>
cp /usr/share/gir-1.0/GModule-2.0.gir /<<PKGBUILDDIR>>
# We need to delete some lines from the freetype2 git file to allow generation
sed -i '11,20d' /<<PKGBUILDDIR>>/freetype2-2.0.gir
sed -i 's/girs_directories\s=\s\[\"\.\.\/\.\.\/gir-files\"\]/girs_directories = \[\".\"\]/' /<<PKGBUILDDIR>>/Gir.toml
gir -o .
Error: "GirXml: ./freetype2-2.0.gir:11:1 Unexpected end of stream: still inside the root element"

after sed'ing the freetype gir file it looks like this:

<?xml version="1.0"?>
<repository version="1.2"
            xmlns="http://www.gtk.org/introspection/core/1.0"
            xmlns:c="http://www.gtk.org/introspection/c/1.0">
  <namespace name="freetype2" version="2.0"
         c:identifier-prefixes="FT"
         c:symbol-prefixes="FT">
    <record name="Bitmap" c:type="FT_Bitmap"/>
    <record name="Face" c:type="FT_Face"/>
    <record name="Library" c:type="FT_Library"/>
  </namespace>
</repository>

Any idea what I am missing here ?

sdroege commented 1 year ago

Did you check the fixup scripts in the gir-files repo? Generally, any .gir files that are not the ones from there are unsupported and it's your job to fix them up in a way that things succeed.

Also you want to make sure they're exactly from the same version, otherwise you will generate bindings with more (newer) or less (older) API, broken API (annotations that were fixed in the meantime), etc.

werdahias commented 1 year ago

ah, thanks, running xmlstarlet on freetype solved this. sorry for the noise.

sdroege commented 1 year ago

Make sure to diff the generated code against the one from the actual releases to catch any API difference or bugs.

werdahias commented 1 year ago

thanks, will do before upload.