diff options
author | 2015-12-10 12:18:50 +0000 | |
---|---|---|
committer | 2015-12-10 12:41:43 +0000 | |
commit | 9ca4df20a84bfc3971a064fe7dce3d0302f0dbf0 (patch) | |
tree | 483fc54c9982cda3bd0032d2370a06818b93a5fb /src/main/java | |
parent | e19ee2743966069c6dcce375fe89b07835c34723 (diff) |
A minor tweak to the mechanism by which Bazel finds out it is in the execroot of another workspace.
--
MOS_MIGRATED_REVID=109885272
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java | 13 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java | 16 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java index 29f76c2593..8daee39a0a 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java @@ -117,15 +117,6 @@ public class BlazeCommandDispatcher { this.runtime = runtime; } - private Path getDoNotBuildFile(Path workspace) { - Path result = workspace.getParentDirectory(); - if (result.getBaseName().equals("execroot")) { - result = result.getParentDirectory(); - } - - return result.getRelative(BlazeRuntime.DO_NOT_BUILD_FILE_NAME); - } - /** * Only some commands work if cwd != workspaceSuffix in Blaze. In that case, also check if Blaze * was called from the output directory and fail if it was. @@ -150,7 +141,9 @@ public class BlazeCommandDispatcher { return ExitCode.LOCAL_ENVIRONMENTAL_ERROR; } - Path doNotBuild = getDoNotBuildFile(workspace); + Path doNotBuild = workspace.getParentDirectory().getRelative( + BlazeRuntime.DO_NOT_BUILD_FILE_NAME); + if (doNotBuild.exists()) { if (!commandAnnotation.canRunInOutputDirectory()) { outErr.printErrLn(getNotInRealWorkspaceError(doNotBuild)); diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java index 2ddf066088..cba1873ff2 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java @@ -209,7 +209,7 @@ public final class BlazeRuntime { if (inWorkspace()) { writeOutputBaseReadmeFile(); - writeOutputBaseDoNotBuildHereFile(); + writeDoNotBuildHereFile(); } setupExecRoot(); } @@ -326,16 +326,24 @@ public final class BlazeRuntime { } } - private void writeOutputBaseDoNotBuildHereFile() { - Preconditions.checkNotNull(getWorkspace()); - Path filePath = getOutputBase().getRelative(DO_NOT_BUILD_FILE_NAME); + private void writeDoNotBuildHereFile(Path filePath) { try { + FileSystemUtils.createDirectoryAndParents(filePath.getParentDirectory()); FileSystemUtils.writeContent(filePath, ISO_8859_1, getWorkspace().toString()); } catch (IOException e) { LOG.warning("Couldn't write to '" + filePath + "': " + e.getMessage()); } } + private void writeDoNotBuildHereFile() { + Preconditions.checkNotNull(getWorkspace()); + writeDoNotBuildHereFile(getOutputBase().getRelative(DO_NOT_BUILD_FILE_NAME)); + if (startupOptionsProvider.getOptions(BlazeServerStartupOptions.class).deepExecRoot) { + writeDoNotBuildHereFile(getOutputBase().getRelative("execroot").getRelative( + DO_NOT_BUILD_FILE_NAME)); + } + } + /** * Creates the execRoot dir under outputBase. */ |