aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/Action.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/ExtraActionsVisitor.java12
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java73
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java18
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java22
9 files changed, 10 insertions, 142 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
index edc49ee2d1..d1d805fcd5 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/AbstractAction.java
@@ -481,11 +481,6 @@ public abstract class AbstractAction implements Action, SkylarkValue {
}
@Override
- public boolean extraActionCanAttach() {
- return true;
- }
-
- @Override
public ExtraActionInfo.Builder getExtraActionInfo() throws CommandLineExpansionException {
ActionOwner owner = getOwner();
ExtraActionInfo.Builder result =
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Action.java b/src/main/java/com/google/devtools/build/lib/actions/Action.java
index 524c20aa94..e1c1b35cff 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Action.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Action.java
@@ -186,12 +186,6 @@ public interface Action extends ActionExecutionMetadata, Describable {
boolean canRemoveAfterExecution();
/**
- * Returns true if an {@link com.google.devtools.build.lib.analysis.extra.ExtraAction} action can
- * be attached to this action. If not, extra actions should not be attached to this action.
- */
- boolean extraActionCanAttach();
-
- /**
* Called by {@link com.google.devtools.build.lib.analysis.extra.ExtraAction} at execution time to
* extract information from this action into a protocol buffer to be used by extra_action rules.
*
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ExtraActionsVisitor.java b/src/main/java/com/google/devtools/build/lib/analysis/ExtraActionsVisitor.java
index ff9f468ecd..f6f41deabf 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/ExtraActionsVisitor.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/ExtraActionsVisitor.java
@@ -47,13 +47,11 @@ final class ExtraActionsVisitor extends ActionGraphVisitor {
void maybeAddExtraAction(ActionAnalysisMetadata original) {
if (original instanceof Action) {
Action action = (Action) original;
- if (action.extraActionCanAttach()) {
- Collection<ExtraActionSpec> extraActions =
- mnemonicToExtraActionMap.get(action.getMnemonic());
- if (extraActions != null) {
- for (ExtraActionSpec extraAction : extraActions) {
- extraArtifacts.addAll(extraAction.addExtraAction(ruleContext, action));
- }
+ Collection<ExtraActionSpec> extraActions =
+ mnemonicToExtraActionMap.get(action.getMnemonic());
+ if (extraActions != null) {
+ for (ExtraActionSpec extraAction : extraActions) {
+ extraArtifacts.addAll(extraAction.addExtraAction(ruleContext, action));
}
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
index 623435bf95..8d35075d9a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java
@@ -86,33 +86,6 @@ import javax.annotation.Nullable;
public class CppCompileAction extends AbstractAction
implements IncludeScannable, ExecutionInfoSpecifier, CommandAction {
- /**
- * Represents logic that determines if an artifact is a special input, meaning that it may require
- * additional inputs when it is compiled or may not be available to other actions.
- */
- public interface SpecialInputsHandler {
- /** Returns if {@code includedFile} is special, so may not be available to other actions. */
- boolean isSpecialFile(Artifact includedFile);
-
- /** Returns the set of files to be added for an included file (as returned in the .d file). */
- Collection<Artifact> getInputsForIncludedFile(
- Artifact includedFile, ArtifactResolver artifactResolver);
- }
-
- static final SpecialInputsHandler VOID_SPECIAL_INPUTS_HANDLER =
- new SpecialInputsHandler() {
- @Override
- public boolean isSpecialFile(Artifact includedFile) {
- return false;
- }
-
- @Override
- public Collection<Artifact> getInputsForIncludedFile(
- Artifact includedFile, ArtifactResolver artifactResolver) {
- return ImmutableList.of();
- }
- };
-
private static final PathFragment BUILD_PATH_FRAGMENT = PathFragment.create("BUILD");
private static final int VALIDATION_DEBUG = 0; // 0==none, 1==warns/errors, 2==all
@@ -216,7 +189,6 @@ public class CppCompileAction extends AbstractAction
@VisibleForTesting final CppConfiguration cppConfiguration;
private final FeatureConfiguration featureConfiguration;
protected final Class<? extends CppCompileActionContext> actionContext;
- protected final SpecialInputsHandler specialInputsHandler;
protected final CppSemantics cppSemantics;
/**
@@ -246,8 +218,6 @@ public class CppCompileAction extends AbstractAction
private CcToolchainFeatures.Variables overwrittenVariables = null;
- private ImmutableList<Artifact> resolvedInputs = ImmutableList.<Artifact>of();
-
private PathFragment gccToolPath;
/**
@@ -275,7 +245,6 @@ public class CppCompileAction extends AbstractAction
* @param context the compilation context
* @param actionContext TODO(bazel-team): Add parameter description.
* @param coptsFilter regular expression to remove options from {@code copts}
- * @param specialInputsHandler TODO(bazel-team): Add parameter description.
* @param lipoScannables List of artifacts to include-scan when this action is a lipo action
* @param additionalIncludeScannables list of additional artifacts to include-scan
* @param actionClassId TODO(bazel-team): Add parameter description
@@ -308,7 +277,6 @@ public class CppCompileAction extends AbstractAction
CppCompilationContext context,
Class<? extends CppCompileActionContext> actionContext,
Predicate<String> coptsFilter,
- SpecialInputsHandler specialInputsHandler,
Iterable<IncludeScannable> lipoScannables,
ImmutableList<Artifact> additionalIncludeScannables,
UUID actionClassId,
@@ -331,7 +299,6 @@ public class CppCompileAction extends AbstractAction
this.outputFile = Preconditions.checkNotNull(outputFile);
this.optionalSourceFile = optionalSourceFile;
this.context = context;
- this.specialInputsHandler = specialInputsHandler;
this.cppConfiguration = cppConfiguration;
this.featureConfiguration = featureConfiguration;
// inputsKnown begins as the logical negation of shouldScanIncludes.
@@ -429,11 +396,6 @@ public class CppCompileAction extends AbstractAction
return result;
}
- @VisibleForTesting
- public void setResolvedInputsForTesting(ImmutableList<Artifact> resolvedInputs) {
- this.resolvedInputs = resolvedInputs;
- }
-
@Override
public boolean discoversInputs() {
return discoversInputs;
@@ -478,12 +440,11 @@ public class CppCompileAction extends AbstractAction
}
result.addTransitive(prunableInputs);
additionalInputs = result.build();
- return result.build();
+ return additionalInputs;
}
- Set<Artifact> initialResultSet = Sets.newLinkedHashSet(initialResult);
-
if (shouldPruneModules) {
+ Set<Artifact> initialResultSet = Sets.newLinkedHashSet(initialResult);
if (CppFileTypes.CPP_MODULE.matches(sourceFile.getFilename())) {
usedModules = ImmutableSet.of(sourceFile);
initialResultSet.add(sourceFile);
@@ -496,26 +457,11 @@ public class CppCompileAction extends AbstractAction
}
initialResultSet.addAll(usedModules);
}
+ initialResult = initialResultSet;
}
- initialResult = initialResultSet;
- this.additionalInputs = initialResult;
- // In some cases, execution backends need extra files for each included file. Add them
- // to the set of inputs the caller may need to be aware of.
- Collection<Artifact> result = new HashSet<>();
- ArtifactResolver artifactResolver =
- actionExecutionContext.getContext(IncludeScanningContext.class).getArtifactResolver();
- for (Artifact artifact : initialResult) {
- result.addAll(specialInputsHandler.getInputsForIncludedFile(artifact, artifactResolver));
- }
- for (Artifact artifact : getInputs()) {
- result.addAll(specialInputsHandler.getInputsForIncludedFile(artifact, artifactResolver));
- }
- // TODO(ulfjack): This only works if include scanning is enabled; the cleanup is in progress,
- // and this needs to be fixed before we can even consider disabling it.
- resolvedInputs = ImmutableList.copyOf(result);
- Iterables.addAll(result, initialResult);
- return Preconditions.checkNotNull(result);
+ additionalInputs = initialResult;
+ return additionalInputs;
}
@Override
@@ -758,12 +704,6 @@ public class CppCompileAction extends AbstractAction
}
@Override
- public boolean extraActionCanAttach() {
- return cppConfiguration.alwaysAttachExtraActions()
- || !specialInputsHandler.isSpecialFile(getPrimaryInput());
- }
-
- @Override
public ExtraActionInfo.Builder getExtraActionInfo() {
CppCompileInfo.Builder info = CppCompileInfo.newBuilder();
info.setTool(gccToolPath.getPathString());
@@ -841,7 +781,6 @@ public class CppCompileAction extends AbstractAction
}
allowedIncludes.add(input);
}
- allowedIncludes.addAll(resolvedInputs);
if (optionalSourceFile != null) {
allowedIncludes.add(optionalSourceFile);
@@ -1235,7 +1174,6 @@ public class CppCompileAction extends AbstractAction
new HeaderDiscovery.Builder()
.setAction(this)
.setSourceFile(getSourceFile())
- .setSpecialInputsHandler(specialInputsHandler)
.setDependencies(dependencies.build())
.setPermittedSystemIncludePrefixes(getPermittedSystemIncludePrefixes(execRoot))
.setAllowedDerivedinputsMap(getAllowedDerivedInputsMap());
@@ -1258,7 +1196,6 @@ public class CppCompileAction extends AbstractAction
new HeaderDiscovery.Builder()
.setAction(this)
.setSourceFile(getSourceFile())
- .setSpecialInputsHandler(specialInputsHandler)
.setDependencies(processDepset(execRoot, reply).getDependencies())
.setPermittedSystemIncludePrefixes(getPermittedSystemIncludePrefixes(execRoot))
.setAllowedDerivedinputsMap(getAllowedDerivedInputsMap());
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java
index 9d89feea2f..c5fe8c2466 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java
@@ -33,7 +33,6 @@ import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.
import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration;
import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables;
import com.google.devtools.build.lib.rules.cpp.CppCompileAction.DotdFile;
-import com.google.devtools.build.lib.rules.cpp.CppCompileAction.SpecialInputsHandler;
import com.google.devtools.build.lib.util.FileType;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -69,7 +68,6 @@ public class CppCompileActionBuilder {
private ImmutableList<PathFragment> extraSystemIncludePrefixes = ImmutableList.of();
private boolean usePic;
private boolean allowUsingHeaderModules;
- private SpecialInputsHandler specialInputsHandler = CppCompileAction.VOID_SPECIAL_INPUTS_HANDLER;
private UUID actionClassId = GUID;
private Class<? extends CppCompileActionContext> actionContext;
private CppConfiguration cppConfiguration;
@@ -161,7 +159,6 @@ public class CppCompileActionBuilder {
this.pluginOpts.addAll(other.pluginOpts);
this.coptsFilter = other.coptsFilter;
this.extraSystemIncludePrefixes = ImmutableList.copyOf(other.extraSystemIncludePrefixes);
- this.specialInputsHandler = other.specialInputsHandler;
this.actionClassId = other.actionClassId;
this.actionContext = other.actionContext;
this.cppConfiguration = other.cppConfiguration;
@@ -397,7 +394,6 @@ public class CppCompileActionBuilder {
context,
actionContext,
coptsFilter,
- specialInputsHandler,
getLipoScannables(realMandatoryInputs),
additionalIncludeFiles.build(),
actionClassId,
@@ -512,12 +508,6 @@ public class CppCompileActionBuilder {
return this;
}
- public CppCompileActionBuilder setSpecialInputsHandler(
- SpecialInputsHandler specialInputsHandler) {
- this.specialInputsHandler = specialInputsHandler;
- return this;
- }
-
public CppCompileActionBuilder setCppConfiguration(CppConfiguration cppConfiguration) {
this.cppConfiguration = cppConfiguration;
return this;
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
index b67f44c687..1212b8a3d0 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
@@ -1277,10 +1277,6 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
return getToolchainIdentifier();
}
- public boolean alwaysAttachExtraActions() {
- return true;
- }
-
/**
* Returns true if we should share identical native libraries between different targets.
*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java
index 383e84f03d..3fa6091dc2 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java
@@ -109,7 +109,6 @@ public class FakeCppCompileAction extends CppCompileAction {
CppCompilationContext.disallowUndeclaredHeaders(context),
actionContext,
nocopts,
- VOID_SPECIAL_INPUTS_HANDLER,
lipoScannables,
ImmutableList.<Artifact>of(),
GUID,
@@ -155,7 +154,6 @@ public class FakeCppCompileAction extends CppCompileAction {
new HeaderDiscovery.Builder()
.setAction(this)
.setSourceFile(getSourceFile())
- .setSpecialInputsHandler(specialInputsHandler)
.setDependencies(processDepset(execRoot, reply).getDependencies())
.setPermittedSystemIncludePrefixes(getPermittedSystemIncludePrefixes(execRoot))
.setAllowedDerivedinputsMap(getAllowedDerivedInputsMap());
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java
index 8072e560d7..85f9238524 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/HeaderDiscovery.java
@@ -26,7 +26,6 @@ import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadCompatible;
-import com.google.devtools.build.lib.rules.cpp.CppCompileAction.SpecialInputsHandler;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -49,7 +48,6 @@ public class HeaderDiscovery {
private final Action action;
private final Artifact sourceFile;
- private final SpecialInputsHandler specialInputsHandler;
private final boolean shouldValidateInclusions;
private final Collection<Path> dependencies;
@@ -61,20 +59,17 @@ public class HeaderDiscovery {
*
* @param action the action instance requiring header discovery
* @param sourceFile the source file for the compile
- * @param specialInputsHandler the SpecialInputsHandler for the build
* @param shouldValidateInclusions true if include validation should be performed
*/
public HeaderDiscovery(
Action action,
Artifact sourceFile,
- SpecialInputsHandler specialInputsHandler,
boolean shouldValidateInclusions,
Collection<Path> dependencies,
List<Path> permittedSystemIncludePrefixes,
Map<PathFragment, Artifact> allowedDerivedInputsMap) {
this.action = Preconditions.checkNotNull(action);
this.sourceFile = Preconditions.checkNotNull(sourceFile);
- this.specialInputsHandler = specialInputsHandler;
this.shouldValidateInclusions = shouldValidateInclusions;
this.dependencies = dependencies;
this.permittedSystemIncludePrefixes = permittedSystemIncludePrefixes;
@@ -135,11 +130,6 @@ public class HeaderDiscovery {
}
if (artifact != null) {
inputs.add(artifact);
- // In some cases, execution backends need extra files for each included file. Add them
- // to the set of actual inputs.
- if (specialInputsHandler != null) {
- inputs.addAll(specialInputsHandler.getInputsForIncludedFile(artifact, artifactResolver));
- }
} else {
// Abort if we see files that we can't resolve, likely caused by
// undeclared includes or illegal include constructs.
@@ -156,7 +146,6 @@ public class HeaderDiscovery {
public static class Builder {
private Action action;
private Artifact sourceFile;
- private SpecialInputsHandler specialInputsHandler;
private boolean shouldValidateInclusions = false;
private Collection<Path> dependencies;
@@ -175,12 +164,6 @@ public class HeaderDiscovery {
return this;
}
- /** Sets the SpecialInputsHandler for inputs to this build. */
- public Builder setSpecialInputsHandler(SpecialInputsHandler specialInputsHandler) {
- this.specialInputsHandler = specialInputsHandler;
- return this;
- }
-
/** Sets that this compile should validate inclusions against the dotd file. */
public Builder shouldValidateInclusions() {
this.shouldValidateInclusions = true;
@@ -210,7 +193,6 @@ public class HeaderDiscovery {
return new HeaderDiscovery(
action,
sourceFile,
- specialInputsHandler,
shouldValidateInclusions,
dependencies,
permittedSystemIncludePrefixes,
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java b/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java
index c92e7a1b8b..064e4b2e16 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/FileSystemUtils.java
@@ -220,28 +220,6 @@ public class FileSystemUtils {
}
/**
- * Returns a new {@code PathFragment} formed by replacing the first, or all if
- * {@code replaceAll} is true, {@code oldSegment} of {@code path} with {@code
- * newSegment}.
- */
- public static PathFragment replaceSegments(PathFragment path,
- String oldSegment, String newSegment, boolean replaceAll) {
- int count = path.segmentCount();
- for (int i = 0; i < count; i++) {
- if (path.getSegment(i).equals(oldSegment)) {
- path = PathFragment.create(
- path.subFragment(0, i),
- PathFragment.create(newSegment),
- path.subFragment(i+1, count));
- if (!replaceAll) {
- return path;
- }
- }
- }
- return path;
- }
-
- /**
* Returns a new {@code PathFragment} formed by appending the given string to the last path
* segment of {@code path} without removing the extension. Returns null if {@code path}
* has zero segments.