Support for passing "--define" option to compiler.jar #21

Closed
RafalBabinicz opened this Issue Jan 23, 2012 · 1 comment

Projects

None yet

2 participants

@RafalBabinicz

for example by specifying in project.clj
:compiler {
:define "goog.userAgent.ASSUME_MOBILE_WEBKIT"
:define "goog.userAgent.product.ASSUME_ANDROID"
}

Resources:
goog.userAgent global props: http://closure-library.googlecode.com/svn/docs/closure_goog_useragent_useragent.js.html
goog.userAgent.product global props: http://closure-library.googlecode.com/svn/docs/closure_goog_useragent_product.js.html
"java -jar compiler.jar --help" for all available options
Google Closure Definitive Guide at Google Books: http://books.google.pl/books?id=p7uyWPcVGZsC

clojurescript/src/clj/cljs/closure.clj: functions "make-options" and "set-options"

(defn set-options
"TODO: Add any other options that we would like to support."
[opts ^CompilerOptions compiler-options](when %28contains? opts :pretty-print%29
%28set! %28.prettyPrint compiler-options%29 %28:pretty-print opts%29%29)
(when (contains? opts :print-input-delimiter)
(set! (.printInputDelimiter compiler-options)
(:print-input-delimiter opts))))

(defn make-options
"Create a CompilerOptions object and set options from opts map."
[opts](let [level %28case %28:optimizations opts%29
:advanced CompilationLevel/ADVANCED_OPTIMIZATIONS
:whitespace CompilationLevel/WHITESPACE_ONLY
:simple CompilationLevel/SIMPLE_OPTIMIZATIONS%29
compiler-options %28doto %28CompilerOptions.%29
%28.setCodingConvention %28ClosureCodingConvention.%29%29%29]
%28do %28.setOptionsForCompilationLevel level compiler-options%29
%28set-options opts compiler-options%29
compiler-options%29))

@emezeske
Owner
emezeske commented Oct 2, 2012

This is, ultimately, a feature request that should go on the ClojureScript issue tracker: http://dev.clojure.org/jira/browse/CLJS . This is a feature that the ClojureScript compiler itself would have to expose.

@emezeske emezeske closed this Oct 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment