blob: e602b9fc5339b90ef7bd7c11041ee56b1c2bdb0c [file] [log] [blame]
# https://code.google.com/p/closure-compiler/wiki/BinaryDownloads?tm=2
CLOSURE_VERSION = '20140407'
CLOSURE_COMPILER_URL = 'http://dl.google.com/closure-compiler/compiler-%s.zip' % CLOSURE_VERSION
COMPILER = 'compiler.jar'
CLOSURE_COMPILER_SHA1 = 'eeb02bfd45eb4a080b66dd423eaee4bdd1d674e9'
def js_minify(
name,
out,
compiler_args = [],
srcs = [],
generated = []):
cmd = ['$(exe :js_minifier) --js_output_file $OUT'] + compiler_args
if srcs:
cmd.append('$SRCS')
if generated:
cmd.extend(['$(location %s)' % n for n in generated])
genrule(
name = name,
cmd = ' '.join(cmd),
srcs = srcs,
out = out,
)
java_binary(
name = 'js_minifier',
main_class = 'com.google.javascript.jscomp.CommandLineRunner',
deps = [':compiler-jar']
)
prebuilt_jar(
name = 'compiler-jar',
binary_jar = ':compiler',
)
genrule(
name = 'compiler',
cmd = 'unzip -p $(location :closure-compiler-zip) %s >$OUT' % COMPILER,
out = COMPILER,
)
genrule(
name = 'closure-compiler-zip',
cmd = '$(exe //tools:download_file)' +
' -o $OUT' +
' -u ' + CLOSURE_COMPILER_URL +
' -v ' + CLOSURE_COMPILER_SHA1,
out = 'closure-compiler.zip',
)