gtk-rs / gir

Tool to generate rust bindings and user API for glib-based libraries
https://gtk-rs.org/gir/book/
MIT License
230 stars 102 forks source link

Panic on GIR codegen #1036

Open SolarLiner opened 3 years ago

SolarLiner commented 3 years ago

I'm trying to generate a sys crate for upower-glib and the tool panics:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/codegen/sys/cargo_toml.rs:117:49
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
   1: core::panicking::panic_fmt
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
   2: core::panicking::panic
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:50
   3: libgir::codegen::sys::cargo_toml::generate
   4: libgir::codegen::sys::generate
   5: gir::main

I have attached the related GIR file, to which I have applied the fix.sh script, without effect on the panic.

UPowerGlib-1.0.gir.txt

bilelmoussaoui commented 3 years ago

Can you paste the Gir.toml configuration as well?

SolarLiner commented 3 years ago
[options]
work_mode = "sys"
library = "UPowerGlib"
version = "1.0"
target_path = "./upower-sys"
girs_dir = "./gir-files"

external_libraries = [
    "GObject",
    "Glib",
]
bilelmoussaoui commented 2 years ago

I see why it fails, the GIR file lacks a package name like here https://github.com/gtk-rs/gir-files/blob/master/Atk-1.0.gir#L7, we need a better error message for such case

arcnmx commented 2 years ago

I just ran into this in the wild, but from what I can tell the package attribute is deprecated, and so presumably this shouldn't be an error or required at all?