Skip to content

Commit

Permalink
fix: Resolve resource loading and import errors in Rust build
Browse files Browse the repository at this point in the history
  • Loading branch information
silviot committed Dec 8, 2024
1 parent 59ccef4 commit fd2680f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod window;
use self::application::AardvarkApplication;
use self::window::AardvarkWindow;

use config::{GETTEXT_PACKAGE, LOCALEDIR, PKGDATADIR};
use config::{GETTEXT_PACKAGE, LOCALEDIR};
use gettextrs::{bind_textdomain_codeset, bindtextdomain, textdomain};
use gtk::{gio, glib};
use gtk::prelude::*;
Expand All @@ -39,7 +39,9 @@ fn main() -> glib::ExitCode {
textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain");

// Load compiled resources
let resources = gio::Resource::load_from_data(&include_bytes!(concat!(env!("OUT_DIR"), "/aardvark.gresource"))[..])
let resource_bytes = std::fs::read(concat!(env!("CARGO_MANIFEST_DIR"), "/src/aardvark.gresource"))
.expect("Could not load resources");
let resources = gio::Resource::from_data(&gio::glib::Bytes::from(&resource_bytes))
.expect("Could not load resources");
gio::resources_register(&resources);

Expand Down
9 changes: 9 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ gresource = gnome.compile_resources('aardvark',
dependencies: [],
export: true,
gresource_bundle: true,
install: false,
)

# Copy the compiled resource bundle to the source directory for Cargo build
run_command(
'cp',
meson.current_build_dir() / 'aardvark.gresource',
meson.current_source_dir() / 'aardvark.gresource',
check: true
)

conf = configuration_data()
Expand Down

0 comments on commit fd2680f

Please sign in to comment.