A build-time dependency for Cargo build scripts to enable easy integration with glib/gio/gtk non-compile build tasks. For now it only supports bundling data files using GResource.

1 unstable release

0.1.0 May 23, 2021

#25 in #build-dependencies

Used in screen-selector

MIT license

110 lines


A library to perform the usual non-compile build tasks on glib/gio/gtk-based libray and applications.

Right now it only supports embedding gio GResources into the final binary.


Using gbuild

First, you'll want to both add a build script for your crate (build.rs) and also add this crate to your Cargo.toml via:

gbuild = "0.1"

Next up, you'll want to write a build script like so:

// build.rs
fn main() {
        .expect("Bad arguments for gresource compilation")

That will generate the .c file from the xmldescription, build it, and it will be linked into your rust binary, making it possible to use resources from your code without any further registration like this, for instance:

fn load_readme() -> Result<String, String>
    let gfile = gio::File::for_uri("resource:///br/kov/duplikat/README");
    match gfile.load_contents(gio::NONE_CANCELLABLE) {
        Ok((bytes, _string)) => {
        Err(e) => format!("Could not load test file: {}", e),

External configuration

This crate uses the pkg-config binary (not the crate) to obtain the flags for including and linking gio-2.0, so it will be affected by any environment variable that affects pkg-config.

For building the resulting C file, this crate uses the cc crate, which can also be affected by various environment variables. Do note that at the moment this crate will replace any existing CFLAGS variable with its own while building the resources c file.


This project is licensed under the MIT license, see the (LICENSE file.


~183K SLoC