Update Buck
Latest version of buck is faster than the prior version used by Gerrit. No-op updates when loading a debug version of the UI now take only 1.804s on my laptop (previously 7s) and a draft UI compile is only 24.659s (previously 39s). The slow acceptance tests must now be excluded with `--exclude slow`. Buck changed the meaning of the -e option to be --emulator, which is unfortunately useful only for Android application developers. genrule() now needs to use $(exe) to reference the binary to run, offers $(location) to make it easier to find files in the build tree. The empty srcs array is no longer required for genrule(). Buck has determined it is sufficiently powerful with $(location) and deps that requiring srcs is unnecessary. Supporting .src.zip files in the srcs array of java_library() means Gerrit no longer needs to run a separate genrule() to extract files produced by ANTLR, or call javac inside of the BuckPrologCompiler support glue. Change-Id: Ib03042921a081b867a7aad0423bd45523e42917a
This commit is contained in:
parent
a7bad77a08
commit
11d27c8ee8
@ -1 +1 @@
|
||||
a3aadacd7c1ccd819420a73975a08ba67110decb
|
||||
0325c2dbc195dcceb963181fd3683b7d20328734
|
||||
|
10
BUCK
10
BUCK
@ -16,7 +16,6 @@ API_DEPS = [
|
||||
genrule(
|
||||
name = 'api',
|
||||
cmd = '',
|
||||
srcs = [],
|
||||
deps = API_DEPS,
|
||||
out = '__fake.api__',
|
||||
)
|
||||
@ -38,8 +37,7 @@ java_library(
|
||||
)
|
||||
genrule(
|
||||
name = 'extension-api-src',
|
||||
cmd = 'ln -s $DEPS $OUT',
|
||||
srcs = [],
|
||||
cmd = 'ln -s $(location //gerrit-extension-api:api-src) $OUT',
|
||||
deps = ['//gerrit-extension-api:api-src'],
|
||||
out = 'extension-api-src.jar',
|
||||
)
|
||||
@ -66,16 +64,14 @@ java_binary(
|
||||
|
||||
genrule(
|
||||
name = 'download',
|
||||
cmd = '${//tools:download_all}',
|
||||
srcs = [],
|
||||
cmd = '$(exe //tools:download_all)',
|
||||
deps = ['//tools:download_all'],
|
||||
out = '__fake.download__',
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = 'download_sources',
|
||||
cmd = '${//tools:download_all} --src',
|
||||
srcs = [],
|
||||
cmd = '$(exe //tools:download_all) --src',
|
||||
deps = ['//tools:download_all'],
|
||||
out = '__fake.download__',
|
||||
)
|
||||
|
@ -41,8 +41,7 @@ genasciidoc(
|
||||
|
||||
genrule(
|
||||
name = 'licenses.txt',
|
||||
cmd = '${:gen_licenses} >$OUT',
|
||||
srcs = [],
|
||||
cmd = '$(exe :gen_licenses) >$OUT',
|
||||
deps = [':gen_licenses'] + MAIN,
|
||||
out = 'licenses.txt',
|
||||
)
|
||||
|
@ -47,7 +47,6 @@ def genasciidoc(
|
||||
genrule(
|
||||
name = name,
|
||||
cmd = ':>$OUT',
|
||||
srcs = [],
|
||||
deps = [':' + o for o in outs],
|
||||
out = name + '__done',
|
||||
visibility = visibility,
|
||||
|
@ -191,7 +191,7 @@ To run all tests including acceptance tests:
|
||||
To exclude slow tests:
|
||||
|
||||
----
|
||||
buck test --all -e slow
|
||||
buck test --all --exclude slow
|
||||
----
|
||||
|
||||
|
||||
|
@ -1,7 +1,3 @@
|
||||
ANTLR_OUTS = [
|
||||
'QueryLexer.java',
|
||||
'QueryParser.java',
|
||||
]
|
||||
PARSER_DEPS = [
|
||||
':query_exception',
|
||||
'//lib/antlr:java_runtime',
|
||||
@ -16,24 +12,22 @@ java_library(
|
||||
genantlr(
|
||||
name = 'query_antlr',
|
||||
srcs = ['src/main/antlr3/com/google/gerrit/server/query/Query.g'],
|
||||
outs = ANTLR_OUTS,
|
||||
out = 'query_antlr.src.zip',
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = 'lib',
|
||||
srcs = [genfile('query_antlr.src.zip')],
|
||||
deps = PARSER_DEPS + [':query_antlr'],
|
||||
)
|
||||
|
||||
# Hack necessary to expose ANTLR generated code as JAR to Eclipse.
|
||||
java_library(
|
||||
name = 'lib',
|
||||
srcs = [genfile(f) for f in ANTLR_OUTS],
|
||||
deps = PARSER_DEPS + [':' + f for f in ANTLR_OUTS],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = 'query_link',
|
||||
cmd = 'ln -s $SRCS $OUT',
|
||||
srcs = [genfile('lib__lib__output/lib.jar')],
|
||||
cmd = 'ln -s $(location :lib) $OUT',
|
||||
deps = [':lib'],
|
||||
out = 'query_parser.jar',
|
||||
)
|
||||
|
||||
prebuilt_jar(
|
||||
name = 'query_parser',
|
||||
binary_jar = genfile('query_parser.jar'),
|
||||
|
@ -53,7 +53,6 @@ def git_describe():
|
||||
genrule(
|
||||
name = 'git_describe',
|
||||
cmd = 'mkdir -p $(dirname $OUT); echo "%s" >$OUT' % git_describe(),
|
||||
srcs = [],
|
||||
out = VER,
|
||||
)
|
||||
|
||||
|
@ -100,5 +100,6 @@ java_test(
|
||||
'//lib/jgit:jgit',
|
||||
],
|
||||
source_under_test = [':ui_module'],
|
||||
vm_args = ['-Xmx512m'],
|
||||
visibility = ['//tools/eclipse:classpath'],
|
||||
)
|
||||
|
@ -52,17 +52,19 @@ def gwt_user_agent_permutations(
|
||||
"<set-property name='locale' value='default'/>",
|
||||
"</module>",
|
||||
])
|
||||
gwt = 'resources/%s_%s.gwt.xml' % (module_target.replace('.', '/'), ua)
|
||||
gwt = '%s_%s.gwt.xml' % (module_target.replace('.', '/'), ua)
|
||||
jar = '%s_%s.gwtxml.jar' % (name, ua)
|
||||
genrule(
|
||||
name = '%s_%s_gwtxml_gen' % (name, ua),
|
||||
cmd = 'mkdir -p $(dirname $OUT);echo "%s">$OUT' % xml,
|
||||
srcs = [],
|
||||
deps = [],
|
||||
out = gwt,
|
||||
cmd = 'cd $TMP;' +
|
||||
('mkdir -p $(dirname %s);' % gwt) +
|
||||
('echo "%s">%s;' % (xml, gwt)) +
|
||||
'zip -qr $OUT .',
|
||||
out = jar,
|
||||
)
|
||||
java_library(
|
||||
prebuilt_jar(
|
||||
name = '%s_%s_gwtxml_lib' % (name, ua),
|
||||
resources = [genfile(gwt)],
|
||||
binary_jar = genfile(jar),
|
||||
deps = [':%s_%s_gwtxml_gen' % (name, ua)],
|
||||
)
|
||||
gwt_application(
|
||||
|
@ -37,7 +37,7 @@ genrule(
|
||||
|
||||
genrule(
|
||||
name = 'log4j-config__jar',
|
||||
cmd = 'jar cf $OUT -C $(dirname $SRCS) .',
|
||||
cmd = 'jar cf $OUT -C $SRCDIR/src/main/resources .',
|
||||
srcs = ['src/main/resources/log4j.properties'],
|
||||
out = 'log4j-config.jar',
|
||||
)
|
||||
|
@ -33,11 +33,10 @@ genrule(
|
||||
|
||||
genrule(
|
||||
name = 'download',
|
||||
cmd = '${//tools:download_file}' +
|
||||
cmd = '$(exe //tools:download_file)' +
|
||||
' -o $OUT' +
|
||||
' -u ' + URL +
|
||||
' -v ' + SHA1,
|
||||
srcs = [],
|
||||
deps = ['//tools:download_file'],
|
||||
out = 'codemirror-' + VERSION + '.zip',
|
||||
)
|
||||
|
@ -62,7 +62,7 @@ def maven_jar(
|
||||
srcjar = jar + '-src.jar'
|
||||
srcurl = url + '-sources.jar'
|
||||
|
||||
cmd = ['${//tools:download_file}', '-o', '$OUT', '-u', binurl]
|
||||
cmd = ['$(exe //tools:download_file)', '-o', '$OUT', '-u', binurl]
|
||||
if sha1:
|
||||
cmd.extend(['-v', sha1])
|
||||
elif bin_sha1:
|
||||
@ -75,20 +75,18 @@ def maven_jar(
|
||||
genrule(
|
||||
name = name + '__download_bin',
|
||||
cmd = ' '.join(cmd),
|
||||
srcs = [],
|
||||
deps = ['//tools:download_file'],
|
||||
out = binjar,
|
||||
)
|
||||
license = ['//lib:LICENSE-' + license]
|
||||
|
||||
if src_sha1 or attach_source:
|
||||
cmd = ['${//tools:download_file}', '-o', '$OUT', '-u', srcurl]
|
||||
cmd = ['$(exe //tools:download_file)', '-o', '$OUT', '-u', srcurl]
|
||||
if src_sha1:
|
||||
cmd.extend(['-v', src_sha1])
|
||||
genrule(
|
||||
name = name + '__download_src',
|
||||
cmd = ' '.join(cmd),
|
||||
srcs = [],
|
||||
deps = ['//tools:download_file'],
|
||||
out = srcjar,
|
||||
)
|
||||
@ -104,7 +102,6 @@ def maven_jar(
|
||||
genrule(
|
||||
name = name + '__download_src',
|
||||
cmd = ':>$OUT',
|
||||
srcs = [],
|
||||
out = '__' + name + '__no_src',
|
||||
)
|
||||
|
||||
|
@ -18,21 +18,29 @@ def prolog_cafe_library(
|
||||
deps = [],
|
||||
visibility = []):
|
||||
genrule(
|
||||
name = name + '_prolog2java',
|
||||
cmd = '${//lib/prolog:compiler} $SRCS $DEPS $OUT',
|
||||
name = name + '__pl2j',
|
||||
cmd = '$(exe //lib/prolog:compiler) $SRCS $DEPS $OUT',
|
||||
srcs = srcs,
|
||||
deps = ['//lib/prolog:compiler'],
|
||||
out = name + '.src.zip',
|
||||
)
|
||||
java_library(
|
||||
name = name + '__lib',
|
||||
srcs = [genfile(name + '.src.zip')],
|
||||
deps = [
|
||||
'//lib/prolog:compiler',
|
||||
':' + name + '__pl2j',
|
||||
'//lib/prolog:prolog-cafe',
|
||||
] + deps,
|
||||
)
|
||||
genrule(
|
||||
name = name + '__ln',
|
||||
cmd = 'ln -s $(location :%s__lib) $OUT' % name,
|
||||
deps = [':%s__lib' % name],
|
||||
out = name + '.jar',
|
||||
)
|
||||
prebuilt_jar(
|
||||
name = name,
|
||||
binary_jar = genfile(name + '.jar'),
|
||||
deps = [
|
||||
':' + name + '_prolog2java',
|
||||
'//lib/prolog:prolog-cafe',
|
||||
] + deps,
|
||||
deps = [':%s__ln' % name],
|
||||
visibility = visibility,
|
||||
)
|
||||
|
@ -20,19 +20,10 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
import javax.tools.ToolProvider;
|
||||
|
||||
public class BuckPrologCompiler {
|
||||
public static void main(String[] argv) throws IOException, CompileException {
|
||||
List<File> srcs = new ArrayList<File>();
|
||||
@ -48,12 +39,10 @@ public class BuckPrologCompiler {
|
||||
|
||||
File out = new File(argv[argv.length - 1]);
|
||||
File java = tmpdir("java");
|
||||
File classes = tmpdir("classes");
|
||||
for (File src : srcs) {
|
||||
new Compiler().prologToJavaSource(src.getPath(), java.getPath());
|
||||
}
|
||||
javac(jars, java, classes);
|
||||
jar(out, classes);
|
||||
jar(out, java);
|
||||
}
|
||||
|
||||
private static File tmpdir(String name) throws IOException {
|
||||
@ -64,59 +53,11 @@ public class BuckPrologCompiler {
|
||||
return d;
|
||||
}
|
||||
|
||||
private static void javac(List<File> cp, File java, File classes)
|
||||
throws IOException, CompileException {
|
||||
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
||||
if (javac == null) {
|
||||
throw new CompileException("JDK required (running inside of JRE)");
|
||||
}
|
||||
|
||||
DiagnosticCollector<JavaFileObject> d =
|
||||
new DiagnosticCollector<JavaFileObject>();
|
||||
StandardJavaFileManager fm = javac.getStandardFileManager(d, null, null);
|
||||
try {
|
||||
StringBuilder classpath = new StringBuilder();
|
||||
for (File jar : cp) {
|
||||
if (classpath.length() > 0) {
|
||||
classpath.append(File.pathSeparatorChar);
|
||||
}
|
||||
classpath.append(jar.getPath());
|
||||
}
|
||||
ArrayList<String> args = new ArrayList<String>();
|
||||
args.addAll(Arrays.asList(new String[]{
|
||||
"-source", "6",
|
||||
"-target", "6",
|
||||
"-g:none",
|
||||
"-nowarn",
|
||||
"-d", classes.getPath()}));
|
||||
if (classpath.length() > 0) {
|
||||
args.add("-classpath");
|
||||
args.add(classpath.toString());
|
||||
}
|
||||
if (!javac.getTask(null, fm, d, args, null,
|
||||
fm.getJavaFileObjectsFromFiles(find(java, ".java"))).call()) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (Diagnostic<? extends JavaFileObject> err : d.getDiagnostics()) {
|
||||
msg.append('\n').append(err.getKind()).append(": ");
|
||||
if (err.getSource() != null) {
|
||||
msg.append(err.getSource().getName());
|
||||
}
|
||||
msg.append(':').append(err.getLineNumber()).append(": ");
|
||||
msg.append(err.getMessage(Locale.getDefault()));
|
||||
}
|
||||
throw new CompileException(msg.toString());
|
||||
}
|
||||
} finally {
|
||||
fm.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static void jar(File jar, File classes) throws IOException {
|
||||
File tmp = File.createTempFile("prolog", ".jar", jar.getParentFile());
|
||||
try {
|
||||
JarOutputStream out = new JarOutputStream(new FileOutputStream(tmp));
|
||||
try {
|
||||
out.setLevel(9);
|
||||
add(out, classes, "");
|
||||
} finally {
|
||||
out.close();
|
||||
@ -154,16 +95,4 @@ public class BuckPrologCompiler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<File> find(File dir, String extension) {
|
||||
ArrayList<File> list = new ArrayList<File>();
|
||||
for (File f : dir.listFiles()) {
|
||||
if (f.getName().endsWith(extension)) {
|
||||
list.add(f);
|
||||
} else if (f.isDirectory()) {
|
||||
list.addAll(find(f, extension));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ genrule(
|
||||
name = 'buck.properties',
|
||||
cmd = 'echo buck=`which buck`>$OUT;' +
|
||||
("echo PATH=\''%s'\' >>$OUT;" % shquote(os_path())),
|
||||
srcs = [],
|
||||
deps = [],
|
||||
out = 'buck.properties',
|
||||
visibility = ['PUBLIC'],
|
||||
|
20
tools/DEFS
20
tools/DEFS
@ -15,26 +15,17 @@
|
||||
def genantlr(
|
||||
name,
|
||||
srcs,
|
||||
outs):
|
||||
tmp = name + '.srcjar'
|
||||
out):
|
||||
tmp = name + '.src.zip'
|
||||
genrule(
|
||||
name = name,
|
||||
srcs = srcs,
|
||||
cmd = '${//lib/antlr:antlr-tool} -o $TMP $SRCS;' +
|
||||
cmd = '$(exe //lib/antlr:antlr-tool) -o $TMP $SRCS;' +
|
||||
'cd $TMP;' +
|
||||
'zip -qr $OUT .',
|
||||
deps = ['//lib/antlr:antlr-tool'],
|
||||
out = tmp,
|
||||
out = out,
|
||||
)
|
||||
for o in outs:
|
||||
genrule(
|
||||
name = o,
|
||||
cmd = 'unzip -qp $SRCS %s >$OUT' % o,
|
||||
srcs = [genfile(tmp)],
|
||||
deps = [':' + name],
|
||||
out = o,
|
||||
)
|
||||
|
||||
|
||||
def gwt_module(
|
||||
name,
|
||||
@ -61,11 +52,10 @@ def gwt_application(
|
||||
compiler_jvm_flags = [],
|
||||
deps = [],
|
||||
visibility = []):
|
||||
cmd = ['${//lib/gwt:compiler}', module_target, '$OUT']
|
||||
cmd = ['$(exe //lib/gwt:compiler)', module_target, '$OUT']
|
||||
cmd += compiler_opts + ['--', '$DEPS']
|
||||
genrule(
|
||||
name = name,
|
||||
srcs = [],
|
||||
cmd = ' '.join(cmd),
|
||||
deps = [
|
||||
'//lib/gwt:compiler',
|
||||
|
@ -38,7 +38,7 @@ def war(
|
||||
context = [],
|
||||
visibility = []
|
||||
):
|
||||
cmd = ['${//tools:pack_war}', '-o', '$OUT']
|
||||
cmd = ['$(exe //tools:pack_war)', '-o', '$OUT']
|
||||
for l in libs:
|
||||
cmd.extend(['--lib', l])
|
||||
for l in pgmlibs:
|
||||
@ -96,7 +96,7 @@ def _maven_util(
|
||||
deps
|
||||
):
|
||||
cmd = [
|
||||
'${//tools:maven_deploy}',
|
||||
'$(exe //tools:maven_deploy)',
|
||||
'-a', name,
|
||||
'-v', GERRIT_VER,
|
||||
'-d', '"$DEPS"'
|
||||
@ -104,7 +104,6 @@ def _maven_util(
|
||||
genrule(
|
||||
name = 'api_%s' % name,
|
||||
cmd = ' '.join(cmd),
|
||||
srcs = [],
|
||||
deps = deps + ['//tools:maven_deploy'],
|
||||
out = '__fake.api_%s__' % name
|
||||
)
|
||||
|
@ -3,7 +3,6 @@ include_defs('//tools/build.defs')
|
||||
genrule(
|
||||
name = 'eclipse',
|
||||
cmd = '',
|
||||
srcs = [],
|
||||
deps = [
|
||||
':_classpath',
|
||||
':_project',
|
||||
@ -15,7 +14,6 @@ genrule(
|
||||
genrule(
|
||||
name = 'eclipse_project',
|
||||
cmd = '',
|
||||
srcs = [],
|
||||
deps = [
|
||||
':_classpath_nocompile',
|
||||
':_project',
|
||||
@ -40,16 +38,14 @@ java_library(
|
||||
|
||||
genrule(
|
||||
name = '_project',
|
||||
cmd = '${:gen_project} $OUT',
|
||||
srcs = [],
|
||||
cmd = '$(exe :gen_project) $OUT',
|
||||
deps = [':gen_project'],
|
||||
out = 'project',
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = '_classpath',
|
||||
cmd = '${:gen_classpath} $OUT $DEPS',
|
||||
srcs = [],
|
||||
cmd = '$(exe :gen_classpath) $OUT $DEPS',
|
||||
deps = [
|
||||
':classpath',
|
||||
':gen_classpath',
|
||||
@ -59,8 +55,7 @@ genrule(
|
||||
|
||||
genrule(
|
||||
name = '_classpath_nocompile',
|
||||
cmd = '${:gen_classpath}',
|
||||
srcs = [],
|
||||
cmd = '$(exe :gen_classpath)',
|
||||
deps = [':gen_classpath'],
|
||||
out = '__fake.eclipse__',
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user