Skip to content

Commit ecab72e

Browse files
djasper-ghcopybara-github
authored andcommitted
Code cleanup: Move decision on whether or not to generate a .d file into a
single location. No functional changes intended. RELNOTES: None. PiperOrigin-RevId: 332911614
1 parent 36ee499 commit ecab72e

File tree

2 files changed

+17
-52
lines changed

2 files changed

+17
-52
lines changed

src/main/java/com/google/devtools/build/lib/rules/cpp/CcCompilationHelper.java

Lines changed: 13 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,8 +1349,7 @@ private CcCompilationOutputs createCcCompileActions(Consumer<String> errorReport
13491349
if (!sourceArtifact.isTreeArtifact()) {
13501350
switch (source.getType()) {
13511351
case HEADER:
1352-
createHeaderAction(
1353-
sourceLabel, outputName, result, builder, isGenerateDotdFile(sourceArtifact));
1352+
createHeaderAction(sourceLabel, outputName, result, builder);
13541353
break;
13551354
default:
13561355
createSourceAction(
@@ -1372,8 +1371,7 @@ private CcCompilationOutputs createCcCompileActions(Consumer<String> errorReport
13721371
// output (since it isn't generating a native object with debug
13731372
// info). In that case the LtoBackendAction will generate the dwo.
13741373
ccToolchain.shouldCreatePerObjectDebugInfo(featureConfiguration, cppConfiguration),
1375-
bitcodeOutput,
1376-
isGenerateDotdFile(sourceArtifact));
1374+
bitcodeOutput);
13771375
break;
13781376
}
13791377
} else {
@@ -1649,8 +1647,7 @@ private void createModuleCodegenAction(
16491647
ruleErrorConsumer,
16501648
label,
16511649
ArtifactCategory.OBJECT_FILE,
1652-
outputName,
1653-
isGenerateDotdFile(module));
1650+
outputName);
16541651
PathFragment ccRelativeName = module.getRootRelativePath();
16551652

16561653
String gcnoFileName =
@@ -1700,18 +1697,11 @@ private void createModuleCodegenAction(
17001697
}
17011698
}
17021699

1703-
/** Returns true if Dotd file should be generated. */
1704-
private boolean isGenerateDotdFile(Artifact sourceArtifact) {
1705-
return CppFileTypes.headerDiscoveryRequired(sourceArtifact)
1706-
&& !featureConfiguration.isEnabled(CppRuleClasses.PARSE_SHOWINCLUDES);
1707-
}
1708-
17091700
private void createHeaderAction(
17101701
Label sourceLabel,
17111702
String outputName,
17121703
CcCompilationOutputs.Builder result,
1713-
CppCompileActionBuilder builder,
1714-
boolean generateDotd)
1704+
CppCompileActionBuilder builder)
17151705
throws RuleErrorException {
17161706
String outputNameBase =
17171707
CppHelper.getArtifactNameForCategory(
@@ -1723,8 +1713,7 @@ private void createHeaderAction(
17231713
ruleErrorConsumer,
17241714
label,
17251715
ArtifactCategory.PROCESSED_HEADER,
1726-
outputNameBase,
1727-
generateDotd)
1716+
outputNameBase)
17281717
// If we generate pic actions, we prefer the header actions to use the pic artifacts.
17291718
.setPicMode(generatePicAction);
17301719
builder.setVariables(
@@ -1768,8 +1757,7 @@ private Collection<Artifact> createModuleAction(
17681757
/* addObject= */ false,
17691758
/* enableCoverage= */ false,
17701759
/* generateDwo= */ false,
1771-
/* bitcodeOutput= */ false,
1772-
isGenerateDotdFile(moduleMapArtifact));
1760+
/* bitcodeOutput= */ false);
17731761
}
17741762

17751763
private Collection<Artifact> createSourceAction(
@@ -1783,8 +1771,7 @@ private Collection<Artifact> createSourceAction(
17831771
boolean addObject,
17841772
boolean enableCoverage,
17851773
boolean generateDwo,
1786-
boolean bitcodeOutput,
1787-
boolean generateDotd)
1774+
boolean bitcodeOutput)
17881775
throws RuleErrorException {
17891776
ImmutableList.Builder<Artifact> directOutputs = new ImmutableList.Builder<>();
17901777
PathFragment ccRelativeName = sourceArtifact.getRootRelativePath();
@@ -1795,8 +1782,7 @@ private Collection<Artifact> createSourceAction(
17951782
String picOutputBase =
17961783
CppHelper.getArtifactNameForCategory(
17971784
ruleErrorConsumer, ccToolchain, ArtifactCategory.PIC_FILE, outputName);
1798-
CppCompileActionBuilder picBuilder =
1799-
copyAsPicBuilder(builder, picOutputBase, outputCategory, generateDotd);
1785+
CppCompileActionBuilder picBuilder = copyAsPicBuilder(builder, picOutputBase, outputCategory);
18001786
String gcnoFileName =
18011787
CppHelper.getArtifactNameForCategory(
18021788
ruleErrorConsumer, ccToolchain, ArtifactCategory.COVERAGE_DATA_FILE, picOutputBase);
@@ -1830,7 +1816,6 @@ private Collection<Artifact> createSourceAction(
18301816
outputName,
18311817
picBuilder,
18321818
/* usePic= */ true,
1833-
/* generateDotd= */ generateDotd,
18341819
ccRelativeName));
18351820

18361821
picBuilder.setGcnoFile(gcnoFile);
@@ -1865,12 +1850,7 @@ private Collection<Artifact> createSourceAction(
18651850
ruleErrorConsumer, ccToolchain, outputCategory, outputName),
18661851
configuration);
18671852
builder.setOutputs(
1868-
actionConstructionContext,
1869-
ruleErrorConsumer,
1870-
label,
1871-
outputCategory,
1872-
outputName,
1873-
generateDotd);
1853+
actionConstructionContext, ruleErrorConsumer, label, outputCategory, outputName);
18741854
String gcnoFileName =
18751855
CppHelper.getArtifactNameForCategory(
18761856
ruleErrorConsumer, ccToolchain, ArtifactCategory.COVERAGE_DATA_FILE, outputName);
@@ -1905,7 +1885,6 @@ private Collection<Artifact> createSourceAction(
19051885
outputName,
19061886
builder,
19071887
/* usePic= */ false,
1908-
generateDotd,
19091888
ccRelativeName));
19101889

19111890
builder.setGcnoFile(gcnoFile);
@@ -1938,21 +1917,13 @@ private Collection<Artifact> createSourceAction(
19381917
* changing output and dotd file names.
19391918
*/
19401919
private CppCompileActionBuilder copyAsPicBuilder(
1941-
CppCompileActionBuilder builder,
1942-
String outputName,
1943-
ArtifactCategory outputCategory,
1944-
boolean generateDotd)
1920+
CppCompileActionBuilder builder, String outputName, ArtifactCategory outputCategory)
19451921
throws RuleErrorException {
19461922
CppCompileActionBuilder picBuilder = new CppCompileActionBuilder(builder);
19471923
picBuilder
19481924
.setPicMode(true)
19491925
.setOutputs(
1950-
actionConstructionContext,
1951-
ruleErrorConsumer,
1952-
label,
1953-
outputCategory,
1954-
outputName,
1955-
generateDotd);
1926+
actionConstructionContext, ruleErrorConsumer, label, outputCategory, outputName);
19561927

19571928
return picBuilder;
19581929
}
@@ -2029,7 +2000,6 @@ private ImmutableList<Artifact> createTempsActions(
20292000
String outputName,
20302001
CppCompileActionBuilder builder,
20312002
boolean usePic,
2032-
boolean generateDotd,
20332003
PathFragment ccRelativeName)
20342004
throws RuleErrorException {
20352005
if (!cppConfiguration.getSaveTemps()) {
@@ -2051,12 +2021,7 @@ private ImmutableList<Artifact> createTempsActions(
20512021

20522022
CppCompileActionBuilder dBuilder = new CppCompileActionBuilder(builder);
20532023
dBuilder.setOutputs(
2054-
actionConstructionContext,
2055-
ruleErrorConsumer,
2056-
label,
2057-
category,
2058-
outputArtifactNameBase,
2059-
generateDotd);
2024+
actionConstructionContext, ruleErrorConsumer, label, category, outputArtifactNameBase);
20602025
dBuilder.setVariables(
20612026
setupCompileBuildVariables(
20622027
dBuilder,
@@ -2082,8 +2047,7 @@ private ImmutableList<Artifact> createTempsActions(
20822047
ruleErrorConsumer,
20832048
label,
20842049
ArtifactCategory.GENERATED_ASSEMBLY,
2085-
outputArtifactNameBase,
2086-
generateDotd);
2050+
outputArtifactNameBase);
20872051
sdBuilder.setVariables(
20882052
setupCompileBuildVariables(
20892053
sdBuilder,

src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileActionBuilder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,7 @@ public CppCompileActionBuilder setOutputs(
431431
RuleErrorConsumer ruleErrorConsumer,
432432
Label label,
433433
ArtifactCategory outputCategory,
434-
String outputName,
435-
boolean generateDotd)
434+
String outputName)
436435
throws RuleErrorException {
437436
this.outputFile =
438437
CppHelper.getCompileOutputArtifact(
@@ -441,7 +440,9 @@ public CppCompileActionBuilder setOutputs(
441440
CppHelper.getArtifactNameForCategory(
442441
ruleErrorConsumer, ccToolchain, outputCategory, outputName),
443442
configuration);
444-
if (generateDotd && !useHeaderModules()) {
443+
if (CppFileTypes.headerDiscoveryRequired(sourceFile)
444+
&& !useHeaderModules()
445+
&& !featureConfiguration.isEnabled(CppRuleClasses.PARSE_SHOWINCLUDES)) {
445446
String dotdFileName =
446447
CppHelper.getDotdFileName(ruleErrorConsumer, ccToolchain, outputCategory, outputName);
447448
dotdFile =

0 commit comments

Comments
 (0)