Skip to content

Commit

Permalink
Add automatic exec groups to cc_common.compile
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 516486514
Change-Id: I05844398289f1a57ce38bba68383065c1c192d9a
  • Loading branch information
kotlaja authored and copybara-github committed Mar 14, 2023
1 parent bc83389 commit 6d004a3
Show file tree
Hide file tree
Showing 4 changed files with 344 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,6 @@ private CcCompilationOutputs createCcCompileActions() throws RuleErrorException
CppCompileActionBuilder builder = initializeCompileAction(sourceArtifact);

builder
.setSemantics(semantics)
.addMandatoryInputs(additionalCompilationInputs)
.addAdditionalIncludeScanningRoots(additionalIncludeScanningRoots);

Expand Down Expand Up @@ -1447,7 +1446,6 @@ private CcCompilationOutputs createCcCompileActions() throws RuleErrorException
}
CppCompileActionBuilder builder = initializeCompileAction(artifact);
builder
.setSemantics(semantics)
.addMandatoryInputs(additionalCompilationInputs)
.addAdditionalIncludeScanningRoots(additionalIncludeScanningRoots);

Expand Down Expand Up @@ -1670,7 +1668,7 @@ private static String toPathString(Artifact a) {
*/
private CppCompileActionBuilder initializeCompileAction(Artifact sourceArtifact) {
return new CppCompileActionBuilder(
actionConstructionContext, grepIncludes, ccToolchain, configuration)
actionConstructionContext, grepIncludes, ccToolchain, configuration, semantics)
.setSourceFile(sourceArtifact)
.setCcCompilationContext(ccCompilationContext)
.setCoptsFilter(coptsFilter)
Expand All @@ -1687,7 +1685,6 @@ private void createModuleCodegenAction(
boolean pic = module.getFilename().contains(".pic.");

CppCompileActionBuilder builder = initializeCompileAction(module);
builder.setSemantics(semantics);
builder.setPicMode(pic);
builder.setOutputs(
actionConstructionContext,
Expand Down Expand Up @@ -1788,7 +1785,6 @@ private ImmutableList<Artifact> createModuleAction(
Artifact moduleMapArtifact = cppModuleMap.getArtifact();
CppCompileActionBuilder builder = initializeCompileAction(moduleMapArtifact);

builder.setSemantics(semantics);
Label label = Label.parseCanonicalUnchecked(cppModuleMap.getName());

// A header module compile action is just like a normal compile action, but:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,16 @@ public CppCompileActionBuilder(
ActionConstructionContext actionConstructionContext,
@Nullable Artifact grepIncludes,
CcToolchainProvider ccToolchain,
BuildConfigurationValue configuration) {
this.owner = actionConstructionContext.getActionOwner();
BuildConfigurationValue configuration,
CppSemantics cppSemantics) {

ActionOwner actionOwner = null;
if (actionConstructionContext instanceof RuleContext
&& ((RuleContext) actionConstructionContext).useAutoExecGroups()) {
actionOwner = actionConstructionContext.getActionOwner(cppSemantics.getCppToolchainType());
}

this.owner = actionOwner == null ? actionConstructionContext.getActionOwner() : actionOwner;
this.shareable = false;
this.configuration = configuration;
this.cppConfiguration = configuration.getFragment(CppConfiguration.class);
Expand All @@ -102,6 +110,7 @@ public CppCompileActionBuilder(
this.ccToolchain = ccToolchain;
this.builtinIncludeDirectories = ccToolchain.getBuiltInIncludeDirectories();
this.grepIncludes = grepIncludes;
this.cppSemantics = cppSemantics;
}

/**
Expand Down Expand Up @@ -572,13 +581,6 @@ public CppCompileActionBuilder setPicMode(boolean usePic) {
return this;
}

/** Sets the CppSemantics for this compile. */
@CanIgnoreReturnValue
public CppCompileActionBuilder setSemantics(CppSemantics semantics) {
this.cppSemantics = semantics;
return this;
}

@CanIgnoreReturnValue
public CppCompileActionBuilder setShareable(boolean shareable) {
this.shareable = shareable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ public static CppCompileAction createLinkstampCompileAction(
CppSemantics semantics) {
CppCompileActionBuilder builder =
new CppCompileActionBuilder(
actionConstructionContext, grepIncludes, ccToolchainProvider, configuration)
actionConstructionContext,
grepIncludes,
ccToolchainProvider,
configuration,
semantics)
.addMandatoryInputs(compilationInputs)
.setVariables(
getVariables(
Expand All @@ -83,7 +87,6 @@ public static CppCompileAction createLinkstampCompileAction(
semantics))
.setFeatureConfiguration(featureConfiguration)
.setSourceFile(sourceFile)
.setSemantics(semantics)
.setOutputs(outputFile, /* dotdFile= */ null, /* diagnosticsFile= */ null)
.setInputsForInvalidation(inputsForInvalidation)
.setBuiltinIncludeFiles(buildInfoHeaderArtifacts)
Expand Down
Loading

0 comments on commit 6d004a3

Please sign in to comment.