diff options
author | Googler <noreply@google.com> | 2016-07-13 15:04:25 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2016-07-14 11:12:00 +0000 |
commit | fb605ae0d6c7c1fe37dc36a208abae5b3643aa16 (patch) | |
tree | 8e412495405e9ef90b054dec98b925e72c1b0610 /src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java | |
parent | 8bdae763c99f8cd8dd4063b060935ded5a93fb7f (diff) |
Properly support interaction of pre-grepped source files and LIPO even in the
presence of interface dependencies.
The problem is that pre-grepped source files can be pulled in through CppCompileActions only available via lipoScannables. In this case, we need to make those pre-grepped source files inputs of the action or else we cannot be sure that the corresponding action is actually executed.
--
MOS_MIGRATED_REVID=127317557
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java | 20 |
1 files changed, 18 insertions, 2 deletions
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 a9083eeb25..b4f1e9aaf4 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 @@ -261,7 +261,8 @@ public class CppCompileAction extends AbstractAction ruleContext, mandatoryInputs, context.getTransitiveCompilationPrerequisites(), - optionalSourceFile), + optionalSourceFile, + lipoScannables), CollectionUtils.asListWithoutNulls( outputFile, (dotdFile == null ? null : dotdFile.artifact()), gcnoFile, dwoFile)); this.configuration = configuration; @@ -333,7 +334,8 @@ public class CppCompileAction extends AbstractAction RuleContext ruleContext, NestedSet<Artifact> mandatoryInputs, Set<Artifact> prerequisites, - Artifact optionalSourceFile) { + Artifact optionalSourceFile, + Iterable<IncludeScannable> lipoScannables) { NestedSetBuilder<Artifact> builder = NestedSetBuilder.stableOrder(); if (optionalSourceFile != null) { builder.add(optionalSourceFile); @@ -341,6 +343,20 @@ public class CppCompileAction extends AbstractAction builder.addAll(prerequisites); builder.addAll(CppHelper.getToolchain(ruleContext).getBuiltinIncludeFiles()); builder.addTransitive(mandatoryInputs); + if (lipoScannables != null && lipoScannables.iterator().hasNext()) { + // We need to add "legal generated scanner files" coming through LIPO scannables here. These + // usually contain pre-grepped source files, i.e. files just containing the #include lines + // extracted from generated files. With LIPO, some of these files can be accessed, even though + // there is no direct dependency on them. Adding the artifacts as inputs to this compile + // action ensures that the action generating them is actually executed. + for (IncludeScannable lipoScannable : lipoScannables) { + for (Artifact value : lipoScannable.getLegalGeneratedScannerFileMap().values()) { + if (value != null) { + builder.add(value); + } + } + } + } return builder.build(); } |