aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules
diff options
context:
space:
mode:
authorGravatar cpeyser <cpeyser@google.com>2018-01-30 12:14:47 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-30 12:16:31 -0800
commit8ab921afbca692dc1ad5c60dd1a247ce4fe07dcb (patch)
tree7524427983f3b0d67e70d3cd284eeb1742c19951 /src/main/java/com/google/devtools/build/lib/rules
parent426ab9067374bfe5af033e22153507c3f38e7221 (diff)
Remove the CppConfiguration field from CppCompileAction. Making
CppCompileAction smaller improves serialization. PiperOrigin-RevId: 183871454
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLine.java20
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java14
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java6
4 files changed, 26 insertions, 20 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLine.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLine.java
index 3f82509a59..db52da2b72 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLine.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLine.java
@@ -36,9 +36,9 @@ public final class CompileCommandLine {
private final Artifact outputFile;
private final Predicate<String> coptsFilter;
private final FeatureConfiguration featureConfiguration;
+ private final PathFragment crosstoolTopPathFragment;
private final CcToolchainFeatures.Variables variables;
private final String actionName;
- private final CppConfiguration cppConfiguration;
private final DotdFile dotdFile;
private CompileCommandLine(
@@ -46,7 +46,7 @@ public final class CompileCommandLine {
Artifact outputFile,
Predicate<String> coptsFilter,
FeatureConfiguration featureConfiguration,
- CppConfiguration cppConfiguration,
+ PathFragment crosstoolTopPathFragment,
CcToolchainFeatures.Variables variables,
String actionName,
DotdFile dotdFile) {
@@ -54,7 +54,7 @@ public final class CompileCommandLine {
this.outputFile = Preconditions.checkNotNull(outputFile);
this.coptsFilter = coptsFilter;
this.featureConfiguration = Preconditions.checkNotNull(featureConfiguration);
- this.cppConfiguration = Preconditions.checkNotNull(cppConfiguration);
+ this.crosstoolTopPathFragment = crosstoolTopPathFragment;
this.variables = variables;
this.actionName = actionName;
this.dotdFile = isGenerateDotdFile(sourceFile) ? dotdFile : null;
@@ -82,7 +82,7 @@ public final class CompileCommandLine {
commandLine.add(
featureConfiguration
.getToolForAction(actionName)
- .getToolPath(cppConfiguration.getCrosstoolTopPathFragment())
+ .getToolPath(crosstoolTopPathFragment)
.getPathString());
// second: The compiler options.
@@ -176,10 +176,10 @@ public final class CompileCommandLine {
Artifact outputFile,
Predicate<String> coptsFilter,
String actionName,
- CppConfiguration cppConfiguration,
+ PathFragment crosstoolTopPathFragment,
DotdFile dotdFile) {
return new Builder(
- sourceFile, outputFile, coptsFilter, actionName, cppConfiguration, dotdFile);
+ sourceFile, outputFile, coptsFilter, actionName, crosstoolTopPathFragment, dotdFile);
}
/** A builder for a {@link CompileCommandLine}. */
@@ -190,7 +190,7 @@ public final class CompileCommandLine {
private FeatureConfiguration featureConfiguration;
private CcToolchainFeatures.Variables variables = Variables.EMPTY;
private final String actionName;
- private final CppConfiguration cppConfiguration;
+ private final PathFragment crosstoolTopPathFragment;
@Nullable private final DotdFile dotdFile;
public CompileCommandLine build() {
@@ -199,7 +199,7 @@ public final class CompileCommandLine {
Preconditions.checkNotNull(outputFile),
Preconditions.checkNotNull(coptsFilter),
Preconditions.checkNotNull(featureConfiguration),
- Preconditions.checkNotNull(cppConfiguration),
+ Preconditions.checkNotNull(crosstoolTopPathFragment),
Preconditions.checkNotNull(variables),
Preconditions.checkNotNull(actionName),
dotdFile);
@@ -210,13 +210,13 @@ public final class CompileCommandLine {
Artifact outputFile,
Predicate<String> coptsFilter,
String actionName,
- CppConfiguration cppConfiguration,
+ PathFragment crosstoolTopPathFragment,
DotdFile dotdFile) {
this.sourceFile = sourceFile;
this.outputFile = outputFile;
this.coptsFilter = coptsFilter;
this.actionName = actionName;
- this.cppConfiguration = cppConfiguration;
+ this.crosstoolTopPathFragment = crosstoolTopPathFragment;
this.dotdFile = dotdFile;
}
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 28a9a01bbe..d292ceb89e 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
@@ -177,6 +177,7 @@ public class CppCompileAction extends AbstractAction
private final boolean shouldPruneModules;
private final boolean usePic;
private final boolean useHeaderModules;
+ private final boolean isStrictSystemIncludes;
private final CppCompilationContext context;
private final Iterable<IncludeScannable> lipoScannables;
private final ImmutableList<Artifact> builtinIncludeFiles;
@@ -189,7 +190,6 @@ public class CppCompileAction extends AbstractAction
private final ImmutableMap<String, String> environment;
private final String actionName;
- @VisibleForTesting final CppConfiguration cppConfiguration;
private final FeatureConfiguration featureConfiguration;
protected final CppSemantics cppSemantics;
@@ -228,12 +228,14 @@ public class CppCompileAction extends AbstractAction
* @param owner the owner of the action, usually the configured target that emitted it
* @param allInputs the list of all action inputs.
* @param featureConfiguration TODO(bazel-team): Add parameter description.
+ * @param crosstoolTopPathFragment the path to the CROSSTOOL given in --crosstool_top
* @param variables TODO(bazel-team): Add parameter description.
* @param sourceFile the source file that should be compiled. {@code mandatoryInputs} must contain
* this file
* @param shouldScanIncludes a boolean indicating whether scanning of {@code sourceFile} is to be
* performed looking for inclusions.
* @param usePic TODO(bazel-team): Add parameter description.
+ * @param isStrictSystemIncludes should this compile action use strict system includes
* @param mandatoryInputs any additional files that need to be present for the compilation to
* succeed, can be empty but not null, for example, extra sources for FDO.
* @param outputFile the object file that is written as result of the compilation, or the fake
@@ -243,7 +245,6 @@ 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 cppConfiguration TODO(bazel-team): Add parameter description.
* @param context the compilation context
* @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
@@ -259,12 +260,14 @@ public class CppCompileAction extends AbstractAction
ActionOwner owner,
NestedSet<Artifact> allInputs,
FeatureConfiguration featureConfiguration,
+ PathFragment crosstoolTopPathFragment,
CcToolchainFeatures.Variables variables,
Artifact sourceFile,
boolean shouldScanIncludes,
boolean shouldPruneModules,
boolean usePic,
boolean useHeaderModules,
+ boolean isStrictSystemIncludes,
NestedSet<Artifact> mandatoryInputs,
ImmutableList<Artifact> builtinIncludeFiles,
NestedSet<Artifact> prunableInputs,
@@ -275,7 +278,6 @@ public class CppCompileAction extends AbstractAction
@Nullable Artifact ltoIndexingFile,
Artifact optionalSourceFile,
ImmutableMap<String, String> localShellEnvironment,
- CppConfiguration cppConfiguration,
CppCompilationContext context,
Predicate<String> coptsFilter,
Iterable<IncludeScannable> lipoScannables,
@@ -300,7 +302,6 @@ public class CppCompileAction extends AbstractAction
this.outputFile = Preconditions.checkNotNull(outputFile);
this.optionalSourceFile = optionalSourceFile;
this.context = context;
- this.cppConfiguration = cppConfiguration;
this.featureConfiguration = featureConfiguration;
// inputsKnown begins as the logical negation of shouldScanIncludes.
// When scanning includes, the inputs begin as not known, and become
@@ -312,6 +313,7 @@ public class CppCompileAction extends AbstractAction
Preconditions.checkArgument(!shouldPruneModules || shouldScanIncludes, this);
this.usePic = usePic;
this.useHeaderModules = useHeaderModules;
+ this.isStrictSystemIncludes = isStrictSystemIncludes;
this.discoversInputs = shouldScanIncludes || cppSemantics.needsDotdInputPruning();
this.compileCommandLine =
CompileCommandLine.builder(
@@ -319,7 +321,7 @@ public class CppCompileAction extends AbstractAction
outputFile,
coptsFilter,
actionName,
- cppConfiguration,
+ crosstoolTopPathFragment,
dotdFile)
.setFeatureConfiguration(featureConfiguration)
.setVariables(variables)
@@ -788,7 +790,7 @@ public class CppCompileAction extends AbstractAction
allowedIncludes.add(optionalSourceFile);
}
Iterable<PathFragment> ignoreDirs =
- cppConfiguration.isStrictSystemIncludes()
+ isStrictSystemIncludes
? getBuiltInIncludeDirectories()
: getValidationIgnoredDirs();
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 2cbeb94918..3d9a3d6c6f 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
@@ -361,12 +361,14 @@ public class CppCompileActionBuilder {
owner,
allInputs,
featureConfiguration,
+ cppConfiguration.getCrosstoolTopPathFragment(),
variables,
sourceFile,
shouldScanIncludes,
shouldPruneModules(),
usePic,
useHeaderModules,
+ cppConfiguration.isStrictSystemIncludes(),
realMandatoryInputs,
getBuiltinIncludeFiles(),
prunableInputs,
@@ -374,7 +376,6 @@ public class CppCompileActionBuilder {
tempOutputFile,
dotdFile,
localShellEnvironment,
- cppConfiguration,
context,
coptsFilter,
getLipoScannables(realMandatoryInputs),
@@ -387,12 +388,14 @@ public class CppCompileActionBuilder {
owner,
allInputs,
featureConfiguration,
+ cppConfiguration.getCrosstoolTopPathFragment(),
variables,
sourceFile,
shouldScanIncludes,
shouldPruneModules(),
usePic,
useHeaderModules,
+ cppConfiguration.isStrictSystemIncludes(),
realMandatoryInputs,
getBuiltinIncludeFiles(),
prunableInputs,
@@ -403,7 +406,6 @@ public class CppCompileActionBuilder {
ltoIndexingFile,
optionalSourceFile,
localShellEnvironment,
- cppConfiguration,
context,
coptsFilter,
getLipoScannables(realMandatoryInputs),
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 cedff8c935..0a497bd8cf 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
@@ -59,12 +59,14 @@ public class FakeCppCompileAction extends CppCompileAction {
ActionOwner owner,
NestedSet<Artifact> allInputs,
FeatureConfiguration featureConfiguration,
+ PathFragment crosstoolTopPathFragment,
CcToolchainFeatures.Variables variables,
Artifact sourceFile,
boolean shouldScanIncludes,
boolean shouldPruneModules,
boolean usePic,
boolean useHeaderModules,
+ boolean isStrictSystemIncludes,
NestedSet<Artifact> mandatoryInputs,
ImmutableList<Artifact> builtinIncludeFiles,
NestedSet<Artifact> prunableInputs,
@@ -72,7 +74,6 @@ public class FakeCppCompileAction extends CppCompileAction {
PathFragment tempOutputFile,
DotdFile dotdFile,
ImmutableMap<String, String> localShellEnvironment,
- CppConfiguration cppConfiguration,
CppCompilationContext context,
Predicate<String> nocopts,
Iterable<IncludeScannable> lipoScannables,
@@ -83,12 +84,14 @@ public class FakeCppCompileAction extends CppCompileAction {
owner,
allInputs,
featureConfiguration,
+ crosstoolTopPathFragment,
variables,
sourceFile,
shouldScanIncludes,
shouldPruneModules,
usePic,
useHeaderModules,
+ isStrictSystemIncludes,
mandatoryInputs,
builtinIncludeFiles,
prunableInputs,
@@ -99,7 +102,6 @@ public class FakeCppCompileAction extends CppCompileAction {
null,
null,
localShellEnvironment,
- cppConfiguration,
// We only allow inclusion of header files explicitly declared in
// "srcs", so we only use declaredIncludeSrcs, not declaredIncludeDirs.
// (Disallowing use of undeclared headers for cc_fake_binary is needed