Rename CppCompilationContext.getCompilationPrerequisites to
getTransitiveCompilationPrerequisites. The missing 'transitive' in the name is
misleading.
This change is a preparation for further refactorings that will in the end
introduce a getCompilationPrerequisites method that actually returns the
compilation prerequisites for a rule - as that will be require some more things
to be shuffled around in CppCompilationContext, this change gets the purely
syntactical change in first.
--
MOS_MIGRATED_REVID=120247461
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
index 7b5e4a3..6b6b5cc 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java
@@ -187,10 +187,17 @@
new PathFragment(ruleContext.getTarget().getName() + OsUtils.executableExtension());
Artifact binary = ruleContext.getPackageRelativeArtifact(
binaryPath, ruleContext.getConfiguration().getBinDirectory());
- CppLinkAction.Builder linkActionBuilder = determineLinkerArguments(
- ruleContext, common, precompiledFiles, ccCompilationOutputs,
- cppCompilationContext.getCompilationPrerequisites(), fake, binary, linkStaticness,
- linkopts);
+ CppLinkAction.Builder linkActionBuilder =
+ determineLinkerArguments(
+ ruleContext,
+ common,
+ precompiledFiles,
+ ccCompilationOutputs,
+ cppCompilationContext.getTransitiveCompilationPrerequisites(),
+ fake,
+ binary,
+ linkStaticness,
+ linkopts);
linkActionBuilder.setUseTestOnlyFlags(useTestOnlyFlags);
linkActionBuilder.addNonLibraryInputs(ccCompilationOutputs.getHeaderTokenFiles());
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java
index af3bbba..14531a4 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java
@@ -93,13 +93,17 @@
}
/**
- * Returns the compilation prerequisites consolidated into middlemen
+ * Returns the transitive compilation prerequisites consolidated into middlemen
* prerequisites, or an empty set if there are no prerequisites.
*
- * <p>For correct dependency tracking, and to reduce the overhead to establish
- * dependencies on generated headers, we express the dependency on compilation
- * prerequisites as a transitive dependency via a middleman. After they have
- * been accumulated (using
+ * <p>Transitive compilation prerequisites are the prerequisites that will be needed by all
+ * reverse dependencies; note that these do specifically not include any compilation prerequisites
+ * that are only needed by the rule itself (for example, compiled source files from the
+ * {@code srcs} attribute).
+ *
+ * <p>To reduce the number of edges in the action graph, we express the dependency on compilation
+ * prerequisites as a transitive dependency via a middleman.
+ * After they have been accumulated (using
* {@link Builder#addCompilationPrerequisites(Iterable)},
* {@link Builder#mergeDependentContext(CppCompilationContext)}, and
* {@link Builder#mergeDependentContexts(Iterable)}, they are consolidated
@@ -108,7 +112,7 @@
* <p>The returned set can be empty if there are no prerequisites. Usually it
* contains a single middleman, but if LIPO is used there can be two.
*/
- public ImmutableSet<Artifact> getCompilationPrerequisites() {
+ public ImmutableSet<Artifact> getTransitiveCompilationPrerequisites() {
return compilationPrerequisites;
}
@@ -693,7 +697,7 @@
*/
public Builder mergeDependentContext(CppCompilationContext otherContext) {
Preconditions.checkNotNull(otherContext);
- compilationPrerequisites.addAll(otherContext.getCompilationPrerequisites());
+ compilationPrerequisites.addAll(otherContext.getTransitiveCompilationPrerequisites());
includeDirs.addAll(otherContext.getIncludeDirs());
quoteIncludeDirs.addAll(otherContext.getQuoteIncludeDirs());
systemIncludeDirs.addAll(otherContext.getSystemIncludeDirs());
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 c9bf665..94cbf57 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
@@ -263,12 +263,15 @@
ImmutableSet<String> executionRequirements,
String actionName,
RuleContext ruleContext) {
- super(owner,
- createInputs(ruleContext,
- mandatoryInputs, context.getCompilationPrerequisites(), optionalSourceFile),
- CollectionUtils.asListWithoutNulls(outputFile,
- (dotdFile == null ? null : dotdFile.artifact()),
- gcnoFile, dwoFile));
+ super(
+ owner,
+ createInputs(
+ ruleContext,
+ mandatoryInputs,
+ context.getTransitiveCompilationPrerequisites(),
+ optionalSourceFile),
+ CollectionUtils.asListWithoutNulls(
+ outputFile, (dotdFile == null ? null : dotdFile.artifact()), gcnoFile, dwoFile));
this.configuration = configuration;
this.sourceLabel = sourceLabel;
this.outputFile = Preconditions.checkNotNull(outputFile);
@@ -769,7 +772,7 @@
Set<PathFragment> warnIncludeDirs = Sets.newHashSet(context.getDeclaredIncludeWarnDirs());
Set<Artifact> declaredIncludeSrcs = Sets.newHashSet(context.getDeclaredIncludeSrcs());
for (Artifact input : inputsForValidation) {
- if (context.getCompilationPrerequisites().contains(input)
+ if (context.getTransitiveCompilationPrerequisites().contains(input)
|| allowedIncludes.contains(input)) {
continue; // ignore our fixed source in mandatoryInput: we just want includes
}
@@ -901,7 +904,7 @@
if (optionalSourceFile != null) {
inputs.add(optionalSourceFile);
}
- inputs.addAll(context.getCompilationPrerequisites());
+ inputs.addAll(context.getTransitiveCompilationPrerequisites());
inputs.addTransitive(discoveredInputs);
inputsKnown = true;
} finally {
@@ -1057,7 +1060,7 @@
Map<PathFragment, Artifact> allowedDerivedInputMap = new HashMap<>();
addToMap(allowedDerivedInputMap, mandatoryInputs);
addToMap(allowedDerivedInputMap, context.getDeclaredIncludeSrcs());
- addToMap(allowedDerivedInputMap, context.getCompilationPrerequisites());
+ addToMap(allowedDerivedInputMap, context.getTransitiveCompilationPrerequisites());
Artifact artifact = getSourceFile();
if (!artifact.isSourceArtifact()) {
allowedDerivedInputMap.put(artifact.getExecPath(), artifact);
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java
index b7fe1be..8fa9dff 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModel.java
@@ -737,7 +737,7 @@
private CppLinkAction.Builder newLinkActionBuilder(Artifact outputArtifact) {
return new CppLinkAction.Builder(ruleContext, outputArtifact)
.setCrosstoolInputs(CppHelper.getToolchain(ruleContext).getLink())
- .addNonLibraryInputs(context.getCompilationPrerequisites());
+ .addNonLibraryInputs(context.getTransitiveCompilationPrerequisites());
}
/**