GNOME Bugzilla – Bug 703440
Support using GResource as a base search path for JS files
Last modified: 2013-10-01 22:37:58 UTC
It would be nice for a gjs application to be able to bundle all of its JS files as a GResource, and having the launcher be an actual C executable. It turns out this is very easy to implement, thanks to the transparent support of resource:/// files inside GIO. The following patch ports the way imported files are loaded in gjs to GIO, which gives us free support for setting a resource:///foo/bar/application search-path on a GjsContext from the C launcher.
Created attachment 248196 [details] [review] Support using GResource as a base search path for JS files This commit changes the way files are imported inside GJS to use GIO, transparently adding support for using a resource:/// search path to lookup JS files in loaded GResources.
Created attachment 248199 [details] [review] Support using GResource as a base search path for JS files -- Fix support for subdirectories
Hmm...can you elaborate a bit more on how you're using this? Did you just write a custom C program to embed gjs? Giovanni has a complex "package" proposal, and while your patch here sounds useful, I'd just like to think about whether it might end up different if we moved forwards with a package type thing.
(In reply to comment #3) > Hmm...can you elaborate a bit more on how you're using this? Did you just > write a custom C program to embed gjs? > > Giovanni has a complex "package" proposal, and while your patch here sounds > useful, I'd just like to think about whether it might end up different if we > moved forwards with a package type thing. Yeah, I just wrote a little 30-lines C launcher helper that sets a gresource search path on the GjsContext - I also ported gnome-shell to test the patch itself. I hadn't thought about how this could be used from a launcher that is itself written in JS. I think we would need at least to add support to GjsContext to dynamically change the search path. I agree it would be awesome to have the two things converge, but using a C launcher with all the JS code compiled in is pretty nice in itself :)
Attachment 248199 [details] pushed as fbc5413 - Support using GResource as a base search path for JS files Pushed an adapted version of this on top of a bunch of cleanups.