Update Buck

Buck changed export_deps from a boolean to be exported_deps, a list of
dependencies that are to be added to deps and also exported.  This
allows libraries to have dependencies for implementation use only, but
not expose them to callers for linkage.

exported_deps aren't transparently transitive anymore.  This mostly
impacts the plugin-api:lib rule.

This is the first time Gerrit is using upstream Buck with no patches.

- Java memory settings for Buck can now be supplied in a project
  specific file using `.buckjavaargs` in the root directory.  The file
  replaces the `.buckrc` previously supported by Gerrit's fork.

- Temporary directories for java_application() invoked from genrule()
  is now supplied as part of the arguments using $TMP.  This removes
  one of the patches Gerrit had for Buck.

- Unit tests use the system temporary directory during testing.  This
  can be faster if the temporary directory is a tmpfs.  Unfortunately
  not all passing tests clean up after themselves, making it possible
  to exhaust system memory and swap with useless tmpfs contents.
  Using the system temporary directory for tests removes another patch
  Gerrit had on top of Buck.

Change-Id: I3a9fe4aab0a33a8673df727e618122027a742638
This commit is contained in:
Shawn Pearce 2013-11-28 18:38:30 -08:00
parent a791cc4fdc
commit 4e1a8bc63d
17 changed files with 103 additions and 121 deletions

View File

@ -1 +1 @@
274acb17e9b6dc9ee60bc1371c47a7f49640c24c
2b80cf780ae31bee6609ebc1bbab9ce6fd004dbe

1
.gitignore vendored
View File

@ -9,6 +9,7 @@
*.sublime-*
/gerrit-package-plugins
/.buckconfig.local
/.buckjavaargs
/.buckd
/buck-cache
/buck-out

View File

@ -63,6 +63,7 @@ genrule(
name = 'index',
cmd = '$(exe //lib/asciidoctor:doc_indexer) ' +
'-z $OUT ' +
'--tmp $TMP ' +
'--prefix "%s/" ' % DOC_DIR +
'--in-ext ".txt" ' +
'--out-ext ".html" ' +

View File

@ -26,6 +26,7 @@ def genasciidoc(
'cd $SRCDIR;',
'$(exe //lib/asciidoctor:asciidoc)',
'-z', '$OUT',
'--tmp', '$TMP',
'--in-ext', '".txt%s"' % EXPN,
'--out-ext', '".html"',
]

View File

@ -412,26 +412,13 @@ run `buck` as usual:
Override Buck's settings
~~~~~~~~~~~~~~~~~~~~~~~~
User-specific configuration can be placed in one of the following files:
`/etc/buck.conf`, `$HOME/.buck/buck.conf` or `$HOME/.buckrc`.
For example to override Buck's default 1GB heap size:
Additional JVM args for Buck can be set in `.buckjavaargs` in the
project root directory. For example to override Buck's default 1GB
heap size:
----
cat > $HOME/.buckrc <<EOF
export BUCK_EXTRA_JAVA_ARGS="\
-XX:MaxPermSize=512m \
-Xms8000m \
-Xmx16000m"
EOF
----
Or to debug BUCK, set `BUCK_DEBUG_MODE` to anything non-empty, then connect to
port 8888:
----
cat > $HOME/.buckrc <<EOF
export BUCK_DEBUG_MODE="yes"
cat > .buckjavaargs <<EOF
-XX:MaxPermSize=512m -Xms8000m -Xmx16000m
EOF
----

View File

@ -3,7 +3,7 @@ include_defs('//gerrit-acceptance-tests/tests.defs')
java_library(
name = 'lib',
srcs = glob(['src/test/java/com/google/gerrit/acceptance/*.java']),
deps = [
exported_deps = [
'//gerrit-common:server',
'//gerrit-extension-api:api',
'//gerrit-launcher:launcher',
@ -34,7 +34,6 @@ java_library(
'//lib/jgit:junit',
'//lib/mina:sshd',
],
export_deps = True,
visibility = [
'//tools/eclipse:classpath',
'//gerrit-acceptance-tests/...',

View File

@ -16,13 +16,12 @@ java_binary(
java_library(
name = 'lib',
deps = [
exported_deps = [
':api',
'//lib/guice:guice',
'//lib/guice:guice-servlet',
'//lib:servlet-api-3_0',
],
export_deps = True,
visibility = ['PUBLIC'],
)

View File

@ -1,14 +1,14 @@
SRCS = [
'gerrit-server/src/main/java/',
'gerrit-httpd/src/main/java/',
'gerrit-sshd/src/main/java/'
'gerrit-sshd/src/main/java/',
]
PLUGIN_API = [
'//gerrit-server:server',
'//gerrit-pgm:init-api',
'//gerrit-sshd:sshd',
'//gerrit-httpd:httpd',
'//gerrit-pgm:init-api',
'//gerrit-server:server',
'//gerrit-sshd:sshd',
]
java_binary(
@ -19,8 +19,22 @@ java_binary(
java_library(
name = 'lib',
deps = PLUGIN_API + ['//lib:servlet-api-3_0'],
export_deps = True,
exported_deps = PLUGIN_API + [
'//gerrit-common:server',
'//gerrit-extension-api:api',
'//gerrit-reviewdb:server',
'//lib:args4j',
'//lib:guava',
'//lib:gwtorm',
'//lib:jsch',
'//lib:servlet-api-3_0',
'//lib/guice:guice',
'//lib/guice:guice-assistedinject',
'//lib/guice:guice-servlet',
'//lib/jgit:jgit',
'//lib/log:api',
'//lib/mina:sshd',
],
visibility = ['PUBLIC'],
)

View File

@ -118,7 +118,6 @@ java_library(
'//lib/guice:guice',
'//lib/prolog:prolog-cafe',
],
export_deps = True,
)
java_test(
@ -127,7 +126,14 @@ java_test(
resources = glob(['src/test/resources/com/google/gerrit/rules/**/*']),
deps = [
':prolog_test_case',
':server',
'//gerrit-common:server',
'//gerrit-reviewdb:server',
'//gerrit-server/src/main/prolog:common',
'//lib:gwtorm',
'//lib:junit',
'//lib/guice:guice',
'//lib/prolog:prolog-cafe',
],
)

View File

@ -12,6 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import com.google.common.io.ByteStreams;
import org.asciidoctor.Asciidoctor;
import org.asciidoctor.AttributesBuilder;
import org.asciidoctor.Options;
import org.asciidoctor.OptionsBuilder;
import org.asciidoctor.SafeMode;
import org.asciidoctor.internal.JRubyAsciidoctor;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -23,20 +36,6 @@ import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import com.google.common.io.ByteStreams;
import org.asciidoctor.Asciidoctor;
import org.asciidoctor.AttributesBuilder;
import org.asciidoctor.Options;
import org.asciidoctor.OptionsBuilder;
import org.asciidoctor.SafeMode;
import org.asciidoctor.internal.JRubyAsciidoctor;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
public class AsciiDoctor {
private static final String DOCTYPE = "article";
@ -54,6 +53,9 @@ public class AsciiDoctor {
@Option(name = "--out-ext", usage = "extension for output files")
private String outExt = ".html";
@Option(name = "--tmp", usage = "temporary output path")
private File tmpdir;
@Option(name = "-a", usage =
"a list of attributes, in the form key or key=value pair")
private List<String> attributes = new ArrayList<String>();
@ -135,31 +137,17 @@ public class AsciiDoctor {
// have to add css files into the SRCS.
continue;
}
String outName = mapInFileToOutFile(inputFile, inExt, outExt);
File out = new File(outName);
Options options = createOptions(out);
renderInput(options, inputFile);
String outName = mapInFileToOutFile(inputFile, inExt, outExt);
File out = new File(tmpdir, outName);
out.getParentFile().mkdirs();
Options options = createOptions(out);
renderInput(options, new File(inputFile));
zipFile(out, outName, zip);
}
zip.close();
}
public static void zipDir(File dir, String prefix, ZipOutputStream zip)
throws IOException {
for (File file : dir.listFiles()) {
String name = file.getName();
if (!prefix.isEmpty()) {
name = prefix + "/" + name;
}
if (file.isDirectory()) {
zipDir(file, name, zip);
} else {
zipFile(file, name, zip);
}
}
}
public static void zipFile(File file, String name, ZipOutputStream zip)
throws IOException {
zip.putNextEntry(new ZipEntry(name));
@ -169,9 +157,9 @@ public class AsciiDoctor {
zip.closeEntry();
}
private void renderInput(Options options, String inputFile) {
private void renderInput(Options options, File inputFile) {
Asciidoctor asciidoctor = JRubyAsciidoctor.create();
asciidoctor.renderFile(new File(inputFile), options);
asciidoctor.renderFile(inputFile, options);
}
public static void main(String[] args) {

View File

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import com.google.common.io.Files;
import com.google.gerrit.server.documentation.Constants;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
@ -48,6 +47,9 @@ public class DocIndexer {
@Option(name = "-z", usage = "output zip file")
private String zipFile;
@Option(name = "--tmp", usage = "temporary output path")
private File tmpdir;
@Option(name = "--prefix", usage = "prefix for the html filepath")
private String prefix = "";
@ -74,8 +76,7 @@ public class DocIndexer {
return;
}
File tmp = Files.createTempDir();
NIOFSDirectory directory = new NIOFSDirectory(tmp);
NIOFSDirectory directory = new NIOFSDirectory(tmpdir);
IndexWriterConfig config = new IndexWriterConfig(
LUCENE_VERSION,
new StandardAnalyzer(LUCENE_VERSION, CharArraySet.EMPTY_SET));
@ -108,10 +109,25 @@ public class DocIndexer {
iwriter.close();
ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(zipFile));
AsciiDoctor.zipDir(tmp, "", zip);
zipDir(tmpdir, "", zip);
zip.close();
}
private static void zipDir(File dir, String prefix, ZipOutputStream zip)
throws IOException {
for (File file : dir.listFiles()) {
String name = file.getName();
if (!prefix.isEmpty()) {
name = prefix + "/" + name;
}
if (file.isDirectory()) {
zipDir(file, name, zip);
} else {
AsciiDoctor.zipFile(file, name, zip);
}
}
}
public static void main(String[] args) {
try {
new DocIndexer().invoke(args);

View File

@ -9,11 +9,10 @@ EXCLUDE = [
java_library(
name = 'guice',
deps = [
exported_deps = [
':guice_library',
':javax-inject',
],
export_deps = True,
visibility = ['PUBLIC'],
)
@ -23,40 +22,10 @@ maven_jar(
sha1 = 'a82be989679df08b66d48b42659a3ca2daaf1d5b',
license = 'Apache2.0',
deps = [':aopalliance'],
exclude_java_sources = True,
exclude = EXCLUDE + [
'META-INF/maven/com.google.guava/guava/pom.properties',
'META-INF/maven/com.google.guava/guava/pom.xml',
'javax/annotation/CheckForNull.java',
'javax/annotation/CheckForSigned.java',
'javax/annotation/CheckReturnValue.java',
'javax/annotation/concurrent/GuardedBy.java',
'javax/annotation/concurrent/Immutable.java',
'javax/annotation/concurrent/NotThreadSafe.java',
'javax/annotation/concurrent/ThreadSafe.java',
'javax/annotation/Detainted.java',
'javax/annotation/MatchesPattern.java',
'javax/annotation/meta/Exclusive.java',
'javax/annotation/meta/Exhaustive.java',
'javax/annotation/meta/TypeQualifier.java',
'javax/annotation/meta/TypeQualifierDefault.java',
'javax/annotation/meta/TypeQualifierNickname.java',
'javax/annotation/meta/TypeQualifierValidator.java',
'javax/annotation/meta/When.java',
'javax/annotation/Nonnegative.java',
'javax/annotation/Nonnull.java',
'javax/annotation/Nullable.java',
'javax/annotation/OverridingMethodsMustInvokeSuper.java',
'javax/annotation/ParametersAreNonnullByDefault.java',
'javax/annotation/ParametersAreNullableByDefault.java',
'javax/annotation/PropertyKey.java',
'javax/annotation/RegEx.java',
'javax/annotation/Signed.java',
'javax/annotation/Syntax.java',
'javax/annotation/Tainted.java',
'javax/annotation/Untainted.java',
'javax/annotation/WillClose.java',
'javax/annotation/WillCloseWhenClosed.java',
'javax/annotation/WillNotClose.java',
],
visibility = ['PUBLIC'],
)

View File

@ -30,11 +30,10 @@ maven_jar(
id = 'org.eclipse.jetty:jetty-server:' + VERSION,
sha1 = 'd89016c2bcd380f548530fa049295e62601dc564',
license = 'Apache2.0',
deps = [
exported_deps = [
':continuation',
':http',
],
export_deps = True,
exclude = EXCLUDE,
)
@ -51,7 +50,7 @@ maven_jar(
id = 'org.eclipse.jetty:jetty-http:' + VERSION,
sha1 = 'b3a2302717ac1889b4a17ed03e2555f8291121b9',
license = 'Apache2.0',
deps = [':io'],
exported_deps = [':io'],
exclude = EXCLUDE,
)
@ -60,7 +59,7 @@ maven_jar(
id = 'org.eclipse.jetty:jetty-io:' + VERSION,
sha1 = 'f3a66e0507d963c51e280243f0472a5b2eadc8b1',
license = 'Apache2.0',
deps = [':util'],
exported_deps = [':util'],
exclude = EXCLUDE,
visibility = [],
)

View File

@ -35,10 +35,10 @@ def maven_jar(
exclude_java_sources = False,
unsign = False,
deps = [],
exported_deps = [],
sha1 = '', bin_sha1 = '', src_sha1 = '',
repository = MAVEN_CENTRAL,
attach_source = True,
export_deps = False,
visibility = ['PUBLIC']):
from os import path
@ -109,7 +109,7 @@ def maven_jar(
out = '__' + name + '__no_src',
)
if export_deps:
if exported_deps:
prebuilt_jar(
name = name + '__jar',
deps = deps + license + [':' + name + '__download_bin'],
@ -118,8 +118,7 @@ def maven_jar(
)
java_library(
name = name,
deps = [':' + name + '__jar'],
export_deps = True,
exported_deps = exported_deps + [':' + name + '__jar'],
visibility = visibility,
)
else:

View File

@ -23,18 +23,21 @@ import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
public class BuckPrologCompiler {
private static File tmpdir;
public static void main(String[] argv) throws IOException, CompileException {
File out = new File(argv[argv.length - 1]);
int i = 0;
tmpdir = new File(argv[i++]);
File out = new File(argv[i++]);
File java = tmpdir("java");
for (int i = 0; i < argv.length - 1; i++) {
File src = new File(argv[i]);
new Compiler().prologToJavaSource(src.getPath(), java.getPath());
for (; i < argv.length; i++) {
new Compiler().prologToJavaSource(argv[i], java.getPath());
}
jar(out, java);
}
private static File tmpdir(String name) throws IOException {
File d = File.createTempFile(name + "_", "");
File d = File.createTempFile(name + "_", "", tmpdir);
if (!d.delete() || !d.mkdir()) {
throw new IOException("Cannot mkdir " + d);
}
@ -42,7 +45,7 @@ public class BuckPrologCompiler {
}
private static void jar(File jar, File classes) throws IOException {
File tmp = File.createTempFile("prolog", ".jar", jar.getParentFile());
File tmp = File.createTempFile("prolog", ".jar", tmpdir);
try {
JarOutputStream out = new JarOutputStream(new FileOutputStream(tmp));
try {

View File

@ -19,9 +19,9 @@ def prolog_cafe_library(
visibility = []):
genrule(
name = name + '__pl2j',
cmd = 'cd $SRCDIR;$(exe //lib/prolog:compiler) ' +
' '.join(srcs) +
' $OUT',
cmd = 'cd $SRCDIR;$(exe //lib/prolog:compiler)' +
' $TMP $OUT ' +
' '.join(srcs),
srcs = srcs,
deps = ['//lib/prolog:compiler'],
out = name + '.src.zip',

View File

@ -17,22 +17,22 @@ def java_library(
name,
srcs=[],
resources=[],
export_deps=False,
source='7',
target='7',
proguard_config=None,
deps=[],
exported_deps=[],
visibility=[],
):
original_java_library(
name=name,
srcs=srcs,
resources=resources,
export_deps=export_deps,
source=source,
target=target,
proguard_config=proguard_config,
deps=deps,
exported_deps=exported_deps,
visibility=visibility,
)