Skip to content

Commit

Permalink
Add optional attribute compile_files_without_includes to cc_toolchain…
Browse files Browse the repository at this point in the history
…. This

attribute is meant to be used with C++ toolchains that can use input discovery
to figure out which includes are actually necessary.

RELNOTES: None.
PiperOrigin-RevId: 212241018
  • Loading branch information
Googler authored and Copybara-Service committed Sep 10, 2018
1 parent e6db655 commit 3008794
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ public ConfiguredTarget create(RuleContext ruleContext)
.getProvider(FileProvider.class).getFilesToBuild();
final NestedSet<Artifact> crosstoolMiddleman = getFiles(ruleContext, "all_files");
final NestedSet<Artifact> compile = getFiles(ruleContext, "compiler_files");
final NestedSet<Artifact> compileWithoutIncludes =
getOptionalFiles(ruleContext, "compiler_files_without_includes");
final NestedSet<Artifact> strip = getFiles(ruleContext, "strip_files");
final NestedSet<Artifact> objcopy = getFiles(ruleContext, "objcopy_files");
final NestedSet<Artifact> as = getOptionalFiles(ruleContext, "as_files");
Expand Down Expand Up @@ -560,6 +562,7 @@ public ConfiguredTarget create(RuleContext ruleContext)
crosstool,
fullInputsForCrosstool(ruleContext, crosstoolMiddleman),
compile,
compileWithoutIncludes,
strip,
objcopy,
as,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,32 @@ public final class CcToolchainProvider extends ToolchainInfo implements CcToolch
/* cppConfiguration= */ null,
/* toolchainInfo= */ null,
/* crosstoolTopPathFragment= */ null,
/* crosstool= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* crosstoolMiddleman= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* compile= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* strip= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* objCopy= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* as= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* ar= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* link= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* crosstool= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* crosstoolMiddleman= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* compile= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* compileWithoutIncludes= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* strip= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* objCopy= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* as= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* ar= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* link= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* interfaceSoBuilder= */ null,
/* dwp= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* coverage= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* libcLink= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* staticRuntimeLinkInputs= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* dwp= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* coverage= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* libcLink= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* staticRuntimeLinkInputs= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* staticRuntimeLinkMiddleman= */ null,
/* dynamicRuntimeLinkInputs= */ NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER),
/* dynamicRuntimeLinkInputs= */ NestedSetBuilder.emptySet(Order.STABLE_ORDER),
/* dynamicRuntimeLinkMiddleman= */ null,
/* dynamicRuntimeSolibDir= */ PathFragment.EMPTY_FRAGMENT,
CcCompilationContext.EMPTY,
/* supportsParamFiles= */ false,
/* supportsHeaderParsing= */ false,
CcToolchainVariables.EMPTY,
/* builtinIncludeFiles= */ ImmutableList.<Artifact>of(),
/* builtinIncludeFiles= */ ImmutableList.of(),
/* coverageEnvironment= */ NestedSetBuilder.emptySet(Order.COMPILE_ORDER),
/* linkDynamicLibraryTool= */ null,
/* builtInIncludeDirectories= */ ImmutableList.<PathFragment>of(),
/* builtInIncludeDirectories= */ ImmutableList.of(),
/* sysroot= */ null,
FdoMode.OFF,
/* fdoProvider= */ null,
Expand All @@ -92,6 +93,7 @@ public final class CcToolchainProvider extends ToolchainInfo implements CcToolch
private final NestedSet<Artifact> crosstool;
private final NestedSet<Artifact> crosstoolMiddleman;
private final NestedSet<Artifact> compile;
private final NestedSet<Artifact> compileWithoutIncludes;
private final NestedSet<Artifact> strip;
private final NestedSet<Artifact> objCopy;
private final NestedSet<Artifact> as;
Expand Down Expand Up @@ -136,6 +138,7 @@ public CcToolchainProvider(
NestedSet<Artifact> crosstool,
NestedSet<Artifact> crosstoolMiddleman,
NestedSet<Artifact> compile,
NestedSet<Artifact> compileWithoutIncludes,
NestedSet<Artifact> strip,
NestedSet<Artifact> objCopy,
NestedSet<Artifact> as,
Expand Down Expand Up @@ -171,6 +174,7 @@ public CcToolchainProvider(
this.crosstool = Preconditions.checkNotNull(crosstool);
this.crosstoolMiddleman = Preconditions.checkNotNull(crosstoolMiddleman);
this.compile = Preconditions.checkNotNull(compile);
this.compileWithoutIncludes = Preconditions.checkNotNull(compileWithoutIncludes);
this.strip = Preconditions.checkNotNull(strip);
this.objCopy = Preconditions.checkNotNull(objCopy);
this.as = Preconditions.checkNotNull(as);
Expand Down Expand Up @@ -366,6 +370,18 @@ public NestedSet<Artifact> getCompile() {
return compile;
}

/**
* Returns the files necessary for compilation excluding headers, assuming that included files
* will be discovered by input discovery. If the toolchain does not provide this fileset, falls
* back to {@link #getCompile()}.
*/
public NestedSet<Artifact> getCompileWithoutIncludes() {
if (compileWithoutIncludes.isEmpty()) {
return getCompile();
}
return compileWithoutIncludes;
}

/**
* Returns the files necessary for a 'strip' invocation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
.legacyAllowAnyFileType()
.cfg(HostTransition.INSTANCE)
.mandatory())
.add(
attr("compiler_files_without_includes", LABEL)
.legacyAllowAnyFileType()
.cfg(HostTransition.INSTANCE))
.add(
attr("strip_files", LABEL)
.legacyAllowAnyFileType()
Expand Down

0 comments on commit 3008794

Please sign in to comment.