Skip to content

Instantly share code, notes, and snippets.

@yokolet
Created November 9, 2011 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save yokolet/1350398 to your computer and use it in GitHub Desktop.
Save yokolet/1350398 to your computer and use it in GitHub Desktop.
ClojureScript compiler from JRuby
# 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