summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2025-02-05 21:19:24 +0000
committer Ivan Lozano <ivanlozano@google.com> 2025-02-06 06:16:45 -0800
commitcf7c1322a38653e68b69a25309fe445b88c13b42 (patch)
treea43132e238668568bd17a5ce73081f7d5e4c87c1
parent8ef256d5b311db8b3eac6775d846062c8b907548 (diff)
rust: Use libprofile-clang-extras_ndk for SDK cov
Bug: 203478530 Test: m & m rust Change-Id: I902cfb761794debf52e6443c44c409593c389292
-rw-r--r--rust/coverage.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/rust/coverage.go b/rust/coverage.go
index ae95e46b1..798b21d78 100644
--- a/rust/coverage.go
+++ b/rust/coverage.go
@@ -16,12 +16,12 @@ package rust
import (
"android/soong/android"
+
"github.com/google/blueprint"
"android/soong/cc"
)
-var CovLibraryName = "libprofile-clang-extras"
var ProfilerBuiltins = "libprofiler_builtins.rust_sysroot"
// Add '%c' to default specifier after we resolve http://b/210012154
@@ -38,12 +38,20 @@ func (cov *coverage) props() []interface{} {
return []interface{}{&cov.Properties}
}
+func getClangProfileLibraryName(ctx ModuleContextIntf) string {
+ if ctx.RustModule().UseSdk() {
+ return "libprofile-clang-extras_ndk"
+ } else {
+ return "libprofile-clang-extras"
+ }
+}
+
func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps {
if cov.Properties.NeedCoverageVariant {
if ctx.Device() {
ctx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
- }, cc.CoverageDepTag, CovLibraryName)
+ }, cc.CoverageDepTag, getClangProfileLibraryName(ctx))
}
// no_std modules are missing libprofiler_builtins which provides coverage, so we need to add it as a dependency.
@@ -66,7 +74,7 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags
flags.RustFlags = append(flags.RustFlags,
"-C instrument-coverage", "-g")
if ctx.Device() {
- m := ctx.GetDirectDepProxyWithTag(CovLibraryName, cc.CoverageDepTag)
+ m := ctx.GetDirectDepProxyWithTag(getClangProfileLibraryName(ctx), cc.CoverageDepTag)
coverage := android.OtherModuleProviderOrDefault(ctx, m, cc.LinkableInfoProvider)
flags.LinkFlags = append(flags.LinkFlags,
profileInstrFlag, "-g", coverage.OutputFile.Path().String(), "-Wl,--wrap,open")