Files
gerrit/lib/codemirror/BUCK
Michael Zhou fae6bb2365 Use the "NPM WebJar" instead of "classic WebJar" for CodeMirror
The NPM WebJar is easier to deploy. As soon as the CodeMirror author
publishes a new version to NPM, anyone can deploy it to WebJars in one
click. In contrast, the classic WebJar requires a WebJars team member to
manually update and deploy it, which usually takes longer [1].

Also update version to 5.13.4, which was a trivial fix to include the
LICENSE file and brought no functionality change.

[1]: http://www.webjars.org/

Change-Id: I9328f371aa99cac7e81b3f8a442d6582275ad3a7
2016-04-06 21:26:50 -04:00

109 lines
3.1 KiB
Python

include_defs('//lib/maven.defs')
include_defs('//lib/codemirror/cm.defs')
VERSION = '5.13.4'
TOP = 'META-INF/resources/webjars/codemirror/%s' % VERSION
TOP_MINIFIED = 'META-INF/resources/webjars/codemirror-minified/%s' % VERSION
maven_jar(
name = 'codemirror-minified',
id = 'org.webjars.npm:codemirror-minified:' + VERSION,
sha1 = 'fb207d777aad82423d098c3660bd2ca72775bf6e',
attach_source = False,
license = 'codemirror-minified',
visibility = [],
)
maven_jar(
name = 'codemirror-original',
id = 'org.webjars.npm:codemirror:' + VERSION,
sha1 = '4130b0a7e998d304277a86062351cb9e2840cbfa',
attach_source = False,
license = 'codemirror-original',
visibility = [],
)
for archive, suffix, top in [('codemirror-original', '', TOP), ('codemirror-minified', '_r', TOP_MINIFIED)]:
# Main JavaScript and addons
genrule(
name = 'cm' + suffix,
cmd = ';'.join([
"echo '/** @license' >$OUT",
'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
"echo '*/' >>$OUT",
] +
['unzip -p $(location :%s) %s/%s >>$OUT' % (archive, top, n) for n in CM_JS] +
['unzip -p $(location :%s) %s/addon/%s >>$OUT' % (archive, top, n)
for n in CM_ADDONS]
),
out = 'cm%s.js' % suffix,
)
# Main CSS
genrule(
name = 'css' + suffix,
cmd = ';'.join([
"echo '/** @license' >$OUT",
'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
"echo '*/' >>$OUT",
] +
['unzip -p $(location :%s) %s/%s >>$OUT' % (archive, top, n)
for n in CM_CSS]
),
out = 'cm%s.css' % suffix,
)
# Modes
for n in CM_MODES:
genrule (
name = 'mode_%s%s' % (n, suffix),
cmd = ';'.join([
"echo '/** @license' >$OUT",
'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
"echo '*/' >>$OUT",
'unzip -p $(location :%s) %s/mode/%s/%s.js >>$OUT' % (archive, top, n, n),
]),
out = 'mode_%s%s.js' % (n, suffix),
)
# Themes
for n in CM_THEMES:
genrule(
name = 'theme_%s%s' % (n, suffix),
cmd = ';'.join([
"echo '/** @license' >$OUT",
'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
"echo '*/' >>$OUT",
'unzip -p $(location :%s) %s/theme/%s.css >>$OUT' % (archive, top, n)
]
),
out = 'theme_%s%s.css' % (n, suffix),
)
# Jar packaging
genrule(
name = 'jar' + suffix,
cmd = ';'.join([
'cd $TMP',
'mkdir -p net/codemirror/{lib,mode,theme}',
'cp $(location :css%s) net/codemirror/lib/cm.css' % suffix,
'cp $(location :cm%s) net/codemirror/lib/cm.js' % suffix]
+ ['cp $(location :mode_%s%s) net/codemirror/mode/%s.js' % (n, suffix, n)
for n in CM_MODES]
+ ['cp $(location :theme_%s%s) net/codemirror/theme/%s.css' % (n, suffix, n)
for n in CM_THEMES]
+ ['zip -qr $OUT net/codemirror/{lib,mode,theme}']),
out = 'codemirror%s.jar' % suffix,
)
prebuilt_jar(
name = 'codemirror' + suffix,
binary_jar = ':jar%s' % suffix,
deps = [
':jar' + suffix,
'//lib:LICENSE-' + archive,
],
visibility = ['PUBLIC'],
)