gerrit/gerrit-gwtui/gwt.defs
David Ostrovsky b0924cafe7 Buck: Remove no-op gwt_jar attribute in prebuilt_jar
If there is a prebuilt jar that defines a different binary jar from
the gwt jar, building a normal java binary will use the binary jar,
and building a gwt binary will use the gwt jar.

If a target defines them both to be the same there's no need to define
the gwt jar, as it will default to being the binary jar.

The actual use case where it is needed when there is an alternative GWT
implementation of a Java library. Specifically, when there is one
implementation that contains JSNI, and one implementation that contains
an implementation that cannot be translated to JS by the GWT compiler:

  prebuilt_jar(
    name = 'guava',
    binary_jar = 'guava-17.0.jar',
    source_jar = 'guava-17.0-sources.jar',
    gwt_jar = 'guava-gwt-17.0.jar',
    visibility = [
      'PUBLIC',
    ],
  )

Change-Id: Ibbc7ea56aad6885625e652b2dedbcdfe038735d7
2016-11-03 15:00:04 +00:00

142 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', 'ie10',
'edge',
]
ALIASES = {
'chrome': 'safari',
'firefox': 'gecko1_8',
'msie': 'ie10',
'edge': 'gecko1_8',
}
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
module_dep = ':ui_module' + 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 = [module_dep],
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 = [module_dep],
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 = [module_dep],
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_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,
)