aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/buildtool
diff options
context:
space:
mode:
authorGravatar Luis Fernando Pino Duque <lpino@google.com>2017-02-10 17:08:00 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-02-10 18:19:18 +0000
commit32b54d0b47ffaa5142b03c5d40b324892225e0c2 (patch)
treeca4125a89dd4ee3f3910a58871f63a9fdea4910e /src/main/java/com/google/devtools/build/lib/buildtool
parent6fdef7b5bd0c9cab1d768c7dda07a460aa4fe25a (diff)
Apply --symlink_prefix to the output and exec root symlinks.
Turns out --symlink_prefix is not applied to the bazel-{out,workspace} unlike bazel-{bin,genfiles,testlogs} thus breaking the semantics of --symlink_prefix. This CL fixes the problem by using the symlink prefix instead of the product name when building the output and exec root symlinks. The bazel-out symlink is still created for backwards compatiblity but will be removed eventually. RELNOTES[INC]: Using --symlink_prefix is now applied to the output symlink (e.g. bazel-out) and the exec root symlink (e.g. bazel-workspace). -- PiperOrigin-RevId: 147161547 MOS_MIGRATED_REVID=147161547
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/buildtool')
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildtool/OutputDirectoryLinksUtils.java38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/OutputDirectoryLinksUtils.java b/src/main/java/com/google/devtools/build/lib/buildtool/OutputDirectoryLinksUtils.java
index ae085ed2bf..0ae420a20c 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/OutputDirectoryLinksUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/OutputDirectoryLinksUtils.java
@@ -13,7 +13,9 @@
// limitations under the License.
package com.google.devtools.build.lib.buildtool;
+import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.events.Event;
@@ -38,12 +40,20 @@ public class OutputDirectoryLinksUtils {
private static final String NO_CREATE_SYMLINKS_PREFIX = "/";
- public static String getOutputSymlinkName(String productName) {
- return productName + "-out";
+ public static ImmutableList<String> getOutputSymlinkNames(String productName,
+ String symlinkPrefix) {
+ ImmutableList.Builder<String> builder = ImmutableList.<String>builder();
+ // TODO(b/35234395): This symlink is created for backwards compatiblity, remove it once
+ // we're sure it won't cause any other issues.
+ builder.add(productName + "-out");
+ if (!productName.equals(symlinkPrefix)) {
+ builder.add(symlinkPrefix + "out");
+ }
+ return builder.build();
}
- private static String execRootSymlink(String productName, String workspaceName) {
- return productName + "-" + workspaceName;
+ private static String execRootSymlink(String symlinkPrefix, String workspaceName) {
+ return symlinkPrefix + workspaceName;
}
/**
* Attempts to create convenience symlinks in the workspaceDirectory and in
@@ -62,11 +72,13 @@ public class OutputDirectoryLinksUtils {
// Make the two non-specific links from the workspace to the output area,
// and the configuration-specific links in both the workspace and the execution root dirs.
- // NB! Keep in sync with removeOutputDirectoryLinks below.
- createLink(workspace, getOutputSymlinkName(productName), outputPath, failures);
+ // IMPORTANT: Keep in sync with removeOutputDirectoryLinks below.
+ for (String outputSymlinkName : getOutputSymlinkNames(productName, symlinkPrefix)) {
+ createLink(workspace, outputSymlinkName, outputPath, failures);
+ }
// Points to execroot
- createLink(workspace, execRootSymlink(productName, workspaceName), execRoot, failures);
+ createLink(workspace, execRootSymlink(symlinkPrefix, workspaceName), execRoot, failures);
if (targetConfig != null) {
createLink(workspace, symlinkPrefix + "bin",
@@ -102,12 +114,14 @@ public class OutputDirectoryLinksUtils {
}
PathFragment result = relativize(file, workspaceDirectory,
- execRootSymlink(productName, workspaceName));
+ execRootSymlink(symlinkPrefix, workspaceName));
if (result != null) {
return result;
}
- result = relativize(file, workspaceDirectory, getOutputSymlinkName(productName));
+ ImmutableList<String> outputSymlinkNames = getOutputSymlinkNames(productName, symlinkPrefix);
+ checkArgument(!outputSymlinkNames.isEmpty());
+ result = relativize(file, workspaceDirectory, outputSymlinkNames.get(0));
if (result != null) {
return result;
}
@@ -150,8 +164,10 @@ public class OutputDirectoryLinksUtils {
}
List<String> failures = new ArrayList<>();
- removeLink(workspace, getOutputSymlinkName(productName), failures);
- removeLink(workspace, execRootSymlink(productName, workspaceName), failures);
+ for (String outputSymlinkName : getOutputSymlinkNames(productName, symlinkPrefix)) {
+ removeLink(workspace, outputSymlinkName, failures);
+ }
+ removeLink(workspace, execRootSymlink(symlinkPrefix, workspaceName), failures);
removeLink(workspace, symlinkPrefix + "bin", failures);
removeLink(workspace, symlinkPrefix + "testlogs", failures);
removeLink(workspace, symlinkPrefix + "genfiles", failures);