From 06e069cfcc587ca4b79801753c54f5d514360a5b Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Tue, 13 May 2014 15:57:36 -0700 Subject: [PATCH 1/5] Update Buck and use gwt_binary() Migrate gwt build tool chain to built in gwt_binary() rule [1]. [1] https://github.com/facebook/buck/issues/109 Change-Id: I1f13f4d29864bc7e7278f8a2b2e39c882acf44aa --- .buckversion | 2 +- BUCK | 2 +- Documentation/dev-buck.txt | 11 +--- gerrit-common/BUCK | 1 + gerrit-gwtexpui/BUCK | 4 +- gerrit-gwtui/BUCK | 57 +++++++++------- gerrit-gwtui/gwt.defs | 50 +++++++------- .../gerrit/pgm/http/jetty/JettyServer.java | 8 ++- lib/gwt/BUCK | 6 -- lib/gwt/compiler.py | 65 ------------------- tools/build.defs | 18 ++--- tools/default.defs | 39 +++-------- tools/gwt-constants.defs | 7 +- 13 files changed, 96 insertions(+), 174 deletions(-) delete mode 100755 lib/gwt/compiler.py diff --git a/.buckversion b/.buckversion index 2c9f529b89..4462205a99 100644 --- a/.buckversion +++ b/.buckversion @@ -1 +1 @@ -021695d5e68cde7457c9849fd0a2397f91e6491e +75000f4273a399d2cd2768512639da80748877b7 diff --git a/BUCK b/BUCK index 5a38439429..2cd3fa8b6d 100644 --- a/BUCK +++ b/BUCK @@ -5,7 +5,7 @@ gerrit_war(name = 'chrome', ui = 'ui_chrome') gerrit_war(name = 'firefox', ui = 'ui_firefox') gerrit_war(name = 'safari', ui = 'ui_safari') gerrit_war(name = 'withdocs', docs = True) -gerrit_war(name = 'release', docs = True, context = ['//plugins:core.zip'], visibility = ['//tools/maven:']) +gerrit_war(name = 'release', docs = True, context = ['//plugins:core'], visibility = ['//tools/maven:']) API_DEPS = [ '//gerrit-extension-api:extension-api', diff --git a/Documentation/dev-buck.txt b/Documentation/dev-buck.txt index 10d0640c22..91cc5859a3 100644 --- a/Documentation/dev-buck.txt +++ b/Documentation/dev-buck.txt @@ -42,13 +42,6 @@ Verify that `buck` is accessible: which buck ---- -If you plan to use the link:#buck-daemon[Buck daemon] add a symbolic -link in `~/bin` to the buckd executable: - ----- - ln -s `pwd`/bin/buckd ~/bin/ ----- - To enable autocompletion of buck commands, install the autocompletion script from `./scripts/bash_completion` in the buck project. Refer to the script's header comments for installation instructions. @@ -470,8 +463,8 @@ It is safe to run several buck daemons started from different project directories and they will not interfere with each other. Buck's documentation covers daemon in http://facebook.github.io/buck/command/buckd.html[buckd]. -The trivial use case is to run `buckd` from the project's root directory and -run `buck` as usual: +To use `buckd` the additional watchman program must be installed, see +link:https://github.com/facebook/watchman[watchman] for details. ---- buckd diff --git a/gerrit-common/BUCK b/gerrit-common/BUCK index e2dcb27b63..7b113b4139 100644 --- a/gerrit-common/BUCK +++ b/gerrit-common/BUCK @@ -22,6 +22,7 @@ gwt_module( srcs = glob([SRC + 'common/**/*.java'], excludes = EXCLUDES), gwtxml = SRC + 'Common.gwt.xml', deps = [ + '//gerrit-extension-api:client', '//gerrit-patch-jgit:client', '//gerrit-prettify:client', '//gerrit-reviewdb:client', diff --git a/gerrit-gwtexpui/BUCK b/gerrit-gwtexpui/BUCK index 028b34e081..15f65ccade 100644 --- a/gerrit-gwtexpui/BUCK +++ b/gerrit-gwtexpui/BUCK @@ -74,12 +74,12 @@ java_test( 'src/test/java/com/google/gwtexpui/safehtml/client/**/*.java', ]), deps = [ - ':SafeHtml_lib', + ':SafeHtml', '//lib:junit', '//lib/gwt:user', '//lib/gwt:dev', ], - source_under_test = [':SafeHtml_lib'], + source_under_test = [':SafeHtml'], ) gwt_module( diff --git a/gerrit-gwtui/BUCK b/gerrit-gwtui/BUCK index 56c52bffb1..44785a48c9 100644 --- a/gerrit-gwtui/BUCK +++ b/gerrit-gwtui/BUCK @@ -1,20 +1,22 @@ include_defs('//gerrit-gwtui/gwt.defs') include_defs('//tools/gwt-constants.defs') +from multiprocessing import cpu_count + +DEPS = [ + '//gerrit-gwtexpui:CSS', + '//lib:gwtjsonrpc', +] genrule( name = 'ui_optdbg', cmd = 'cd $TMP;' + - 'unzip -q $SRCDIR/ui_dbg.zip;' + + 'unzip -q $(location :ui_dbg);' + 'mv' + ' gerrit_ui/gerrit_ui.nocache.js' + ' gerrit_ui/dbg_gerrit_ui.nocache.js;' + - 'unzip -qo $SRCDIR/ui_opt.zip;' + + 'unzip -qo $(location :ui_opt);' + 'mkdir -p $(dirname $OUT);' + 'zip -qr $OUT .', - srcs = [ - genfile('ui_dbg.zip'), - genfile('ui_opt.zip'), - ], deps = [ ':ui_dbg', ':ui_opt', @@ -23,28 +25,39 @@ genrule( visibility = ['PUBLIC'], ) -gwt_application( +gwt_binary( name = 'ui_opt', - module_target = MODULE, - compiler_opts = GWT_COMPILER_OPTS, - deps = APP_DEPS + [':ui_dbg'], + modules = [MODULE], + style = 'OBF', + optimize = 9, + module_deps = [':ui_module'], + deps = DEPS + ['//lib/gwt:dev', ':ui_dbg'], + local_workers = cpu_count(), + strict = True, + experimental_args = GWT_COMPILER_ARGS, + vm_args = GWT_JVM_ARGS, ) -gwt_application( +gwt_binary( name = 'ui_dbg', - module_target = MODULE, - compiler_opts = DEBUG_OPTS + ['-strict'], - deps = APP_DEPS, + modules = [MODULE], + style = 'PRETTY', + optimize = 0, + module_deps = [':ui_module'], + deps = DEPS + ['//lib/gwt:dev'], + local_workers = cpu_count(), + strict = True, + experimental_args = GWT_COMPILER_ARGS, + vm_args = GWT_JVM_ARGS, visibility = ['//:eclipse'], ) gwt_user_agent_permutations( name = 'ui', module_name = 'gerrit_ui', - module_target = MODULE, - compiler_opts = DEBUG_OPTS + ['-draftCompile'], - browsers = BROWSERS, - deps = APP_DEPS, + modules = [MODULE], + module_deps = [':ui_module'], + deps = DEPS, visibility = ['//:'], ) @@ -113,16 +126,16 @@ java_test( 'src/main/java/com/google/gerrit/GerritGwtUI.gwt.xml', ], deps = [ - ':ui_module_lib', - '//gerrit-common:client_lib', - '//gerrit-extension-api:client_lib', + ':ui_module', + '//gerrit-common:client', + '//gerrit-extension-api:client', '//lib:junit', '//lib/gwt:dev', '//lib/gwt:user', '//lib/gwt:gwt-test-utils', '//lib/jgit:jgit', ], - source_under_test = [':ui_module_lib'], + source_under_test = [':ui_module'], vm_args = ['-Xmx512m'], visibility = ['//tools/eclipse:classpath'], ) diff --git a/gerrit-gwtui/gwt.defs b/gerrit-gwtui/gwt.defs index e407854b53..b9039771e8 100644 --- a/gerrit-gwtui/gwt.defs +++ b/gerrit-gwtui/gwt.defs @@ -26,36 +26,35 @@ ALIASES = { } MODULE = 'com.google.gerrit.GerritGwtUI' -DEBUG_OPTS = [ - '-style', 'PRETTY', - '-optimize', '0', -] - -APP_DEPS = [':ui_module'] - def gwt_user_agent_permutations( name, module_name, - module_target, - compiler_opts = [], + modules, + style = 'PRETTY', + optimize = 0, + draft_compile = True, + module_deps = [], deps = [], - browsers = [], + browsers = BROWSERS, visibility = []): + from multiprocessing import cpu_count for ua in browsers: impl = ua if ua in ALIASES: impl = ALIASES[ua] xml = ''.join([ "" % module_name, - "" % module_target, + "" % modules[0], "" % impl, "", "", ]) - gwt = '%s_%s.gwt.xml' % (module_target.replace('.', '/'), ua) - jar = '%s_%s.gwtxml.jar' % (name, ua) + gwt = '%s_%s.gwt.xml' % (modules[0].replace('.', '/'), ua) + gwt_name = '%s_%s' % (name, ua) + jar = '%s.gwtxml.jar' % (gwt_name) + genrule( - name = '%s_%s_gwtxml_gen' % (name, ua), + name = '%s_gwtxml_gen' % gwt_name, cmd = 'cd $TMP;' + ('mkdir -p $(dirname %s);' % gwt) + ('echo "%s">%s;' % (xml, gwt)) + @@ -63,15 +62,22 @@ def gwt_user_agent_permutations( out = jar, ) prebuilt_jar( - name = '%s_%s_gwtxml_lib' % (name, ua), + name = '%s_gwtxml_lib' % gwt_name, binary_jar = genfile(jar), - deps = [':%s_%s_gwtxml_gen' % (name, ua)], + gwt_jar = genfile(jar), + deps = [':%s_gwtxml_gen' % gwt_name], ) - gwt_application( - name = '%s_%s' % (name, ua), - module_target = module_target + '_' + ua, - compiler_opts = compiler_opts, - deps = deps + [':%s_%s_gwtxml_lib' % (name, ua)], + 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, ) - diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/JettyServer.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/JettyServer.java index 31d75f1851..a98b564bd8 100644 --- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/JettyServer.java +++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/JettyServer.java @@ -588,7 +588,13 @@ public class JettyServer { String pkg = "gerrit-gwtui"; String target = "ui_" + rule.select((HttpServletRequest) request); String rule = "//" + pkg + ":" + target; - File zip = new File(new File(gen, pkg), target + ".zip"); + // TODO(davido): instead of assuming specific Buck's internal + // target directory for gwt_binary() artifacts, ask Buck for + // the location of user agent permutation GWT zip, e. g.: + // $ buck targets --show_output //gerrit-gwtui:ui_safari \ + // | awk '{print $2}' + String child = String.format("%s/__gwt_binary_%s__", pkg, target); + File zip = new File(new File(gen, child), target + ".zip"); synchronized (this) { try { diff --git a/lib/gwt/BUCK b/lib/gwt/BUCK index 537c6d8579..ce10120610 100644 --- a/lib/gwt/BUCK +++ b/lib/gwt/BUCK @@ -32,12 +32,6 @@ maven_jar( visibility = [], ) -python_binary( - name = 'compiler', - main = 'compiler.py', - visibility = ['PUBLIC'], -) - maven_jar( name = 'gwt-test-utils', id = 'com.googlecode.gwt-test-utils:gwt-test-utils:0.47', diff --git a/lib/gwt/compiler.py b/lib/gwt/compiler.py deleted file mode 100755 index f7b478cc57..0000000000 --- a/lib/gwt/compiler.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/python -# 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 __future__ import print_function - -from multiprocessing import cpu_count -from os import makedirs, mkdir, path -from subprocess import Popen, PIPE -from sys import argv, stderr - -cp, opt, end = [], [], False -module, TMP, outzip = argv[1], argv[2], argv[3] - -for a in argv[4:]: - if end: - if a.endswith('.jar'): - cp.append(path.expandvars(a)) - elif a == '--': - end = True - else: - opt.append(a) - -if not outzip.endswith('.zip'): - print("%s must end with .zip" % outzip, file=stderr) - exit(1) - -for d in ['deploy', 'unit_cache', 'work']: - mkdir(path.join(TMP, d)) -if not path.exists(path.dirname(outzip)): - makedirs(path.dirname(outzip)) - -cmd = [ - 'java', '-Xmx512m', - '-Djava.io.tmpdir=' + TMP, - '-Dgwt.normalizeTimestamps=true', - '-Dgwt.persistentunitcachedir=' + path.join(TMP, 'unit_cache'), - '-classpath', ':'.join(cp), - 'com.google.gwt.dev.Compiler', - '-deploy', path.join(TMP, 'deploy'), - '-workDir', path.join(TMP, 'work'), - '-war', outzip, - '-localWorkers', str(cpu_count()), -] + opt + [module] - -try: - gwt = Popen(cmd, stdout=PIPE, stderr=PIPE) - out, err = gwt.communicate() - if gwt.returncode != 0: - print(out + err, file=stderr) - exit(gwt.returncode) -except KeyboardInterrupt: - print("Interrupted by user", file=stderr) - exit(1) diff --git a/tools/build.defs b/tools/build.defs index 5c01e8f7b1..9ce28f210b 100644 --- a/tools/build.defs +++ b/tools/build.defs @@ -57,15 +57,9 @@ def war( dep.extend(DOCS_DEP) cmd.extend(['--lib', DOCS_LIB]) if context: - root = get_base_path() - if root: - root = '/'.join(['..' for _ in root.split('/')]) + '/' - for r in context: - dep.append(r[:r.rindex('.')]) - if r.startswith('//'): - r = root + r[2:] - r = r.replace(':', '/') - src.append(genfile(r)) + for t in context: + dep.append(t) + cmd.append('$(location %s)' % t) if src: cmd.append('$SRCS') @@ -84,9 +78,9 @@ def gerrit_war(name, ui = 'ui_optdbg', context = [], docs = False, visibility = libs = LIBS + ['//gerrit-war:version'], pgmlibs = PGMLIBS, context = [ - '//gerrit-main:main_bin.jar', - '//gerrit-war:webapp_assets.zip', - '//gerrit-gwtui:' + ui + '.zip', + '//gerrit-main:main_bin', + '//gerrit-war:webapp_assets', + '//gerrit-gwtui:' + ui, ] + context, docs = docs, visibility = visibility, diff --git a/tools/default.defs b/tools/default.defs index a550a473a1..f3f29fc2c9 100644 --- a/tools/default.defs +++ b/tools/default.defs @@ -43,36 +43,11 @@ def gwt_module( resources = resources + [gwtxml] java_library( name = name, + srcs = srcs, deps = deps + compile_deps, resources = srcs + resources, visibility = visibility, ) - java_library( - name = name + '_lib', - srcs = srcs, - deps = [':' + name] + [d + '_lib' for d in deps] + compile_deps, - visibility = visibility, - ) - -def gwt_application( - name, - module_target, - compiler_opts = [], - compiler_jvm_flags = [], - deps = [], - visibility = []): - cmd = ['$(exe //lib/gwt:compiler)', module_target, '$TMP', '$OUT'] - cmd += compiler_opts + ['--', '$DEPS'] - genrule( - name = name, - cmd = ' '.join(cmd), - deps = [ - '//lib/gwt:compiler', - '//lib/gwt:dev', - ] + deps, - out = '%s.zip' % name, - visibility = visibility, - ) def gerrit_extension( name, @@ -106,6 +81,7 @@ def gerrit_plugin( manifest_entries = [], type = 'plugin', visibility = ['PUBLIC']): + from multiprocessing import cpu_count mf_cmd = 'v=$(git describe HEAD);' if manifest_file: mf_src = [manifest_file] @@ -154,11 +130,16 @@ def gerrit_plugin( out = '%s-static.zip' % name, deps = [':%s__gwt_application' % name] ) - gwt_application( + gwt_binary( name = name + '__gwt_application', - module_target = gwt_module, - compiler_opts = GWT_COMPILER_OPTS, + modules = [gwt_module], + style = 'OBF', + optimize = 9, deps = [':%s__plugin' % name] + gwt_deps, + local_workers = cpu_count(), + strict = True, + experimental_args = GWT_COMPILER_ARGS, + vm_args = GWT_JVM_ARGS, ) java_binary( name = name, diff --git a/tools/gwt-constants.defs b/tools/gwt-constants.defs index b5f6292e9e..44d2a625e6 100644 --- a/tools/gwt-constants.defs +++ b/tools/gwt-constants.defs @@ -1,7 +1,6 @@ -GWT_COMPILER_OPTS = [ - '-strict', - '-style', 'OBF', - '-optimize', '9', +GWT_JVM_ARGS = ['-Xmx512m'] + +GWT_COMPILER_ARGS = [ '-XdisableClassMetadata', '-XdisableCastChecking', ] From 834708c8eaeb9b12cc15d5bfa2cceeb9423d0709 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sat, 17 May 2014 07:44:31 +0200 Subject: [PATCH 2/5] Buck: Merge deps and compile_deps parameters in gwt_module() rule After migration to Buck's own gwt_binary() rule, gwt module libraries must contain compiled classes. That makes the differentiation between deps and compile_deps unnecessary. Change-Id: I26fd741d566709a4d56b6e9623766012279903e4 --- gerrit-common/BUCK | 4 +--- gerrit-gwtexpui/BUCK | 10 ++++------ gerrit-gwtui-common/BUCK | 2 +- gerrit-gwtui/BUCK | 4 +--- gerrit-patch-jgit/BUCK | 2 +- gerrit-prettify/BUCK | 4 +--- gerrit-reviewdb/BUCK | 2 +- tools/default.defs | 3 +-- 8 files changed, 11 insertions(+), 20 deletions(-) diff --git a/gerrit-common/BUCK b/gerrit-common/BUCK index 7b113b4139..cc7a00b817 100644 --- a/gerrit-common/BUCK +++ b/gerrit-common/BUCK @@ -22,13 +22,11 @@ gwt_module( srcs = glob([SRC + 'common/**/*.java'], excludes = EXCLUDES), gwtxml = SRC + 'Common.gwt.xml', deps = [ + ':annotations', '//gerrit-extension-api:client', '//gerrit-patch-jgit:client', '//gerrit-prettify:client', '//gerrit-reviewdb:client', - ], - compile_deps = [ - ':annotations', '//lib:gwtjsonrpc', '//lib:gwtorm', '//lib/jgit:jgit', diff --git a/gerrit-gwtexpui/BUCK b/gerrit-gwtexpui/BUCK index 15f65ccade..4e0165f413 100644 --- a/gerrit-gwtexpui/BUCK +++ b/gerrit-gwtexpui/BUCK @@ -11,8 +11,6 @@ gwt_module( deps = [ ':SafeHtml', ':UserAgent', - ], - compile_deps = [ '//lib/gwt:user', '//lib:LICENSE-clippy', ], @@ -38,8 +36,8 @@ gwt_module( deps = [ ':SafeHtml', ':UserAgent', + '//lib/gwt:user', ], - compile_deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) @@ -55,7 +53,7 @@ gwt_module( srcs = glob([SRC + 'progress/client/*.java']), gwtxml = SRC + 'progress/Progress.gwt.xml', resources = [SRC + 'progress/client/progress.css'], - compile_deps = ['//lib/gwt:user'], + deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) @@ -64,7 +62,7 @@ gwt_module( srcs = glob([SRC + 'safehtml/client/*.java']), gwtxml = SRC + 'safehtml/SafeHtml.gwt.xml', resources = [SRC + 'safehtml/client/safehtml.css'], - compile_deps = ['//lib/gwt:user'], + deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) @@ -86,7 +84,7 @@ gwt_module( name = 'UserAgent', srcs = glob([SRC + 'user/client/*.java']), gwtxml = SRC + 'user/User.gwt.xml', - compile_deps = ['//lib/gwt:user'], + deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) diff --git a/gerrit-gwtui-common/BUCK b/gerrit-gwtui-common/BUCK index debad476be..dcac3210a1 100644 --- a/gerrit-gwtui-common/BUCK +++ b/gerrit-gwtui-common/BUCK @@ -4,7 +4,7 @@ gwt_module( name = 'client', srcs = glob([SRC + 'client/**/*.java']), gwtxml = SRC + 'GerritGwtUICommon.gwt.xml', - compile_deps = ['//lib/gwt:user'], + deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) diff --git a/gerrit-gwtui/BUCK b/gerrit-gwtui/BUCK index 44785a48c9..2105e06aee 100644 --- a/gerrit-gwtui/BUCK +++ b/gerrit-gwtui/BUCK @@ -69,6 +69,7 @@ gwt_module( gwtxml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'), resources = glob(['src/main/java/**/*'], excludes = DIFFY), deps = [ + ':diffy_logo', '//gerrit-gwtexpui:Clippy', '//gerrit-gwtexpui:GlobalKey', '//gerrit-gwtexpui:Progress', @@ -80,9 +81,6 @@ gwt_module( '//gerrit-patch-jgit:client', '//gerrit-prettify:client', '//gerrit-reviewdb:client', - ], - compile_deps = [ - ':diffy_logo', '//gerrit-gwtexpui:CSS', '//lib:gwtjsonrpc', '//lib:gwtjsonrpc_src', diff --git a/gerrit-patch-jgit/BUCK b/gerrit-patch-jgit/BUCK index 00b82284e7..1e0953f6b8 100644 --- a/gerrit-patch-jgit/BUCK +++ b/gerrit-patch-jgit/BUCK @@ -7,7 +7,7 @@ gwt_module( SRC + 'diff/ReplaceEdit.java', ], gwtxml = SRC + 'JGit.gwt.xml', - compile_deps = [ + deps = [ '//lib:gwtjsonrpc', '//lib/gwt:user', '//lib/jgit:jgit', diff --git a/gerrit-prettify/BUCK b/gerrit-prettify/BUCK index e753ad941a..79dc76010a 100644 --- a/gerrit-prettify/BUCK +++ b/gerrit-prettify/BUCK @@ -11,12 +11,10 @@ gwt_module( 'src/main/java/com/google/gerrit/prettify/client/*.properties', ]), deps = [ + ':google-code-prettify', '//gerrit-patch-jgit:client', '//gerrit-reviewdb:client', '//gerrit-gwtexpui:SafeHtml', - ], - compile_deps = [ - ':google-code-prettify', '//lib:guava', '//lib:gwtjsonrpc', '//lib/gwt:user', diff --git a/gerrit-reviewdb/BUCK b/gerrit-reviewdb/BUCK index 370c8692e3..8ff523d837 100644 --- a/gerrit-reviewdb/BUCK +++ b/gerrit-reviewdb/BUCK @@ -4,7 +4,7 @@ gwt_module( name = 'client', srcs = glob([SRC + 'client/**/*.java']), gwtxml = SRC + 'ReviewDB.gwt.xml', - compile_deps = [ + deps = [ '//gerrit-extension-api:client', '//lib:gwtorm', '//lib:gwtorm_src' diff --git a/tools/default.defs b/tools/default.defs index f3f29fc2c9..607f7adfba 100644 --- a/tools/default.defs +++ b/tools/default.defs @@ -37,14 +37,13 @@ def gwt_module( gwtxml = None, resources = [], deps = [], - compile_deps = [], visibility = []): if gwtxml: resources = resources + [gwtxml] java_library( name = name, srcs = srcs, - deps = deps + compile_deps, + deps = deps, resources = srcs + resources, visibility = visibility, ) From 4af374c5afaeb70c9f778c33b6fa0b368abdace4 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sat, 17 May 2014 08:04:25 +0200 Subject: [PATCH 3/5] Buck: Make gwt_module() rule more pythonic gwt_module() rule is a normal java_library() rule with optional xml description of the GWT module included in resources list. The current implementation of this rule maps hard coded all parameters from gwt_module() to java_library(). This is not future proof, as java_library() may become additional parameters, like provided_deps recently and the implementation must be extended. This change provides alternative implementation that copy parameter list in generic way, adding GWT xml to resources list on the fly. Inspired-By: Michael Bolin Change-Id: I7f1ee1d6b3e142f14a199e80dea4e91817b5c7d5 --- tools/default.defs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/tools/default.defs b/tools/default.defs index 607f7adfba..606c3569c0 100644 --- a/tools/default.defs +++ b/tools/default.defs @@ -15,6 +15,7 @@ # Rule definitions loaded by default into every BUCK file. include_defs('//tools/gwt-constants.defs') +import copy def genantlr( name, @@ -31,22 +32,15 @@ def genantlr( out = out, ) -def gwt_module( - name, - srcs, - gwtxml = None, - resources = [], - deps = [], - visibility = []): +def gwt_module(gwtxml=None, **kwargs): + kw = copy.deepcopy(kwargs) + if 'resources' not in kw: + kw['resources'] = [] if gwtxml: - resources = resources + [gwtxml] - java_library( - name = name, - srcs = srcs, - deps = deps, - resources = srcs + resources, - visibility = visibility, - ) + kw['resources'] += [gwtxml] + if 'srcs' in kw: + kw['resources'] += kw['srcs'] + java_library(**kw) def gerrit_extension( name, From 7d6b923e17676f46edce361a5f0cfdce6061b988 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sat, 17 May 2014 08:11:54 +0200 Subject: [PATCH 4/5] Buck: Omit default values to gwt_binary() rule style = 'OBF' and optimze = 9 are default values in gwt_binary() rule definition and do not need to be passed. Change-Id: Ic09dc032461ede6e236a267f2a32efbe161dd69c --- gerrit-gwtui/BUCK | 2 -- tools/default.defs | 2 -- 2 files changed, 4 deletions(-) diff --git a/gerrit-gwtui/BUCK b/gerrit-gwtui/BUCK index 2105e06aee..2b64cac8c5 100644 --- a/gerrit-gwtui/BUCK +++ b/gerrit-gwtui/BUCK @@ -28,8 +28,6 @@ genrule( gwt_binary( name = 'ui_opt', modules = [MODULE], - style = 'OBF', - optimize = 9, module_deps = [':ui_module'], deps = DEPS + ['//lib/gwt:dev', ':ui_dbg'], local_workers = cpu_count(), diff --git a/tools/default.defs b/tools/default.defs index 606c3569c0..031d058de8 100644 --- a/tools/default.defs +++ b/tools/default.defs @@ -126,8 +126,6 @@ def gerrit_plugin( gwt_binary( name = name + '__gwt_application', modules = [gwt_module], - style = 'OBF', - optimize = 9, deps = [':%s__plugin' % name] + gwt_deps, local_workers = cpu_count(), strict = True, From 76e396b49b65619acba56363e8e4292362d93708 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sat, 17 May 2014 08:24:12 +0200 Subject: [PATCH 5/5] Buck: Rename gwtxml to gwt_xml in gwt_module() gwt_xml is more pythonic naming convention. Beside that recent Buck version introduced new gwt_jar parameter in prebuilt_jar() rule and future Buck versions may introduce gwt_xml parameter to java_library() rule. Change-Id: Ia6447e62945ce3eb5ff951421ebf2f0fdf622b3d --- gerrit-common/BUCK | 2 +- gerrit-extension-api/BUCK | 2 +- gerrit-gwtexpui/BUCK | 10 +++++----- gerrit-gwtui-common/BUCK | 2 +- gerrit-gwtui/BUCK | 2 +- gerrit-patch-jgit/BUCK | 2 +- gerrit-prettify/BUCK | 2 +- gerrit-reviewdb/BUCK | 2 +- tools/default.defs | 6 +++--- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gerrit-common/BUCK b/gerrit-common/BUCK index cc7a00b817..8ce8f7764f 100644 --- a/gerrit-common/BUCK +++ b/gerrit-common/BUCK @@ -20,7 +20,7 @@ java_library( gwt_module( name = 'client', srcs = glob([SRC + 'common/**/*.java'], excludes = EXCLUDES), - gwtxml = SRC + 'Common.gwt.xml', + gwt_xml = SRC + 'Common.gwt.xml', deps = [ ':annotations', '//gerrit-extension-api:client', diff --git a/gerrit-extension-api/BUCK b/gerrit-extension-api/BUCK index 38707368ae..aad79d7adb 100644 --- a/gerrit-extension-api/BUCK +++ b/gerrit-extension-api/BUCK @@ -10,7 +10,7 @@ gwt_module( SRC + 'common/SubmitType.java', SRC + 'webui/GerritTopMenu.java', ]), - gwtxml = SRC + 'Extensions.gwt.xml', + gwt_xml = SRC + 'Extensions.gwt.xml', visibility = ['PUBLIC'], ) diff --git a/gerrit-gwtexpui/BUCK b/gerrit-gwtexpui/BUCK index 4e0165f413..e06bf17068 100644 --- a/gerrit-gwtexpui/BUCK +++ b/gerrit-gwtexpui/BUCK @@ -3,7 +3,7 @@ SRC = 'src/main/java/com/google/gwtexpui/' gwt_module( name = 'Clippy', srcs = glob([SRC + 'clippy/client/*.java']), - gwtxml = SRC + 'clippy/Clippy.gwt.xml', + gwt_xml = SRC + 'clippy/Clippy.gwt.xml', resources = [ SRC + 'clippy/client/clippy.css', SRC + 'clippy/client/clippy.swf', @@ -28,7 +28,7 @@ java_library( gwt_module( name = 'GlobalKey', srcs = glob([SRC + 'globalkey/client/*.java']), - gwtxml = SRC + 'globalkey/GlobalKey.gwt.xml', + gwt_xml = SRC + 'globalkey/GlobalKey.gwt.xml', resources = [ SRC + 'globalkey/client/KeyConstants.properties', SRC + 'globalkey/client/key.css', @@ -51,7 +51,7 @@ java_library( gwt_module( name = 'Progress', srcs = glob([SRC + 'progress/client/*.java']), - gwtxml = SRC + 'progress/Progress.gwt.xml', + gwt_xml = SRC + 'progress/Progress.gwt.xml', resources = [SRC + 'progress/client/progress.css'], deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], @@ -60,7 +60,7 @@ gwt_module( gwt_module( name = 'SafeHtml', srcs = glob([SRC + 'safehtml/client/*.java']), - gwtxml = SRC + 'safehtml/SafeHtml.gwt.xml', + gwt_xml = SRC + 'safehtml/SafeHtml.gwt.xml', resources = [SRC + 'safehtml/client/safehtml.css'], deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], @@ -83,7 +83,7 @@ java_test( gwt_module( name = 'UserAgent', srcs = glob([SRC + 'user/client/*.java']), - gwtxml = SRC + 'user/User.gwt.xml', + gwt_xml = SRC + 'user/User.gwt.xml', deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) diff --git a/gerrit-gwtui-common/BUCK b/gerrit-gwtui-common/BUCK index dcac3210a1..f4c2358870 100644 --- a/gerrit-gwtui-common/BUCK +++ b/gerrit-gwtui-common/BUCK @@ -3,7 +3,7 @@ SRC = 'src/main/java/com/google/gerrit/' gwt_module( name = 'client', srcs = glob([SRC + 'client/**/*.java']), - gwtxml = SRC + 'GerritGwtUICommon.gwt.xml', + gwt_xml = SRC + 'GerritGwtUICommon.gwt.xml', deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) diff --git a/gerrit-gwtui/BUCK b/gerrit-gwtui/BUCK index 2b64cac8c5..6525ed678c 100644 --- a/gerrit-gwtui/BUCK +++ b/gerrit-gwtui/BUCK @@ -64,7 +64,7 @@ DIFFY = glob(['src/main/java/com/google/gerrit/client/diffy*.png']) gwt_module( name = 'ui_module', srcs = glob(['src/main/java/**/*.java']), - gwtxml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'), + gwt_xml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'), resources = glob(['src/main/java/**/*'], excludes = DIFFY), deps = [ ':diffy_logo', diff --git a/gerrit-patch-jgit/BUCK b/gerrit-patch-jgit/BUCK index 1e0953f6b8..e62172229c 100644 --- a/gerrit-patch-jgit/BUCK +++ b/gerrit-patch-jgit/BUCK @@ -6,7 +6,7 @@ gwt_module( SRC + 'diff/Edit_JsonSerializer.java', SRC + 'diff/ReplaceEdit.java', ], - gwtxml = SRC + 'JGit.gwt.xml', + gwt_xml = SRC + 'JGit.gwt.xml', deps = [ '//lib:gwtjsonrpc', '//lib/gwt:user', diff --git a/gerrit-prettify/BUCK b/gerrit-prettify/BUCK index 79dc76010a..cc42d2b769 100644 --- a/gerrit-prettify/BUCK +++ b/gerrit-prettify/BUCK @@ -6,7 +6,7 @@ gwt_module( SRC + 'client/**/*.java', SRC + 'common/**/*.java', ]), - gwtxml = SRC + 'PrettyFormatter.gwt.xml', + gwt_xml = SRC + 'PrettyFormatter.gwt.xml', resources = glob([ 'src/main/java/com/google/gerrit/prettify/client/*.properties', ]), diff --git a/gerrit-reviewdb/BUCK b/gerrit-reviewdb/BUCK index 8ff523d837..faf80a8c5a 100644 --- a/gerrit-reviewdb/BUCK +++ b/gerrit-reviewdb/BUCK @@ -3,7 +3,7 @@ SRC = 'src/main/java/com/google/gerrit/reviewdb/' gwt_module( name = 'client', srcs = glob([SRC + 'client/**/*.java']), - gwtxml = SRC + 'ReviewDB.gwt.xml', + gwt_xml = SRC + 'ReviewDB.gwt.xml', deps = [ '//gerrit-extension-api:client', '//lib:gwtorm', diff --git a/tools/default.defs b/tools/default.defs index 031d058de8..a8a323f594 100644 --- a/tools/default.defs +++ b/tools/default.defs @@ -32,12 +32,12 @@ def genantlr( out = out, ) -def gwt_module(gwtxml=None, **kwargs): +def gwt_module(gwt_xml=None, **kwargs): kw = copy.deepcopy(kwargs) if 'resources' not in kw: kw['resources'] = [] - if gwtxml: - kw['resources'] += [gwtxml] + if gwt_xml: + kw['resources'] += [gwt_xml] if 'srcs' in kw: kw['resources'] += kw['srcs'] java_library(**kw)