-
Notifications
You must be signed in to change notification settings - Fork 57
Build and Install
Make sure you've got these packages installed:
libglib2.0-dev libgc-dev
Incidentally, on Xubuntu 13.04, installing libgc-dev will actually get you a specific version for your particular platform. For example, on this author's system:
$ dpkg -l | grep libgc-dev
ii libgc-dev:amd64 ...
You should now be able to run the following two commands with no errors:
pkg-config --cflags glib-2.0
pkg-config --cflags bdw-gc
cd ~/opt
git clone git://github.com/schani/clojurec.git
cd clojurec
You'll notice it looks just like any other typical Clojure project: it's got a top-level project.clj file, src & test directories, and so on.
While still in ~/opt/clojurec, run:
git submodule init
git submodule update
cd ~/temp
# edit foo.cljc
Have that foo.cljc file contain:
(ns cljc.user)
(defn -main
[& args]
(apply println args))
Please Note: The following build procedure is just temporary. This project is still very new --- most walls don't even have sheetrock on them yet, and there are lots of exposed wires:
cd ~/opt/clojurec
lein run -c src/cljc/cljc/core.cljc cljc.core run run
lein run -c ~/temp/foo.cljc cljc.user run run
lein run -d cljc.user/-main run
cd run
make -f c/Makefile
Some notes on the above commands:
-c
compiles one .cljc file --> one .c file. You pass it:
- the path to the .cljc file,
- the namespace,
- the output directory for the .c file, and
- the output directory for the exports file.
The exports files are used internally by the compiler to record which symbols and types are exported by a namespace. ClojureScript doesn't need that because JavaScript can do late binding which C cannot do. Compilation must be done in dependency order, meaning if namespace B depends on namespace A, then A must be compiled before B.
-d
generates the driver .c file, which is really just a main() function. You pass the full name of the ClojureC main function and the output directory for the .c file.
Finally, run your program:
./cljc foo bar baz
You should get output which looks not entirely unlike what echo
might produce. :)