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..8ce8f7764f 100644 --- a/gerrit-common/BUCK +++ b/gerrit-common/BUCK @@ -20,14 +20,13 @@ 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', '//gerrit-patch-jgit:client', '//gerrit-prettify:client', '//gerrit-reviewdb:client', - ], - compile_deps = [ - ':annotations', '//lib:gwtjsonrpc', '//lib:gwtorm', '//lib/jgit:jgit', 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 028b34e081..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', @@ -11,8 +11,6 @@ gwt_module( deps = [ ':SafeHtml', ':UserAgent', - ], - compile_deps = [ '//lib/gwt:user', '//lib:LICENSE-clippy', ], @@ -30,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', @@ -38,8 +36,8 @@ gwt_module( deps = [ ':SafeHtml', ':UserAgent', + '//lib/gwt:user', ], - compile_deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) @@ -53,18 +51,18 @@ 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'], - compile_deps = ['//lib/gwt:user'], + deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) 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'], - compile_deps = ['//lib/gwt:user'], + deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) @@ -74,19 +72,19 @@ 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( name = 'UserAgent', srcs = glob([SRC + 'user/client/*.java']), - gwtxml = SRC + 'user/User.gwt.xml', - compile_deps = ['//lib/gwt:user'], + 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 debad476be..f4c2358870 100644 --- a/gerrit-gwtui-common/BUCK +++ b/gerrit-gwtui-common/BUCK @@ -3,8 +3,8 @@ SRC = 'src/main/java/com/google/gerrit/' gwt_module( name = 'client', srcs = glob([SRC + 'client/**/*.java']), - gwtxml = SRC + 'GerritGwtUICommon.gwt.xml', - compile_deps = ['//lib/gwt:user'], + gwt_xml = SRC + 'GerritGwtUICommon.gwt.xml', + deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) diff --git a/gerrit-gwtui/BUCK b/gerrit-gwtui/BUCK index 56c52bffb1..6525ed678c 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,37 @@ 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], + 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 = ['//:'], ) @@ -53,9 +64,10 @@ 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', '//gerrit-gwtexpui:Clippy', '//gerrit-gwtexpui:GlobalKey', '//gerrit-gwtexpui:Progress', @@ -67,9 +79,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', @@ -113,16 +122,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-patch-jgit/BUCK b/gerrit-patch-jgit/BUCK index 00b82284e7..e62172229c 100644 --- a/gerrit-patch-jgit/BUCK +++ b/gerrit-patch-jgit/BUCK @@ -6,8 +6,8 @@ gwt_module( SRC + 'diff/Edit_JsonSerializer.java', SRC + 'diff/ReplaceEdit.java', ], - gwtxml = SRC + 'JGit.gwt.xml', - compile_deps = [ + gwt_xml = SRC + 'JGit.gwt.xml', + deps = [ '//lib:gwtjsonrpc', '//lib/gwt:user', '//lib/jgit:jgit', 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/gerrit-prettify/BUCK b/gerrit-prettify/BUCK index e753ad941a..cc42d2b769 100644 --- a/gerrit-prettify/BUCK +++ b/gerrit-prettify/BUCK @@ -6,17 +6,15 @@ 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', ]), 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..faf80a8c5a 100644 --- a/gerrit-reviewdb/BUCK +++ b/gerrit-reviewdb/BUCK @@ -3,8 +3,8 @@ SRC = 'src/main/java/com/google/gerrit/reviewdb/' gwt_module( name = 'client', srcs = glob([SRC + 'client/**/*.java']), - gwtxml = SRC + 'ReviewDB.gwt.xml', - compile_deps = [ + gwt_xml = SRC + 'ReviewDB.gwt.xml', + deps = [ '//gerrit-extension-api:client', '//lib:gwtorm', '//lib:gwtorm_src' 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..a8a323f594 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,48 +32,15 @@ def genantlr( out = out, ) -def gwt_module( - name, - srcs, - gwtxml = None, - resources = [], - deps = [], - compile_deps = [], - visibility = []): - if gwtxml: - resources = resources + [gwtxml] - java_library( - name = name, - 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 gwt_module(gwt_xml=None, **kwargs): + kw = copy.deepcopy(kwargs) + if 'resources' not in kw: + kw['resources'] = [] + if gwt_xml: + kw['resources'] += [gwt_xml] + if 'srcs' in kw: + kw['resources'] += kw['srcs'] + java_library(**kw) def gerrit_extension( name, @@ -106,6 +74,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 +123,14 @@ 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], 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', ]