-
Notifications
You must be signed in to change notification settings - Fork 1
Generate Cargo build files and make the crate template more accepting #1
base: master
Are you sure you want to change the base?
Conversation
The type must still be a pointer so that for example function arguments continue to be pointers if they are an array of something.
Use the data available from the gir file to add dependencies. For now these dependencies are assumed to be placed in the same directory as the crate itself is place in.
The va_list type cannot be used from Rust, so don't generate any mapping for functions or aliases that lead to it.
If a struct cannot be mapped because it has bit fields or unions, make it opaque instead of just ignoring it.
In order to generate a crate without having to also depend on a set of crates that won't ever be used, add options to include or exclude crates from being referenced. Including crates will result in only the crates specified via the --include option will ever be referenced, and any declaration referencing any other crate will be excluded from being generated. Excluding works the other way around, meaning all crates are included, except the ones specified using the --exclude option.
We need to properly deal with the pkg-config description to manage to build packages where the GIR package name differs from the pkg-config package (such as GTK+ 3.0).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work overall!
I'd like to think more about versioning for dependency packages: if the .pc specified a certain version number for an introspected library dependency, we'd be interested to map it to a version of the generated crate. The latest idea was to encode crate's major version as the "grust-gen epoch" to allow breaking changes in the generator, and the crate's minor version to equal the minor version of the library package (the package major version is, by convention, encoded in the pkgconfig module name and the crate name derived from it).
@@ -206,11 +207,15 @@ pub struct ${node.ctype}(gpointer); | |||
pub enum ${node.ctype} { } | |||
% else: | |||
#[repr(C)] | |||
% if not mapper.struct_is_valid(node): | |||
pub struct ${node.ctype}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might work for objects and some boxed types, but I wouldn't like to get unusable types for copyable values. What I did in the few crate-specific templates I created in repo gi-rust/crates
is suppress the unmappable structures and place manual representations in the crate template. With support for unions available in stable Rust, there will be less need for these overrides.
Bit fields could be automated too, if there is a equivalent #[repr(C)]
guaranteed by the C standard.
Hi,
Sorry for the catch-all pull request, but with these patches I can generate for example glib, gio and gtk without any special template (though with plenty of compiler warnings still), while also not having to also generate all the other dependencies those would have. I also have them generate the Cargo.toml and a build.rs to build.
In summary, the patches do
Let me know what you think.