aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime
diff options
context:
space:
mode:
authorGravatar Ulf Adams <ulfjack@google.com>2016-03-29 17:15:06 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-03-30 08:13:52 +0000
commit45f63bb7374ddd9a73b7484bfa5c4fbd3aba7d31 (patch)
tree3cea834e8c824a7a2fd54be11b98ee0d18b4520e /src/main/java/com/google/devtools/build/lib/runtime
parent4f6d0350e1ea71acf8eea6732fd14cd1bb4ac3de (diff)
Delay BuildView creation in CommandEnvironment until beforeCommand().
This is so that we can access the build options during creation, which is a step towards making the coverage module stateless. -- MOS_MIGRATED_REVID=118475354
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
index 687e7ae1fb..f0a424c741 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
@@ -81,7 +81,7 @@ public final class CommandEnvironment {
private final Map<String, String> clientEnv = new HashMap<>();
private final TimestampGranularityMonitor timestampGranularityMonitor;
- private final BuildView view;
+ private BuildView view;
private PathFragment relativeWorkingDirectory = PathFragment.EMPTY_FRAGMENT;
private long commandStartTime;
@@ -120,9 +120,6 @@ public final class CommandEnvironment {
// the command's execution.
timestampGranularityMonitor.setCommandStartTime();
- this.view = new BuildView(runtime.getDirectories(), runtime.getRuleClassProvider(),
- runtime.getSkyframeExecutor(), runtime.getCoverageReportActionFactory());
-
// TODO(ulfjack): We don't call beforeCommand() in tests, but rely on workingDirectory being set
// in setupPackageCache(). This leads to NPE if we don't set it here.
this.workingDirectory = runtime.getWorkspace();
@@ -338,6 +335,12 @@ public final class CommandEnvironment {
return outputFileSystem;
}
+ @VisibleForTesting
+ public void initViewForTesting() {
+ this.view = new BuildView(runtime.getDirectories(), runtime.getRuleClassProvider(),
+ runtime.getSkyframeExecutor(), runtime.getCoverageReportActionFactory());
+ }
+
/**
* Hook method called by the BlazeCommandDispatcher prior to the dispatch of
* each command.
@@ -394,6 +397,8 @@ public final class CommandEnvironment {
runtime.getStartupOptionsProvider().getOptions(BlazeServerStartupOptions.class).batch,
optionsParser.getOptions(BuildView.Options.class));
+ initViewForTesting();
+
// Start the performance and memory profilers.
runtime.beforeCommand(this, options, execStartTimeNanos);