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

@@ -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);