diff options
Diffstat (limited to 'src/main/java')
29 files changed, 419 insertions, 360 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppSemantics.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppSemantics.java index 23ea2a39ed..7cbb0dda83 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/BazelCppSemantics.java @@ -20,7 +20,7 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.collect.nestedset.Order; import com.google.devtools.build.lib.rules.cpp.AspectLegalCppSemantics; -import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo.Builder; +import com.google.devtools.build.lib.rules.cpp.CcCompilationContextInfo.Builder; import com.google.devtools.build.lib.rules.cpp.CppCompileActionBuilder; import com.google.devtools.build.lib.rules.cpp.CppConfiguration; import com.google.devtools.build.lib.rules.cpp.CppConfiguration.HeadersCheckingMode; @@ -50,7 +50,8 @@ public class BazelCppSemantics implements AspectLegalCppSemantics { } @Override - public void setupCcCompilationInfo(RuleContext ruleContext, Builder ccCompilationInfoBuilder) {} + public void setupCcCompilationContextInfo( + RuleContext ruleContext, Builder ccCompilationContextInfoBuilder) {} @Override public NestedSet<Artifact> getAdditionalPrunableIncludes() { 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 2059b96c84..b06003c89a 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 @@ -98,7 +98,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { CcToolchainProvider toolchain, CcLinkingOutputs linkingOutputs, CcLinkingOutputs ccLibraryLinkingOutputs, - CcCompilationInfo ccCompilationInfo, + CcCompilationContextInfo ccCompilationContextInfo, LinkStaticness linkStaticness, NestedSet<Artifact> filesToBuild, Iterable<Artifact> fakeLinkerInputs, @@ -152,12 +152,12 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { sourcesBuilder.add(cppSource.getSource()); } builder.addSymlinksToArtifacts(sourcesBuilder.build()); - builder.addSymlinksToArtifacts(ccCompilationInfo.getDeclaredIncludeSrcs()); + builder.addSymlinksToArtifacts(ccCompilationContextInfo.getDeclaredIncludeSrcs()); // Add additional files that are referenced from the compile command, like module maps // or header modules. - builder.addSymlinksToArtifacts(ccCompilationInfo.getAdditionalInputs()); + builder.addSymlinksToArtifacts(ccCompilationContextInfo.getAdditionalInputs()); builder.addSymlinksToArtifacts( - ccCompilationInfo.getTransitiveModules(usePic(context, toolchain))); + ccCompilationContextInfo.getTransitiveModules(usePic(context, toolchain))); } return builder.build(); } @@ -234,7 +234,8 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { .setFake(fake) .addPrecompiledFiles(precompiledFiles); CompilationInfo compilationInfo = compilationHelper.compile(); - CcCompilationInfo ccCompilationInfo = compilationInfo.getCcCompilationInfo(); + CcCompilationContextInfo ccCompilationContextInfo = + compilationInfo.getCcCompilationContextInfo(); CcCompilationOutputs ccCompilationOutputs = compilationInfo.getCcCompilationOutputs(); // We currently only want link the dynamic library generated for test code separately. @@ -269,7 +270,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { .enableInterfaceSharedObjects(); linkingHelper.setStaticLinkType(LinkTargetType.STATIC_LIBRARY); ccLinkingOutputs = - linkingHelper.link(ccCompilationOutputs, ccCompilationInfo).getCcLinkingOutputs(); + linkingHelper.link(ccCompilationOutputs, ccCompilationContextInfo).getCcLinkingOutputs(); } CcLinkParams linkParams = @@ -288,7 +289,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { precompiledFiles, ccCompilationOutputs, ccLinkingOutputs, - ccCompilationInfo.getTransitiveCompilationPrerequisites(), + ccCompilationContextInfo.getTransitiveCompilationPrerequisites(), fake, binary, linkParams, @@ -468,7 +469,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { ccToolchain, linkingOutputs, ccLinkingOutputs, - ccCompilationInfo, + ccCompilationContextInfo, linkStaticness, filesToBuild, fakeLinkerInputs, @@ -494,7 +495,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { ruleBuilder, filesToBuild, ccCompilationOutputs, - ccCompilationInfo, + ccCompilationContextInfo, linkingOutputs, dwoArtifacts, transitiveLipoInfo, @@ -543,7 +544,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { .addProvider( LipoContextProvider.class, new LipoContextProvider( - ccCompilationInfo, + ccCompilationContextInfo, ImmutableMap.copyOf(scannableMap), ImmutableMap.copyOf(sourceFileMap))) .addProvider(CppLinkAction.Context.class, linkContext) @@ -873,7 +874,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { RuleConfiguredTargetBuilder builder, NestedSet<Artifact> filesToBuild, CcCompilationOutputs ccCompilationOutputs, - CcCompilationInfo ccCompilationInfo, + CcCompilationContextInfo ccCompilationContextInfo, CcLinkingOutputs linkingOutputs, DwoArtifactsCollector dwoArtifacts, TransitiveLipoInfoProvider transitiveLipoInfo, @@ -893,7 +894,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { CppHelper.usePicForDynamicLibraries(ruleContext, toolchain)); builder .setFilesToBuild(filesToBuild) - .addNativeDeclaredProvider(ccCompilationInfo) + .addNativeDeclaredProvider(ccCompilationContextInfo) .addProvider(TransitiveLipoInfoProvider.class, transitiveLipoInfo) .addProvider( CcExecutionDynamicLibrariesProvider.class, @@ -919,7 +920,7 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { .addOutputGroup(OutputGroupInfo.HIDDEN_TOP_LEVEL, headerTokens) .addOutputGroup( OutputGroupInfo.COMPILATION_PREREQUISITES, - CcCommon.collectCompilationPrerequisites(ruleContext, ccCompilationInfo)); + CcCommon.collectCompilationPrerequisites(ruleContext, ccCompilationContextInfo)); CppHelper.maybeAddStaticLinkMarkerProvider(builder, ruleContext); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java index 8ddd0a1e5f..dbca6e6571 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCommon.java @@ -597,10 +597,12 @@ public final class CcCommon { /** Collects compilation prerequisite artifacts. */ static NestedSet<Artifact> collectCompilationPrerequisites( - RuleContext ruleContext, CcCompilationInfo ccCompilationInfo) { - // TODO(bazel-team): Use ccCompilationInfo.getCompilationPrerequisites() instead; note that this + RuleContext ruleContext, CcCompilationContextInfo ccCompilationContextInfo) { + // TODO(bazel-team): Use ccCompilationContextInfo.getCompilationPrerequisites() instead; note + // that this // will - // need cleaning up the prerequisites, as the {@code CcCompilationInfo} currently collects them + // need cleaning up the prerequisites, as the {@code CcCompilationContextInfo} currently + // collects them // transitively (to get transitive headers), but source files are not transitive compilation // prerequisites. NestedSetBuilder<Artifact> prerequisites = NestedSetBuilder.stableOrder(); @@ -612,10 +614,10 @@ public final class CcCommon { provider.getFilesToBuild(), SourceCategory.CC_AND_OBJC.getSourceTypes())); } } - prerequisites.addTransitive(ccCompilationInfo.getDeclaredIncludeSrcs()); - prerequisites.addTransitive(ccCompilationInfo.getAdditionalInputs()); - prerequisites.addTransitive(ccCompilationInfo.getTransitiveModules(true)); - prerequisites.addTransitive(ccCompilationInfo.getTransitiveModules(false)); + prerequisites.addTransitive(ccCompilationContextInfo.getDeclaredIncludeSrcs()); + prerequisites.addTransitive(ccCompilationContextInfo.getAdditionalInputs()); + prerequisites.addTransitive(ccCompilationContextInfo.getTransitiveModules(true)); + prerequisites.addTransitive(ccCompilationContextInfo.getTransitiveModules(false)); return prerequisites.build(); } @@ -711,7 +713,7 @@ public final class CcCommon { unsupportedFeaturesBuilder.add(CppRuleClasses.PARSE_HEADERS); unsupportedFeaturesBuilder.add(CppRuleClasses.PREPROCESS_HEADERS); } - if (toolchain.getCcCompilationInfo().getCppModuleMap() == null) { + if (toolchain.getCcCompilationContextInfo().getCppModuleMap() == null) { unsupportedFeaturesBuilder.add(CppRuleClasses.MODULE_MAPS); } ImmutableSet<String> allUnsupportedFeatures = unsupportedFeaturesBuilder.build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationInfo.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationContextInfo.java index b020862723..c7b64d7c05 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationInfo.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationContextInfo.java @@ -56,14 +56,15 @@ import javax.annotation.Nullable; "Immutable store of information needed for C++ compilation that is aggregated across " + "dependencies." ) -public final class CcCompilationInfo extends NativeInfo { - public static final NativeProvider<CcCompilationInfo> PROVIDER = - new NativeProvider<CcCompilationInfo>(CcCompilationInfo.class, "CcCompilationInfo") {}; +public final class CcCompilationContextInfo extends NativeInfo { + public static final NativeProvider<CcCompilationContextInfo> PROVIDER = + new NativeProvider<CcCompilationContextInfo>( + CcCompilationContextInfo.class, "CcCompilationContextInfo") {}; - /** An empty {@code CcCompilationInfo}. */ - public static final CcCompilationInfo EMPTY = new Builder(null).build(); + /** An empty {@code CcCompilationContextInfo}. */ + public static final CcCompilationContextInfo EMPTY = new Builder(null).build(); - private final CommandLineCcCompilationInfo commandLineCcCompilationInfo; + private final CommandLineCcCompilationContextInfo commandLineCcCompilationContextInfo; private final NestedSet<PathFragment> declaredIncludeDirs; private final NestedSet<PathFragment> declaredIncludeWarnDirs; @@ -92,8 +93,8 @@ public final class CcCompilationInfo extends NativeInfo { @AutoCodec.Instantiator @VisibleForSerialization - CcCompilationInfo( - CommandLineCcCompilationInfo commandLineCcCompilationInfo, + CcCompilationContextInfo( + CommandLineCcCompilationContextInfo commandLineCcCompilationContextInfo, ImmutableSet<Artifact> compilationPrerequisites, NestedSet<PathFragment> declaredIncludeDirs, NestedSet<PathFragment> declaredIncludeWarnDirs, @@ -107,8 +108,8 @@ public final class CcCompilationInfo extends NativeInfo { @Nullable CppModuleMap verificationModuleMap, boolean propagateModuleMapAsActionInput) { super(PROVIDER); - Preconditions.checkNotNull(commandLineCcCompilationInfo); - this.commandLineCcCompilationInfo = commandLineCcCompilationInfo; + Preconditions.checkNotNull(commandLineCcCompilationContextInfo); + this.commandLineCcCompilationContextInfo = commandLineCcCompilationContextInfo; this.declaredIncludeDirs = declaredIncludeDirs; this.declaredIncludeWarnDirs = declaredIncludeWarnDirs; this.declaredIncludeSrcs = declaredIncludeSrcs; @@ -135,8 +136,8 @@ public final class CcCompilationInfo extends NativeInfo { * <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#mergeDependentCcCompilationInfo(CcCompilationInfo)}, and {@link - * Builder#mergeDependentCcCompilationInfos(Iterable)}, they are consolidated into a single + * Builder#mergeDependentCcCompilationContextInfo(CcCompilationContextInfo)}, and {@link + * Builder#mergeDependentCcCompilationContextInfos(Iterable)}, they are consolidated into a single * middleman Artifact when {@link Builder#build()} is called. * * <p>The returned set can be empty if there are no prerequisites. Usually it contains a single @@ -154,7 +155,7 @@ public final class CcCompilationInfo extends NativeInfo { * (see {@link com.google.devtools.build.lib.analysis.BlazeDirectories#getExecRoot}). */ public ImmutableList<PathFragment> getIncludeDirs() { - return commandLineCcCompilationInfo.includeDirs; + return commandLineCcCompilationContextInfo.includeDirs; } /** @@ -165,7 +166,7 @@ public final class CcCompilationInfo extends NativeInfo { * (see {@link com.google.devtools.build.lib.analysis.BlazeDirectories#getExecRoot}). */ public ImmutableList<PathFragment> getQuoteIncludeDirs() { - return commandLineCcCompilationInfo.quoteIncludeDirs; + return commandLineCcCompilationContextInfo.quoteIncludeDirs; } /** @@ -176,7 +177,7 @@ public final class CcCompilationInfo extends NativeInfo { * (see {@link com.google.devtools.build.lib.analysis.BlazeDirectories#getExecRoot}). */ public ImmutableList<PathFragment> getSystemIncludeDirs() { - return commandLineCcCompilationInfo.systemIncludeDirs; + return commandLineCcCompilationContextInfo.systemIncludeDirs; } /** @@ -260,29 +261,30 @@ public final class CcCompilationInfo extends NativeInfo { * for the target. The order of the returned collection is deterministic. */ public ImmutableList<String> getDefines() { - return commandLineCcCompilationInfo.defines; + return commandLineCcCompilationContextInfo.defines; } /** - * Returns a {@code CcCompilationInfo} that is based on a given {@code CcCompilationInfo} but - * returns empty sets for {@link #getDeclaredIncludeDirs()} and {@link - * #getDeclaredIncludeWarnDirs()}. + * Returns a {@code CcCompilationContextInfo} that is based on a given {@code + * CcCompilationContextInfo} but returns empty sets for {@link #getDeclaredIncludeDirs()} and + * {@link #getDeclaredIncludeWarnDirs()}. */ - public static CcCompilationInfo disallowUndeclaredHeaders(CcCompilationInfo ccCompilationInfo) { - return new CcCompilationInfo( - ccCompilationInfo.commandLineCcCompilationInfo, - ccCompilationInfo.compilationPrerequisites, + public static CcCompilationContextInfo disallowUndeclaredHeaders( + CcCompilationContextInfo ccCompilationContextInfo) { + return new CcCompilationContextInfo( + ccCompilationContextInfo.commandLineCcCompilationContextInfo, + ccCompilationContextInfo.compilationPrerequisites, NestedSetBuilder.<PathFragment>emptySet(Order.STABLE_ORDER), NestedSetBuilder.<PathFragment>emptySet(Order.STABLE_ORDER), - ccCompilationInfo.declaredIncludeSrcs, - ccCompilationInfo.pregreppedHdrs, - ccCompilationInfo.nonCodeInputs, - ccCompilationInfo.moduleInfo, - ccCompilationInfo.picModuleInfo, - ccCompilationInfo.directModuleMaps, - ccCompilationInfo.cppModuleMap, - ccCompilationInfo.verificationModuleMap, - ccCompilationInfo.propagateModuleMapAsActionInput); + ccCompilationContextInfo.declaredIncludeSrcs, + ccCompilationContextInfo.pregreppedHdrs, + ccCompilationContextInfo.nonCodeInputs, + ccCompilationContextInfo.moduleInfo, + ccCompilationContextInfo.picModuleInfo, + ccCompilationContextInfo.directModuleMaps, + ccCompilationContextInfo.cppModuleMap, + ccCompilationContextInfo.verificationModuleMap, + ccCompilationContextInfo.propagateModuleMapAsActionInput); } /** @@ -304,38 +306,46 @@ public final class CcCompilationInfo extends NativeInfo { * <p>Include scanning is not handled by this method. See {@code * IncludeScannable#getAuxiliaryScannables()} instead. * - * @param ownerCcCompilationInfo the {@code CcCompilationInfo} of the owner binary - * @param libCcCompilationInfo the {@code CcCompilationInfo} of the library + * @param ownerCcCompilationContextInfo the {@code CcCompilationContextInfo} of the owner binary + * @param libCcCompilationContextInfo the {@code CcCompilationContextInfo} of the library */ - public static CcCompilationInfo mergeForLipo( - CcCompilationInfo ownerCcCompilationInfo, CcCompilationInfo libCcCompilationInfo) { + public static CcCompilationContextInfo mergeForLipo( + CcCompilationContextInfo ownerCcCompilationContextInfo, + CcCompilationContextInfo libCcCompilationContextInfo) { ImmutableSet.Builder<Artifact> prerequisites = ImmutableSet.builder(); - prerequisites.addAll(ownerCcCompilationInfo.compilationPrerequisites); - prerequisites.addAll(libCcCompilationInfo.compilationPrerequisites); + prerequisites.addAll(ownerCcCompilationContextInfo.compilationPrerequisites); + prerequisites.addAll(libCcCompilationContextInfo.compilationPrerequisites); ModuleInfo.Builder moduleInfo = new ModuleInfo.Builder(); - moduleInfo.merge(ownerCcCompilationInfo.moduleInfo); - moduleInfo.merge(libCcCompilationInfo.moduleInfo); + moduleInfo.merge(ownerCcCompilationContextInfo.moduleInfo); + moduleInfo.merge(libCcCompilationContextInfo.moduleInfo); ModuleInfo.Builder picModuleInfo = new ModuleInfo.Builder(); - picModuleInfo.merge(ownerCcCompilationInfo.picModuleInfo); - picModuleInfo.merge(libCcCompilationInfo.picModuleInfo); - return new CcCompilationInfo( - libCcCompilationInfo.commandLineCcCompilationInfo, + picModuleInfo.merge(ownerCcCompilationContextInfo.picModuleInfo); + picModuleInfo.merge(libCcCompilationContextInfo.picModuleInfo); + return new CcCompilationContextInfo( + libCcCompilationContextInfo.commandLineCcCompilationContextInfo, prerequisites.build(), mergeSets( - ownerCcCompilationInfo.declaredIncludeDirs, libCcCompilationInfo.declaredIncludeDirs), + ownerCcCompilationContextInfo.declaredIncludeDirs, + libCcCompilationContextInfo.declaredIncludeDirs), mergeSets( - ownerCcCompilationInfo.declaredIncludeWarnDirs, - libCcCompilationInfo.declaredIncludeWarnDirs), + ownerCcCompilationContextInfo.declaredIncludeWarnDirs, + libCcCompilationContextInfo.declaredIncludeWarnDirs), mergeSets( - ownerCcCompilationInfo.declaredIncludeSrcs, libCcCompilationInfo.declaredIncludeSrcs), - mergeSets(ownerCcCompilationInfo.pregreppedHdrs, libCcCompilationInfo.pregreppedHdrs), - mergeSets(ownerCcCompilationInfo.nonCodeInputs, libCcCompilationInfo.nonCodeInputs), + ownerCcCompilationContextInfo.declaredIncludeSrcs, + libCcCompilationContextInfo.declaredIncludeSrcs), + mergeSets( + ownerCcCompilationContextInfo.pregreppedHdrs, + libCcCompilationContextInfo.pregreppedHdrs), + mergeSets( + ownerCcCompilationContextInfo.nonCodeInputs, libCcCompilationContextInfo.nonCodeInputs), moduleInfo.build(), picModuleInfo.build(), - mergeSets(ownerCcCompilationInfo.directModuleMaps, libCcCompilationInfo.directModuleMaps), - libCcCompilationInfo.cppModuleMap, - libCcCompilationInfo.verificationModuleMap, - libCcCompilationInfo.propagateModuleMapAsActionInput); + mergeSets( + ownerCcCompilationContextInfo.directModuleMaps, + libCcCompilationContextInfo.directModuleMaps), + libCcCompilationContextInfo.cppModuleMap, + libCcCompilationContextInfo.verificationModuleMap, + libCcCompilationContextInfo.propagateModuleMapAsActionInput); } /** @@ -359,19 +369,19 @@ public final class CcCompilationInfo extends NativeInfo { } /** - * The parts of the {@code CcCompilationInfo} that influence the command line of compilation - * actions. + * The parts of the {@code CcCompilationContextInfo} that influence the command line of + * compilation actions. */ @Immutable @AutoCodec @VisibleForSerialization - static class CommandLineCcCompilationInfo { + static class CommandLineCcCompilationContextInfo { private final ImmutableList<PathFragment> includeDirs; private final ImmutableList<PathFragment> quoteIncludeDirs; private final ImmutableList<PathFragment> systemIncludeDirs; private final ImmutableList<String> defines; - CommandLineCcCompilationInfo( + CommandLineCcCompilationContextInfo( ImmutableList<PathFragment> includeDirs, ImmutableList<PathFragment> quoteIncludeDirs, ImmutableList<PathFragment> systemIncludeDirs, @@ -383,7 +393,7 @@ public final class CcCompilationInfo extends NativeInfo { } } - /** Builder class for {@link CcCompilationInfo}. */ + /** Builder class for {@link CcCompilationContextInfo}. */ public static class Builder { private String purpose; private final Set<Artifact> compilationPrerequisites = new LinkedHashSet<>(); @@ -410,15 +420,15 @@ public final class CcCompilationInfo extends NativeInfo { /** The rule that owns the context */ private final RuleContext ruleContext; - /** Creates a new builder for a {@link CcCompilationInfo} instance. */ + /** Creates a new builder for a {@link CcCompilationContextInfo} instance. */ public Builder(RuleContext ruleContext) { this.ruleContext = ruleContext; } /** * Overrides the purpose of this context. This is useful if a Target needs more than one - * CcCompilationInfo. (The purpose is used to construct the name of the prerequisites middleman - * for the context, and all artifacts for a given Target must have distinct names.) + * CcCompilationContextInfo. (The purpose is used to construct the name of the prerequisites + * middleman for the context, and all artifacts for a given Target must have distinct names.) * * @param purpose must be a string which is suitable for use as a filename. A single rule may * have many middlemen with distinct purposes. @@ -434,41 +444,45 @@ public final class CcCompilationInfo extends NativeInfo { } /** - * Merges the context of a dependency into this one by adding the contents of all of its - * attributes. + * Merges the {@link CcCompilationContextInfo} of a dependency into this one by adding the + * contents of all of its attributes. */ - public Builder mergeDependentCcCompilationInfo(CcCompilationInfo otherCcCompilationInfo) { - Preconditions.checkNotNull(otherCcCompilationInfo); + public Builder mergeDependentCcCompilationContextInfo( + CcCompilationContextInfo otherCcCompilationContextInfo) { + Preconditions.checkNotNull(otherCcCompilationContextInfo); compilationPrerequisites.addAll( - otherCcCompilationInfo.getTransitiveCompilationPrerequisites()); - includeDirs.addAll(otherCcCompilationInfo.getIncludeDirs()); - quoteIncludeDirs.addAll(otherCcCompilationInfo.getQuoteIncludeDirs()); - systemIncludeDirs.addAll(otherCcCompilationInfo.getSystemIncludeDirs()); - declaredIncludeDirs.addTransitive(otherCcCompilationInfo.getDeclaredIncludeDirs()); - declaredIncludeWarnDirs.addTransitive(otherCcCompilationInfo.getDeclaredIncludeWarnDirs()); - declaredIncludeSrcs.addTransitive(otherCcCompilationInfo.getDeclaredIncludeSrcs()); - pregreppedHdrs.addTransitive(otherCcCompilationInfo.getPregreppedHeaders()); - moduleInfo.addTransitive(otherCcCompilationInfo.moduleInfo); - picModuleInfo.addTransitive(otherCcCompilationInfo.picModuleInfo); - nonCodeInputs.addTransitive(otherCcCompilationInfo.nonCodeInputs); + otherCcCompilationContextInfo.getTransitiveCompilationPrerequisites()); + includeDirs.addAll(otherCcCompilationContextInfo.getIncludeDirs()); + quoteIncludeDirs.addAll(otherCcCompilationContextInfo.getQuoteIncludeDirs()); + systemIncludeDirs.addAll(otherCcCompilationContextInfo.getSystemIncludeDirs()); + declaredIncludeDirs.addTransitive(otherCcCompilationContextInfo.getDeclaredIncludeDirs()); + declaredIncludeWarnDirs.addTransitive( + otherCcCompilationContextInfo.getDeclaredIncludeWarnDirs()); + declaredIncludeSrcs.addTransitive(otherCcCompilationContextInfo.getDeclaredIncludeSrcs()); + pregreppedHdrs.addTransitive(otherCcCompilationContextInfo.getPregreppedHeaders()); + moduleInfo.addTransitive(otherCcCompilationContextInfo.moduleInfo); + picModuleInfo.addTransitive(otherCcCompilationContextInfo.picModuleInfo); + nonCodeInputs.addTransitive(otherCcCompilationContextInfo.nonCodeInputs); // All module maps of direct dependencies are inputs to the current compile independently of // the build type. - if (otherCcCompilationInfo.getCppModuleMap() != null) { - directModuleMaps.add(otherCcCompilationInfo.getCppModuleMap().getArtifact()); + if (otherCcCompilationContextInfo.getCppModuleMap() != null) { + directModuleMaps.add(otherCcCompilationContextInfo.getCppModuleMap().getArtifact()); } - defines.addAll(otherCcCompilationInfo.getDefines()); + defines.addAll(otherCcCompilationContextInfo.getDefines()); return this; } /** - * Merges the {@code CcCompilationInfo}s of some targets into this one by adding the contents of - * all of their attributes. Targets that do not implement {@link CcCompilationInfo} are ignored. + * Merges the {@code CcCompilationContextInfo}s of some targets into this one by adding the + * contents of all of their attributes. Targets that do not implement {@link + * CcCompilationContextInfo} are ignored. */ - public Builder mergeDependentCcCompilationInfos(Iterable<CcCompilationInfo> targets) { - for (CcCompilationInfo target : targets) { - mergeDependentCcCompilationInfo(target); + public Builder mergeDependentCcCompilationContextInfos( + Iterable<CcCompilationContextInfo> targets) { + for (CcCompilationContextInfo target : targets) { + mergeDependentCcCompilationContextInfo(target); } return this; } @@ -670,15 +684,15 @@ public final class CcCompilationInfo extends NativeInfo { return this; } - /** Builds the {@link CcCompilationInfo}. */ - public CcCompilationInfo build() { + /** Builds the {@link CcCompilationContextInfo}. */ + public CcCompilationContextInfo build() { return build( ruleContext == null ? null : ruleContext.getActionOwner(), ruleContext == null ? null : ruleContext.getAnalysisEnvironment().getMiddlemanFactory()); } @VisibleForTesting // productionVisibility = Visibility.PRIVATE - public CcCompilationInfo build(ActionOwner owner, MiddlemanFactory middlemanFactory) { + public CcCompilationContextInfo build(ActionOwner owner, MiddlemanFactory middlemanFactory) { // We don't create middlemen in LIPO collector subtree, because some target CT // will do that instead. Artifact prerequisiteStampFile = (ruleContext != null @@ -686,8 +700,8 @@ public final class CcCompilationInfo extends NativeInfo { ? getMiddlemanArtifact(middlemanFactory) : createMiddleman(owner, middlemanFactory); - return new CcCompilationInfo( - new CommandLineCcCompilationInfo( + return new CcCompilationContextInfo( + new CommandLineCcCompilationContextInfo( ImmutableList.copyOf(includeDirs), ImmutableList.copyOf(quoteIncludeDirs), ImmutableList.copyOf(systemIncludeDirs), diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java index 102b42427c..a097a81790 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java @@ -128,13 +128,14 @@ public final class CcCompilationHelper { /** Function for extracting module maps from CppCompilationDependencies. */ private static final Function<TransitiveInfoCollection, CppModuleMap> CPP_DEPS_TO_MODULES = dep -> { - CcCompilationInfo ccCompilationInfo = dep.get(CcCompilationInfo.PROVIDER); - return ccCompilationInfo == null ? null : ccCompilationInfo.getCppModuleMap(); + CcCompilationContextInfo ccCompilationContextInfo = + dep.get(CcCompilationContextInfo.PROVIDER); + return ccCompilationContextInfo == null ? null : ccCompilationContextInfo.getCppModuleMap(); }; /** * Contains the providers as well as the {@code CcCompilationOutputs} and the {@code - * CcCompilationInfo}. + * CcCompilationContextInfo}. */ @SkylarkModule( name = "compilation_info", @@ -142,23 +143,24 @@ public final class CcCompilationHelper { category = SkylarkModuleCategory.BUILTIN, doc = "Helper class containing CC compilation providers." ) - // TODO(plf): Rename so that it's not confused with CcCompilationInfo and also consider merging + // TODO(plf): Rename so that it's not confused with CcCompilationContextInfo and also consider + // merging // this class with {@code CcCompilationOutputs}. public static final class CompilationInfo { private final TransitiveInfoProviderMap providers; private final Map<String, NestedSet<Artifact>> outputGroups; private final CcCompilationOutputs compilationOutputs; - private final CcCompilationInfo ccCompilationInfo; + private final CcCompilationContextInfo ccCompilationContextInfo; private CompilationInfo( TransitiveInfoProviderMap providers, Map<String, NestedSet<Artifact>> outputGroups, CcCompilationOutputs compilationOutputs, - CcCompilationInfo ccCompilationInfo) { + CcCompilationContextInfo ccCompilationContextInfo) { this.providers = providers; this.outputGroups = outputGroups; this.compilationOutputs = compilationOutputs; - this.ccCompilationInfo = ccCompilationInfo; + this.ccCompilationContextInfo = ccCompilationContextInfo; } public TransitiveInfoProviderMap getProviders() { @@ -175,8 +177,8 @@ public final class CcCompilationHelper { } @SkylarkCallable(name = "cc_compilation_info", documented = false) - public CcCompilationInfo getCcCompilationInfo() { - return ccCompilationInfo; + public CcCompilationContextInfo getCcCompilationContextInfo() { + return ccCompilationContextInfo; } } @@ -201,7 +203,7 @@ public final class CcCompilationHelper { private CoptsFilter coptsFilter = CoptsFilter.alwaysPasses(); private final Set<String> defines = new LinkedHashSet<>(); private final List<TransitiveInfoCollection> deps = new ArrayList<>(); - private final List<CcCompilationInfo> depCcCompilationInfos = new ArrayList<>(); + private final List<CcCompilationContextInfo> depCcCompilationContextInfos = new ArrayList<>(); private final List<PathFragment> looseIncludeDirs = new ArrayList<>(); private final List<PathFragment> systemIncludeDirs = new ArrayList<>(); private final List<PathFragment> includeDirs = new ArrayList<>(); @@ -227,7 +229,7 @@ public final class CcCompilationHelper { private boolean generatePicAction; // TODO(plf): Pull out of class. - private CcCompilationInfo ccCompilationInfo; + private CcCompilationContextInfo ccCompilationContextInfo; /** * Creates a CcCompilationHelper. @@ -542,8 +544,9 @@ public final class CcCompilationHelper { return this; } - public CcCompilationHelper addDepCcCompilationInfo(CcCompilationInfo ccCompilationInfo) { - this.depCcCompilationInfos.add(Preconditions.checkNotNull(ccCompilationInfo)); + public CcCompilationHelper addDepCcCompilationContextInfo( + CcCompilationContextInfo ccCompilationContextInfo) { + this.depCcCompilationContextInfos.add(Preconditions.checkNotNull(ccCompilationContextInfo)); return this; } @@ -693,11 +696,11 @@ public final class CcCompilationHelper { } } - ccCompilationInfo = initializeCcCompilationInfo(); + ccCompilationContextInfo = initializeCcCompilationContextInfo(); boolean compileHeaderModules = featureConfiguration.isEnabled(CppRuleClasses.HEADER_MODULES); Preconditions.checkState( - !compileHeaderModules || ccCompilationInfo.getCppModuleMap() != null, + !compileHeaderModules || ccCompilationContextInfo.getCppModuleMap() != null, "All cc rules must support module maps."); // Create compile actions (both PIC and no-PIC). @@ -728,7 +731,7 @@ public final class CcCompilationHelper { new CppDebugFileProvider( dwoArtifacts.getDwoArtifacts(), dwoArtifacts.getPicDwoArtifacts()), collectTransitiveLipoInfo(ccOutputs)); - providers.put(ccCompilationInfo); + providers.put(ccCompilationContextInfo); Map<String, NestedSet<Artifact>> outputGroups = new TreeMap<>(); outputGroups.put(OutputGroupInfo.TEMP_FILES, getTemps(ccOutputs)); @@ -741,10 +744,11 @@ public final class CcCompilationHelper { ccOutputs.getFilesToCompile(isLipoCollector, processHeadersInDependencies, usePic)); outputGroups.put( OutputGroupInfo.COMPILATION_PREREQUISITES, - CcCommon.collectCompilationPrerequisites(ruleContext, ccCompilationInfo)); + CcCommon.collectCompilationPrerequisites(ruleContext, ccCompilationContextInfo)); } - return new CompilationInfo(providers.build(), outputGroups, ccOutputs, ccCompilationInfo); + return new CompilationInfo( + providers.build(), outputGroups, ccOutputs, ccCompilationContextInfo); } @Immutable @@ -882,12 +886,13 @@ public final class CcCompilationHelper { } /** - * Create {@code CcCompilationInfo} for cc compile action from generated inputs. + * Create {@code CcCompilationContextInfo} for cc compile action from generated inputs. * - * <p>TODO(plf): Try to pull out CcCompilationInfo building out of this class. + * <p>TODO(plf): Try to pull out CcCompilationContextInfo building out of this class. */ - public CcCompilationInfo initializeCcCompilationInfo() { - CcCompilationInfo.Builder ccCompilationInfoBuilder = new CcCompilationInfo.Builder(ruleContext); + public CcCompilationContextInfo initializeCcCompilationContextInfo() { + CcCompilationContextInfo.Builder ccCompilationContextInfoBuilder = + new CcCompilationContextInfo.Builder(ruleContext); // Setup the include path; local include directories come before those inherited from deps or // from the toolchain; in case of aliasing (same include file found on different entries), @@ -899,61 +904,63 @@ public final class CcCompilationHelper { // we might pick up stale generated files. PathFragment repositoryPath = ruleContext.getLabel().getPackageIdentifier().getRepository().getPathUnderExecRoot(); - ccCompilationInfoBuilder.addQuoteIncludeDir(repositoryPath); - ccCompilationInfoBuilder.addQuoteIncludeDir( + ccCompilationContextInfoBuilder.addQuoteIncludeDir(repositoryPath); + ccCompilationContextInfoBuilder.addQuoteIncludeDir( ruleContext.getConfiguration().getGenfilesFragment().getRelative(repositoryPath)); for (PathFragment systemIncludeDir : systemIncludeDirs) { - ccCompilationInfoBuilder.addSystemIncludeDir(systemIncludeDir); + ccCompilationContextInfoBuilder.addSystemIncludeDir(systemIncludeDir); } for (PathFragment includeDir : includeDirs) { - ccCompilationInfoBuilder.addIncludeDir(includeDir); + ccCompilationContextInfoBuilder.addIncludeDir(includeDir); } PublicHeaders publicHeaders = computePublicHeaders(); if (publicHeaders.getVirtualIncludePath() != null) { - ccCompilationInfoBuilder.addIncludeDir(publicHeaders.getVirtualIncludePath()); + ccCompilationContextInfoBuilder.addIncludeDir(publicHeaders.getVirtualIncludePath()); } if (useDeps) { - ccCompilationInfoBuilder.mergeDependentCcCompilationInfos( - AnalysisUtils.getProviders(deps, CcCompilationInfo.PROVIDER)); - ccCompilationInfoBuilder.mergeDependentCcCompilationInfos(depCcCompilationInfos); + ccCompilationContextInfoBuilder.mergeDependentCcCompilationContextInfos( + AnalysisUtils.getProviders(deps, CcCompilationContextInfo.PROVIDER)); + ccCompilationContextInfoBuilder.mergeDependentCcCompilationContextInfos( + depCcCompilationContextInfos); } - CppHelper.mergeToolchainDependentCcCompilationInfo( - ruleContext, ccToolchain, ccCompilationInfoBuilder); + CppHelper.mergeToolchainDependentCcCompilationContextInfo( + ruleContext, ccToolchain, ccCompilationContextInfoBuilder); // But defines come after those inherited from deps. - ccCompilationInfoBuilder.addDefines(defines); + ccCompilationContextInfoBuilder.addDefines(defines); // There are no ordering constraints for declared include dirs/srcs, or the pregrepped headers. - ccCompilationInfoBuilder.addDeclaredIncludeSrcs(publicHeaders.getHeaders()); - ccCompilationInfoBuilder.addDeclaredIncludeSrcs(publicTextualHeaders); - ccCompilationInfoBuilder.addDeclaredIncludeSrcs(privateHeaders); - ccCompilationInfoBuilder.addDeclaredIncludeSrcs(additionalInputs); - ccCompilationInfoBuilder.addNonCodeInputs(additionalInputs); - ccCompilationInfoBuilder.addModularHdrs(publicHeaders.getHeaders()); - ccCompilationInfoBuilder.addModularHdrs(privateHeaders); - ccCompilationInfoBuilder.addTextualHdrs(publicTextualHeaders); - ccCompilationInfoBuilder.addPregreppedHeaders( + ccCompilationContextInfoBuilder.addDeclaredIncludeSrcs(publicHeaders.getHeaders()); + ccCompilationContextInfoBuilder.addDeclaredIncludeSrcs(publicTextualHeaders); + ccCompilationContextInfoBuilder.addDeclaredIncludeSrcs(privateHeaders); + ccCompilationContextInfoBuilder.addDeclaredIncludeSrcs(additionalInputs); + ccCompilationContextInfoBuilder.addNonCodeInputs(additionalInputs); + ccCompilationContextInfoBuilder.addModularHdrs(publicHeaders.getHeaders()); + ccCompilationContextInfoBuilder.addModularHdrs(privateHeaders); + ccCompilationContextInfoBuilder.addTextualHdrs(publicTextualHeaders); + ccCompilationContextInfoBuilder.addPregreppedHeaders( CppHelper.createExtractInclusions(ruleContext, semantics, publicHeaders.getHeaders())); - ccCompilationInfoBuilder.addPregreppedHeaders( + ccCompilationContextInfoBuilder.addPregreppedHeaders( CppHelper.createExtractInclusions(ruleContext, semantics, publicTextualHeaders)); - ccCompilationInfoBuilder.addPregreppedHeaders( + ccCompilationContextInfoBuilder.addPregreppedHeaders( CppHelper.createExtractInclusions(ruleContext, semantics, privateHeaders)); // Add this package's dir to declaredIncludeDirs, & this rule's headers to declaredIncludeSrcs // Note: no include dir for STRICT mode. if (headersCheckingMode == HeadersCheckingMode.WARN) { - ccCompilationInfoBuilder.addDeclaredIncludeWarnDir( + ccCompilationContextInfoBuilder.addDeclaredIncludeWarnDir( ruleContext.getLabel().getPackageFragment()); for (PathFragment looseIncludeDir : looseIncludeDirs) { - ccCompilationInfoBuilder.addDeclaredIncludeWarnDir(looseIncludeDir); + ccCompilationContextInfoBuilder.addDeclaredIncludeWarnDir(looseIncludeDir); } } else if (headersCheckingMode == HeadersCheckingMode.LOOSE) { - ccCompilationInfoBuilder.addDeclaredIncludeDir(ruleContext.getLabel().getPackageFragment()); + ccCompilationContextInfoBuilder.addDeclaredIncludeDir( + ruleContext.getLabel().getPackageFragment()); for (PathFragment looseIncludeDir : looseIncludeDirs) { - ccCompilationInfoBuilder.addDeclaredIncludeDir(looseIncludeDir); + ccCompilationContextInfoBuilder.addDeclaredIncludeDir(looseIncludeDir); } } @@ -962,9 +969,9 @@ public final class CcCompilationHelper { cppModuleMap = CppHelper.createDefaultCppModuleMap(ruleContext, /*suffix=*/ ""); } - ccCompilationInfoBuilder.setPropagateCppModuleMapAsActionInput( + ccCompilationContextInfoBuilder.setPropagateCppModuleMapAsActionInput( propagateModuleMapToCompileAction); - ccCompilationInfoBuilder.setCppModuleMap(cppModuleMap); + ccCompilationContextInfoBuilder.setCppModuleMap(cppModuleMap); // There are different modes for module compilation: // 1. We create the module map and compile the module so that libraries depending on us can // use the resulting module artifacts in their compilation (compiled is true). @@ -986,10 +993,12 @@ public final class CcCompilationHelper { createModuleMapAction(cppModuleMap, publicHeaders, dependentModuleMaps, compiled)); } if (getGeneratesPicHeaderModule()) { - ccCompilationInfoBuilder.setPicHeaderModule(getPicHeaderModule(cppModuleMap.getArtifact())); + ccCompilationContextInfoBuilder.setPicHeaderModule( + getPicHeaderModule(cppModuleMap.getArtifact())); } if (getGeneratesNoPicHeaderModule()) { - ccCompilationInfoBuilder.setHeaderModule(getHeaderModule(cppModuleMap.getArtifact())); + ccCompilationContextInfoBuilder.setHeaderModule( + getHeaderModule(cppModuleMap.getArtifact())); } if (!compiled && featureConfiguration.isEnabled(CppRuleClasses.PARSE_HEADERS) @@ -1003,13 +1012,13 @@ public final class CcCompilationHelper { ruleContext.registerAction( createModuleMapAction( verificationMap, publicHeaders, dependentModuleMaps, /*compiledModule=*/ true)); - ccCompilationInfoBuilder.setVerificationModuleMap(verificationMap); + ccCompilationContextInfoBuilder.setVerificationModuleMap(verificationMap); } } - ccCompilationInfoBuilder.setPurpose(purpose); + ccCompilationContextInfoBuilder.setPurpose(purpose); - semantics.setupCcCompilationInfo(ruleContext, ccCompilationInfoBuilder); - return ccCompilationInfoBuilder.build(); + semantics.setupCcCompilationContextInfo(ruleContext, ccCompilationContextInfoBuilder); + return ccCompilationContextInfoBuilder.build(); } /** @@ -1039,9 +1048,9 @@ public final class CcCompilationHelper { } /** - * Sets the purpose for the {@code CcCompilationInfo}. + * Sets the purpose for the {@code CcCompilationContextInfo}. * - * @see CcCompilationInfo.Builder#setPurpose + * @see CcCompilationContextInfo.Builder#setPurpose * @param purpose must be a string which is suitable for use as a filename. A single rule may have * many middlemen with distinct purposes. */ @@ -1088,15 +1097,15 @@ public final class CcCompilationHelper { List<CppModuleMap> result = deps.stream().map(CPP_DEPS_TO_MODULES).collect(toCollection(ArrayList::new)); if (ruleContext.getRule().getAttributeDefinition(":stl") != null) { - CcCompilationInfo stl = - ruleContext.getPrerequisite(":stl", Mode.TARGET, CcCompilationInfo.PROVIDER); + CcCompilationContextInfo stl = + ruleContext.getPrerequisite(":stl", Mode.TARGET, CcCompilationContextInfo.PROVIDER); if (stl != null) { result.add(stl.getCppModuleMap()); } } if (ccToolchain != null) { - result.add(ccToolchain.getCcCompilationInfo().getCppModuleMap()); + result.add(ccToolchain.getCcCompilationContextInfo().getCppModuleMap()); } for (CppModuleMap additionalCppModuleMap : additionalCppModuleMaps) { result.add(additionalCppModuleMap); @@ -1227,14 +1236,14 @@ public final class CcCompilationHelper { */ private CcCompilationOutputs createCcCompileActions() throws RuleErrorException { CcCompilationOutputs.Builder result = new CcCompilationOutputs.Builder(); - Preconditions.checkNotNull(ccCompilationInfo); + Preconditions.checkNotNull(ccCompilationContextInfo); AnalysisEnvironment env = ruleContext.getAnalysisEnvironment(); if (shouldProvideHeaderModules()) { Label moduleMapLabel = - Label.parseAbsoluteUnchecked(ccCompilationInfo.getCppModuleMap().getName()); + Label.parseAbsoluteUnchecked(ccCompilationContextInfo.getCppModuleMap().getName()); Collection<Artifact> modules = - createModuleAction(result, ccCompilationInfo.getCppModuleMap()); + createModuleAction(result, ccCompilationContextInfo.getCppModuleMap()); if (featureConfiguration.isEnabled(CppRuleClasses.HEADER_MODULE_CODEGEN)) { for (Artifact module : modules) { // TODO(djasper): Investigate whether we need to use a label separate from that of the @@ -1242,9 +1251,9 @@ public final class CcCompilationHelper { createModuleCodegenAction(result, moduleMapLabel, module); } } - } else if (ccCompilationInfo.getVerificationModuleMap() != null) { + } else if (ccCompilationContextInfo.getVerificationModuleMap() != null) { Collection<Artifact> modules = - createModuleAction(result, ccCompilationInfo.getVerificationModuleMap()); + createModuleAction(result, ccCompilationContextInfo.getVerificationModuleMap()); for (Artifact module : modules) { result.addHeaderTokenFile(module); } @@ -1304,7 +1313,7 @@ public final class CcCompilationHelper { source.getType() == CppSource.Type.CLIF_INPUT_PROTO ? ArtifactCategory.CLIF_OUTPUT_PROTO : ArtifactCategory.OBJECT_FILE, - ccCompilationInfo.getCppModuleMap(), + ccCompilationContextInfo.getCppModuleMap(), /* addObject= */ true, isCodeCoverageEnabled(), // The source action does not generate dwo when it has bitcode @@ -1383,7 +1392,7 @@ public final class CcCompilationHelper { usePic, /* ccRelativeName= */ null, /* autoFdoImportPath= */ null, - ccCompilationInfo.getCppModuleMap(), + ccCompilationContextInfo.getCppModuleMap(), /* gcnoFile= */ null, /* dwoFile= */ null, /* ltoIndexingFile= */ null, @@ -1476,7 +1485,7 @@ public final class CcCompilationHelper { gcnoFile, dwoFile, ltoIndexingFile, - ccCompilationInfo, + ccCompilationContextInfo, ImmutableList.of(), userCompileFlags.build(), cppModuleMap, @@ -1502,13 +1511,13 @@ public final class CcCompilationHelper { /** * Creates a basic cpp compile action builder for source file. Configures options, crosstool - * inputs, output and dotd file names, {@code CcCompilationInfo} and copts. + * inputs, output and dotd file names, {@code CcCompilationContextInfo} and copts. */ private CppCompileActionBuilder createCompileActionBuilder(Artifact source) { CppCompileActionBuilder builder = new CppCompileActionBuilder(ruleContext, ccToolchain, configuration); builder.setSourceFile(source); - builder.setCcCompilationInfo(ccCompilationInfo); + builder.setCcCompilationContextInfo(ccCompilationContextInfo); builder.setCoptsFilter(coptsFilter); return builder; } @@ -1563,7 +1572,7 @@ public final class CcCompilationHelper { /* usePic= */ pic, ccRelativeName, module.getExecPath(), - ccCompilationInfo.getCppModuleMap(), + ccCompilationContextInfo.getCppModuleMap(), gcnoFile, dwoFile, /* ltoIndexingFile= */ null, @@ -1614,7 +1623,7 @@ public final class CcCompilationHelper { generatePicAction, /* ccRelativeName= */ null, /* autoFdoImportPath= */ null, - ccCompilationInfo.getCppModuleMap(), + ccCompilationContextInfo.getCppModuleMap(), /* gcnoFile= */ null, /* dwoFile= */ null, /* ltoIndexingFile= */ null, @@ -1675,13 +1684,14 @@ public final class CcCompilationHelper { ImmutableList.Builder<Artifact> directOutputs = new ImmutableList.Builder<>(); PathFragment ccRelativeName = sourceArtifact.getRootRelativePath(); if (CppHelper.isLipoOptimization(cppConfiguration, ccToolchain)) { - // TODO(bazel-team): we shouldn't be needing this, merging ccCompilationInfo with the binary + // TODO(bazel-team): we shouldn't be needing this, merging ccCompilationContextInfo with the + // binary // is a superset of necessary information. LipoContextProvider lipoProvider = Preconditions.checkNotNull(CppHelper.getLipoContextProvider(ruleContext), outputName); - builder.setCcCompilationInfo( - CcCompilationInfo.mergeForLipo( - lipoProvider.getLipoCcCompilationInfo(), ccCompilationInfo)); + builder.setCcCompilationContextInfo( + CcCompilationContextInfo.mergeForLipo( + lipoProvider.getLipoCcCompilationContextInfo(), ccCompilationContextInfo)); } Preconditions.checkState(generatePicAction || generateNoPicAction); if (fake) { @@ -1730,7 +1740,7 @@ public final class CcCompilationHelper { /* usePic= */ true, ccRelativeName, sourceArtifact.getExecPath(), - ccCompilationInfo.getCppModuleMap(), + ccCompilationContextInfo.getCppModuleMap(), gcnoFile, dwoFile, ltoIndexingFile, @@ -1905,7 +1915,7 @@ public final class CcCompilationHelper { usePic, ccRelativeName, execPath, - ccCompilationInfo.getCppModuleMap(), + ccCompilationContextInfo.getCppModuleMap(), /* gcnoFile= */ null, /* dwoFile= */ null, /* ltoIndexingFile= */ null, @@ -1944,7 +1954,7 @@ public final class CcCompilationHelper { // implementation (with caching results of this method) to avoid O(N^2) slowdown. if (ruleContext.getRule().isAttrDefined("deps", BuildType.LABEL_LIST)) { for (TransitiveInfoCollection dep : ruleContext.getPrerequisites("deps", Mode.TARGET)) { - if (dep.get(CcCompilationInfo.PROVIDER) != null + if (dep.get(CcCompilationContextInfo.PROVIDER) != null && InstrumentedFilesCollector.shouldIncludeLocalSources(configuration, dep)) { return true; } @@ -2013,7 +2023,7 @@ public final class CcCompilationHelper { usePic, ccRelativeName, source.getExecPath(), - ccCompilationInfo.getCppModuleMap(), + ccCompilationContextInfo.getCppModuleMap(), /* gcnoFile= */ null, /* dwoFile= */ null, /* ltoIndexingFile= */ null, @@ -2035,7 +2045,7 @@ public final class CcCompilationHelper { usePic, ccRelativeName, source.getExecPath(), - ccCompilationInfo.getCppModuleMap(), + ccCompilationContextInfo.getCppModuleMap(), /* gcnoFile= */ null, /* dwoFile= */ null, /* ltoIndexingFile= */ null, diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcImport.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcImport.java index 3a100a777e..3df13788ce 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcImport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcImport.java @@ -170,7 +170,8 @@ public abstract class CcImport implements RuleConfiguredTargetFactory { LinkingInfo linkingInfo = linkingHelper.link( - compilationInfo.getCcCompilationOutputs(), compilationInfo.getCcCompilationInfo()); + compilationInfo.getCcCompilationOutputs(), + compilationInfo.getCcCompilationContextInfo()); return new RuleConfiguredTargetBuilder(ruleContext) .addProviders(compilationInfo.getProviders()) diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java index 80f3950d4a..8d0406545d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java @@ -284,7 +284,8 @@ public abstract class CcLibrary implements RuleConfiguredTargetFactory { CompilationInfo compilationInfo = compilationHelper.compile(); LinkingInfo linkingInfo = linkingHelper.link( - compilationInfo.getCcCompilationOutputs(), compilationInfo.getCcCompilationInfo()); + compilationInfo.getCcCompilationOutputs(), + compilationInfo.getCcCompilationContextInfo()); /* * We always generate a static library, even if there aren't any source files. diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java index a842b86be9..df9613d460 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkParams.java @@ -327,9 +327,10 @@ public final class CcLinkParams { /** Adds a collection of linkstamps. */ public Builder addLinkstamps( - NestedSet<Artifact> linkstamps, CcCompilationInfo ccCompilationInfo) { + NestedSet<Artifact> linkstamps, CcCompilationContextInfo ccCompilationContextInfo) { for (Artifact linkstamp : linkstamps) { - linkstampsBuilder.add(new Linkstamp(linkstamp, ccCompilationInfo.getDeclaredIncludeSrcs())); + linkstampsBuilder.add( + new Linkstamp(linkstamp, ccCompilationContextInfo.getDeclaredIncludeSrcs())); } return this; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java index 2606f9056c..a764e8752e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java @@ -438,12 +438,14 @@ public final class CcLinkingHelper { * * @throws RuleErrorException */ - // TODO(b/73997894): Try to remove CcCompilationInfo. Right now headers are passed as non code + // TODO(b/73997894): Try to remove CcCompilationContextInfo. Right now headers are passed as non + // code // inputs to the linker. - public LinkingInfo link(CcCompilationOutputs ccOutputs, CcCompilationInfo ccCompilationInfo) + public LinkingInfo link( + CcCompilationOutputs ccOutputs, CcCompilationContextInfo ccCompilationContextInfo) throws RuleErrorException, InterruptedException { Preconditions.checkNotNull(ccOutputs); - Preconditions.checkNotNull(ccCompilationInfo); + Preconditions.checkNotNull(ccCompilationContextInfo); if (checkDepsGenerateCpp) { for (LanguageDependentFragment dep : @@ -548,11 +550,11 @@ public final class CcLinkingHelper { if (emitCcSpecificLinkParamsProvider) { providers.add( new CcSpecificLinkParamsProvider( - createCcLinkParamsStore(ccLinkingOutputs, ccCompilationInfo, forcePic))); + createCcLinkParamsStore(ccLinkingOutputs, ccCompilationContextInfo, forcePic))); } else { providers.put( new CcLinkParamsInfo( - createCcLinkParamsStore(ccLinkingOutputs, ccCompilationInfo, forcePic))); + createCcLinkParamsStore(ccLinkingOutputs, ccCompilationContextInfo, forcePic))); } return new LinkingInfo( providers.build(), outputGroups, ccLinkingOutputs, originalLinkingOutputs); @@ -633,13 +635,13 @@ public final class CcLinkingHelper { private CcLinkParamsStore createCcLinkParamsStore( final CcLinkingOutputs ccLinkingOutputs, - final CcCompilationInfo ccCompilationInfo, + final CcCompilationContextInfo ccCompilationContextInfo, final boolean forcePic) { return new CcLinkParamsStore() { @Override protected void collect( CcLinkParams.Builder builder, boolean linkingStatically, boolean linkShared) { - builder.addLinkstamps(linkstamps.build(), ccCompilationInfo); + builder.addLinkstamps(linkstamps.build(), ccCompilationContextInfo); builder.addTransitiveTargets( deps, CcLinkParamsInfo.TO_LINK_PARAMS, CcSpecificLinkParamsProvider.TO_LINK_PARAMS); if (!neverlink) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java index 95a5a9436a..61c89dd801 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcSkylarkApiProvider.java @@ -50,8 +50,9 @@ public final class CcSkylarkApiProvider extends SkylarkApiProvider { + " <code>src</code> or <code>headers</code> attribute" + "(possibly empty but never <code>None</code>).") public NestedSet<Artifact> getTransitiveHeaders() { - CcCompilationInfo ccCompilationInfo = getInfo().get(CcCompilationInfo.PROVIDER); - return ccCompilationInfo.getDeclaredIncludeSrcs(); + CcCompilationContextInfo ccCompilationContextInfo = + getInfo().get(CcCompilationContextInfo.PROVIDER); + return ccCompilationContextInfo.getDeclaredIncludeSrcs(); } @SkylarkCallable( @@ -97,8 +98,11 @@ public final class CcSkylarkApiProvider extends SkylarkApiProvider { "Returns the list of defines used to compile this target " + "(possibly empty but never <code>None</code>).") public ImmutableList<String> getDefines() { - CcCompilationInfo ccCompilationInfo = getInfo().get(CcCompilationInfo.PROVIDER); - return ccCompilationInfo == null ? ImmutableList.<String>of() : ccCompilationInfo.getDefines(); + CcCompilationContextInfo ccCompilationContextInfo = + getInfo().get(CcCompilationContextInfo.PROVIDER); + return ccCompilationContextInfo == null + ? ImmutableList.<String>of() + : ccCompilationContextInfo.getDefines(); } @SkylarkCallable( @@ -108,12 +112,13 @@ public final class CcSkylarkApiProvider extends SkylarkApiProvider { "Returns the list of system include directories used to compile this target " + "(possibly empty but never <code>None</code>).") public ImmutableList<String> getSystemIncludeDirs() { - CcCompilationInfo ccCompilationInfo = getInfo().get(CcCompilationInfo.PROVIDER); - if (ccCompilationInfo == null) { + CcCompilationContextInfo ccCompilationContextInfo = + getInfo().get(CcCompilationContextInfo.PROVIDER); + if (ccCompilationContextInfo == null) { return ImmutableList.of(); } ImmutableList.Builder<String> builder = ImmutableList.builder(); - for (PathFragment path : ccCompilationInfo.getSystemIncludeDirs()) { + for (PathFragment path : ccCompilationContextInfo.getSystemIncludeDirs()) { builder.add(path.getSafePathString()); } return builder.build(); @@ -126,12 +131,13 @@ public final class CcSkylarkApiProvider extends SkylarkApiProvider { "Returns the list of include directories used to compile this target " + "(possibly empty but never <code>None</code>).") public ImmutableList<String> getIncludeDirs() { - CcCompilationInfo ccCompilationInfo = getInfo().get(CcCompilationInfo.PROVIDER); - if (ccCompilationInfo == null) { + CcCompilationContextInfo ccCompilationContextInfo = + getInfo().get(CcCompilationContextInfo.PROVIDER); + if (ccCompilationContextInfo == null) { return ImmutableList.of(); } ImmutableList.Builder<String> builder = ImmutableList.builder(); - for (PathFragment path : ccCompilationInfo.getIncludeDirs()) { + for (PathFragment path : ccCompilationContextInfo.getIncludeDirs()) { builder.add(path.getSafePathString()); } return builder.build(); @@ -144,12 +150,13 @@ public final class CcSkylarkApiProvider extends SkylarkApiProvider { "Returns the list of quote include directories used to compile this target " + "(possibly empty but never <code>None</code>).") public ImmutableList<String> getQuoteIncludeDirs() { - CcCompilationInfo ccCompilationInfo = getInfo().get(CcCompilationInfo.PROVIDER); - if (ccCompilationInfo == null) { + CcCompilationContextInfo ccCompilationContextInfo = + getInfo().get(CcCompilationContextInfo.PROVIDER); + if (ccCompilationContextInfo == null) { return ImmutableList.of(); } ImmutableList.Builder<String> builder = ImmutableList.builder(); - for (PathFragment path : ccCompilationInfo.getQuoteIncludeDirs()) { + for (PathFragment path : ccCompilationContextInfo.getQuoteIncludeDirs()) { builder.add(path.getSafePathString()); } return builder.build(); @@ -162,19 +169,20 @@ public final class CcSkylarkApiProvider extends SkylarkApiProvider { "Returns the list of flags used to compile this target " + "(possibly empty but never <code>None</code>).") public ImmutableList<String> getCcFlags() { - CcCompilationInfo ccCompilationInfo = getInfo().get(CcCompilationInfo.PROVIDER); + CcCompilationContextInfo ccCompilationContextInfo = + getInfo().get(CcCompilationContextInfo.PROVIDER); ImmutableList.Builder<String> options = ImmutableList.builder(); - for (String define : ccCompilationInfo.getDefines()) { + for (String define : ccCompilationContextInfo.getDefines()) { options.add("-D" + define); } - for (PathFragment path : ccCompilationInfo.getSystemIncludeDirs()) { + for (PathFragment path : ccCompilationContextInfo.getSystemIncludeDirs()) { options.add("-isystem " + path.getSafePathString()); } - for (PathFragment path : ccCompilationInfo.getIncludeDirs()) { + for (PathFragment path : ccCompilationContextInfo.getIncludeDirs()) { options.add("-I " + path.getSafePathString()); } - for (PathFragment path : ccCompilationInfo.getQuoteIncludeDirs()) { + for (PathFragment path : ccCompilationContextInfo.getQuoteIncludeDirs()) { options.add("-iquote " + path.getSafePathString()); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java index c99bf1d24a..650f7c75c5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchain.java @@ -471,12 +471,14 @@ public class CcToolchain implements RuleConfiguredTargetFactory { Preconditions.checkState( (dynamicRuntimeLinkMiddleman == null) == dynamicRuntimeLinkSymlinks.isEmpty()); - CcCompilationInfo.Builder ccCompilationInfoBuilder = new CcCompilationInfo.Builder(ruleContext); + CcCompilationContextInfo.Builder ccCompilationContextInfoBuilder = + new CcCompilationContextInfo.Builder(ruleContext); CppModuleMap moduleMap = createCrosstoolModuleMap(ruleContext); if (moduleMap != null) { - ccCompilationInfoBuilder.setCppModuleMap(moduleMap); + ccCompilationContextInfoBuilder.setCppModuleMap(moduleMap); } - final CcCompilationInfo ccCompilationInfo = ccCompilationInfoBuilder.build(); + final CcCompilationContextInfo ccCompilationContextInfo = + ccCompilationContextInfoBuilder.build(); boolean supportsParamFiles = ruleContext.attributes().get("supports_param_files", BOOLEAN); boolean supportsHeaderParsing = ruleContext.attributes().get("supports_header_parsing", BOOLEAN); @@ -545,7 +547,7 @@ public class CcToolchain implements RuleConfiguredTargetFactory { dynamicRuntimeLinkSymlinks, dynamicRuntimeLinkMiddleman, runtimeSolibDir, - ccCompilationInfo, + ccCompilationContextInfo, supportsParamFiles, supportsHeaderParsing, getBuildVariables(ruleContext, toolchainInfo.getDefaultSysroot()), diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java index 5347f5175b..d7625aae83 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java @@ -74,7 +74,7 @@ public final class CcToolchainProvider extends ToolchainInfo { /* dynamicRuntimeLinkInputs= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER), /* dynamicRuntimeLinkMiddleman= */ null, /* dynamicRuntimeSolibDir= */ PathFragment.EMPTY_FRAGMENT, - CcCompilationInfo.EMPTY, + CcCompilationContextInfo.EMPTY, /* supportsParamFiles= */ false, /* supportsHeaderParsing= */ false, Variables.EMPTY, @@ -105,7 +105,7 @@ public final class CcToolchainProvider extends ToolchainInfo { private final NestedSet<Artifact> dynamicRuntimeLinkInputs; @Nullable private final Artifact dynamicRuntimeLinkMiddleman; private final PathFragment dynamicRuntimeSolibDir; - private final CcCompilationInfo ccCompilationInfo; + private final CcCompilationContextInfo ccCompilationContextInfo; private final boolean supportsParamFiles; private final boolean supportsHeaderParsing; private final Variables buildVariables; @@ -138,7 +138,7 @@ public final class CcToolchainProvider extends ToolchainInfo { NestedSet<Artifact> dynamicRuntimeLinkInputs, @Nullable Artifact dynamicRuntimeLinkMiddleman, PathFragment dynamicRuntimeSolibDir, - CcCompilationInfo ccCompilationInfo, + CcCompilationContextInfo ccCompilationContextInfo, boolean supportsParamFiles, boolean supportsHeaderParsing, Variables buildVariables, @@ -169,7 +169,7 @@ public final class CcToolchainProvider extends ToolchainInfo { this.dynamicRuntimeLinkInputs = Preconditions.checkNotNull(dynamicRuntimeLinkInputs); this.dynamicRuntimeLinkMiddleman = dynamicRuntimeLinkMiddleman; this.dynamicRuntimeSolibDir = Preconditions.checkNotNull(dynamicRuntimeSolibDir); - this.ccCompilationInfo = Preconditions.checkNotNull(ccCompilationInfo); + this.ccCompilationContextInfo = Preconditions.checkNotNull(ccCompilationContextInfo); this.supportsParamFiles = supportsParamFiles; this.supportsHeaderParsing = supportsHeaderParsing; this.buildVariables = buildVariables; @@ -375,9 +375,9 @@ public final class CcToolchainProvider extends ToolchainInfo { return dynamicRuntimeSolibDir; } - /** Returns the {@code CcCompilationInfo} for the toolchain. */ - public CcCompilationInfo getCcCompilationInfo() { - return ccCompilationInfo; + /** Returns the {@code CcCompilationContextInfo} for the toolchain. */ + public CcCompilationContextInfo getCcCompilationContextInfo() { + return ccCompilationContextInfo; } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariables.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariables.java index 453d61f37a..155b070dcc 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariables.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileBuildVariables.java @@ -54,19 +54,19 @@ public enum CompileBuildVariables { /** * Variable for the collection of include paths. * - * @see CcCompilationInfo#getIncludeDirs(). + * @see CcCompilationContextInfo#getIncludeDirs(). */ INCLUDE_PATHS("include_paths"), /** * Variable for the collection of quote include paths. * - * @see CcCompilationInfo#getIncludeDirs(). + * @see CcCompilationContextInfo#getIncludeDirs(). */ QUOTE_INCLUDE_PATHS("quote_include_paths"), /** * Variable for the collection of system include paths. * - * @see CcCompilationInfo#getIncludeDirs(). + * @see CcCompilationContextInfo#getIncludeDirs(). */ SYSTEM_INCLUDE_PATHS("system_include_paths"), /** Variable for the module map file name. */ @@ -111,7 +111,7 @@ public enum CompileBuildVariables { Artifact gcnoFile, Artifact dwoFile, Artifact ltoIndexingFile, - CcCompilationInfo ccCompilationInfo, + CcCompilationContextInfo ccCompilationContextInfo, ImmutableList<String> includes, ImmutableList<String> userCompileFlags, CppModuleMap cppModuleMap, @@ -174,7 +174,7 @@ public enum CompileBuildVariables { buildVariables.addStringVariable( MODULE_MAP_FILE.getVariableName(), cppModuleMap.getArtifact().getExecPathString()); StringSequenceBuilder sequence = new StringSequenceBuilder(); - for (Artifact artifact : ccCompilationInfo.getDirectModuleMaps()) { + for (Artifact artifact : ccCompilationContextInfo.getDirectModuleMaps()) { sequence.addValue(artifact.getExecPathString()); } buildVariables.addCustomBuiltVariable(DEPENDENT_MODULE_MAP_FILES.getVariableName(), sequence); @@ -185,13 +185,14 @@ public enum CompileBuildVariables { } if (featureConfiguration.isEnabled(CppRuleClasses.INCLUDE_PATHS)) { buildVariables.addStringSequenceVariable( - INCLUDE_PATHS.getVariableName(), getSafePathStrings(ccCompilationInfo.getIncludeDirs())); + INCLUDE_PATHS.getVariableName(), + getSafePathStrings(ccCompilationContextInfo.getIncludeDirs())); buildVariables.addStringSequenceVariable( QUOTE_INCLUDE_PATHS.getVariableName(), - getSafePathStrings(ccCompilationInfo.getQuoteIncludeDirs())); + getSafePathStrings(ccCompilationContextInfo.getQuoteIncludeDirs())); buildVariables.addStringSequenceVariable( SYSTEM_INCLUDE_PATHS.getVariableName(), - getSafePathStrings(ccCompilationInfo.getSystemIncludeDirs())); + getSafePathStrings(ccCompilationContextInfo.getSystemIncludeDirs())); } if (!includes.isEmpty()) { @@ -204,11 +205,11 @@ public enum CompileBuildVariables { // Stamp FDO builds with FDO subtype string defines = ImmutableList.<String>builder() - .addAll(ccCompilationInfo.getDefines()) + .addAll(ccCompilationContextInfo.getDefines()) .add(CppConfiguration.FDO_STAMP_MACRO + "=\"" + fdoStamp + "\"") .build(); } else { - defines = ccCompilationInfo.getDefines(); + defines = ccCompilationContextInfo.getDefines(); } buildVariables.addStringSequenceVariable(PREPROCESSOR_DEFINES.getVariableName(), defines); 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 9d42abea81..3533ce071d 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 @@ -185,7 +185,7 @@ public class CppCompileAction extends AbstractAction protected final boolean needsIncludeValidation; private final IncludeProcessing includeProcessing; - private final CcCompilationInfo ccCompilationInfo; + private final CcCompilationContextInfo ccCompilationContextInfo; private final Iterable<IncludeScannable> lipoScannables; private final ImmutableList<Artifact> builtinIncludeFiles; // A list of files to include scan that are not source files, pcm files, lipo scannables, or @@ -250,7 +250,7 @@ public class CppCompileAction extends AbstractAction * @param dwoFile the .dwo output file where debug information is stored for Fission builds (null * if Fission mode is disabled) * @param optionalSourceFile an additional optional source file (null if unneeded) - * @param ccCompilationInfo the {@code CcCompilationInfo} + * @param ccCompilationContextInfo the {@code CcCompilationContextInfo} * @param coptsFilter regular expression to remove options from {@code copts} * @param lipoScannables List of artifacts to include-scan when this action is a lipo action * @param additionalIncludeScanningRoots list of additional artifacts to include-scan @@ -283,7 +283,7 @@ public class CppCompileAction extends AbstractAction @Nullable Artifact ltoIndexingFile, Artifact optionalSourceFile, ImmutableMap<String, String> localShellEnvironment, - CcCompilationInfo ccCompilationInfo, + CcCompilationContextInfo ccCompilationContextInfo, CoptsFilter coptsFilter, Iterable<IncludeScannable> lipoScannables, ImmutableList<Artifact> additionalIncludeScanningRoots, @@ -320,7 +320,7 @@ public class CppCompileAction extends AbstractAction usePic, useHeaderModules, isStrictSystemIncludes, - ccCompilationInfo, + ccCompilationContextInfo, lipoScannables, builtinIncludeFiles, ImmutableList.copyOf(additionalIncludeScanningRoots), @@ -364,7 +364,7 @@ public class CppCompileAction extends AbstractAction boolean usePic, boolean useHeaderModules, boolean isStrictSystemIncludes, - CcCompilationInfo ccCompilationInfo, + CcCompilationContextInfo ccCompilationContextInfo, Iterable<IncludeScannable> lipoScannables, ImmutableList<Artifact> builtinIncludeFiles, ImmutableList<Artifact> additionalIncludeScanningRoots, @@ -396,7 +396,7 @@ public class CppCompileAction extends AbstractAction this.usePic = usePic; this.useHeaderModules = useHeaderModules; this.isStrictSystemIncludes = isStrictSystemIncludes; - this.ccCompilationInfo = ccCompilationInfo; + this.ccCompilationContextInfo = ccCompilationContextInfo; this.lipoScannables = lipoScannables; this.builtinIncludeFiles = builtinIncludeFiles; this.additionalIncludeScanningRoots = additionalIncludeScanningRoots; @@ -509,8 +509,9 @@ public class CppCompileAction extends AbstractAction // Here, we cannot really know what the top-level modules are, so we just mark all // transitive modules as "top level". topLevelModules = - Sets.newLinkedHashSet(ccCompilationInfo.getTransitiveModules(usePic).toCollection()); - result.addTransitive(ccCompilationInfo.getTransitiveModules(usePic)); + Sets.newLinkedHashSet( + ccCompilationContextInfo.getTransitiveModules(usePic).toCollection()); + result.addTransitive(ccCompilationContextInfo.getTransitiveModules(usePic)); } result.addTransitive(prunableInputs); return result.build(); @@ -537,8 +538,8 @@ public class CppCompileAction extends AbstractAction } else { usedModules = Sets.newLinkedHashSet(); topLevelModules = null; - for (CcCompilationInfo.TransitiveModuleHeaders usedModule : - ccCompilationInfo.getUsedModules(usePic, initialResultSet)) { + for (CcCompilationContextInfo.TransitiveModuleHeaders usedModule : + ccCompilationContextInfo.getUsedModules(usePic, initialResultSet)) { usedModules.add(usedModule.getModule()); } initialResultSet.addAll(usedModules); @@ -630,12 +631,12 @@ public class CppCompileAction extends AbstractAction public Map<Artifact, Artifact> getLegalGeneratedScannerFileMap() { Map<Artifact, Artifact> legalOuts = new HashMap<>(); - for (Artifact a : ccCompilationInfo.getDeclaredIncludeSrcs()) { + for (Artifact a : ccCompilationContextInfo.getDeclaredIncludeSrcs()) { if (!a.isSourceArtifact()) { legalOuts.put(a, null); } } - for (PregreppedHeader pregreppedSrcs : ccCompilationInfo.getPregreppedHeaders()) { + for (PregreppedHeader pregreppedSrcs : ccCompilationContextInfo.getPregreppedHeaders()) { Artifact hdr = pregreppedSrcs.originalHeader(); Preconditions.checkState(!hdr.isSourceArtifact(), hdr); legalOuts.put(hdr, pregreppedSrcs.greppedHeader()); @@ -658,19 +659,19 @@ public class CppCompileAction extends AbstractAction } @VisibleForTesting - public CcCompilationInfo getCcCompilationInfo() { - return ccCompilationInfo; + public CcCompilationContextInfo getCcCompilationContextInfo() { + return ccCompilationContextInfo; } @Override public List<PathFragment> getQuoteIncludeDirs() { - return ccCompilationInfo.getQuoteIncludeDirs(); + return ccCompilationContextInfo.getQuoteIncludeDirs(); } @Override public List<PathFragment> getIncludeDirs() { ImmutableList.Builder<PathFragment> result = ImmutableList.builder(); - result.addAll(ccCompilationInfo.getIncludeDirs()); + result.addAll(ccCompilationContextInfo.getIncludeDirs()); for (String opt : compileCommandLine.getCopts()) { if (opt.startsWith("-I") && opt.length() > 2) { // We insist on the combined form "-Idir". @@ -687,7 +688,7 @@ public class CppCompileAction extends AbstractAction // system_includes attribute in cc_toolchain); note that that would disallow users from // specifying system include paths via the copts attribute. // Currently, this works together with the include_paths features because getCommandLine() will - // get the system include paths from the {@code CcCompilationInfo} instead. + // get the system include paths from the {@code CcCompilationContextInfo} instead. ImmutableList.Builder<PathFragment> result = ImmutableList.builder(); List<String> compilerOptions = getCompilerOptions(); for (int i = 0; i < compilerOptions.size(); i++) { @@ -722,7 +723,7 @@ public class CppCompileAction extends AbstractAction @Override public Artifact getMainIncludeScannerSource() { return getSourceFile().isFileType(CppFileTypes.CPP_MODULE_MAP) - ? Iterables.getFirst(ccCompilationInfo.getHeaderModuleSrcs(), null) + ? Iterables.getFirst(ccCompilationContextInfo.getHeaderModuleSrcs(), null) : getSourceFile(); } @@ -734,7 +735,7 @@ public class CppCompileAction extends AbstractAction // module map, and we need to include-scan all headers that are referenced in the module map. // We need to do include scanning as long as we want to support building code bases that are // not fully strict layering clean. - builder.addAll(ccCompilationInfo.getHeaderModuleSrcs()); + builder.addAll(ccCompilationContextInfo.getHeaderModuleSrcs()); } else { builder.add(getSourceFile()); builder.addAll(additionalIncludeScanningRoots); @@ -753,7 +754,7 @@ public class CppCompileAction extends AbstractAction */ @VisibleForTesting public ImmutableCollection<String> getDefines() { - return ccCompilationInfo.getDefines(); + return ccCompilationContextInfo.getDefines(); } @Override @@ -795,7 +796,7 @@ public class CppCompileAction extends AbstractAction } else { info.addSourcesAndHeaders(getSourceFile().getExecPathString()); info.addAllSourcesAndHeaders( - Artifact.toExecPaths(ccCompilationInfo.getDeclaredIncludeSrcs())); + Artifact.toExecPaths(ccCompilationContextInfo.getDeclaredIncludeSrcs())); } for (Entry<String, String> envVariable : getEnvironment().entrySet()) { info.addVariable( @@ -872,14 +873,14 @@ public class CppCompileAction extends AbstractAction // Copy the sets to hash sets for fast contains checking. // Avoid immutable sets here to limit memory churn. Set<PathFragment> declaredIncludeDirs = - Sets.newHashSet(ccCompilationInfo.getDeclaredIncludeDirs()); + Sets.newHashSet(ccCompilationContextInfo.getDeclaredIncludeDirs()); Set<PathFragment> warnIncludeDirs = - Sets.newHashSet(ccCompilationInfo.getDeclaredIncludeWarnDirs()); + Sets.newHashSet(ccCompilationContextInfo.getDeclaredIncludeWarnDirs()); Set<Artifact> declaredIncludeSrcs = Sets.newHashSet(getDeclaredIncludeSrcs()); Set<Artifact> transitiveModules = - Sets.newHashSet(ccCompilationInfo.getTransitiveModules(usePic)); + Sets.newHashSet(ccCompilationContextInfo.getTransitiveModules(usePic)); for (Artifact input : inputsForValidation) { - if (ccCompilationInfo.getTransitiveCompilationPrerequisites().contains(input) + if (ccCompilationContextInfo.getTransitiveCompilationPrerequisites().contains(input) || transitiveModules.contains(input) || allowedIncludes.contains(input)) { continue; // ignore our fixed source in mandatoryInput: we just want includes @@ -909,19 +910,21 @@ public class CppCompileAction extends AbstractAction System.err.println("INFO: Include(s) were OK for '" + getSourceFile() + "', declared srcs:"); } - for (Artifact a : ccCompilationInfo.getDeclaredIncludeSrcs()) { + for (Artifact a : ccCompilationContextInfo.getDeclaredIncludeSrcs()) { System.err.println(" '" + a.toDetailString() + "'"); } System.err.println(" or under declared dirs:"); - for (PathFragment f : Sets.newTreeSet(ccCompilationInfo.getDeclaredIncludeDirs())) { + for (PathFragment f : + Sets.newTreeSet(ccCompilationContextInfo.getDeclaredIncludeDirs())) { System.err.println(" '" + f + "'"); } System.err.println(" or under declared warn dirs:"); - for (PathFragment f : Sets.newTreeSet(ccCompilationInfo.getDeclaredIncludeWarnDirs())) { + for (PathFragment f : + Sets.newTreeSet(ccCompilationContextInfo.getDeclaredIncludeWarnDirs())) { System.err.println(" '" + f + "'"); } System.err.println(" with prefixes:"); - for (PathFragment dirpath : ccCompilationInfo.getQuoteIncludeDirs()) { + for (PathFragment dirpath : ccCompilationContextInfo.getQuoteIncludeDirs()) { System.err.println(" '" + dirpath + "'"); } } @@ -940,7 +943,7 @@ public class CppCompileAction extends AbstractAction Iterable<PathFragment> getValidationIgnoredDirs() { List<PathFragment> cxxSystemIncludeDirs = getBuiltInIncludeDirectories(); - return Iterables.concat(cxxSystemIncludeDirs, ccCompilationInfo.getSystemIncludeDirs()); + return Iterables.concat(cxxSystemIncludeDirs, ccCompilationContextInfo.getSystemIncludeDirs()); } /** @@ -1056,8 +1059,9 @@ public class CppCompileAction extends AbstractAction addToMap(allowedDerivedInputMap, mandatoryInputs); addToMap(allowedDerivedInputMap, prunableInputs); addToMap(allowedDerivedInputMap, getDeclaredIncludeSrcs()); - addToMap(allowedDerivedInputMap, ccCompilationInfo.getTransitiveCompilationPrerequisites()); - addToMap(allowedDerivedInputMap, ccCompilationInfo.getTransitiveModules(usePic)); + addToMap( + allowedDerivedInputMap, ccCompilationContextInfo.getTransitiveCompilationPrerequisites()); + addToMap(allowedDerivedInputMap, ccCompilationContextInfo.getTransitiveModules(usePic)); Artifact artifact = getSourceFile(); if (!artifact.isSourceArtifact()) { allowedDerivedInputMap.put(artifact.getExecPath(), artifact); @@ -1083,7 +1087,7 @@ public class CppCompileAction extends AbstractAction * listed in {@code declaredIncludeSrcs}). */ public NestedSet<PathFragment> getDeclaredIncludeDirs() { - return ccCompilationInfo.getDeclaredIncludeDirs(); + return ccCompilationContextInfo.getDeclaredIncludeDirs(); } /** @@ -1091,7 +1095,7 @@ public class CppCompileAction extends AbstractAction * not specifically listed in {@code declaredIncludeSrcs}). */ public NestedSet<PathFragment> getDeclaredIncludeWarnDirs() { - return ccCompilationInfo.getDeclaredIncludeWarnDirs(); + return ccCompilationContextInfo.getDeclaredIncludeWarnDirs(); } /** Return explicitly listed header files. */ @@ -1099,13 +1103,13 @@ public class CppCompileAction extends AbstractAction public NestedSet<Artifact> getDeclaredIncludeSrcs() { if (lipoScannables != null && lipoScannables.iterator().hasNext()) { NestedSetBuilder<Artifact> srcs = NestedSetBuilder.stableOrder(); - srcs.addTransitive(ccCompilationInfo.getDeclaredIncludeSrcs()); + srcs.addTransitive(ccCompilationContextInfo.getDeclaredIncludeSrcs()); for (IncludeScannable lipoScannable : lipoScannables) { srcs.addTransitive(lipoScannable.getDeclaredIncludeSrcs()); } return srcs.build(); } - return ccCompilationInfo.getDeclaredIncludeSrcs(); + return ccCompilationContextInfo.getDeclaredIncludeSrcs(); } /** @@ -1140,9 +1144,10 @@ public class CppCompileAction extends AbstractAction * that affect whether validateIncludes() will report an error or warning * have changed, otherwise we might miss some errors. */ - fp.addPaths(ccCompilationInfo.getDeclaredIncludeDirs()); - fp.addPaths(ccCompilationInfo.getDeclaredIncludeWarnDirs()); - actionKeyContext.addNestedSetToFingerprint(fp, ccCompilationInfo.getDeclaredIncludeSrcs()); + fp.addPaths(ccCompilationContextInfo.getDeclaredIncludeDirs()); + fp.addPaths(ccCompilationContextInfo.getDeclaredIncludeWarnDirs()); + actionKeyContext.addNestedSetToFingerprint( + fp, ccCompilationContextInfo.getDeclaredIncludeSrcs()); fp.addInt(0); // mark the boundary between input types actionKeyContext.addNestedSetToFingerprint(fp, getMandatoryInputs()); fp.addInt(0); @@ -1375,7 +1380,7 @@ public class CppCompileAction extends AbstractAction legend = " Argument: "; } - for (PathFragment path : ccCompilationInfo.getDeclaredIncludeDirs()) { + for (PathFragment path : ccCompilationContextInfo.getDeclaredIncludeDirs()) { message.append(" Declared include directory: "); message.append(ShellEscaper.escapeString(path.getPathString())); message.append('\n'); 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 6a5271520a..43c54bc2bf 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 @@ -63,7 +63,7 @@ public class CppCompileActionBuilder { private PathFragment tempOutputFile; private DotdFile dotdFile; private Artifact gcnoFile; - private CcCompilationInfo ccCompilationInfo = CcCompilationInfo.EMPTY; + private CcCompilationContextInfo ccCompilationContextInfo = CcCompilationContextInfo.EMPTY; private final List<String> pluginOpts = new ArrayList<>(); private CoptsFilter coptsFilter = CoptsFilter.alwaysPasses(); private ImmutableList<PathFragment> extraSystemIncludePrefixes = ImmutableList.of(); @@ -147,7 +147,7 @@ public class CppCompileActionBuilder { this.tempOutputFile = other.tempOutputFile; this.dotdFile = other.dotdFile; this.gcnoFile = other.gcnoFile; - this.ccCompilationInfo = other.ccCompilationInfo; + this.ccCompilationContextInfo = other.ccCompilationContextInfo; this.pluginOpts.addAll(other.pluginOpts); this.coptsFilter = other.coptsFilter; this.extraSystemIncludePrefixes = ImmutableList.copyOf(other.extraSystemIncludePrefixes); @@ -200,8 +200,8 @@ public class CppCompileActionBuilder { return sourceFile; } - public CcCompilationInfo getCcCompilationInfo() { - return ccCompilationInfo; + public CcCompilationContextInfo getCcCompilationContextInfo() { + return ccCompilationContextInfo; } public NestedSet<Artifact> getMandatoryInputs() { @@ -336,7 +336,7 @@ public class CppCompileActionBuilder { NestedSet<Artifact> allInputs = buildAllInputs(realMandatoryInputs); NestedSetBuilder<Artifact> prunableInputBuilder = NestedSetBuilder.stableOrder(); - prunableInputBuilder.addTransitive(ccCompilationInfo.getDeclaredIncludeSrcs()); + prunableInputBuilder.addTransitive(ccCompilationContextInfo.getDeclaredIncludeSrcs()); prunableInputBuilder.addTransitive(cppSemantics.getAdditionalPrunableIncludes()); Iterable<IncludeScannable> lipoScannables = getLipoScannables(realMandatoryInputs); @@ -380,7 +380,7 @@ public class CppCompileActionBuilder { tempOutputFile, dotdFile, localShellEnvironment, - ccCompilationInfo, + ccCompilationContextInfo, coptsFilter, getLipoScannables(realMandatoryInputs), cppSemantics, @@ -412,7 +412,7 @@ public class CppCompileActionBuilder { ltoIndexingFile, optionalSourceFile, localShellEnvironment, - ccCompilationInfo, + ccCompilationContextInfo, coptsFilter, getLipoScannables(realMandatoryInputs), additionalIncludeScanningRoots.build(), @@ -446,11 +446,13 @@ public class CppCompileActionBuilder { NestedSetBuilder<Artifact> realMandatoryInputsBuilder = NestedSetBuilder.compileOrder(); realMandatoryInputsBuilder.addTransitive(mandatoryInputsBuilder.build()); realMandatoryInputsBuilder.addAll(getBuiltinIncludeFiles()); - realMandatoryInputsBuilder.addAll(ccCompilationInfo.getTransitiveCompilationPrerequisites()); + realMandatoryInputsBuilder.addAll( + ccCompilationContextInfo.getTransitiveCompilationPrerequisites()); if (useHeaderModules() && !shouldPruneModules()) { - realMandatoryInputsBuilder.addTransitive(ccCompilationInfo.getTransitiveModules(usePic)); + realMandatoryInputsBuilder.addTransitive( + ccCompilationContextInfo.getTransitiveModules(usePic)); } - realMandatoryInputsBuilder.addTransitive(ccCompilationInfo.getAdditionalInputs()); + realMandatoryInputsBuilder.addTransitive(ccCompilationContextInfo.getAdditionalInputs()); realMandatoryInputsBuilder.add(Preconditions.checkNotNull(sourceFile)); if (grepIncludes != null) { realMandatoryInputsBuilder.add(grepIncludes); @@ -658,8 +660,9 @@ public class CppCompileActionBuilder { return this; } - public CppCompileActionBuilder setCcCompilationInfo(CcCompilationInfo ccCompilationInfo) { - this.ccCompilationInfo = ccCompilationInfo; + public CppCompileActionBuilder setCcCompilationContextInfo( + CcCompilationContextInfo ccCompilationContextInfo) { + this.ccCompilationContextInfo = ccCompilationContextInfo; 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 a8e609824e..2f9f067dbc 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 @@ -199,10 +199,9 @@ public final class CppConfiguration extends BuildConfiguration.Fragment { private final boolean shouldProvideMakeVariables; private final boolean dropFullyStaticLinkingMode; - /** * If true, the ConfiguredTarget is only used to get the necessary cross-referenced {@code - * CcCompilationInfo}s, but registering build actions is disabled. + * CcCompilationContextInfo}s, but registering build actions is disabled. */ private final boolean lipoContextCollector; diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java index c79c3da3e6..c95219225c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java @@ -57,7 +57,7 @@ import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; import com.google.devtools.build.lib.collect.nestedset.Order; import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException; import com.google.devtools.build.lib.packages.RuleErrorConsumer; -import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo.Builder; +import com.google.devtools.build.lib.rules.cpp.CcCompilationContextInfo.Builder; import com.google.devtools.build.lib.rules.cpp.CcLinkParams.Linkstamp; import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration; import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Tool; @@ -113,22 +113,25 @@ public class CppHelper { * Merges the STL and toolchain contexts into context builder. The STL is automatically determined * using the ":stl" attribute. */ - public static void mergeToolchainDependentCcCompilationInfo( - RuleContext ruleContext, CcToolchainProvider toolchain, Builder ccCompilationInfoBuilder) { + public static void mergeToolchainDependentCcCompilationContextInfo( + RuleContext ruleContext, + CcToolchainProvider toolchain, + Builder ccCompilationContextInfoBuilder) { if (ruleContext.getRule().getAttributeDefinition(":stl") != null) { TransitiveInfoCollection stl = ruleContext.getPrerequisite(":stl", Mode.TARGET); if (stl != null) { - CcCompilationInfo provider = stl.get(CcCompilationInfo.PROVIDER); + CcCompilationContextInfo provider = stl.get(CcCompilationContextInfo.PROVIDER); if (provider == null) { ruleContext.ruleError("Unable to merge the STL '" + stl.getLabel() + "' and toolchain contexts"); return; } - ccCompilationInfoBuilder.mergeDependentCcCompilationInfo(provider); + ccCompilationContextInfoBuilder.mergeDependentCcCompilationContextInfo(provider); } } if (toolchain != null) { - ccCompilationInfoBuilder.mergeDependentCcCompilationInfo(toolchain.getCcCompilationInfo()); + ccCompilationContextInfoBuilder.mergeDependentCcCompilationContextInfo( + toolchain.getCcCompilationContextInfo()); } } @@ -697,7 +700,7 @@ public class CppHelper { /** * Emits a warning on the rule if there are identical linkstamp artifacts with different {@code - * CcCompilationInfo}s. + * CcCompilationContextInfo}s. */ public static void checkLinkstampsUnique(RuleErrorConsumer listener, CcLinkParams linkParams) { Map<Artifact, NestedSet<Artifact>> result = new LinkedHashMap<>(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkstampCompileHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkstampCompileHelper.java index b3e8b56a92..f059510d91 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkstampCompileHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkstampCompileHelper.java @@ -143,8 +143,8 @@ public class CppLinkstampCompileHelper { // TODO(b/34761650): Remove all this hardcoding by separating a full blown compile action. Preconditions.checkArgument( featureConfiguration.actionIsConfigured(CppCompileAction.LINKSTAMP_COMPILE)); - CcCompilationInfo ccCompilationInfo = - new CcCompilationInfo.Builder(ruleContext) + CcCompilationContextInfo ccCompilationContextInfo = + new CcCompilationContextInfo.Builder(ruleContext) .addIncludeDir(PathFragment.create(".")) .addDefines( computeAllLinkstampDefines( @@ -165,7 +165,7 @@ public class CppLinkstampCompileHelper { /* gcnoFile= */ null, /* dwoFile= */ null, /* ltoIndexingFile= */ null, - ccCompilationInfo, + ccCompilationContextInfo, buildInfoHeaderArtifacts .stream() .map(Artifact::getExecPathString) diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppSemantics.java index 4dce64b0fe..fe939422d1 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppSemantics.java @@ -30,13 +30,13 @@ public interface CppSemantics { void finalizeCompileActionBuilder(RuleContext ruleContext, CppCompileActionBuilder actionBuilder); /** - * Called before {@link CcCompilationInfo}s are finalized. + * Called before {@link CcCompilationContextInfo}s are finalized. * * <p>Gives the semantics implementation the opportunity to change what the C++ rule propagates to * dependent rules. */ - void setupCcCompilationInfo( - RuleContext ruleContext, CcCompilationInfo.Builder ccCompilationInfoBuilder); + void setupCcCompilationContextInfo( + RuleContext ruleContext, CcCompilationContextInfo.Builder ccCompilationContextInfoBuilder); /** * Returns the set of includes which are not mandatory and may be pruned by include processing. 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 a3aa127b07..0a35544599 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 @@ -75,7 +75,7 @@ public class FakeCppCompileAction extends CppCompileAction { PathFragment tempOutputFile, DotdFile dotdFile, ImmutableMap<String, String> localShellEnvironment, - CcCompilationInfo ccCompilationInfo, + CcCompilationContextInfo ccCompilationContextInfo, CoptsFilter nocopts, Iterable<IncludeScannable> lipoScannables, CppSemantics cppSemantics, @@ -112,7 +112,7 @@ public class FakeCppCompileAction extends CppCompileAction { // cc_fake_binary and for the negative compilation tests that depend on // the cc_fake_binary, and the runfiles must be determined at analysis // time, so they can't depend on the contents of the ".d" file.) - CcCompilationInfo.disallowUndeclaredHeaders(ccCompilationInfo), + CcCompilationContextInfo.disallowUndeclaredHeaders(ccCompilationContextInfo), nocopts, lipoScannables, ImmutableList.<Artifact>of(), diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java index e86514e199..7f19208e98 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java @@ -116,12 +116,12 @@ import java.util.zip.ZipFile; * .gcda files are added, too. * </ul> * - * <p>If we do LIPO, the actual {@code CcCompilationInfo} for LIPO compilation actions is pieced - * together from the {@code CcCompilationInfo} in LipoContextProvider and that of the rule being - * compiled. (see {@link CcCompilationInfo#mergeForLipo}) This is so that the include files for the - * extra LIPO sources are found and is, strictly speaking, incorrect, since it also changes the - * declared include directories of the main source file, which in theory can result in the - * compilation passing even though it should fail with undeclared inclusion errors. + * <p>If we do LIPO, the actual {@code CcCompilationContextInfo} for LIPO compilation actions is + * pieced together from the {@code CcCompilationContextInfo} in LipoContextProvider and that of the + * rule being compiled. (see {@link CcCompilationContextInfo#mergeForLipo}) This is so that the + * include files for the extra LIPO sources are found and is, strictly speaking, incorrect, since it + * also changes the declared include directories of the main source file, which in theory can result + * in the compilation passing even though it should fail with undeclared inclusion errors. * * <p>During the actual execution of the C++ compile action, the extra sources also need to be * include scanned, which is the reason why they are {@link IncludeScannable} objects and not simple diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LipoContextProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LipoContextProvider.java index bf3771718e..6f9f5fc697 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LipoContextProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LipoContextProvider.java @@ -33,24 +33,24 @@ import java.util.Map; @Immutable @AutoCodec public final class LipoContextProvider implements TransitiveInfoProvider { - private final CcCompilationInfo ccCompilationInfo; + private final CcCompilationContextInfo ccCompilationContextInfo; private final ImmutableMap<Artifact, IncludeScannable> includeScannables; private final ImmutableMap<PathFragment, Artifact> sourceArtifactMap; @AutoCodec.Instantiator public LipoContextProvider( - CcCompilationInfo ccCompilationInfo, + CcCompilationContextInfo ccCompilationContextInfo, Map<Artifact, IncludeScannable> includeScannables, Map<PathFragment, Artifact> sourceArtifactMap) { - this.ccCompilationInfo = ccCompilationInfo; + this.ccCompilationContextInfo = ccCompilationContextInfo; this.includeScannables = ImmutableMap.copyOf(includeScannables); this.sourceArtifactMap = ImmutableMap.copyOf(sourceArtifactMap); } - /** Returns merged {@code CcCompilationInfo} for the whole LIPO subtree. */ - public CcCompilationInfo getLipoCcCompilationInfo() { - return ccCompilationInfo; + /** Returns merged {@code CcCompilationContextInfo} for the whole LIPO subtree. */ + public CcCompilationContextInfo getLipoCcCompilationContextInfo() { + return ccCompilationContextInfo; } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java index acb8bd7aeb..3d5adfc97d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/proto/CcProtoAspect.java @@ -194,7 +194,7 @@ public abstract class CcProtoAspect extends NativeAspectClass implements Configu initializeLinkingHelper(featureConfiguration) .link( compilationInfo.getCcCompilationOutputs(), - compilationInfo.getCcCompilationInfo()); + compilationInfo.getCcCompilationContextInfo()); ccLibraryProviders = new TransitiveInfoProviderMapBuilder() diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java index 3b34318e64..49832a9d4d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java @@ -49,7 +49,7 @@ import com.google.devtools.build.lib.packages.Info; import com.google.devtools.build.lib.packages.NativeProvider; import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.packages.TargetUtils; -import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo; +import com.google.devtools.build.lib.rules.cpp.CcCompilationContextInfo; import com.google.devtools.build.lib.rules.cpp.LinkerInput; import com.google.devtools.build.lib.rules.java.JavaCompilationArgs.ClasspathType; import com.google.devtools.build.lib.syntax.Type; @@ -410,12 +410,13 @@ public class JavaCommon { } /** Collects transitive C++ dependencies. */ - protected CcCompilationInfo collectTransitiveCppDeps() { - CcCompilationInfo.Builder builder = new CcCompilationInfo.Builder(ruleContext); + protected CcCompilationContextInfo collectTransitiveCppDeps() { + CcCompilationContextInfo.Builder builder = new CcCompilationContextInfo.Builder(ruleContext); for (TransitiveInfoCollection dep : targetsTreatedAsDeps(ClasspathType.BOTH)) { - CcCompilationInfo ccCompilationInfo = dep.get(CcCompilationInfo.PROVIDER); - if (ccCompilationInfo != null) { - builder.mergeDependentCcCompilationInfo(ccCompilationInfo); + CcCompilationContextInfo ccCompilationContextInfo = + dep.get(CcCompilationContextInfo.PROVIDER); + if (ccCompilationContextInfo != null) { + builder.mergeDependentCcCompilationContextInfo(ccCompilationContextInfo); } } return builder.build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java index 6de440a748..def979fdb3 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java @@ -89,9 +89,9 @@ import com.google.devtools.build.lib.rules.apple.AppleToolchain; import com.google.devtools.build.lib.rules.apple.XcodeConfig; import com.google.devtools.build.lib.rules.apple.XcodeConfigProvider; import com.google.devtools.build.lib.rules.cpp.CcCommon; +import com.google.devtools.build.lib.rules.cpp.CcCompilationContextInfo; import com.google.devtools.build.lib.rules.cpp.CcCompilationHelper; import com.google.devtools.build.lib.rules.cpp.CcCompilationHelper.CompilationInfo; -import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo; import com.google.devtools.build.lib.rules.cpp.CcCompilationOutputs; import com.google.devtools.build.lib.rules.cpp.CcLinkingHelper; import com.google.devtools.build.lib.rules.cpp.CcLinkingHelper.LinkingInfo; @@ -446,21 +446,22 @@ public class CompilationSupport { resultLink.addLinkActionInput(linkActionInput); } - CcCompilationInfo.Builder ccCompilationInfoBuilder = new CcCompilationInfo.Builder(ruleContext); - ccCompilationInfoBuilder.mergeDependentCcCompilationInfos( + CcCompilationContextInfo.Builder ccCompilationContextInfoBuilder = + new CcCompilationContextInfo.Builder(ruleContext); + ccCompilationContextInfoBuilder.mergeDependentCcCompilationContextInfos( Arrays.asList( - objcArcCompilationInfo.getCcCompilationInfo(), - nonObjcArcCompilationInfo.getCcCompilationInfo())); - ccCompilationInfoBuilder.setPurpose( + objcArcCompilationInfo.getCcCompilationContextInfo(), + nonObjcArcCompilationInfo.getCcCompilationContextInfo())); + ccCompilationContextInfoBuilder.setPurpose( String.format("%s_merged_arc_non_arc_objc", semantics.getPurpose())); - semantics.setupCcCompilationInfo(ruleContext, ccCompilationInfoBuilder); + semantics.setupCcCompilationContextInfo(ruleContext, ccCompilationContextInfoBuilder); CcCompilationOutputs.Builder compilationOutputsBuilder = new CcCompilationOutputs.Builder(); compilationOutputsBuilder.merge(objcArcCompilationInfo.getCcCompilationOutputs()); compilationOutputsBuilder.merge(nonObjcArcCompilationInfo.getCcCompilationOutputs()); LinkingInfo linkingInfo = - resultLink.link(compilationOutputsBuilder.build(), ccCompilationInfoBuilder.build()); + resultLink.link(compilationOutputsBuilder.build(), ccCompilationContextInfoBuilder.build()); Map<String, NestedSet<Artifact>> mergedOutputGroups = CcCommon.mergeOutputGroups( diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java index 1b1a89d527..d4a26a234d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java @@ -67,7 +67,7 @@ import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTa import com.google.devtools.build.lib.packages.Info; import com.google.devtools.build.lib.packages.NativeProvider; import com.google.devtools.build.lib.rules.apple.AppleToolchain; -import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo; +import com.google.devtools.build.lib.rules.cpp.CcCompilationContextInfo; import com.google.devtools.build.lib.rules.cpp.CcLinkParams; import com.google.devtools.build.lib.rules.cpp.CcLinkParamsInfo; import com.google.devtools.build.lib.rules.cpp.CppFileTypes; @@ -167,7 +167,7 @@ public final class ObjcCommon { private DsymOutputType dsymOutputType; private Optional<Artifact> linkedBinary = Optional.absent(); private Optional<Artifact> linkmapFile = Optional.absent(); - private Iterable<CcCompilationInfo> depCcHeaderProviders = ImmutableList.of(); + private Iterable<CcCompilationContextInfo> depCcHeaderProviders = ImmutableList.of(); private Iterable<CcLinkParamsInfo> depCcLinkProviders = ImmutableList.of(); /** @@ -256,17 +256,18 @@ public final class ObjcCommon { Builder addDeps(List<ConfiguredTargetAndData> deps) { ImmutableList.Builder<ObjcProvider> propagatedObjcDeps = ImmutableList.<ObjcProvider>builder(); - ImmutableList.Builder<CcCompilationInfo> cppDeps = ImmutableList.<CcCompilationInfo>builder(); + ImmutableList.Builder<CcCompilationContextInfo> cppDeps = + ImmutableList.<CcCompilationContextInfo>builder(); ImmutableList.Builder<CcLinkParamsInfo> cppDepLinkParams = ImmutableList.<CcLinkParamsInfo>builder(); for (ConfiguredTargetAndData dep : deps) { ConfiguredTarget depCT = dep.getConfiguredTarget(); addAnyProviders(propagatedObjcDeps, depCT, ObjcProvider.SKYLARK_CONSTRUCTOR); - addAnyProviders(cppDeps, depCT, CcCompilationInfo.PROVIDER); + addAnyProviders(cppDeps, depCT, CcCompilationContextInfo.PROVIDER); if (isCcLibrary(dep)) { cppDepLinkParams.add(depCT.get(CcLinkParamsInfo.PROVIDER)); - addDefines(depCT.get(CcCompilationInfo.PROVIDER).getDefines()); + addDefines(depCT.get(CcCompilationContextInfo.PROVIDER).getDefines()); } } addDepObjcProviders(propagatedObjcDeps.build()); @@ -422,11 +423,11 @@ public final class ObjcCommon { objcProvider.addTransitiveAndPropagate(ObjcProvider.MERGE_ZIP, provider); } - for (CcCompilationInfo headerProvider : depCcHeaderProviders) { + for (CcCompilationContextInfo headerProvider : depCcHeaderProviders) { objcProvider.addAll(HEADER, filterFileset(headerProvider.getDeclaredIncludeSrcs())); objcProvider.addAll(INCLUDE, headerProvider.getIncludeDirs()); // TODO(bazel-team): This pulls in stl via - // CppHelper.mergeToolchainDependentCcCompilationInfo but + // CppHelper.mergeToolchainDependentCcCompilationContextInfo but // probably shouldn't. objcProvider.addAll(INCLUDE_SYSTEM, headerProvider.getSystemIncludeDirs()); objcProvider.addAll(DEFINE, headerProvider.getDefines()); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCppSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCppSemantics.java index 53836f4348..9e496fa3ce 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCppSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCppSemantics.java @@ -24,8 +24,8 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.RuleContext; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.collect.nestedset.NestedSet; -import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo; -import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo.Builder; +import com.google.devtools.build.lib.rules.cpp.CcCompilationContextInfo; +import com.google.devtools.build.lib.rules.cpp.CcCompilationContextInfo.Builder; import com.google.devtools.build.lib.rules.cpp.CppCompileActionBuilder; import com.google.devtools.build.lib.rules.cpp.CppConfiguration; import com.google.devtools.build.lib.rules.cpp.CppConfiguration.HeadersCheckingMode; @@ -122,12 +122,13 @@ public class ObjcCppSemantics implements CppSemantics { } @Override - public void setupCcCompilationInfo(RuleContext ruleContext, Builder ccCompilationInfoBuilder) { + public void setupCcCompilationContextInfo( + RuleContext ruleContext, Builder ccCompilationContextInfoBuilder) { // The genfiles root of each child configuration must be added to the compile action so that // generated headers can be resolved. for (PathFragment iquotePath : ObjcCommon.userHeaderSearchPaths(objcProvider, ruleContext.getConfiguration())) { - ccCompilationInfoBuilder.addQuoteIncludeDir(iquotePath); + ccCompilationContextInfoBuilder.addQuoteIncludeDir(iquotePath); } } @@ -168,12 +169,13 @@ public class ObjcCppSemantics implements CppSemantics { } /** - * Gets the purpose for the {@code CcCompilationInfo}. + * Gets the purpose for the {@code CcCompilationContextInfo}. * - * @see CcCompilationInfo.Builder#setPurpose + * @see CcCompilationContextInfo.Builder#setPurpose */ public String getPurpose() { - // ProtoSupport creates multiple {@code CcCompilationInfo}s for a single rule, potentially + // ProtoSupport creates multiple {@code CcCompilationContextInfo}s for a single rule, + // potentially // multiple archives per build configuration. This covers that worst case. return "ObjcCppSemantics_build_arch_" + buildConfiguration.getMnemonic() diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java index 323de180cd..ec1be25f8b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcLibrary.java @@ -24,7 +24,7 @@ import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTa import com.google.devtools.build.lib.analysis.test.InstrumentedFilesProvider; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; -import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo; +import com.google.devtools.build.lib.rules.cpp.CcCompilationContextInfo; import com.google.devtools.build.lib.rules.cpp.CcLinkParamsInfo; import com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes; import com.google.devtools.build.lib.syntax.Type; @@ -92,8 +92,8 @@ public class ObjcLibrary implements RuleConfiguredTargetFactory { J2ObjcEntryClassProvider j2ObjcEntryClassProvider = new J2ObjcEntryClassProvider.Builder() .addTransitive(ruleContext.getPrerequisites("deps", Mode.TARGET, J2ObjcEntryClassProvider.class)).build(); - CcCompilationInfo ccCompilationInfo = - new CcCompilationInfo.Builder(ruleContext) + CcCompilationContextInfo ccCompilationContextInfo = + new CcCompilationContextInfo.Builder(ruleContext) .addDeclaredIncludeSrcs( CompilationAttributes.Builder.fromRuleContext(ruleContext) .build() @@ -103,7 +103,7 @@ public class ObjcLibrary implements RuleConfiguredTargetFactory { return ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build()) .addNativeDeclaredProvider(common.getObjcProvider()) - .addNativeDeclaredProvider(ccCompilationInfo) + .addNativeDeclaredProvider(ccCompilationContextInfo) .addProvider(J2ObjcEntryClassProvider.class, j2ObjcEntryClassProvider) .addProvider(J2ObjcMappingFileProvider.class, j2ObjcMappingFileProvider) .addProvider( diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/PrintActionCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/PrintActionCommand.java index 9b61941914..10cc6500d0 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/PrintActionCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/PrintActionCommand.java @@ -312,7 +312,7 @@ public final class PrintActionCommand implements BlazeCommand { * <p>However, since there is a scheduling dependency on the header files, we can use the system * to implement said scheduling dependency to figure them out. Thus, we go a-fishing in the action * graph reaching through error propagating middlemen: one of these exists for each {@code - * CcCompilationInfo} in the transitive closure of the rule. + * CcCompilationContextInfo} in the transitive closure of the rule. */ private static void expandRecursiveHelper( ActionGraph actionGraph, |