Comments:"schani/clojurec · GitHub"
URL:https://github.com/schani/clojurec
ClojureC
This is compiler for the Clojure programming language that targets C as a backend. It is based on ClojureScript and was started off ClojureScript's commit 0e0aa7fdd379649bf87f8fff5c6a64e37fe616a4
.
Community and Organization
We use a Trello board to keep track of ideas, proposals, TODOs, bugs and who's doing what. If you plan to contribute, please do join the board.
Additional documentation for the project can be found at the wiki.
Preparations
Submodules
ClojureC includes a submodule. To fetch it, do
git submodule init
git submodule update
Dependencies
Before you can run anything make sure you have GLib 2 and the Boehm-Demers-Weiser garbage collector installed. If
pkg-config --cflags glib-2.0
pkg-config --cflags bdw-gc
don't report errors you should be good.
Make sure you're using Leiningen 2 - older versions of Leiningen won't work. Run the testsuite:
lein test
All tests should pass.
Using ClojureC
Note that ClojureC is still in its experimental phase, so please don't expect a polished experience, yet.
From the command line
ClojureC provides a very simple command line compiler interface. Let's say you have the following in the file /tmp/echo.cljc
:
(ns cljc.user)
(defn main [& args]
(doseq [arg args]
(pr arg "\n")))
Then if you do the following in the clojurec
directory
lein run -c src/cljc/cljc/core.cljc cljc.core run run
lein run -c /tmp/echo.cljc cljc.user run run
lein run -d cljc.user/main run
cd run
make
you should have a cljc
executable in the run
directory that acts a little like echo
.
From the REPL
The easiest way to play around with ClojureC interactively is in the namespace clojurec.core-test
. For example:
(core-run '(pr (+ 1 2)))
=> [3]
Mobile Platform Notes
Android
See the README.md file in "clojurec/run/android".
iOS
See the README.md file in "clojurec/run/ios".