gerrit/lib/codemirror/BUCK
Shawn Pearce 101a8c4b65 Only pack CM3 themes selectable by the user
This avoids packing too many CSS rules, which bloats the download
to the browser and may slow down rendering while the browser picks
matching CSS classes.

Change-Id: I8888bc9daa9693ff2598ccfe29d150fa3fac0916
2014-01-21 15:07:10 -08:00

90 lines
1.9 KiB
Python

include_defs('//lib/maven.defs')
include_defs('//lib/codemirror/cm3.defs')
VERSION = '28a638a984'
SHA1 = '68f8f136092a5965778186fb401a33be34cf73ed'
URL = GERRIT + 'net/codemirror/codemirror-%s.zip' % VERSION
ZIP = 'codemirror-%s.zip' % VERSION
TOP = 'codemirror-%s' % VERSION
genrule(
name = 'css',
cmd = ';'.join([
':>$OUT',
"echo '/** @license' >>$OUT",
'unzip -p $SRCDIR/%s %s/LICENSE >>$OUT' % (ZIP, TOP),
"echo '*/' >>$OUT",
] +
['unzip -p $SRCDIR/%s %s/%s >>$OUT' % (ZIP, TOP, n)
for n in CM3_CSS + CM3_THEMES]
),
srcs = [genfile(ZIP)],
deps = [':download'],
out = 'cm3.css',
)
# TODO(sop) Minify with Closure JavaScript compiler.
genrule(
name = 'js',
cmd = ';'.join([
':>$OUT',
"echo '/** @license' >>$OUT",
'unzip -p $SRCDIR/%s %s/LICENSE >>$OUT' % (ZIP, TOP),
"echo '*/' >>$OUT",
] +
['unzip -p $SRCDIR/%s %s/%s >>$OUT' % (ZIP, TOP, n)
for n in CM3_JS]
),
srcs = [genfile(ZIP)],
deps = [':download'],
out = 'cm3.js',
)
prebuilt_jar(
name = 'codemirror',
binary_jar = genfile('codemirror.jar'),
deps = [
':jar',
'//lib:LICENSE-codemirror',
],
visibility = ['PUBLIC'],
)
genrule(
name = 'jar',
cmd = ';'.join([
'cd $TMP',
'unzip -q $SRCDIR/%s %s' % (
ZIP,
' '.join(['%s/mode/%s' % (TOP, n) for n in CM3_MODES])),
'mkdir net',
'mv %s net/codemirror' % TOP,
'mkdir net/codemirror/lib',
'mv $SRCDIR/cm3.css net/codemirror/lib',
'mv $SRCDIR/cm3.js net/codemirror/lib',
'zip -qr $OUT *'
]),
srcs = [
genfile(ZIP),
genfile('cm3.css'),
genfile('cm3.js'),
],
deps = [
':download',
':css',
':js',
],
out = 'codemirror.jar',
)
genrule(
name = 'download',
cmd = '$(exe //tools:download_file)' +
' -o $OUT' +
' -u ' + URL +
' -v ' + SHA1,
deps = ['//tools:download_file'],
out = 'codemirror-' + VERSION + '.zip',
)