-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow running the demo from the build dir #151
Conversation
62602c8
to
9763c8e
Compare
Could use a rebase |
Running the demo from the builddir fails with the missing gresources file. Hack around this by copying the binary into a ashpd-demo.devel and, if argv0 ends with .devel, loading the gresources file from the meson builddir instead.
9763c8e
to
dc74a5a
Compare
Rebased but switched back to draft. I tried running this on a new machine and luckily caught the error: the current branch still requires that the schemas are installed. Simply adding to |
For the schemas, you can use |
let res = gio::Resource::load(RESOURCES_FILE).expect("Could not load gresource file"); | ||
let argv0 = std::env::args().next(); | ||
let res = if argv0.is_some() && argv0.unwrap().ends_with(".devel") { | ||
gio::Resource::load(BUILDDIR_RESOURCES_FILE) | ||
} else { | ||
gio::Resource::load(RESOURCES_FILE) | ||
}.expect("Could not load gresource file"); |
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.
I am not particularly happy with this approach of checking the binary name. I think a viable path forward is to have a separate meson build option that would influence from where we load the gresource file making the changes to config.rs/main.rs not needed at all. The other option is to embed the gresource into the final binary but nobody took the time to figure out a nice way to do it that integrates well with the hackish meson/cargo thing we are doing
So from what I've gathered so far
If I hack around the two above, I get a segfault somewhere deep inside GTK4's But I agree, the hackish way right now is not nice and since it doesn't work anyway, let's close this PR - I'm not sure when I'll have time to look at this again in the near future. |
It feels a bit awkward, mostly because glib-compile-schemas only compiles a single directory, and we hacked it up with --target to place the compiled version in a different tree hierarchy. I don't know that it's feasible to merge the two together, so we'd either need to pick one, or generate another directory as an internal implementation detail and append to the GSETTINGS_SCHEMA_DIR directory. Of course this is all nothing users can't do manually, the main value of the module is to guarantee it is correct... |
Thanks for the explanation! From what I can tell from a quick browse |
This sits on top of #150 so it builds on my machine but can be split out if need be.
Unless there's a trick I'm missing, we can't easily run the demo from the meson build dir because it looks in
/usr/local/share/
for the gresources file. This could (possibly?) be worked around by setting the datadir in meson but another hack is to build the same binary with a.devel
suffix, check for that suffix inargv0
and load the gresources from the builddir instead. Not overly pretty but for this use-case it's probably good enough.