aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
authorGravatar Cal Peyser <cpeyser@google.com>2017-02-07 19:50:33 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-02-08 15:51:20 +0000
commite3c4d32bc4d209df56562250c1bbcfd2622bfc0c (patch)
tree78585b37c6241602d21ad47137e1fa9d5fb82072 /src/main/java/com/google
parentd11d510c571b10787856395709f9ad945ca70bb2 (diff)
Directory headers are filtered out of header inputs to objc compilation.
-- PiperOrigin-RevId: 146813606 MOS_MIGRATED_REVID=146813606
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompilationContext.java16
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java20
2 files changed, 28 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 c72388779b..e33c655b66 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
@@ -548,20 +548,28 @@ public final class CppCompilationContext implements TransitiveInfoProvider {
/**
* Adds a header that has been declared in the {@code src} or {@code headers attribute}. The
* header will also be added to the compilation prerequisites.
+ *
+ * <p>Filters out fileset directory artifacts, which are not valid inputs.
*/
public Builder addDeclaredIncludeSrc(Artifact header) {
- declaredIncludeSrcs.add(header);
- compilationPrerequisites.add(header);
+ if (!header.isFileset()) {
+ declaredIncludeSrcs.add(header);
+ compilationPrerequisites.add(header);
+ }
return this;
}
/**
* Adds multiple headers that have been declared in the {@code src} or {@code headers
* attribute}. The headers will also be added to the compilation prerequisites.
+ *
+ * <p>Filters out fileset directory artifacts, which are not valid inputs.
*/
public Builder addDeclaredIncludeSrcs(Collection<Artifact> declaredIncludeSrcs) {
- this.declaredIncludeSrcs.addAll(declaredIncludeSrcs);
- return addCompilationPrerequisites(declaredIncludeSrcs);
+ for (Artifact source : declaredIncludeSrcs) {
+ addDeclaredIncludeSrc(source);
+ }
+ return this;
}
public Builder addModularHdrs(Collection<Artifact> headers) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java
index 2da5511875..9a47734630 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java
@@ -90,6 +90,18 @@ import java.util.Set;
// classes. Make sure to distinguish rule output (providers, runfiles, ...) from intermediate,
// rule-internal information. Any provider created by a rule should not be read, only published.
public final class ObjcCommon {
+
+ /** Filters fileset artifacts out of a group of artifacts. */
+ public static Iterable<Artifact> filterFileset(Iterable<Artifact> artifacts) {
+ ImmutableList.Builder<Artifact> inputs = ImmutableList.<Artifact>builder();
+ for (Artifact artifact : artifacts) {
+ if (!artifact.isFileset()) {
+ inputs.add(artifact);
+ }
+ }
+ return inputs.build();
+ }
+
/**
* Provides a way to access attributes that are common to all resources rules.
*/
@@ -416,7 +428,7 @@ public final class ObjcCommon {
}
for (CppCompilationContext headerProvider : depCcHeaderProviders) {
- objcProvider.addTransitiveAndPropagate(HEADER, headerProvider.getDeclaredIncludeSrcs());
+ objcProvider.addAll(HEADER, filterFileset(headerProvider.getDeclaredIncludeSrcs()));
objcProvider.addAll(INCLUDE, headerProvider.getIncludeDirs());
// TODO(bazel-team): This pulls in stl via CppHelper.mergeToolchainDependentContext but
// probably shouldn't.
@@ -463,8 +475,8 @@ public final class ObjcCommon {
PathFragment.safePathStrings(attributes.sdkIncludes())),
TO_PATH_FRAGMENT);
objcProvider
- .addAll(HEADER, attributes.hdrs())
- .addAll(HEADER, attributes.textualHdrs())
+ .addAll(HEADER, filterFileset(attributes.hdrs()))
+ .addAll(HEADER, filterFileset(attributes.textualHdrs()))
.addAll(INCLUDE, attributes.headerSearchPaths(buildConfiguration.getGenfilesFragment()))
.addAll(INCLUDE, sdkIncludes)
.addAll(SDK_FRAMEWORK, attributes.sdkFrameworks())
@@ -512,7 +524,7 @@ public final class ObjcCommon {
// TODO(bazel-team): Add private headers to the provider when we have module maps to enforce
// them.
objcProvider
- .addAll(HEADER, artifacts.getAdditionalHdrs())
+ .addAll(HEADER, filterFileset(artifacts.getAdditionalHdrs()))
.addAll(LIBRARY, artifacts.getArchive().asSet())
.addAll(SOURCE, allSources);