Fix launching daemon in Eclipse on MacOS
Change I5fc96bf1f removed the generation of the .primary_build_tool file and change I3d6b90320 removed the build system abstraction with the motivation that we now only have one build tool. However this broke launching the daemon from Eclipse on MacOS, which now fails because bazel is not on the path and can't be found. Restore the removed functionality, but rename the file to .bazel_path Change-Id: Ibd0ec09d3bf47f383ca68a37cca4e81640960416
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,6 +9,7 @@
|
||||
.DS_Store
|
||||
.gwt_work_dir
|
||||
/.apt_generated
|
||||
/.bazel_path
|
||||
/.buckd
|
||||
/.classpath
|
||||
/.factorypath
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.httpd.raw;
|
||||
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.escape.Escaper;
|
||||
@@ -25,7 +26,11 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.eclipse.jgit.util.RawParseUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -117,8 +122,24 @@ public class BazelBuild {
|
||||
}
|
||||
}
|
||||
|
||||
private ProcessBuilder newBuildProcess(Label label) {
|
||||
return new ProcessBuilder("bazel", "build", label.fullName());
|
||||
private Properties loadBuildProperties(Path propPath) throws IOException {
|
||||
Properties properties = new Properties();
|
||||
try (InputStream in = Files.newInputStream(propPath)) {
|
||||
properties.load(in);
|
||||
} catch (NoSuchFileException e) {
|
||||
// Ignore; will be run from PATH, with a descriptive error if it fails.
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
private ProcessBuilder newBuildProcess(Label label) throws IOException {
|
||||
Properties properties = loadBuildProperties(sourceRoot.resolve(".bazel_path"));
|
||||
String bazel = firstNonNull(properties.getProperty("bazel"), "bazel");
|
||||
ProcessBuilder proc = new ProcessBuilder(bazel, "build", label.fullName());
|
||||
if (properties.containsKey("PATH")) {
|
||||
proc.environment().put("PATH", properties.getProperty("PATH"));
|
||||
}
|
||||
return proc;
|
||||
}
|
||||
|
||||
/** returns the root relative path to the artifact for the given label */
|
||||
|
@@ -56,6 +56,12 @@ args, _ = opts.parse_args()
|
||||
def retrieve_ext_location():
|
||||
return check_output(['bazel', 'info', 'output_base']).strip()
|
||||
|
||||
def gen_bazel_path():
|
||||
bazel = check_output(['which', 'bazel']).strip()
|
||||
with open(path.join(ROOT, ".bazel_path"), 'w') as fd:
|
||||
fd.write("bazel=%s\n" % bazel)
|
||||
fd.write("PATH=%s\n" % environ["PATH"])
|
||||
|
||||
def _query_classpath(target):
|
||||
deps = []
|
||||
t = cp_targets[target]
|
||||
@@ -258,6 +264,7 @@ try:
|
||||
gen_project(args.project_name)
|
||||
gen_classpath(ext_location)
|
||||
gen_factorypath(ext_location)
|
||||
gen_bazel_path()
|
||||
|
||||
# TODO(davido): Remove this when GWT gone
|
||||
gwt_working_dir = ".gwt_work_dir"
|
||||
|
Reference in New Issue
Block a user