aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/actions
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-02-15 10:33:53 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-15 10:35:15 -0800
commitcb314a2e36031c8a5f1dd26bb3b94f1b8f1cb901 (patch)
treee04b828849bd9b5be4d4bc1dde67b46cf46de9d7 /src/main/java/com/google/devtools/build/lib/analysis/actions
parent10b1a5fc3ade9c5f12078cd616218f9ef45ef13c (diff)
Stop storing ActionTemplate in a SkyKey: it's too heavyweight. Use the same mechanism as for normal actions, have the ActionTemplateExpansionFunction look the template up when needed.
PiperOrigin-RevId: 185861672
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/actions')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/actions/ActionTemplate.java89
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTemplate.java1
2 files changed, 1 insertions, 89 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/ActionTemplate.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/ActionTemplate.java
deleted file mode 100644
index 5fbc5ea5c8..0000000000
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/ActionTemplate.java
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2017 The Bazel Authors. 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.analysis.actions;
-
-import com.google.devtools.build.lib.actions.Action;
-import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact;
-import com.google.devtools.build.lib.actions.ArtifactOwner;
-
-/**
- * A placeholder action that, at execution time, expands into a list of {@link Action}s to be
- * executed.
- *
- * <p>ActionTemplate is for users who want to dynamically register Actions operating on
- * individual {@link TreeFileArtifact} inside input and output TreeArtifacts at execution time.
- *
- * <p>It takes in one TreeArtifact and generates one TreeArtifact. The following happens at
- * execution time for ActionTemplate:
- * <ol>
- * <li>Input TreeArtifact is resolved.
- * <li>For each individual {@link TreeFileArtifact} inside input TreeArtifact, generate an output
- * {@link TreeFileArtifact} inside output TreeArtifact.
- * <li>For each pair of input and output {@link TreeFileArtifact}s, generate an associated
- * {@link Action}.
- * <li>All expanded {@link Action}s are executed and their output {@link TreeFileArtifact}s
- * collected.
- * <li>Output TreeArtifact is resolved.
- * </ol>
- *
- * <p>Implementations of ActionTemplate must follow the contract of this interface and also make
- * sure:
- * <ol>
- * <li>ActionTemplate instances should be immutable and side-effect free.
- * <li>ActionTemplate inputs and outputs are supersets of the inputs and outputs of expanded
- * actions, excluding inputs discovered at execution time. This ensures the ActionTemplate
- * can properly represent the expanded actions at analysis time, and the action graph
- * at analysis time is correct. This is important because the action graph is walked in a lot
- * of places for correctness checks and build analysis.
- * <li>The outputs of expanded actions must be under the output TreeArtifact and must not have
- * artifact or artifact path prefix conflicts.
- * </ol>
- */
-public interface ActionTemplate<T extends Action> extends ActionAnalysisMetadata {
-
- /** An exception signalling that the template expansion failed during execution phase */
- class ActionTemplateExpansionException extends Exception {
-
- public ActionTemplateExpansionException(String cause) {
- super(cause);
- }
-
- public ActionTemplateExpansionException(Throwable cause) {
- super(cause);
- }
- }
-
- /**
- * Given a list of input TreeFileArtifacts resolved at execution time, returns a list of expanded
- * SpawnActions to be executed.
- *
- * @param inputTreeFileArtifacts the list of {@link TreeFileArtifact}s inside input TreeArtifact
- * resolved at execution time
- * @param artifactOwner the {@link ArtifactOwner} of the generated output
- * {@link TreeFileArtifact}s
- * @return a list of expanded {@link Action}s to execute, one for each input
- * {@link TreeFileArtifact}
- */
- Iterable<T> generateActionForInputArtifacts(
- Iterable<TreeFileArtifact> inputTreeFileArtifacts, ArtifactOwner artifactOwner)
- throws ActionTemplateExpansionException;
-
- /** Returns the input TreeArtifact. */
- Artifact getInputTreeArtifact();
-
- /** Returns the output TreeArtifact. */
- Artifact getOutputTreeArtifact();
-}
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTemplate.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTemplate.java
index 1b944d44e8..c3d1228d96 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTemplate.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTemplate.java
@@ -20,6 +20,7 @@ import com.google.devtools.build.lib.actions.ActionAnalysisMetadata;
import com.google.devtools.build.lib.actions.ActionExecutionContext;
import com.google.devtools.build.lib.actions.ActionInputHelper;
import com.google.devtools.build.lib.actions.ActionOwner;
+import com.google.devtools.build.lib.actions.ActionTemplate;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.Artifact.SpecialArtifact;
import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact;