aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Chris Parsons <cparsons@google.com>2015-09-09 17:32:25 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2015-09-11 08:45:41 +0000
commit1d619c2d0c46a9b8962707736f096d37e59bc10a (patch)
treea0e980a96f7d90abb0b23432ed1897f7c408ff03 /src/main/java/com/google/devtools/build
parent8fa0ddcc9165b77f989e5c7be04fbff21189c085 (diff)
Remove expectation of clang in producing .gcno of assembly files for instrumentation/coverage purposes.
This is easier by grouping together all assembly files in a file set, thus justifying a simultaneous cleanup of the redundant usage of the assembler-with-cpp flag -- MOS_MIGRATED_REVID=102671848
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommon.java6
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java16
3 files changed, 17 insertions, 10 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 9fa16756ab..05eaa44702 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
@@ -205,7 +205,7 @@ public final class CompilationSupport {
ImmutableList.Builder<String> coverageFlags = new ImmutableList.Builder<>();
ImmutableList.Builder<Artifact> gcnoFiles = new ImmutableList.Builder<>();
ImmutableList.Builder<Artifact> additionalInputs = new ImmutableList.Builder<>();
- if (isCodeCoverageEnabled) {
+ if (isCodeCoverageEnabled && ObjcRuleClasses.isInstrumentable(sourceFile)) {
coverageFlags.addAll(CLANG_COVERAGE_FLAGS);
gcnoFiles.add(intermediateArtifacts.gcnoFile(sourceFile));
}
@@ -213,9 +213,6 @@ public final class CompilationSupport {
if (ObjcRuleClasses.CPP_SOURCES.matches(sourceFile.getExecPath())) {
commandLine.add("-stdlib=libc++");
}
- if (ObjcRuleClasses.PREPROCESSED_ASSEMBLY_SOURCES.matches(sourceFile.getExecPath())) {
- commandLine.add("-x").add("assembler-with-cpp");
- }
if (compilationArtifacts.hasSwiftSources()) {
// Add the directory that contains merged TargetName-Swift.h header to search path, in case
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 3a2ce46dd0..7c2c1d9a44 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
@@ -461,8 +461,10 @@ public final class ObjcCommon {
if (configuration.isCodeCoverageEnabled()
&& filter.isIncluded(context.getLabel().toString())) {
for (Artifact source : allSources) {
- objcProvider.add(INSTRUMENTED_SOURCE, source);
- objcProvider.add(GCNO, intermediateArtifacts.gcnoFile(source));
+ if (ObjcRuleClasses.isInstrumentable(source)) {
+ objcProvider.add(INSTRUMENTED_SOURCE, source);
+ objcProvider.add(GCNO, intermediateArtifacts.gcnoFile(source));
+ }
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
index 7760a42dbf..ec8cf2eb01 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java
@@ -142,6 +142,14 @@ public class ObjcRuleClasses {
return ruleContext.getFragment(ObjcConfiguration.class);
}
+ /**
+ * Returns true if the source file can be instrumented for coverage.
+ */
+ public static boolean isInstrumentable(Artifact sourceArtifact) {
+ return !ASSEMBLY_SOURCES.matches(sourceArtifact.getFilename());
+ }
+
+
@VisibleForTesting
static final Iterable<SdkFramework> AUTOMATIC_SDK_FRAMEWORKS = ImmutableList.of(
new SdkFramework("Foundation"), new SdkFramework("UIKit"));
@@ -318,9 +326,9 @@ public class ObjcRuleClasses {
*/
static final FileType CPP_SOURCES = FileType.of(".cc", ".cpp", ".mm", ".cxx", ".C");
- private static final FileType NON_CPP_SOURCES = FileType.of(".m", ".c", ".s", ".asm");
+ private static final FileType NON_CPP_SOURCES = FileType.of(".m", ".c");
- static final FileType PREPROCESSED_ASSEMBLY_SOURCES = FileType.of(".S");
+ static final FileType ASSEMBLY_SOURCES = FileType.of(".s", ".S", ".asm");
static final FileType SWIFT_SOURCES = FileType.of(".swift");
@@ -333,13 +341,13 @@ public class ObjcRuleClasses {
* Files allowed in the srcs attribute. This includes private headers.
*/
static final FileTypeSet SRCS_TYPE = FileTypeSet.of(NON_CPP_SOURCES, CPP_SOURCES,
- PREPROCESSED_ASSEMBLY_SOURCES, SWIFT_SOURCES, HEADERS);
+ ASSEMBLY_SOURCES, SWIFT_SOURCES, HEADERS);
/**
* Files that should actually be compiled.
*/
static final FileTypeSet COMPILABLE_SRCS_TYPE = FileTypeSet.of(NON_CPP_SOURCES, CPP_SOURCES,
- PREPROCESSED_ASSEMBLY_SOURCES, SWIFT_SOURCES);
+ ASSEMBLY_SOURCES, SWIFT_SOURCES);
static final FileTypeSet NON_ARC_SRCS_TYPE = FileTypeSet.of(FileType.of(".m", ".mm"));