Loading cc/cc.go +2 −1 Original line number Diff line number Diff line Loading @@ -368,6 +368,7 @@ var ( ndkLateStubDepTag = dependencyTag{name: "ndk late stub", library: true} vndkExtDepTag = dependencyTag{name: "vndk extends", library: true} runtimeDepTag = dependencyTag{name: "runtime lib"} coverageDepTag = dependencyTag{name: "coverage"} ) // Module contains the properties and members used by all C/C++ module types, and implements Loading Loading @@ -974,7 +975,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { flags = c.sanitize.flags(ctx, flags) } if c.coverage != nil { flags = c.coverage.flags(ctx, flags) flags, deps = c.coverage.flags(ctx, flags, deps) } if c.lto != nil { flags = c.lto.flags(ctx, flags) Loading cc/coverage.go +24 −22 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package cc import ( "strconv" "github.com/google/blueprint" "android/soong/android" ) Loading @@ -41,30 +43,28 @@ func (cov *coverage) props() []interface{} { return []interface{}{&cov.Properties} } func (cov *coverage) deps(ctx BaseModuleContext, deps Deps) Deps { if cov.Properties.NeedCoverageBuild { // Link libprofile-extras/libprofile-extras_ndk when coverage // variant is required. This is a no-op unless coverage is // actually enabled during linking, when // '-uinit_profile_extras' is added (in flags()) to force the // setup code in libprofile-extras be linked into the // binary/library. // // We cannot narrow it further to only the 'cov' variant since // the mutator hasn't run (and we don't have the 'cov' variant // yet). if !ctx.useSdk() { deps.LateStaticLibs = append(deps.LateStaticLibs, "libprofile-extras") func getProfileLibraryName(ctx ModuleContextIntf) string { // This function should only ever be called for a cc.Module, so the // following statement should always succeed. if ctx.useSdk() { return "libprofile-extras_ndk" } else { deps.LateStaticLibs = append(deps.LateStaticLibs, "libprofile-extras_ndk") return "libprofile-extras" } } func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps { if cov.Properties.NeedCoverageVariant { ctx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, coverageDepTag, getProfileLibraryName(ctx)) } return deps } func (cov *coverage) flags(ctx ModuleContext, flags Flags) Flags { func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) { if !ctx.DeviceConfig().NativeCoverageEnabled() { return flags return flags, deps } if cov.Properties.CoverageEnabled { Loading Loading @@ -114,11 +114,13 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags) Flags { if cov.linkCoverage { flags.LdFlags = append(flags.LdFlags, "--coverage") // Force linking of constructor/setup code in libprofile-extras flags.LdFlags = append(flags.LdFlags, "-uinit_profile_extras") coverage := ctx.GetDirectDepWithTag(getProfileLibraryName(ctx), coverageDepTag).(*Module) deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path()) flags.LdFlags = append(flags.LdFlags, "-Wl,--wrap,getenv") } return flags return flags, deps } func (cov *coverage) begin(ctx BaseModuleContext) { Loading Loading
cc/cc.go +2 −1 Original line number Diff line number Diff line Loading @@ -368,6 +368,7 @@ var ( ndkLateStubDepTag = dependencyTag{name: "ndk late stub", library: true} vndkExtDepTag = dependencyTag{name: "vndk extends", library: true} runtimeDepTag = dependencyTag{name: "runtime lib"} coverageDepTag = dependencyTag{name: "coverage"} ) // Module contains the properties and members used by all C/C++ module types, and implements Loading Loading @@ -974,7 +975,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { flags = c.sanitize.flags(ctx, flags) } if c.coverage != nil { flags = c.coverage.flags(ctx, flags) flags, deps = c.coverage.flags(ctx, flags, deps) } if c.lto != nil { flags = c.lto.flags(ctx, flags) Loading
cc/coverage.go +24 −22 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package cc import ( "strconv" "github.com/google/blueprint" "android/soong/android" ) Loading @@ -41,30 +43,28 @@ func (cov *coverage) props() []interface{} { return []interface{}{&cov.Properties} } func (cov *coverage) deps(ctx BaseModuleContext, deps Deps) Deps { if cov.Properties.NeedCoverageBuild { // Link libprofile-extras/libprofile-extras_ndk when coverage // variant is required. This is a no-op unless coverage is // actually enabled during linking, when // '-uinit_profile_extras' is added (in flags()) to force the // setup code in libprofile-extras be linked into the // binary/library. // // We cannot narrow it further to only the 'cov' variant since // the mutator hasn't run (and we don't have the 'cov' variant // yet). if !ctx.useSdk() { deps.LateStaticLibs = append(deps.LateStaticLibs, "libprofile-extras") func getProfileLibraryName(ctx ModuleContextIntf) string { // This function should only ever be called for a cc.Module, so the // following statement should always succeed. if ctx.useSdk() { return "libprofile-extras_ndk" } else { deps.LateStaticLibs = append(deps.LateStaticLibs, "libprofile-extras_ndk") return "libprofile-extras" } } func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps { if cov.Properties.NeedCoverageVariant { ctx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, }, coverageDepTag, getProfileLibraryName(ctx)) } return deps } func (cov *coverage) flags(ctx ModuleContext, flags Flags) Flags { func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) { if !ctx.DeviceConfig().NativeCoverageEnabled() { return flags return flags, deps } if cov.Properties.CoverageEnabled { Loading Loading @@ -114,11 +114,13 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags) Flags { if cov.linkCoverage { flags.LdFlags = append(flags.LdFlags, "--coverage") // Force linking of constructor/setup code in libprofile-extras flags.LdFlags = append(flags.LdFlags, "-uinit_profile_extras") coverage := ctx.GetDirectDepWithTag(getProfileLibraryName(ctx), coverageDepTag).(*Module) deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path()) flags.LdFlags = append(flags.LdFlags, "-Wl,--wrap,getenv") } return flags return flags, deps } func (cov *coverage) begin(ctx BaseModuleContext) { Loading