blob: 4c235e4b6fbf29f669c70ae7806ad03cb010ff95 [file] [log] [blame]
include_defs('//lib/maven.defs')
include_defs('//lib/codemirror/cm.defs')
include_defs('//lib/codemirror/closure.defs')
REPO = MAVEN_CENTRAL
VERSION = '5.0'
SHA1 = '24982be364be130fd7b2930c41f7203b63dbd86c'
if REPO == MAVEN_CENTRAL:
URL = REPO + 'org/webjars/codemirror/%s/codemirror-%s.jar' % (VERSION, VERSION)
TOP = 'META-INF/resources/webjars/codemirror/%s' % VERSION
ZIP = 'codemirror-%s.jar' % VERSION
else:
URL = REPO + 'net/codemirror/codemirror-%s.zip' % VERSION
TOP = 'codemirror-%s' % VERSION
ZIP = 'codemirror-%s.zip' % VERSION
CLOSURE_VERSION = 'v20141120'
CLOSURE_COMPILER_ARGS = [
'--compilation_level SIMPLE_OPTIMIZATIONS',
'--warning_level QUIET'
]
genrule(
name = 'css',
cmd = ';'.join([
"echo '/** @license' >$OUT",
'unzip -p $(location :zip) %s/LICENSE >>$OUT' % TOP,
"echo '*/' >>$OUT",
] +
['unzip -p $(location :zip) %s/%s >>$OUT' % (TOP, n)
for n in CM_CSS]
),
out = 'cm.css',
)
for n in CM_THEMES:
genrule(
name = 'theme_%s' % n,
cmd = ';'.join([
"echo '/** @license' >$OUT",
'unzip -p $(location :zip) %s/LICENSE >>$OUT' % TOP,
"echo '*/' >>$OUT",
'unzip -p $(location :zip) %s/theme/%s.css >>$OUT' % (TOP, n)
]
),
out = 'theme_%s.css' % n,
)
genrule(
name = 'cm-verbose',
cmd = ';'.join([
"echo '/** @license' >$OUT",
'unzip -p $(location :zip) %s/LICENSE >>$OUT' % TOP,
"echo '*/' >>$OUT",
] +
['unzip -p $(location :zip) %s/%s >>$OUT' % (TOP, n) for n in CM_JS] +
['unzip -p $(location :zip) %s/addon/%s >>$OUT' % (TOP, n)
for n in CM_ADDONS]
),
out = 'cm-verbose.js',
)
js_minify(
name = 'js',
generated = [':cm-verbose'],
compiler_args = CLOSURE_COMPILER_ARGS,
out = 'cm.js'
)
for n in CM_MODES:
genrule (
name = 'mode_%s_src' % n,
cmd = ';'.join([
"echo '/** @license' >$OUT",
'unzip -p $(location :zip) %s/LICENSE >>$OUT' % TOP,
"echo '*/' >>$OUT",
'unzip -p $(location :zip) %s/mode/%s/%s.js >>$OUT' % (TOP, n, n),
]),
out = 'mode_%s_src.js' %n,
)
js_minify(
name = 'mode_%s_js' % n,
generated = [':mode_%s_src' % n],
compiler_args = CLOSURE_COMPILER_ARGS,
out = 'mode_%s.js' % n,
)
prebuilt_jar(
name = 'codemirror',
binary_jar = ':jar',
deps = [
':jar',
'//lib:LICENSE-codemirror',
],
visibility = ['PUBLIC'],
)
genrule(
name = 'jar',
cmd = ';'.join([
'cd $TMP',
'mkdir -p net/codemirror/{lib,mode,theme}',
'cp $(location :css) net/codemirror/lib',
'cp $(location :js) net/codemirror/lib']
+ ['cp $(location :mode_%s_js) net/codemirror/mode/%s.js' % (n, n)
for n in CM_MODES]
+ ['cp $(location :theme_%s) net/codemirror/theme/%s.css' % (n, n)
for n in CM_THEMES]
+ ['zip -qr $OUT net/codemirror/{lib,mode,theme}']),
out = 'codemirror.jar',
)
genrule(
name = 'zip',
cmd = '$(exe //tools:download_file)' +
' -o $OUT' +
' -u ' + URL +
' -v ' + SHA1,
out = ZIP,
)
java_binary(
name = 'js_minifier',
main_class = 'com.google.javascript.jscomp.CommandLineRunner',
deps = [':compiler-jar']
)
maven_jar(
name = 'compiler-jar',
id = 'com.google.javascript:closure-compiler:' + CLOSURE_VERSION,
sha1 = '369618bf5a96f73e32655dc48919c0f97558d3b1',
license = 'Apache2.0',
deps = [
':closure-compiler-externs',
'//lib:args4j',
'//lib:gson',
'//lib:guava',
'//lib:protobuf',
],
visibility = [],
)
maven_jar(
name = 'closure-compiler-externs',
id = 'com.google.javascript:closure-compiler-externs:' + CLOSURE_VERSION,
sha1 = '247eff337e2737de43c8d963aaaef15bd8cda132',
license = 'Apache2.0',
visibility = [],
)