diff options
author | 2015-09-25 23:30:38 +0000 | |
---|---|---|
committer | 2015-09-28 11:39:47 +0000 | |
commit | 8d437d138b280d770aa4dec15939e9b0e6e4a915 (patch) | |
tree | 0df1be5e9e73902b2e2c7b0c74b1c4e5cd7a1d17 /src/main/java | |
parent | 7b51b1a32d35ab3a056475e6e0c0765c32cd3c99 (diff) |
Give a nice error message on double included files in objc rules.
--
MOS_MIGRATED_REVID=103986912
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java index 8c5a0b6c1c..60b90f2560 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java @@ -169,6 +169,10 @@ public final class CompilationSupport { static final String FILE_IN_SRCS_AND_HDRS_WARNING_FORMAT = "File '%s' is in both srcs and hdrs."; + @VisibleForTesting + static final String FILE_IN_SRCS_AND_NON_ARC_SRCS_ERROR_FORMAT = + "File '%s' is present in both srcs and non_arc_srcs which is forbidden."; + /** * Returns information about the given rule's compilation artifacts. */ @@ -1048,17 +1052,28 @@ public final class CompilationSupport { "includes", String.format(ABSOLUTE_INCLUDES_PATH_FORMAT, absoluteInclude)); } - // Check for overlap between srcs and hdrs. if (ruleContext.attributes().has("srcs", BuildType.LABEL_LIST)) { Set<Artifact> hdrsSet = new HashSet<>(attributes.hdrs()); Set<Artifact> srcsSet = new HashSet<>(ruleContext.getPrerequisiteArtifacts("srcs", Mode.TARGET).list()); + + // Check for overlap between srcs and hdrs. for (Artifact header : Sets.intersection(hdrsSet, srcsSet)) { String path = header.getRootRelativePath().toString(); ruleContext.attributeWarning( "srcs", String.format(FILE_IN_SRCS_AND_HDRS_WARNING_FORMAT, path)); } + + // Check for overlap between srcs and non_arc_srcs. + Set<Artifact> nonArcSrcsSet = + new HashSet<>(ruleContext.getPrerequisiteArtifacts("non_arc_srcs", Mode.TARGET).list()); + for (Artifact conflict : Sets.intersection(nonArcSrcsSet, srcsSet)) { + String path = conflict.getRootRelativePath().toString(); + ruleContext.attributeError( + "srcs", String.format(FILE_IN_SRCS_AND_NON_ARC_SRCS_ERROR_FORMAT, path)); + } } + return this; } |