Expose source symlink planting to modules.
Emit an event when ExecutionTool plants the source symlink forest in
execution root; modules may need to be able to access to recreate the
symlink forest elsewhere later during the build process.
PiperOrigin-RevId: 266462555
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
index a8e6682..da4fc24 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
@@ -45,6 +45,7 @@
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction;
import com.google.devtools.build.lib.analysis.actions.SymlinkTreeActionContext;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
+import com.google.devtools.build.lib.buildtool.buildevent.ExecRootPreparedEvent;
import com.google.devtools.build.lib.buildtool.buildevent.ExecutionPhaseCompleteEvent;
import com.google.devtools.build.lib.buildtool.buildevent.ExecutionStartingEvent;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
@@ -443,19 +444,19 @@
throws ExecutorInitException, InterruptedException {
Optional<ImmutableMap<PackageIdentifier, Root>> packageRootMap =
packageRoots.getPackageRootsMap();
- if (!packageRootMap.isPresent()) {
- return;
- }
- // Prepare for build.
- Profiler.instance().markPhase(ProfilePhase.PREPARE);
+ if (packageRootMap.isPresent()) {
+ // Prepare for build.
+ Profiler.instance().markPhase(ProfilePhase.PREPARE);
- // Plant the symlink forest.
- try (SilentCloseable c = Profiler.instance().profile("plantSymlinkForest")) {
- new SymlinkForest(packageRootMap.get(), getExecRoot(), runtime.getProductName())
- .plantSymlinkForest();
- } catch (IOException e) {
- throw new ExecutorInitException("Source forest creation failed", e);
+ // Plant the symlink forest.
+ try (SilentCloseable c = Profiler.instance().profile("plantSymlinkForest")) {
+ new SymlinkForest(packageRootMap.get(), getExecRoot(), runtime.getProductName())
+ .plantSymlinkForest();
+ } catch (IOException e) {
+ throw new ExecutorInitException("Source forest creation failed", e);
+ }
}
+ env.getEventBus().post(new ExecRootPreparedEvent(packageRootMap));
}
private void createActionLogDirectory() throws ExecutorInitException {