diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-02-04 02:07:31 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-02-04 02:07:31 +0000 |
commit | 30977d507dd15b7df366b467f4012a3c75a25775 (patch) | |
tree | 0ff3043948e709a20f30e856413bb0a1aab72d7d | |
parent | 93567935fd147a7a0086fd94594ccf113953bfd8 (diff) | |
parent | 8d8639d5f506d2058949a517c170d277203da566 (diff) | |
download | build_soong-30977d507dd15b7df366b467f4012a3c75a25775.tar.gz build_soong-30977d507dd15b7df366b467f4012a3c75a25775.tar.bz2 build_soong-30977d507dd15b7df366b467f4012a3c75a25775.zip |
Snap for 6179254 from 8d8639d5f506d2058949a517c170d277203da566 to qt-qpr3-release
Change-Id: Id9cdbaf3ab69ff34fa860bb9e6ae660571a27820
-rw-r--r-- | cc/binary.go | 2 | ||||
-rw-r--r-- | cc/builder.go | 23 | ||||
-rw-r--r-- | cc/cc.go | 3 | ||||
-rw-r--r-- | cc/coverage.go | 46 | ||||
-rw-r--r-- | cc/library.go | 4 |
5 files changed, 48 insertions, 30 deletions
diff --git a/cc/binary.go b/cc/binary.go index aa5b2794..1b749146 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -388,7 +388,7 @@ func (binary *binaryDecorator) link(ctx ModuleContext, objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...) objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...) - binary.coverageOutputFile = TransformCoverageFilesToLib(ctx, objs, builderFlags, binary.getStem(ctx)) + binary.coverageOutputFile = TransformCoverageFilesToZip(ctx, objs, binary.getStem(ctx)) // Need to determine symlinks early since some targets (ie APEX) need this // information but will not call 'install' diff --git a/cc/builder.go b/cc/builder.go index fc5400c7..a9ee4e92 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -227,6 +227,14 @@ var ( blueprint.RuleParams{ Command: "gunzip -c $in > $out", }) + + zip = pctx.AndroidStaticRule("zip", + blueprint.RuleParams{ + Command: "cat $out.rsp | tr ' ' '\\n' | tr -d \\' | sort -u > ${out}.tmp && ${SoongZipCmd} -o ${out} -C $$OUT_DIR -l ${out}.tmp", + CommandDeps: []string{"${SoongZipCmd}"}, + Rspfile: "$out.rsp", + RspfileContent: "$in", + }) ) func init() { @@ -239,6 +247,8 @@ func init() { // Darwin doesn't have /proc pctx.StaticVariable("relPwd", "") } + + pctx.HostBinToolVariable("SoongZipCmd", "soong_zip") } type builderFlags struct { @@ -867,13 +877,18 @@ func TransformDarwinStrip(ctx android.ModuleContext, inputFile android.Path, }) } -func TransformCoverageFilesToLib(ctx android.ModuleContext, - inputs Objects, flags builderFlags, baseName string) android.OptionalPath { +func TransformCoverageFilesToZip(ctx android.ModuleContext, + inputs Objects, baseName string) android.OptionalPath { if len(inputs.coverageFiles) > 0 { - outputFile := android.PathForModuleOut(ctx, baseName+".gcnodir") + outputFile := android.PathForModuleOut(ctx, baseName+".zip") - TransformObjToStaticLib(ctx, inputs.coverageFiles, flags, outputFile, nil) + ctx.Build(pctx, android.BuildParams{ + Rule: zip, + Description: "zip " + outputFile.Base(), + Inputs: inputs.coverageFiles, + Output: outputFile, + }) return android.OptionalPathForPath(outputFile) } @@ -360,6 +360,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 @@ -955,7 +956,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) diff --git a/cc/coverage.go b/cc/coverage.go index 9dc7f06b..0de0c1c9 100644 --- a/cc/coverage.go +++ b/cc/coverage.go @@ -17,6 +17,8 @@ package cc import ( "strconv" + "github.com/google/blueprint" + "android/soong/android" ) @@ -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") - } else { - deps.LateStaticLibs = append(deps.LateStaticLibs, "libprofile-extras_ndk") - } +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 { + 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 { @@ -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) { diff --git a/cc/library.go b/cc/library.go index d8eb5b4e..71d8170e 100644 --- a/cc/library.go +++ b/cc/library.go @@ -629,7 +629,7 @@ func (library *libraryDecorator) linkStatic(ctx ModuleContext, TransformObjToStaticLib(ctx, library.objects.objFiles, builderFlags, outputFile, objs.tidyFiles) - library.coverageOutputFile = TransformCoverageFilesToLib(ctx, library.objects, builderFlags, + library.coverageOutputFile = TransformCoverageFilesToZip(ctx, library.objects, ctx.ModuleName()+library.MutatedProperties.VariantName) library.wholeStaticMissingDeps = ctx.GetMissingDependencies() @@ -741,7 +741,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext, objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.StaticLibObjs.sAbiDumpFiles...) objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.WholeStaticLibObjs.sAbiDumpFiles...) - library.coverageOutputFile = TransformCoverageFilesToLib(ctx, objs, builderFlags, library.getLibName(ctx)) + library.coverageOutputFile = TransformCoverageFilesToZip(ctx, objs, library.getLibName(ctx)) library.linkSAbiDumpFiles(ctx, objs, fileName, ret) return ret |