Loading rust/androidmk.go +0 −7 Original line number Diff line number Diff line Loading @@ -82,9 +82,6 @@ func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.Andr } ret.Class = "EXECUTABLES" ret.ExtraEntries = append(ret.ExtraEntries, func(entries *android.AndroidMkEntries) { entries.SetOptionalPath("LOCAL_PREBUILT_COVERAGE_ARCHIVE", binary.coverageOutputZipFile) }) } func (test *testDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) { Loading Loading @@ -117,10 +114,6 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An if library.distFile.Valid() { ret.DistFiles = android.MakeDefaultDistFiles(library.distFile.Path()) } ret.ExtraEntries = append(ret.ExtraEntries, func(entries *android.AndroidMkEntries) { entries.SetOptionalPath("LOCAL_PREBUILT_COVERAGE_ARCHIVE", library.coverageOutputZipFile) }) } func (procMacro *procMacroDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) { Loading rust/binary.go +1 −16 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps Path flags.RustFlags = append(flags.RustFlags, deps.depFlags...) flags.LinkFlags = append(flags.LinkFlags, deps.linkObjects...) outputs := TransformSrcToBinary(ctx, srcPath, deps, flags, outputFile, deps.linkDirs) TransformSrcToBinary(ctx, srcPath, deps, flags, outputFile, deps.linkDirs) if binary.stripper.NeedsStrip(ctx) { strippedOutputFile := android.PathForModuleOut(ctx, "stripped", fileName) Loading @@ -129,24 +129,9 @@ func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps Path binary.strippedOutputFile = android.OptionalPathForPath(strippedOutputFile) } binary.coverageFile = outputs.coverageFile var coverageFiles android.Paths if outputs.coverageFile != nil { coverageFiles = append(coverageFiles, binary.coverageFile) } if len(deps.coverageFiles) > 0 { coverageFiles = append(coverageFiles, deps.coverageFiles...) } binary.coverageOutputZipFile = TransformCoverageFilesToZip(ctx, coverageFiles, binary.getStem(ctx)) return outputFile } func (binary *binaryDecorator) coverageOutputZipPath() android.OptionalPath { return binary.coverageOutputZipFile } func (binary *binaryDecorator) autoDep(ctx BaseModuleContext) autoDep { // Binaries default to dylib dependencies for device, rlib for host. if binary.preferRlib() { Loading rust/builder.go +1 −43 Original line number Diff line number Diff line Loading @@ -19,10 +19,8 @@ import ( "strings" "github.com/google/blueprint" "github.com/google/blueprint/pathtools" "android/soong/android" "android/soong/cc" "android/soong/rust/config" ) Loading Loading @@ -77,7 +75,6 @@ var ( type buildOutput struct { outputFile android.Path coverageFile android.Path } func init() { Loading Loading @@ -195,27 +192,6 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl implicits = append(implicits, deps.CrtBegin.Path(), deps.CrtEnd.Path()) } if flags.Coverage { var gcnoFile android.WritablePath // Provide consistency with cc gcda output, see cc/builder.go init() profileEmitArg := strings.TrimPrefix(cc.PwdPrefix(), "PWD=") + "/" if outputFile.Ext() != "" { // rustc seems to split the output filename at the first '.' when determining the gcno filename // so we need to do the same here. gcnoFile = android.PathForModuleOut(ctx, strings.Split(outputFile.Base(), ".")[0]+".gcno") rustcFlags = append(rustcFlags, "-Z profile-emit="+profileEmitArg+android.PathForModuleOut( ctx, pathtools.ReplaceExtension(outputFile.Base(), "gcda")).String()) } else { gcnoFile = android.PathForModuleOut(ctx, outputFile.Base()+".gcno") rustcFlags = append(rustcFlags, "-Z profile-emit="+profileEmitArg+android.PathForModuleOut( ctx, outputFile.Base()+".gcda").String()) } implicitOutputs = append(implicitOutputs, gcnoFile) output.coverageFile = gcnoFile } if len(deps.SrcDeps) > 0 { genSubDir := "out/" moduleGenDir := android.PathForModuleOut(ctx, genSubDir) Loading Loading @@ -292,21 +268,3 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl return output } func TransformCoverageFilesToZip(ctx ModuleContext, covFiles android.Paths, baseName string) android.OptionalPath { if len(covFiles) > 0 { outputFile := android.PathForModuleOut(ctx, baseName+".zip") ctx.Build(pctx, android.BuildParams{ Rule: zip, Description: "zip " + outputFile.Base(), Inputs: covFiles, Output: outputFile, }) return android.OptionalPathForPath(outputFile) } return android.OptionalPath{} } rust/compiler.go +2 −4 Original line number Diff line number Diff line Loading @@ -137,7 +137,6 @@ type BaseCompilerProperties struct { type baseCompiler struct { Properties BaseCompilerProperties coverageFile android.Path //rustc generates a single gcno file // Install related dir string Loading @@ -148,7 +147,6 @@ type baseCompiler struct { location installLocation sanitize *sanitize coverageOutputZipFile android.OptionalPath distFile android.OptionalPath // Stripped output file. If Valid(), this file will be installed instead of outputFile. strippedOutputFile android.OptionalPath Loading rust/coverage.go +5 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,9 @@ import ( "android/soong/cc" ) var CovLibraryName = "libprofile-extras" var CovLibraryName = "libprofile-clang-extras" const profileInstrFlag = "-fprofile-instr-generate=/data/misc/trace/clang-%p-%m.profraw" type coverage struct { Properties cc.CoverageProperties Loading Loading @@ -53,9 +55,9 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags flags.Coverage = true coverage := ctx.GetDirectDepWithTag(CovLibraryName, cc.CoverageDepTag).(cc.LinkableInterface) flags.RustFlags = append(flags.RustFlags, "-Z profile", "-g", "-C opt-level=0", "-C link-dead-code") "-Z instrument-coverage", "-g", "-C link-dead-code") flags.LinkFlags = append(flags.LinkFlags, "--coverage", "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,getenv") profileInstrFlag, "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,open") deps.StaticLibs = append(deps.StaticLibs, coverage.OutputFile().Path()) } Loading Loading
rust/androidmk.go +0 −7 Original line number Diff line number Diff line Loading @@ -82,9 +82,6 @@ func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.Andr } ret.Class = "EXECUTABLES" ret.ExtraEntries = append(ret.ExtraEntries, func(entries *android.AndroidMkEntries) { entries.SetOptionalPath("LOCAL_PREBUILT_COVERAGE_ARCHIVE", binary.coverageOutputZipFile) }) } func (test *testDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) { Loading Loading @@ -117,10 +114,6 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An if library.distFile.Valid() { ret.DistFiles = android.MakeDefaultDistFiles(library.distFile.Path()) } ret.ExtraEntries = append(ret.ExtraEntries, func(entries *android.AndroidMkEntries) { entries.SetOptionalPath("LOCAL_PREBUILT_COVERAGE_ARCHIVE", library.coverageOutputZipFile) }) } func (procMacro *procMacroDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkEntries) { Loading
rust/binary.go +1 −16 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps Path flags.RustFlags = append(flags.RustFlags, deps.depFlags...) flags.LinkFlags = append(flags.LinkFlags, deps.linkObjects...) outputs := TransformSrcToBinary(ctx, srcPath, deps, flags, outputFile, deps.linkDirs) TransformSrcToBinary(ctx, srcPath, deps, flags, outputFile, deps.linkDirs) if binary.stripper.NeedsStrip(ctx) { strippedOutputFile := android.PathForModuleOut(ctx, "stripped", fileName) Loading @@ -129,24 +129,9 @@ func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps Path binary.strippedOutputFile = android.OptionalPathForPath(strippedOutputFile) } binary.coverageFile = outputs.coverageFile var coverageFiles android.Paths if outputs.coverageFile != nil { coverageFiles = append(coverageFiles, binary.coverageFile) } if len(deps.coverageFiles) > 0 { coverageFiles = append(coverageFiles, deps.coverageFiles...) } binary.coverageOutputZipFile = TransformCoverageFilesToZip(ctx, coverageFiles, binary.getStem(ctx)) return outputFile } func (binary *binaryDecorator) coverageOutputZipPath() android.OptionalPath { return binary.coverageOutputZipFile } func (binary *binaryDecorator) autoDep(ctx BaseModuleContext) autoDep { // Binaries default to dylib dependencies for device, rlib for host. if binary.preferRlib() { Loading
rust/builder.go +1 −43 Original line number Diff line number Diff line Loading @@ -19,10 +19,8 @@ import ( "strings" "github.com/google/blueprint" "github.com/google/blueprint/pathtools" "android/soong/android" "android/soong/cc" "android/soong/rust/config" ) Loading Loading @@ -77,7 +75,6 @@ var ( type buildOutput struct { outputFile android.Path coverageFile android.Path } func init() { Loading Loading @@ -195,27 +192,6 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl implicits = append(implicits, deps.CrtBegin.Path(), deps.CrtEnd.Path()) } if flags.Coverage { var gcnoFile android.WritablePath // Provide consistency with cc gcda output, see cc/builder.go init() profileEmitArg := strings.TrimPrefix(cc.PwdPrefix(), "PWD=") + "/" if outputFile.Ext() != "" { // rustc seems to split the output filename at the first '.' when determining the gcno filename // so we need to do the same here. gcnoFile = android.PathForModuleOut(ctx, strings.Split(outputFile.Base(), ".")[0]+".gcno") rustcFlags = append(rustcFlags, "-Z profile-emit="+profileEmitArg+android.PathForModuleOut( ctx, pathtools.ReplaceExtension(outputFile.Base(), "gcda")).String()) } else { gcnoFile = android.PathForModuleOut(ctx, outputFile.Base()+".gcno") rustcFlags = append(rustcFlags, "-Z profile-emit="+profileEmitArg+android.PathForModuleOut( ctx, outputFile.Base()+".gcda").String()) } implicitOutputs = append(implicitOutputs, gcnoFile) output.coverageFile = gcnoFile } if len(deps.SrcDeps) > 0 { genSubDir := "out/" moduleGenDir := android.PathForModuleOut(ctx, genSubDir) Loading Loading @@ -292,21 +268,3 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl return output } func TransformCoverageFilesToZip(ctx ModuleContext, covFiles android.Paths, baseName string) android.OptionalPath { if len(covFiles) > 0 { outputFile := android.PathForModuleOut(ctx, baseName+".zip") ctx.Build(pctx, android.BuildParams{ Rule: zip, Description: "zip " + outputFile.Base(), Inputs: covFiles, Output: outputFile, }) return android.OptionalPathForPath(outputFile) } return android.OptionalPath{} }
rust/compiler.go +2 −4 Original line number Diff line number Diff line Loading @@ -137,7 +137,6 @@ type BaseCompilerProperties struct { type baseCompiler struct { Properties BaseCompilerProperties coverageFile android.Path //rustc generates a single gcno file // Install related dir string Loading @@ -148,7 +147,6 @@ type baseCompiler struct { location installLocation sanitize *sanitize coverageOutputZipFile android.OptionalPath distFile android.OptionalPath // Stripped output file. If Valid(), this file will be installed instead of outputFile. strippedOutputFile android.OptionalPath Loading
rust/coverage.go +5 −3 Original line number Diff line number Diff line Loading @@ -20,7 +20,9 @@ import ( "android/soong/cc" ) var CovLibraryName = "libprofile-extras" var CovLibraryName = "libprofile-clang-extras" const profileInstrFlag = "-fprofile-instr-generate=/data/misc/trace/clang-%p-%m.profraw" type coverage struct { Properties cc.CoverageProperties Loading Loading @@ -53,9 +55,9 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags flags.Coverage = true coverage := ctx.GetDirectDepWithTag(CovLibraryName, cc.CoverageDepTag).(cc.LinkableInterface) flags.RustFlags = append(flags.RustFlags, "-Z profile", "-g", "-C opt-level=0", "-C link-dead-code") "-Z instrument-coverage", "-g", "-C link-dead-code") flags.LinkFlags = append(flags.LinkFlags, "--coverage", "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,getenv") profileInstrFlag, "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,open") deps.StaticLibs = append(deps.StaticLibs, coverage.OutputFile().Path()) } Loading