Created
November 9, 2011 04:35
-
-
Save yokolet/1350398 to your computer and use it in GitHub Desktop.
ClojureScript compiler from JRuby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# clojurescript compiler from JRuby | |
# see https://github.com/clojure/clojurescript/wiki/Quick-Start | |
require 'java' | |
CLOJURESCRIPT_HOME = File.dirname(__FILE__) | |
$: << CLOJURESCRIPT_HOME | |
%w{compiler.jar goog.jar js.jar clj cljs}.each {|path| $CLASSPATH << CLOJURESCRIPT_HOME + "/" + path} | |
require 'clojure' | |
%w{RT Keyword PersistentHashMap}.each do |name| | |
java_import "clojure.lang.#{name}" | |
end | |
RT.loadResourceScript("cljs/closure.clj") | |
builder = RT.var("cljs.closure", "build") | |
optimizations = Keyword.intern("optimizations") | |
advanced = Keyword.intern("advanced") | |
output_to = Keyword.intern("output-to") | |
value = Keyword.intern("print") | |
opts = PersistentHashMap.create({optimizations => advanced, output_to => "hello.js"}) | |
result = builder.invoke("/Users/yoko/Works/tmp/clojurescript/hello.clj", opts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment