c43dd07c17
Introduce new :gwtgerrit target that only depends on non optimized GWT UI module. For one that accelerates artifact creation, as in development the optimized UI module is not needed, for another it skips building PolyGerrit dependencies. As a side effect of this change, PolyGerrit is not bundled any more, when safari or firefox user agents are used. Change-Id: Ib908a8e3b840deae0a6f0899794dc37bc3526cb6
140 lines
3.7 KiB
Plaintext
140 lines
3.7 KiB
Plaintext
# Copyright (C) 2013 The Android Open Source Project
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
from multiprocessing import cpu_count
|
|
|
|
BROWSERS = [
|
|
'chrome',
|
|
'firefox',
|
|
'gecko1_8',
|
|
'safari',
|
|
'msie', 'ie8', 'ie9',
|
|
]
|
|
ALIASES = {
|
|
'chrome': 'safari',
|
|
'firefox': 'gecko1_8',
|
|
'msie': 'ie9',
|
|
}
|
|
MODULE = 'com.google.gerrit.GerritGwtUI'
|
|
CPU_COUNT = cpu_count()
|
|
|
|
def gwt_genrule(module, deps, suffix = ""):
|
|
dbg = 'ui_dbg' + suffix
|
|
opt = 'ui_opt' + suffix
|
|
soyc = 'ui_soyc' + suffix
|
|
args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS
|
|
|
|
genrule(
|
|
name = 'ui_optdbg' + suffix,
|
|
cmd = 'cd $TMP;' +
|
|
'unzip -q $(location :%s);' % dbg +
|
|
'mv' +
|
|
' gerrit_ui/gerrit_ui.nocache.js' +
|
|
' gerrit_ui/dbg_gerrit_ui.nocache.js;' +
|
|
'unzip -qo $(location :%s);' % opt +
|
|
'mkdir -p \$(dirname $OUT);' +
|
|
'zip -qr $OUT .',
|
|
out = 'ui_optdbg' + suffix + '.zip',
|
|
visibility = ['PUBLIC'],
|
|
)
|
|
|
|
gwt_binary(
|
|
name = opt,
|
|
modules = [module],
|
|
module_deps = [':ui_module'],
|
|
deps = deps + ([':' + dbg] if CPU_COUNT < 8 else []),
|
|
local_workers = CPU_COUNT,
|
|
strict = True,
|
|
experimental_args = args,
|
|
vm_args = GWT_JVM_ARGS,
|
|
)
|
|
|
|
gwt_binary(
|
|
name = dbg,
|
|
modules = [module],
|
|
style = 'PRETTY',
|
|
optimize = 0,
|
|
module_deps = [':ui_module'],
|
|
deps = deps,
|
|
local_workers = CPU_COUNT,
|
|
strict = True,
|
|
experimental_args = args,
|
|
vm_args = GWT_JVM_ARGS,
|
|
visibility = ['PUBLIC'],
|
|
)
|
|
|
|
gwt_binary(
|
|
name = soyc,
|
|
modules = [module],
|
|
module_deps = [':ui_module'],
|
|
deps = deps + [':' + dbg],
|
|
local_workers = CPU_COUNT,
|
|
strict = True,
|
|
experimental_args = args + ['-compileReport'],
|
|
vm_args = GWT_JVM_ARGS,
|
|
)
|
|
|
|
def gwt_user_agent_permutations(
|
|
name,
|
|
module_name,
|
|
modules,
|
|
style = 'PRETTY',
|
|
optimize = 0,
|
|
draft_compile = True,
|
|
module_deps = [],
|
|
deps = [],
|
|
browsers = BROWSERS,
|
|
visibility = []):
|
|
for ua in browsers:
|
|
impl = ua
|
|
if ua in ALIASES:
|
|
impl = ALIASES[ua]
|
|
xml = ''.join([
|
|
"<module rename-to='%s'>" % module_name,
|
|
"<inherits name='%s'/>" % modules[0],
|
|
"<set-property name='user.agent' value='%s'/>" % impl,
|
|
"<set-property name='locale' value='default'/>",
|
|
"</module>",
|
|
])
|
|
gwt = '%s_%s.gwt.xml' % (modules[0].replace('.', '/'), ua)
|
|
gwt_name = '%s_%s' % (name, ua)
|
|
jar = '%s.gwtxml.jar' % (gwt_name)
|
|
|
|
genrule(
|
|
name = '%s_gwtxml_gen' % gwt_name,
|
|
cmd = 'cd $TMP;' +
|
|
('mkdir -p \$(dirname %s);' % gwt) +
|
|
('echo "%s">%s;' % (xml, gwt)) +
|
|
'zip -qr $OUT .',
|
|
out = jar,
|
|
)
|
|
prebuilt_jar(
|
|
name = '%s_gwtxml_lib' % gwt_name,
|
|
binary_jar = ':%s_gwtxml_gen' % gwt_name,
|
|
gwt_jar = ':%s_gwtxml_gen' % gwt_name,
|
|
)
|
|
gwt_binary(
|
|
name = gwt_name,
|
|
modules = [modules[0] + '_' + ua],
|
|
style = style,
|
|
optimize = optimize,
|
|
draft_compile = draft_compile,
|
|
module_deps = module_deps + [':%s_gwtxml_lib' % gwt_name],
|
|
deps = deps,
|
|
local_workers = CPU_COUNT,
|
|
strict = True,
|
|
experimental_args = GWT_COMPILER_ARGS,
|
|
vm_args = GWT_JVM_ARGS,
|
|
visibility = visibility,
|
|
)
|