Merge changes from topic 'codemirror-obfuscation'
* changes: Use a pre-built minified CodeMirror in the release build Buck: Turn off Codemirror obfuscation in non release build
This commit is contained in:
commit
cc825eea10
Documentation
gerrit-gwtui
lib
@ -56,13 +56,6 @@ def parse_graph():
|
|||||||
if target in KNOWN_PROVIDED_DEPS:
|
if target in KNOWN_PROVIDED_DEPS:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# js_minifier is only used by the build process.
|
|
||||||
# Skip it, even if --partial is not passed.
|
|
||||||
if dep == '//lib/codemirror:js_minifier':
|
|
||||||
if (target == '//lib/codemirror:js'
|
|
||||||
or target.startswith('//lib/codemirror:mode_')):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if (args.partial
|
if (args.partial
|
||||||
and dep == '//gerrit-gwtexpui:CSS'
|
and dep == '//gerrit-gwtexpui:CSS'
|
||||||
and target == '//gerrit-gwtui:ui_module'):
|
and target == '//gerrit-gwtui:ui_module'):
|
||||||
|
@ -19,25 +19,29 @@ gwt_user_agent_permutations(
|
|||||||
visibility = ['//:'],
|
visibility = ['//:'],
|
||||||
)
|
)
|
||||||
|
|
||||||
gwt_module(
|
def gen_ui_module(name, suffix = ""):
|
||||||
name = 'ui_module',
|
gwt_module(
|
||||||
srcs = glob(['src/main/java/**/*.java']),
|
name = name + suffix,
|
||||||
gwt_xml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'),
|
srcs = glob(['src/main/java/**/*.java']),
|
||||||
resources = glob(['src/main/java/**/*']),
|
gwt_xml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'),
|
||||||
deps = [
|
resources = glob(['src/main/java/**/*']),
|
||||||
':silk_icons',
|
deps = [
|
||||||
'//gerrit-gwtui-common:diffy_logo',
|
':silk_icons',
|
||||||
'//gerrit-gwtui-common:client',
|
'//gerrit-gwtui-common:diffy_logo',
|
||||||
'//gerrit-gwtexpui:CSS',
|
'//gerrit-gwtui-common:client',
|
||||||
'//lib/codemirror:codemirror',
|
'//gerrit-gwtexpui:CSS',
|
||||||
'//lib/gwt:user',
|
'//lib/codemirror:codemirror' + suffix,
|
||||||
],
|
'//lib/gwt:user',
|
||||||
visibility = [
|
],
|
||||||
'//tools/eclipse:classpath',
|
visibility = [
|
||||||
'//Documentation:licenses.txt',
|
'//tools/eclipse:classpath',
|
||||||
'//Documentation:js_licenses.txt',
|
'//Documentation:licenses.txt',
|
||||||
],
|
'//Documentation:js_licenses.txt',
|
||||||
)
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
gen_ui_module(name = 'ui_module')
|
||||||
|
gen_ui_module(name = 'ui_module', suffix = '_r')
|
||||||
|
|
||||||
java_library(
|
java_library(
|
||||||
name = 'silk_icons',
|
name = 'silk_icons',
|
||||||
|
@ -32,6 +32,7 @@ def gwt_genrule(module, deps, suffix = ""):
|
|||||||
dbg = 'ui_dbg' + suffix
|
dbg = 'ui_dbg' + suffix
|
||||||
opt = 'ui_opt' + suffix
|
opt = 'ui_opt' + suffix
|
||||||
soyc = 'ui_soyc' + suffix
|
soyc = 'ui_soyc' + suffix
|
||||||
|
module_dep = ':ui_module' + suffix
|
||||||
args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS
|
args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS
|
||||||
|
|
||||||
genrule(
|
genrule(
|
||||||
@ -51,7 +52,7 @@ def gwt_genrule(module, deps, suffix = ""):
|
|||||||
gwt_binary(
|
gwt_binary(
|
||||||
name = opt,
|
name = opt,
|
||||||
modules = [module],
|
modules = [module],
|
||||||
module_deps = [':ui_module'],
|
module_deps = [module_dep],
|
||||||
deps = deps + ([':' + dbg] if CPU_COUNT < 8 else []),
|
deps = deps + ([':' + dbg] if CPU_COUNT < 8 else []),
|
||||||
local_workers = CPU_COUNT,
|
local_workers = CPU_COUNT,
|
||||||
strict = True,
|
strict = True,
|
||||||
@ -64,7 +65,7 @@ def gwt_genrule(module, deps, suffix = ""):
|
|||||||
modules = [module],
|
modules = [module],
|
||||||
style = 'PRETTY',
|
style = 'PRETTY',
|
||||||
optimize = 0,
|
optimize = 0,
|
||||||
module_deps = [':ui_module'],
|
module_deps = [module_dep],
|
||||||
deps = deps,
|
deps = deps,
|
||||||
local_workers = CPU_COUNT,
|
local_workers = CPU_COUNT,
|
||||||
strict = True,
|
strict = True,
|
||||||
@ -76,7 +77,7 @@ def gwt_genrule(module, deps, suffix = ""):
|
|||||||
gwt_binary(
|
gwt_binary(
|
||||||
name = soyc,
|
name = soyc,
|
||||||
modules = [module],
|
modules = [module],
|
||||||
module_deps = [':ui_module'],
|
module_deps = [module_dep],
|
||||||
deps = deps + [':' + dbg],
|
deps = deps + [':' + dbg],
|
||||||
local_workers = CPU_COUNT,
|
local_workers = CPU_COUNT,
|
||||||
strict = True,
|
strict = True,
|
||||||
|
3
lib/BUCK
3
lib/BUCK
@ -8,7 +8,8 @@ define_license(name = 'automaton')
|
|||||||
define_license(name = 'bouncycastle')
|
define_license(name = 'bouncycastle')
|
||||||
define_license(name = 'CC-BY3.0')
|
define_license(name = 'CC-BY3.0')
|
||||||
define_license(name = 'clippy')
|
define_license(name = 'clippy')
|
||||||
define_license(name = 'codemirror')
|
define_license(name = 'codemirror-minified')
|
||||||
|
define_license(name = 'codemirror-original')
|
||||||
define_license(name = 'diffy')
|
define_license(name = 'diffy')
|
||||||
define_license(name = 'fetch')
|
define_license(name = 'fetch')
|
||||||
define_license(name = 'h2')
|
define_license(name = 'h2')
|
||||||
|
22
lib/LICENSE-codemirror-minified
Normal file
22
lib/LICENSE-codemirror-minified
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 Marijn Haverbeke <marijnh@gmail.com> and others
|
||||||
|
Copyright (c) 2016 Michael Zhou <zhoumotongxue008@gmail.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
@ -1,148 +1,108 @@
|
|||||||
include_defs('//lib/maven.defs')
|
include_defs('//lib/maven.defs')
|
||||||
include_defs('//lib/codemirror/cm.defs')
|
include_defs('//lib/codemirror/cm.defs')
|
||||||
include_defs('//lib/codemirror/closure.defs')
|
|
||||||
|
|
||||||
REPO = MAVEN_CENTRAL
|
|
||||||
VERSION = '5.13.2'
|
VERSION = '5.13.2'
|
||||||
SHA1 = '4a26f060aeca679fdf751d2b480499c8a5f71e47'
|
TOP = 'META-INF/resources/webjars/codemirror/%s' % VERSION
|
||||||
|
TOP_MINIFIED = 'META-INF/resources/webjars/codemirror-minified/%s' % VERSION
|
||||||
|
|
||||||
if REPO == MAVEN_CENTRAL:
|
maven_jar(
|
||||||
URL = REPO + 'org/webjars/codemirror/%s/codemirror-%s.jar' % (VERSION, VERSION)
|
name = 'codemirror-minified',
|
||||||
TOP = 'META-INF/resources/webjars/codemirror/%s' % VERSION
|
id = 'org.webjars.npm:codemirror-minified:' + VERSION,
|
||||||
ZIP = 'codemirror-%s.jar' % VERSION
|
sha1 = '420b73c0dfa7885ff7f60df2dce7d2cbae4ffeef',
|
||||||
else:
|
attach_source = False,
|
||||||
URL = REPO + 'net/codemirror/codemirror-%s.zip' % VERSION
|
license = 'codemirror-minified',
|
||||||
TOP = 'codemirror-%s' % VERSION
|
visibility = [],
|
||||||
ZIP = 'codemirror-%s.zip' % VERSION
|
|
||||||
|
|
||||||
|
|
||||||
CLOSURE_VERSION = 'v20160315'
|
|
||||||
|
|
||||||
CLOSURE_COMPILER_ARGS = [
|
|
||||||
'--compilation_level SIMPLE_OPTIMIZATIONS',
|
|
||||||
'--language_out ECMASCRIPT5_STRICT',
|
|
||||||
'--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:
|
maven_jar(
|
||||||
|
name = 'codemirror-original',
|
||||||
|
id = 'org.webjars.npm:codemirror:' + VERSION,
|
||||||
|
sha1 = '4a26f060aeca679fdf751d2b480499c8a5f71e47',
|
||||||
|
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(
|
genrule(
|
||||||
name = 'theme_%s' % n,
|
name = 'cm' + suffix,
|
||||||
cmd = ';'.join([
|
cmd = ';'.join([
|
||||||
"echo '/** @license' >$OUT",
|
"echo '/** @license' >$OUT",
|
||||||
'unzip -p $(location :zip) %s/LICENSE >>$OUT' % TOP,
|
'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
|
||||||
"echo '*/' >>$OUT",
|
"echo '*/' >>$OUT",
|
||||||
'unzip -p $(location :zip) %s/theme/%s.css >>$OUT' % (TOP, n)
|
] +
|
||||||
]
|
['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 = 'theme_%s.css' % n,
|
out = 'cm%s.js' % suffix,
|
||||||
)
|
)
|
||||||
|
|
||||||
genrule(
|
# Main CSS
|
||||||
name = 'cm-verbose',
|
genrule(
|
||||||
cmd = ';'.join([
|
name = 'css' + suffix,
|
||||||
"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([
|
cmd = ';'.join([
|
||||||
"echo '/** @license' >$OUT",
|
"echo '/** @license' >$OUT",
|
||||||
'unzip -p $(location :zip) %s/LICENSE >>$OUT' % TOP,
|
'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
|
||||||
"echo '*/' >>$OUT",
|
"echo '*/' >>$OUT",
|
||||||
'unzip -p $(location :zip) %s/mode/%s/%s.js >>$OUT' % (TOP, n, n),
|
] +
|
||||||
]),
|
['unzip -p $(location :%s) %s/%s >>$OUT' % (archive, top, n)
|
||||||
out = 'mode_%s_src.js' %n,
|
for n in CM_CSS]
|
||||||
)
|
),
|
||||||
js_minify(
|
out = 'cm%s.css' % suffix,
|
||||||
name = 'mode_%s_js' % n,
|
|
||||||
generated = [':mode_%s_src' % n],
|
|
||||||
compiler_args = CLOSURE_COMPILER_ARGS,
|
|
||||||
out = 'mode_%s.js' % n,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
prebuilt_jar(
|
# Modes
|
||||||
name = 'codemirror',
|
for n in CM_MODES:
|
||||||
binary_jar = ':jar',
|
genrule (
|
||||||
deps = [
|
name = 'mode_%s%s' % (n, suffix),
|
||||||
':jar',
|
cmd = ';'.join([
|
||||||
'//lib:LICENSE-codemirror',
|
"echo '/** @license' >$OUT",
|
||||||
],
|
'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
|
||||||
visibility = ['PUBLIC'],
|
"echo '*/' >>$OUT",
|
||||||
)
|
'unzip -p $(location :%s) %s/mode/%s/%s.js >>$OUT' % (archive, top, n, n),
|
||||||
|
]),
|
||||||
|
out = 'mode_%s%s.js' % (n, suffix),
|
||||||
|
)
|
||||||
|
|
||||||
genrule(
|
# Themes
|
||||||
name = 'jar',
|
for n in CM_THEMES:
|
||||||
cmd = ';'.join([
|
genrule(
|
||||||
'cd $TMP',
|
name = 'theme_%s%s' % (n, suffix),
|
||||||
'mkdir -p net/codemirror/{lib,mode,theme}',
|
cmd = ';'.join([
|
||||||
'cp $(location :css) net/codemirror/lib',
|
"echo '/** @license' >$OUT",
|
||||||
'cp $(location :js) net/codemirror/lib']
|
'unzip -p $(location :%s) %s/LICENSE >>$OUT' % (archive, top),
|
||||||
+ ['cp $(location :mode_%s_js) net/codemirror/mode/%s.js' % (n, n)
|
"echo '*/' >>$OUT",
|
||||||
for n in CM_MODES]
|
'unzip -p $(location :%s) %s/theme/%s.css >>$OUT' % (archive, top, n)
|
||||||
+ ['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 = 'theme_%s%s.css' % (n, suffix),
|
||||||
out = 'codemirror.jar',
|
)
|
||||||
)
|
|
||||||
|
|
||||||
genrule(
|
# Jar packaging
|
||||||
name = 'zip',
|
genrule(
|
||||||
cmd = '$(exe //tools:download_file)' +
|
name = 'jar' + suffix,
|
||||||
' -o $OUT' +
|
cmd = ';'.join([
|
||||||
' -u ' + URL +
|
'cd $TMP',
|
||||||
' -v ' + SHA1,
|
'mkdir -p net/codemirror/{lib,mode,theme}',
|
||||||
out = ZIP,
|
'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,
|
||||||
|
)
|
||||||
|
|
||||||
java_binary(
|
prebuilt_jar(
|
||||||
name = 'js_minifier',
|
name = 'codemirror' + suffix,
|
||||||
main_class = 'com.google.javascript.jscomp.CommandLineRunner',
|
binary_jar = ':jar%s' % suffix,
|
||||||
deps = [':compiler-jar']
|
deps = [
|
||||||
)
|
':jar' + suffix,
|
||||||
|
'//lib:LICENSE-' + archive,
|
||||||
|
],
|
||||||
|
visibility = ['PUBLIC'],
|
||||||
|
)
|
||||||
|
|
||||||
maven_jar(
|
|
||||||
name = 'compiler-jar',
|
|
||||||
id = 'com.google.javascript:closure-compiler:' + CLOSURE_VERSION,
|
|
||||||
sha1 = 'f5b1a03f83a014e545db60a795fcf94db14a5ba2',
|
|
||||||
license = 'DO_NOT_DISTRIBUTE',
|
|
||||||
deps = [':closure-compiler-externs'],
|
|
||||||
visibility = [],
|
|
||||||
)
|
|
||||||
|
|
||||||
maven_jar(
|
|
||||||
name = 'closure-compiler-externs',
|
|
||||||
id = 'com.google.javascript:closure-compiler-externs:' + CLOSURE_VERSION,
|
|
||||||
sha1 = 'a0c252a8fced5f0a542302e3f03066c8144d7371',
|
|
||||||
license = 'Apache2.0',
|
|
||||||
visibility = [],
|
|
||||||
attach_source = False,
|
|
||||||
)
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
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,
|
|
||||||
)
|
|
Loading…
x
Reference in New Issue
Block a user