Implement changes in symlink forest creation related to dont_symlink_directories_in_execroot.
This is a continuation of https://github.com/bazelbuild/bazel/pull/10589.
If dont_symlink_directories_in_execroot is used in WORKSPACE file with some directories (immediate children of the workspace root directory), do not symlink those directories under the execroot during symlink forest creation.
(See SymlinkForest class for more context, and also https://docs.bazel.build/versions/master/output_directories.html)
Normally, source directories are symlinked to the execroot, so that the actions can access the input (source) files.
In the case of Ninja execution (enabled with --experimental_ninja_actions flag), it is typical that the directory with build-related files contains source files for the build, and Ninja prescribes creation of the outputs in that same directory.
Since commands in the Ninja file use relative paths to address source files and directories, we must recreate the exact same directory structure under the execroot.
However, Bazel requires output directories to be separated from input directories: it is Bazel?s concept, not something that is related to this change or Ninja integration.
That is why Ninja build configuration directory (though it is part of the sources in the sense that it contains the source files) can not be directly symlinked to the execroot (if it was, the source tree would be changed by the build).
dont_symlink_directories_in_execroot can be used to specify that Ninja build configuration directories should not be symlinked to the execroot.
It is not expected that there could be other use cases for using this method.
Closes #10600.
PiperOrigin-RevId: 291681522
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java
index 0675ba9..01a490b 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/AnalysisResult.java
@@ -16,6 +16,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
import com.google.devtools.build.lib.actions.ActionGraph;
import com.google.devtools.build.lib.actions.PackageRoots;
import com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection;
@@ -41,6 +42,7 @@
private final PackageRoots packageRoots;
private final String workspaceName;
private final Collection<TargetAndConfiguration> topLevelTargetsWithConfigs;
+ private final ImmutableSortedSet<String> nonSymlinkedDirectoriesUnderExecRoot;
AnalysisResult(
BuildConfigurationCollection configurations,
@@ -56,7 +58,8 @@
TopLevelArtifactContext topLevelContext,
PackageRoots packageRoots,
String workspaceName,
- Collection<TargetAndConfiguration> topLevelTargetsWithConfigs) {
+ Collection<TargetAndConfiguration> topLevelTargetsWithConfigs,
+ ImmutableSortedSet<String> nonSymlinkedDirectoriesUnderExecRoot) {
this.configurations = configurations;
this.targetsToBuild = targetsToBuild;
this.aspects = aspects;
@@ -71,6 +74,7 @@
this.packageRoots = packageRoots;
this.workspaceName = workspaceName;
this.topLevelTargetsWithConfigs = topLevelTargetsWithConfigs;
+ this.nonSymlinkedDirectoriesUnderExecRoot = nonSymlinkedDirectoriesUnderExecRoot;
}
public BuildConfigurationCollection getConfigurationCollection() {
@@ -159,4 +163,8 @@
public Collection<TargetAndConfiguration> getTopLevelTargetsWithConfigs() {
return topLevelTargetsWithConfigs;
}
+
+ public ImmutableSortedSet<String> getNonSymlinkedDirectoriesUnderExecRoot() {
+ return nonSymlinkedDirectoriesUnderExecRoot;
+ }
}