aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2016-08-10 16:05:00 +0000
committerGravatar Yue Gan <yueg@google.com>2016-08-11 09:13:55 +0000
commitc511cb53595cd724900fff026c45b2702950f115 (patch)
tree773690cb882af09415150d134201bfa3490739ed /src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java
parent92fbef0f816107a70e934624043169b414fef892 (diff)
Store non-code inputs to link actions separately.
This is a re-submission of commit 99de0d07574f808fee36826289cb1f5c83e3b3e0 (rolled back in commit eff8b365c172b7e904ac6f7bba0c893fed7c91a8) and a few tweaks: - The fix for the bug that caused the rollback (see line 888 in CppModel.java -- we now use addNonCodeInputs() instead of addObjectFiles() to pass in the processed header tokens) - A few extra assertions - A test case - The re-submission of the parts of commit 603b540bbcd7414cd3e2c0b92c1c8985b035e41b that were also rolled back as collateral damage. The bug report didn't contain a precise reproduction, but the bug is trivial enough that I'm comfortable with things this way. -- MOS_MIGRATED_REVID=129872117
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java
index 6432b70bdf..c53b049153 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java
@@ -23,7 +23,6 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.MiddlemanFactory;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
-import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
@@ -662,13 +661,20 @@ public final class CppCompilationContext implements TransitiveInfoProvider {
public Builder addCompilationPrerequisites(Iterable<Artifact> prerequisites) {
// LIPO collector must not add compilation prerequisites in order to avoid
// the creation of a middleman action.
+ for (Artifact prerequisite : prerequisites) {
+ String basename = prerequisite.getFilename();
+ Preconditions.checkArgument(!Link.OBJECT_FILETYPES.matches(basename));
+ Preconditions.checkArgument(!Link.ARCHIVE_LIBRARY_FILETYPES.matches(basename));
+ Preconditions.checkArgument(!Link.SHARED_LIBRARY_FILETYPES.matches(basename));
+ }
Iterables.addAll(compilationPrerequisites, prerequisites);
return this;
}
/**
* Add a single include directory to be added with "-I". It can be either
- * relative to the exec root (see {@link BuildConfiguration#getExecRoot}) or
+ * relative to the exec root (see
+ * {@link com.google.devtools.build.lib.analysis.BlazeDirectories#getExecRoot}) or
* absolute. Before it is stored, the include directory is normalized.
*/
public Builder addIncludeDir(PathFragment includeDir) {
@@ -679,8 +685,8 @@ public final class CppCompilationContext implements TransitiveInfoProvider {
/**
* Add multiple include directories to be added with "-I". These can be
* either relative to the exec root (see {@link
- * BuildConfiguration#getExecRoot}) or absolute. The entries are normalized
- * before they are stored.
+ * com.google.devtools.build.lib.analysis.BlazeDirectories#getExecRoot}) or absolute. The
+ * entries are normalized before they are stored.
*/
public Builder addIncludeDirs(Iterable<PathFragment> includeDirs) {
for (PathFragment includeDir : includeDirs) {
@@ -692,8 +698,8 @@ public final class CppCompilationContext implements TransitiveInfoProvider {
/**
* Add a single include directory to be added with "-iquote". It can be
* either relative to the exec root (see {@link
- * BuildConfiguration#getExecRoot}) or absolute. Before it is stored, the
- * include directory is normalized.
+ * com.google.devtools.build.lib.analysis.BlazeDirectories#getExecRoot}) or absolute. Before it
+ * is stored, the include directory is normalized.
*/
public Builder addQuoteIncludeDir(PathFragment quoteIncludeDir) {
quoteIncludeDirs.add(quoteIncludeDir.normalize());
@@ -703,8 +709,8 @@ public final class CppCompilationContext implements TransitiveInfoProvider {
/**
* Add a single include directory to be added with "-isystem". It can be
* either relative to the exec root (see {@link
- * BuildConfiguration#getExecRoot}) or absolute. Before it is stored, the
- * include directory is normalized.
+ * com.google.devtools.build.lib.analysis.BlazeDirectories#getExecRoot}) or absolute. Before it
+ * is stored, the include directory is normalized.
*/
public Builder addSystemIncludeDir(PathFragment systemIncludeDir) {
systemIncludeDirs.add(systemIncludeDir.normalize());