aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/SimpleActionContextProvider.java55
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java32
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java43
-rw-r--r--src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java11
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java12
-rw-r--r--src/main/java/com/google/devtools/build/lib/standalone/StandaloneModule.java10
6 files changed, 81 insertions, 82 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/SimpleActionContextProvider.java b/src/main/java/com/google/devtools/build/lib/actions/SimpleActionContextProvider.java
new file mode 100644
index 0000000000..f289c3e1fe
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/actions/SimpleActionContextProvider.java
@@ -0,0 +1,55 @@
+// Copyright 2015 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.lib.actions;
+
+import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.actions.Executor.ActionContext;
+
+import java.util.List;
+
+/**
+ * An {@link ActionContextProvider} that just provides the {@link ActionContext}s it's given.
+ */
+public class SimpleActionContextProvider implements ActionContextProvider {
+
+ /**
+ * Creates an immutable list containing a single SimpleActionContextProvider with the given
+ * contexts as a convenience for BlazeModule.getActionContextProviders().
+ */
+ public static List<ActionContextProvider> of(ActionContext ... contexts) {
+ return ImmutableList.<ActionContextProvider>of(new SimpleActionContextProvider(contexts));
+ }
+
+ private final List<ActionContext> actionContexts;
+
+ public SimpleActionContextProvider(ActionContext ... contexts) {
+ actionContexts = ImmutableList.<ActionContext>copyOf(contexts);
+ }
+
+ @Override
+ public Iterable<ActionContext> getActionContexts() {
+ return actionContexts;
+ }
+
+ @Override
+ public void executorCreated(Iterable<ActionContext> usedContexts) {}
+
+ @Override
+ public void executionPhaseStarting(ActionInputFileCache actionInputFileCache,
+ ActionGraph actionGraph, Iterable<Artifact> topLevelArtifacts) {}
+
+ @Override
+ public void executionPhaseEnding() {}
+
+}
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java b/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java
index 21cb0c8c17..8bb29ab72f 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java
@@ -20,17 +20,14 @@ import com.google.common.eventbus.Subscribe;
import com.google.devtools.build.lib.actions.ActionContextProvider;
import com.google.devtools.build.lib.actions.ActionExecutionContext;
import com.google.devtools.build.lib.actions.ActionExecutionException;
-import com.google.devtools.build.lib.actions.ActionGraph;
-import com.google.devtools.build.lib.actions.ActionInputFileCache;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.ArtifactFactory;
import com.google.devtools.build.lib.actions.ArtifactOwner;
import com.google.devtools.build.lib.actions.ExecutionStrategy;
import com.google.devtools.build.lib.actions.Executor;
-import com.google.devtools.build.lib.actions.Executor.ActionContext;
-import com.google.devtools.build.lib.actions.ExecutorInitException;
import com.google.devtools.build.lib.actions.ResourceSet;
import com.google.devtools.build.lib.actions.Root;
+import com.google.devtools.build.lib.actions.SimpleActionContextProvider;
import com.google.devtools.build.lib.analysis.BuildInfoHelper;
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction;
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction.Key;
@@ -174,29 +171,6 @@ public class BazelWorkspaceStatusModule extends BlazeModule {
}
}
-
- private class WorkspaceActionContextProvider implements ActionContextProvider {
- @Override
- public Iterable<ActionContext> getActionContexts() {
- return ImmutableList.<ActionContext>of(new BazelWorkspaceStatusActionContext());
- }
-
- @Override
- public void executorCreated(Iterable<ActionContext> usedContexts)
- throws ExecutorInitException {
- }
-
- @Override
- public void executionPhaseEnding() {
- }
-
- @Override
- public void executionPhaseStarting(ActionInputFileCache actionInputFileCache,
- ActionGraph actionGraph, Iterable<Artifact> topLevelArtifacts) throws ExecutorInitException,
- InterruptedException {
- }
- }
-
private BlazeRuntime runtime;
private AtomicReference<WorkspaceStatusAction.Options> options = new AtomicReference<>();
@@ -219,8 +193,8 @@ public class BazelWorkspaceStatusModule extends BlazeModule {
}
@Override
- public ActionContextProvider getActionContextProvider() {
- return new WorkspaceActionContextProvider();
+ public Iterable<ActionContextProvider> getActionContextProviders() {
+ return SimpleActionContextProvider.of(new BazelWorkspaceStatusActionContext());
}
@Override
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java
index e59218c63f..db7233e864 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRulesModule.java
@@ -20,11 +20,8 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.eventbus.Subscribe;
import com.google.devtools.build.lib.actions.ActionContextConsumer;
import com.google.devtools.build.lib.actions.ActionContextProvider;
-import com.google.devtools.build.lib.actions.ActionGraph;
-import com.google.devtools.build.lib.actions.ActionInputFileCache;
-import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.Executor.ActionContext;
-import com.google.devtools.build.lib.actions.ExecutorInitException;
+import com.google.devtools.build.lib.actions.SimpleActionContextProvider;
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider;
import com.google.devtools.build.lib.query2.output.OutputFormatter;
import com.google.devtools.build.lib.rules.cpp.CppCompileActionContext;
@@ -100,30 +97,6 @@ public class BazelRulesModule extends BlazeModule {
}
}
- private class BazelActionContextProvider implements ActionContextProvider {
- @Override
- public Iterable<ActionContext> getActionContexts() {
- return ImmutableList.of(
- new LocalGccStrategy(optionsProvider),
- new LocalLinkStrategy());
- }
-
- @Override
- public void executorCreated(Iterable<ActionContext> usedContexts)
- throws ExecutorInitException {
- }
-
- @Override
- public void executionPhaseStarting(ActionInputFileCache actionInputFileCache,
- ActionGraph actionGraph, Iterable<Artifact> topLevelArtifacts)
- throws ExecutorInitException, InterruptedException {
- }
-
- @Override
- public void executionPhaseEnding() {
- }
- }
-
private BlazeRuntime runtime;
private OptionsProvider optionsProvider;
@@ -141,14 +114,16 @@ public class BazelRulesModule extends BlazeModule {
}
@Override
- public ActionContextConsumer getActionContextConsumer() {
- return new BazelActionContextConsumer(
- optionsProvider.getOptions(BazelExecutionOptions.class));
+ public Iterable<ActionContextConsumer> getActionContextConsumers() {
+ return ImmutableList.<ActionContextConsumer>of(new BazelActionContextConsumer(
+ optionsProvider.getOptions(BazelExecutionOptions.class)));
}
-
+
@Override
- public ActionContextProvider getActionContextProvider() {
- return new BazelActionContextProvider();
+ public Iterable<ActionContextProvider> getActionContextProviders() {
+ return SimpleActionContextProvider.of(
+ new LocalGccStrategy(optionsProvider),
+ new LocalLinkStrategy());
}
@Subscribe
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 65ad7a7550..8051a0cb52 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
@@ -184,15 +184,8 @@ public class ExecutionTool {
List<ActionContextConsumer> actionContextConsumers = new ArrayList<>();
actionContextProviders = new ArrayList<>();
for (BlazeModule module : runtime.getBlazeModules()) {
- ActionContextProvider provider = module.getActionContextProvider();
- if (provider != null) {
- actionContextProviders.add(provider);
- }
-
- ActionContextConsumer consumer = module.getActionContextConsumer();
- if (consumer != null) {
- actionContextConsumers.add(consumer);
- }
+ Iterables.addAll(actionContextProviders, module.getActionContextProviders());
+ Iterables.addAll(actionContextConsumers, module.getActionContextConsumers());
}
actionContextProviders.add(new FilesetActionContextImpl.Provider(
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java
index 1385647615..884b0ec96e 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java
@@ -298,24 +298,24 @@ public abstract class BlazeModule {
}
/**
- * Returns the action context provider the module contributes to Blaze, if any.
+ * Returns the action context providers the module contributes to Blaze, if any.
*
* <p>This method will be called at the beginning of the execution phase, e.g. of the
* "blaze build" command.
*/
- public ActionContextProvider getActionContextProvider() {
- return null;
+ public Iterable<ActionContextProvider> getActionContextProviders() {
+ return ImmutableList.of();
}
/**
- * Returns the action context consumer that pulls in action contexts required by this module,
+ * Returns the action context consumers that pulls in action contexts required by this module,
* if any.
*
* <p>This method will be called at the beginning of the execution phase, e.g. of the
* "blaze build" command.
*/
- public ActionContextConsumer getActionContextConsumer() {
- return null;
+ public Iterable<ActionContextConsumer> getActionContextConsumers() {
+ return ImmutableList.of();
}
/**
diff --git a/src/main/java/com/google/devtools/build/lib/standalone/StandaloneModule.java b/src/main/java/com/google/devtools/build/lib/standalone/StandaloneModule.java
index 06bffd0bd8..02d6a3a39f 100644
--- a/src/main/java/com/google/devtools/build/lib/standalone/StandaloneModule.java
+++ b/src/main/java/com/google/devtools/build/lib/standalone/StandaloneModule.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.standalone;
+import com.google.common.collect.ImmutableList;
import com.google.common.eventbus.Subscribe;
import com.google.devtools.build.lib.actions.ActionContextConsumer;
import com.google.devtools.build.lib.actions.ActionContextProvider;
@@ -34,16 +35,17 @@ public class StandaloneModule extends BlazeModule {
* Returns the action context provider the module contributes to Blaze, if any.
*/
@Override
- public ActionContextProvider getActionContextProvider() {
- return new StandaloneContextProvider(runtime, buildRequest);
+ public Iterable<ActionContextProvider> getActionContextProviders() {
+ return ImmutableList.<ActionContextProvider>of(
+ new StandaloneContextProvider(runtime, buildRequest));
}
/**
* Returns the action context consumer the module contributes to Blaze, if any.
*/
@Override
- public ActionContextConsumer getActionContextConsumer() {
- return actionContextConsumer;
+ public Iterable<ActionContextConsumer> getActionContextConsumers() {
+ return ImmutableList.of(actionContextConsumer);
}
@Override