After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 703440 - Support using GResource as a base search path for JS files
Support using GResource as a base search path for JS files
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2013-07-02 04:53 UTC by Cosimo Cecchi
Modified: 2013-10-01 22:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Support using GResource as a base search path for JS files (4.74 KB, patch)
2013-07-02 04:53 UTC, Cosimo Cecchi
none Details | Review
Support using GResource as a base search path for JS files (6.92 KB, patch)
2013-07-02 06:36 UTC, Cosimo Cecchi
committed Details | Review

Description Cosimo Cecchi 2013-07-02 04:53:01 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.
Comment 1 Cosimo Cecchi 2013-07-02 04:53:03 UTC
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.
Comment 2 Cosimo Cecchi 2013-07-02 06:36:40 UTC
Created attachment 248199 [details] [review]
Support using GResource as a base search path for JS files

--

Fix support for subdirectories
Comment 3 Colin Walters 2013-07-26 00:39:32 UTC
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.
Comment 4 Cosimo Cecchi 2013-07-26 02:34:05 UTC
(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 :)
Comment 5 Jasper St. Pierre (not reading bugmail) 2013-10-01 22:37:53 UTC
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.