Bazel: Build release GWT UI

Change-Id: Iec6dba5dea7be8a2117076a16aa627e0284ff42b
This commit is contained in:
David Ostrovsky 2016-09-23 14:18:00 +02:00
parent c48e6c9730
commit b5313f0663
2 changed files with 106 additions and 91 deletions

View File

@ -1,95 +1,9 @@
load('//tools/bzl:gwt.bzl', 'gwt_module')
load('//tools/bzl:genrule2.bzl', 'genrule2')
load(':gwt.bzl', 'gwt_binary')
load(':gwt.bzl', 'gwt_binary', 'gwt_genrule', 'gen_ui_module')
MODULE = 'com.google.gerrit.GerritGwtUI'
gwt_genrule()
gwt_genrule('_r')
GWT_JVM_ARGS = ['-Xmx512m']
GWT_COMPILER_ARGS = [
'-XdisableClassMetadata',
]
GWT_COMPILER_ARGS_RELEASE_MODE = GWT_COMPILER_ARGS + [
'-XdisableCastChecking',
]
GWT_TRANSITIVE_DEPS = [
'//lib/gwt:ant',
'//lib/gwt:colt',
'//lib/gwt:javax-validation',
'//lib/gwt:javax-validation_src',
'//lib/gwt:jsinterop-annotations',
'//lib/gwt:jsinterop-annotations_src',
'//lib/gwt:tapestry',
'//lib/gwt:w3c-css-sac',
'//lib/ow2:ow2-asm',
'//lib/ow2:ow2-asm-analysis',
'//lib/ow2:ow2-asm-commons',
'//lib/ow2:ow2-asm-tree',
'//lib/ow2:ow2-asm-util',
]
DEPS = GWT_TRANSITIVE_DEPS + [
'//gerrit-gwtexpui:CSS',
'//lib:gwtjsonrpc',
'//lib/gwt:dev',
'@jgit_src//file',
]
gwt_module(
name = 'ui_module',
srcs = glob(['src/main/java/**/*.java']),
gwt_xml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'),
resources = glob(
['src/main/java/**/*'],
exclude = ['src/main/java/**/*.java'] +
['src/main/java/%s.gwt.xml' % MODULE.replace('.', '/')]
),
deps = [
'//gerrit-gwtui-common:diffy_logo',
'//gerrit-gwtui-common:client',
'//gerrit-gwtexpui:CSS',
'//lib/codemirror:codemirror',
'//lib/gwt:user',
],
visibility = ['//visibility:public'],
)
genrule2(
name = 'ui_optdbg',
srcs = [
':ui_dbg',
':ui_opt',
],
cmd = 'cd $$TMP;' +
'unzip -q $$ROOT/$(location :ui_dbg);' +
'mv' +
' gerrit_ui/gerrit_ui.nocache.js' +
' gerrit_ui/dbg_gerrit_ui.nocache.js;' +
'unzip -qo $$ROOT/$(location :ui_opt);' +
'mkdir -p $$(dirname $@);' +
'zip -qr $$ROOT/$@ .',
out = 'ui_optdbg.zip',
visibility = ['//visibility:public'],
)
gwt_binary(
name = 'ui_opt',
modules = [MODULE],
module_deps = [':ui_module'],
deps = DEPS,
compiler_args = GWT_COMPILER_ARGS,
jvm_args = GWT_JVM_ARGS,
)
gwt_binary(
name = 'ui_dbg',
modules = [MODULE],
style = 'PRETTY',
optimize = "0",
module_deps = [':ui_module'],
deps = DEPS,
compiler_args = GWT_COMPILER_ARGS,
jvm_args = GWT_JVM_ARGS,
)
gen_ui_module(name = 'ui_module')
gen_ui_module(name = 'ui_module', suffix = '_r')

View File

@ -14,10 +14,48 @@
# Port of Buck native gwt_binary() rule. See discussion in context of
# https://github.com/facebook/buck/issues/109
load('//tools/bzl:genrule2.bzl', 'genrule2')
load('//tools/bzl:gwt.bzl', 'gwt_module')
jar_filetype = FileType(['.jar'])
MODULE = 'com.google.gerrit.GerritGwtUI'
GWT_COMPILER = "com.google.gwt.dev.Compiler"
GWT_JVM_ARGS = ['-Xmx512m']
GWT_COMPILER_ARGS = [
'-XdisableClassMetadata',
]
GWT_COMPILER_ARGS_RELEASE_MODE = GWT_COMPILER_ARGS + [
'-XdisableCastChecking',
]
GWT_TRANSITIVE_DEPS = [
'//lib/gwt:ant',
'//lib/gwt:colt',
'//lib/gwt:javax-validation',
'//lib/gwt:javax-validation_src',
'//lib/gwt:jsinterop-annotations',
'//lib/gwt:jsinterop-annotations_src',
'//lib/gwt:tapestry',
'//lib/gwt:w3c-css-sac',
'//lib/ow2:ow2-asm',
'//lib/ow2:ow2-asm-analysis',
'//lib/ow2:ow2-asm-commons',
'//lib/ow2:ow2-asm-tree',
'//lib/ow2:ow2-asm-util',
]
DEPS = GWT_TRANSITIVE_DEPS + [
'//gerrit-gwtexpui:CSS',
'//lib:gwtjsonrpc',
'//lib/gwt:dev',
'@jgit_src//file',
]
def _impl(ctx):
output_zip = ctx.outputs.output
output_dir = output_zip.path + '.gwt_output'
@ -93,3 +131,66 @@ gwt_binary = rule(
"output": "%{name}.zip",
},
)
def gwt_genrule(suffix = ""):
dbg = 'ui_dbg' + suffix
opt = 'ui_opt' + suffix
module_dep = ':ui_module' + suffix
args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS
genrule2(
name = 'ui_optdbg' + suffix,
srcs = [
':' + dbg,
':' + opt,
],
cmd = 'cd $$TMP;' +
'unzip -q $$ROOT/$(location :%s);' % dbg +
'mv' +
' gerrit_ui/gerrit_ui.nocache.js' +
' gerrit_ui/dbg_gerrit_ui.nocache.js;' +
'unzip -qo $$ROOT/$(location :%s);' % opt +
'mkdir -p $$(dirname $@);' +
'zip -qr $$ROOT/$@ .',
out = 'ui_optdbg' + suffix + '.zip',
visibility = ['//visibility:public'],
)
gwt_binary(
name = opt,
modules = [MODULE],
module_deps = [module_dep],
deps = DEPS,
compiler_args = args,
jvm_args = GWT_JVM_ARGS,
)
gwt_binary(
name = dbg,
modules = [MODULE],
style = 'PRETTY',
optimize = "0",
module_deps = [module_dep],
deps = DEPS,
compiler_args = GWT_COMPILER_ARGS,
jvm_args = GWT_JVM_ARGS,
)
def gen_ui_module(name, suffix = ""):
gwt_module(
name = name + suffix,
srcs = native.glob(['src/main/java/**/*.java']),
gwt_xml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'),
resources = native.glob(
['src/main/java/**/*'],
exclude = ['src/main/java/**/*.java'] +
['src/main/java/%s.gwt.xml' % MODULE.replace('.', '/')]),
deps = [
'//gerrit-gwtui-common:diffy_logo',
'//gerrit-gwtui-common:client',
'//gerrit-gwtexpui:CSS',
'//lib/codemirror:codemirror' + suffix,
'//lib/gwt:user',
],
visibility = ['//visibility:public'],
)