Any progress on separate compilation for a JavaScript target? (I am interested in using it for a large project that can't be done without separate compilation ability - 450+ screens).
Thanks.
Blake McBride
Afficher les réponses par date
Blake,
For memory the universal backend is now supported by the linker but individual modules still need to be manually called as required.
I've yet to try this out yet though so YMMV.
James
On Fri, Jan 1, 2016 at 1:49 PM, Blake McBride blake@mcbride.name wrote:
Any progress on separate compilation for a JavaScript target? (I am interested in using it for a large project that can't be done without separate compilation ability - 450+ screens).
Thanks.
Blake McBride
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
First of all happy new year to you and all the other members of this list!
Yes separate compilation is supported by the linker (the -link option to gsc). Here is an example. Please do a “git pull;make from-scratch;make install” to use the latest Gambit.
First you need to build the JS version of the Gambit library (the file lib/_gambit.js). So from the Gambit source directory do:
% cd lib;rm _gambit.js;make _gambit.js;cd .. ../gsc/gsc -:~~bin=../bin,~~lib=../lib,~~include=../include -f -target js -prelude "(##include "header.scm")" -o _gambit.js ../lib/_univlib.scm
Ideally the Gambit library should be copied to the Gambit installation directory in the lib subdirectory, but it is not essential because you can specify the Gambit library to the linker with the “-l <path>” option (see below).
Then separately compile your Scheme files to JS. Here I use two files “a.scm” and “b.scm”:
% cat a.scm (println "a.scm loaded") (define (f x) (println x)) % cat b.scm (println "b.scm loaded") (f "hello world!") % gsc -target js -c a.scm % gsc -target js -c b.scm
Now link the files with the Gambit library to generate the link file b_.js :
% gsc -link -l lib/_gambit.js a.js b.js
And finally run the code by loading the link file, the Gambit library, and the compiled files:
% d8 b_.js lib/_gambit.js a.js b.js a.scm loaded b.scm loaded hello world!
Note that the link file must be loaded first, but the other files can be loaded in any order:
% d8 b_.js b.js lib/_gambit.js a.js a.scm loaded b.scm loaded hello world!
Currently there is no support for dynamically loading compiled files (i.e. the “load” procedure) but that’s something that could be added fairly easily (the hardest part is finding a portable way to do this across the supported target languages… even for JS this will vary between target environments, i.e. node.js vs browser).
Marc
On Dec 31, 2015, at 9:49 PM, Blake McBride blake@mcbride.name wrote:
Any progress on separate compilation for a JavaScript target? (I am interested in using it for a large project that can't be done without separate compilation ability - 450+ screens).
Thanks.
Blake McBride
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
On Jan 2, 2016, at 7:35 PM, Marc Feeley feeley@iro.umontreal.ca wrote:
First of all happy new year to you and all the other members of this list!
Yes separate compilation is supported by the linker (the -link option to gsc). Here is an example. Please do a “git pull;make from-scratch;make install” to use the latest Gambit.
“make update” should do a “git pull; make -j <whatever> from-scratch” where <whatever> comes from a configure setting (or default).
Brad