diff --git a/src/main/java/com/google/devtools/build/lib/includescanning/IncludeParser.java b/src/main/java/com/google/devtools/build/lib/includescanning/IncludeParser.java index 53188d7ce43b4b..86f3fea0f213a7 100644 --- a/src/main/java/com/google/devtools/build/lib/includescanning/IncludeParser.java +++ b/src/main/java/com/google/devtools/build/lib/includescanning/IncludeParser.java @@ -867,6 +867,9 @@ Collection extractInclusions( boolean isOutputFile) throws IOException, ExecException, InterruptedException { Collection inclusions; + + // TODO(ulfjack): grepIncludes may be null if the corresponding attribute on the rule is missing + // (see CppHelper.getGrepIncludes) or misspelled. It would be better to disallow this case. if (remoteIncludeScanner != null && grepIncludes != null && remoteIncludeScanner.shouldParseRemotely(file)) { 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 2098d3af45fad8..ac760c09e955b9 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 @@ -300,12 +300,14 @@ public CcCompilationContext getCcCompilationContext() { private final ActionRegistry actionRegistry; private final ActionConstructionContext actionConstructionContext; private final Label label; + @Nullable private final Artifact grepIncludes; /** Creates a CcCompilationHelper that outputs artifacts in a given configuration. */ public CcCompilationHelper( ActionRegistry actionRegistry, ActionConstructionContext actionConstructionContext, Label label, + @Nullable Artifact grepIncludes, CppSemantics semantics, FeatureConfiguration featureConfiguration, SourceCategory sourceCategory, @@ -331,6 +333,7 @@ public CcCompilationHelper( this.ruleErrorConsumer = actionConstructionContext.getRuleErrorConsumer(); this.actionRegistry = Preconditions.checkNotNull(actionRegistry); this.label = Preconditions.checkNotNull(label); + this.grepIncludes = grepIncludes; this.executionInfo = Preconditions.checkNotNull(executionInfo); this.shouldProcessHeaders = shouldProcessHeaders; } @@ -340,6 +343,7 @@ public CcCompilationHelper( ActionRegistry actionRegistry, ActionConstructionContext actionConstructionContext, Label label, + @Nullable Artifact grepIncludes, CppSemantics semantics, FeatureConfiguration featureConfiguration, CcToolchainProvider ccToolchain, @@ -350,6 +354,7 @@ public CcCompilationHelper( actionRegistry, actionConstructionContext, label, + grepIncludes, semantics, featureConfiguration, SourceCategory.CC, @@ -1669,7 +1674,7 @@ private static String toPathString(Artifact a) { */ private CppCompileActionBuilder initializeCompileAction(Artifact sourceArtifact) { return new CppCompileActionBuilder( - actionConstructionContext, ccToolchain, configuration, semantics) + actionConstructionContext, grepIncludes, ccToolchain, configuration, semantics) .setSourceFile(sourceArtifact) .setCcCompilationContext(ccCompilationContext) .setCoptsFilter(coptsFilter) 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 58e697645c9628..83eeadbdd91542 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 @@ -127,6 +127,7 @@ public CcLinkingOutputs getCcLinkingOutputs() { private final SymbolGenerator symbolGenerator; private final ImmutableMap executionInfo; + private Artifact grepIncludes; private boolean isStampingEnabled; private boolean isTestOrTestOnlyTarget; @@ -507,6 +508,15 @@ public CcLinkingHelper setTestOrTestOnlyTarget(boolean isTestOrTestOnlyTarget) { return this; } + /** + * Used to test the grep-includes tool. This is needing during linking because of linkstamping. + */ + @CanIgnoreReturnValue + public CcLinkingHelper setGrepIncludes(Artifact grepIncludes) { + this.grepIncludes = grepIncludes; + return this; + } + /** Whether linkstamping is enabled. */ @CanIgnoreReturnValue public CcLinkingHelper setIsStampingEnabled(boolean isStampingEnabled) { @@ -866,6 +876,7 @@ private CppLinkActionBuilder newLinkActionBuilder( fdoContext, featureConfiguration, semantics) + .setGrepIncludes(grepIncludes) .setMnemonic(mnemonic) .setIsStampingEnabled(isStampingEnabled) .setTestOrTestOnlyTarget(isTestOrTestOnlyTarget) diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java index 74ae22b5a5be4b..78d6a819695e32 100755 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java @@ -1911,6 +1911,7 @@ public Tuple createLinkingContextFromCompilationOutputs( TargetUtils.getExecutionInfo( actions.getRuleContext().getRule(), actions.getRuleContext().isAllowTagsPropagation())) + .setGrepIncludes(convertFromNoneable(grepIncludes, /* defaultValue= */ null)) .addNonCodeLinkerInputs( Sequence.cast(additionalInputs, Artifact.class, "additional_inputs")) .setShouldCreateStaticLibraries(!disallowStaticLibraries) @@ -2422,6 +2423,7 @@ public Tuple compile( StarlarkThread thread) throws EvalException, InterruptedException { isCalledFromStarlarkCcCommon(thread); + Artifact grepIncludes = convertFromNoneable(grepIncludesObject, /* defaultValue= */ null); getSemantics() .validateStarlarkCompileApiCall( starlarkActionFactoryApi, @@ -2507,6 +2509,7 @@ public Tuple compile( actions.asActionRegistry(actions), actions.getActionConstructionContext(), label, + grepIncludes, getSemantics(language), featureConfiguration.getFeatureConfiguration(), sourceCategory, @@ -2751,6 +2754,7 @@ public CcLinkingOutputs link( TargetUtils.getExecutionInfo( actions.getRuleContext().getRule(), actions.getRuleContext().isAllowTagsPropagation())) + .setGrepIncludes(convertFromNoneable(grepIncludes, /* defaultValue= */ null)) .setLinkingMode(linkDepsStatically ? LinkingMode.STATIC : LinkingMode.DYNAMIC) .setIsStampingEnabled(isStampingEnabled) .addTransitiveAdditionalLinkerInputs(additionalInputsSet) @@ -2909,6 +2913,7 @@ public void registerLinkstampCompileAction( CppLinkstampCompileHelper.createLinkstampCompileAction( ruleContext, ruleContext, + grepIncludes, ruleContext.getConfiguration(), sourceFile, outputFile, diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcStarlarkInternal.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcStarlarkInternal.java index d91a0402ed6a75..00118673825f19 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcStarlarkInternal.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcStarlarkInternal.java @@ -224,7 +224,6 @@ public CcToolchainProvider getCcToolchainProvider( targetBuiltinIncludeFiles, Artifact.class, "target_builtin_include_files") .getImmutableList(), /* linkDynamicLibraryTool= */ attributes.getLinkDynamicLibraryTool(), - /* grepIncludes= */ attributes.getGrepIncludes(), /* builtInIncludeDirectories= */ builtInIncludeDirectories, /* sysroot= */ sysroot, /* targetSysroot= */ targetSysroot, diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainAttributesProvider.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainAttributesProvider.java index 9b0b04d25da79f..426ad196fd0ccf 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainAttributesProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainAttributesProvider.java @@ -79,7 +79,6 @@ public class CcToolchainAttributesProvider extends NativeInfo implements HasCcTo private final String cpu; private final Artifact ifsoBuilder; private final Artifact linkDynamicLibraryTool; - @Nullable private final Artifact grepIncludes; private final TransitiveInfoCollection fdoOptimize; private final ImmutableList fdoOptimizeArtifacts; private final FdoPrefetchHintsProvider fdoPrefetch; @@ -119,11 +118,6 @@ public CcToolchainAttributesProvider( + "https://github.com/bazelbuild/bazel/issues/7075 for details."); } - // grep_includes is not supported by Bazel. - String toolsRepository = ruleContext.getRuleClassProvider().getToolsRepository().getName(); - this.grepIncludes = - toolsRepository.isEmpty() ? ruleContext.getPrerequisiteArtifact("$grep_includes") : null; - this.cpu = ruleContext.attributes().get("cpu", Type.STRING); this.compiler = ruleContext.attributes().get("compiler", Type.STRING); this.supportsParamFiles = ruleContext.attributes().get("supports_param_files", BOOLEAN); @@ -350,11 +344,6 @@ public Artifact getLinkDynamicLibraryTool() { return linkDynamicLibraryTool; } - @Nullable - public Artifact getGrepIncludes() { - return grepIncludes; - } - @StarlarkMethod( name = "module_map", documented = false, 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 72fe309176fbe5..c285a47433998b 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 @@ -91,7 +91,6 @@ public final class CcToolchainProvider extends NativeInfo private final ImmutableList builtinIncludeFiles; private final ImmutableList targetBuiltinIncludeFiles; @Nullable private final Artifact linkDynamicLibraryTool; - @Nullable private final Artifact grepIncludes; private final ImmutableList builtInIncludeDirectories; @Nullable private final PathFragment sysroot; private final PathFragment targetSysroot; @@ -164,7 +163,6 @@ public CcToolchainProvider( ImmutableList builtinIncludeFiles, ImmutableList targetBuiltinIncludeFiles, Artifact linkDynamicLibraryTool, - @Nullable Artifact grepIncludes, ImmutableList builtInIncludeDirectories, @Nullable PathFragment sysroot, @Nullable PathFragment targetSysroot, @@ -262,7 +260,6 @@ public CcToolchainProvider( this.stripExecutable = stripExecutable; this.ldExecutable = ldExecutable; this.gcovExecutable = gcovExecutable; - this.grepIncludes = grepIncludes; } @Override @@ -794,12 +791,6 @@ public Artifact getLinkDynamicLibraryTool() { return linkDynamicLibraryTool; } - /** Returns the grep-includes tool which is needing during linking because of linkstamping. */ - @Nullable - public Artifact getGrepIncludes() { - return grepIncludes; - } - /** Returns the tool that builds interface libraries from dynamic libraries. */ public Artifact getInterfaceSoBuilder() { return interfaceSoBuilder; diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java index 5b86bfbb53380a..cf4597287d0126 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProviderHelper.java @@ -221,7 +221,6 @@ public static CcToolchainProvider getCcToolchainProvider( getBuiltinIncludes(attributes.getLibc()), getBuiltinIncludes(attributes.getTargetLibc()), attributes.getLinkDynamicLibraryTool(), - attributes.getGrepIncludes(), builtInIncludeDirectories, sysroot, targetSysroot, diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java index 71e18923ed8a99..49d84c1ed7f1e8 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainRule.java @@ -304,11 +304,6 @@ instead of having no transition (i.e. target platform by default). .cfg(ExecutionTransitionFactory.createFactory()) .singleArtifact() .value(env.getToolsLabel("//tools/cpp:link_dynamic_library"))) - .add( - attr("$grep_includes", LABEL) - .exec() - .cfg(ExecutionTransitionFactory.createFactory()) - .value(env.getToolsLabel("//tools/cpp:grep-includes"))) .add( attr(CcToolchain.CC_TOOLCHAIN_TYPE_ATTRIBUTE_NAME, NODEP_LABEL) .value(CppRuleClasses.ccToolchainTypeAttribute(env))) 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 458fee46bdd43e..63d5c5f192b4d7 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 @@ -73,6 +73,7 @@ public class CppCompileActionBuilder { private Map executionInfo = new LinkedHashMap<>(); private CppSemantics cppSemantics; private final CcToolchainProvider ccToolchain; + @Nullable private final Artifact grepIncludes; private ActionEnvironment env; private final boolean codeCoverageEnabled; @Nullable private String actionName; @@ -87,6 +88,7 @@ public class CppCompileActionBuilder { /** Creates a builder from a rule and configuration. */ public CppCompileActionBuilder( ActionConstructionContext actionConstructionContext, + @Nullable Artifact grepIncludes, CcToolchainProvider ccToolchain, BuildConfigurationValue configuration, CppSemantics cppSemantics) { @@ -107,6 +109,7 @@ public CppCompileActionBuilder( this.codeCoverageEnabled = configuration.isCodeCoverageEnabled(); this.ccToolchain = ccToolchain; this.builtinIncludeDirectories = ccToolchain.getBuiltInIncludeDirectories(); + this.grepIncludes = grepIncludes; this.cppSemantics = cppSemantics; } @@ -143,6 +146,7 @@ public CppCompileActionBuilder(CppCompileActionBuilder other) { this.cppSemantics = other.cppSemantics; this.ccToolchain = other.ccToolchain; this.actionName = other.actionName; + this.grepIncludes = other.grepIncludes; this.builtinIncludeDirectories = other.builtinIncludeDirectories; this.additionalOutputs = ImmutableList.copyOf(other.additionalOutputs); } @@ -328,7 +332,7 @@ public CppCompileAction buildAndVerify() throws UnconfiguredActionConfigExceptio actionName, cppSemantics, builtinIncludeDirectories, - ccToolchain.getGrepIncludes(), + grepIncludes, additionalOutputs); return action; } @@ -358,8 +362,8 @@ NestedSet buildMandatoryInputs() { } ccCompilationContext.addAdditionalInputs(realMandatoryInputsBuilder); realMandatoryInputsBuilder.add(Preconditions.checkNotNull(sourceFile)); - if (ccToolchain.getGrepIncludes() != null) { - realMandatoryInputsBuilder.add(ccToolchain.getGrepIncludes()); + if (grepIncludes != null) { + realMandatoryInputsBuilder.add(grepIncludes); } if (!shouldScanIncludes && dotdFile == null && !shouldParseShowIncludes()) { realMandatoryInputsBuilder.addTransitive(ccCompilationContext.getDeclaredIncludeSrcs()); @@ -663,4 +667,9 @@ public boolean shouldCompileHeaders() { Preconditions.checkNotNull(featureConfiguration); return ccToolchain.shouldProcessHeaders(featureConfiguration, cppConfiguration); } + + @Nullable + public Artifact getGrepIncludes() { + return grepIncludes; + } } 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 cb536cbdaeb2bf..3699acb5fd7d39 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 @@ -660,4 +660,11 @@ static boolean useToolchainResolution(RuleContext ruleContext) { return cppOptions.enableCcToolchainResolution; } + + @Nullable + public static Artifact getGrepIncludes(RuleContext ruleContext) { + return ruleContext.attributes().has("$grep_includes") + ? ruleContext.getPrerequisiteArtifact("$grep_includes") + : null; + } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java index 8e008a248232a7..e5fb5b2863f788 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java @@ -141,6 +141,7 @@ public Artifact create( private final RuleErrorConsumer ruleErrorConsumer; private final RepositoryName repositoryName; + private Artifact grepIncludes; // TODO(plf): This is not exactly the same as `useTestOnlyFlags` but perhaps we can remove one // of them. private boolean isTestOrTestOnlyTarget; @@ -987,6 +988,7 @@ public CppLinkAction build() throws InterruptedException, RuleErrorException { CppLinkstampCompileHelper.createLinkstampCompileAction( ruleErrorConsumer, actionConstructionContext, + grepIncludes, configuration, source, linkstampEntry.getValue(), @@ -1490,6 +1492,15 @@ public CppLinkActionBuilder setTestOrTestOnlyTarget(boolean isTestOrTestOnlyTarg return this; } + /** + * Used to test the grep-includes tool. This is needing during linking because of linkstamping. + */ + @CanIgnoreReturnValue + public CppLinkActionBuilder setGrepIncludes(Artifact grepIncludes) { + this.grepIncludes = grepIncludes; + return this; + } + /** Whether linkstamping is enabled. */ @CanIgnoreReturnValue public CppLinkActionBuilder setIsStampingEnabled(boolean isStampingEnabled) { 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 41beb1e9bc11b9..4d346a85480c94 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 @@ -29,6 +29,7 @@ import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration; import com.google.devtools.build.lib.vfs.PathFragment; import java.util.regex.Pattern; +import javax.annotation.Nullable; /** Handles creation of CppCompileAction used to compile linkstamp sources. */ public class CppLinkstampCompileHelper { @@ -41,6 +42,7 @@ public class CppLinkstampCompileHelper { public static CppCompileAction createLinkstampCompileAction( RuleErrorConsumer ruleErrorConsumer, ActionConstructionContext actionConstructionContext, + @Nullable Artifact grepIncludes, BuildConfigurationValue configuration, Artifact sourceFile, Artifact outputFile, @@ -60,7 +62,11 @@ public static CppCompileAction createLinkstampCompileAction( CppSemantics semantics) { CppCompileActionBuilder builder = new CppCompileActionBuilder( - actionConstructionContext, ccToolchainProvider, configuration, semantics) + actionConstructionContext, + grepIncludes, + ccToolchainProvider, + configuration, + semantics) .addMandatoryInputs(compilationInputs) .setVariables( getVariables( diff --git a/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java b/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java index e9f786e31a9e02..6fe0e9c8bdba8c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java @@ -279,6 +279,7 @@ public static NativeDepsRunfiles createNativeDepsAction( ruleContext.getSymbolGenerator(), TargetUtils.getExecutionInfo( ruleContext.getRule(), ruleContext.isAllowTagsPropagation())) + .setGrepIncludes(CppHelper.getGrepIncludes(ruleContext)) .setIsStampingEnabled(AnalysisUtils.isStampingEnabled(ruleContext)) .setTestOrTestOnlyTarget(ruleContext.isTestTarget() || ruleContext.isTestOnlyTarget()) .setLinkerOutputArtifact(sharedLibrary) 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 42829043f0de6e..25de6766f71e3d 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 @@ -650,6 +650,7 @@ public CompilationSupport registerLinkActions( ruleContext.getSymbolGenerator(), TargetUtils.getExecutionInfo( ruleContext.getRule(), ruleContext.isAllowTagsPropagation())) + .setGrepIncludes(CppHelper.getGrepIncludes(ruleContext)) .setIsStampingEnabled(isStampingEnabled) .setTestOrTestOnlyTarget(ruleContext.isTestOnlyTarget() || ruleContext.isTestTarget()) .addNonCodeLinkerInputs(asNeededLibraryList) diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelperTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelperTest.java index c473a53ee9312c..a30f3d5be98efc 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelperTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelperTest.java @@ -61,6 +61,7 @@ public void testConstructorThrowsNPE() throws Exception { ruleContext, ruleContext, target.getLabel(), + /* grepIncludes= */ null, MockCppSemantics.INSTANCE, FeatureConfiguration.EMPTY, ccToolchain, @@ -83,6 +84,7 @@ public void testCanIgnoreObjcSource() throws Exception { ruleContext, ruleContext, ruleContext.getLabel(), + /* grepIncludes= */ null, MockCppSemantics.INSTANCE, FeatureConfiguration.EMPTY, ccToolchain, @@ -113,6 +115,7 @@ public void testCanConsumeObjcSource() throws Exception { ruleContext, ruleContext, ruleContext.getLabel(), + /* grepIncludes= */ null, MockCppSemantics.INSTANCE, FeatureConfiguration.EMPTY, SourceCategory.CC_AND_OBJC, diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/StarlarkCcCommonTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/StarlarkCcCommonTest.java index 648ca221afb9a9..d0d4e65cdcc2c8 100755 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/StarlarkCcCommonTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/StarlarkCcCommonTest.java @@ -8185,36 +8185,4 @@ public void testCheckPrivateApiAllowlistAllowsPrivateParameter() throws Exceptio getConfiguredTarget("//tools/build_defs/android:custom"); } - - // grep_includes is not supported by Bazel. - @Test - public void testGrepIncludesIsSetToNullInsideCcToolchain() throws Exception { - if (!AnalysisMock.get().isThisBazel()) { - return; - } - scratch.file( - "foo/BUILD", - "load(':extension.bzl', 'cc_skylark_library')", - "cc_skylark_library(", - " name = 'skylark_lib',", - ")"); - scratch.file( - "foo/extension.bzl", - "def _cc_skylark_library_impl(ctx):", - " return [ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]]", - "cc_skylark_library = rule(", - " implementation = _cc_skylark_library_impl,", - " attrs = {", - " '_cc_toolchain': attr.label(default =", - " configuration_field(fragment = 'cpp', name = 'cc_toolchain')),", - " },", - " fragments = ['cpp'],", - ")"); - - ConfiguredTarget target = getConfiguredTarget("//foo:skylark_lib"); - CcToolchainProvider toolchainProvider = target.get(CcToolchainProvider.PROVIDER); - Artifact grepIncludes = toolchainProvider.getGrepIncludes(); - - assertThat(grepIncludes).isNull(); - } }