Support cc code coverage for mixed build
Bug: 231322627
Test: Manual tests and unit tests
Change-Id: I786042af0d612192c54c3572f63a86a47174a242
diff --git a/cc/bp2build.go b/cc/bp2build.go
index ba02b7e..cbb2056 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -55,6 +55,8 @@
Enabled bazel.BoolAttribute
+ Native_coverage bazel.BoolAttribute
+
sdkAttributes
}
@@ -567,10 +569,15 @@
}
}
}
-
compilerAttrs.convertStlProps(ctx, module)
(&linkerAttrs).convertStripProps(ctx, module)
+ if module.coverage != nil && module.coverage.Properties.Native_coverage != nil &&
+ !Bool(module.coverage.Properties.Native_coverage) {
+ // Native_coverage is arch neutral
+ (&linkerAttrs).features.Append(bazel.MakeStringListAttribute([]string{"-coverage"}))
+ }
+
productVariableProps := android.ProductVariableProperties(ctx)
(&compilerAttrs).convertProductVariables(ctx, productVariableProps)