Also generate api lists based on symbol files for cc_library rule during build time.
Test: build/soong/soong_ui.bash --make-mode SKIP_ABI_CHECKS=true TARGET_PRODUCT=aosp_cf_x86_phone TARGET_BUILD_VARIANT=userdebug droid dist DIST_DIR=/usr/local/google/home/sophiez/my_dist_dir EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true CLANG_COVERAGE=true SKIP_BOOT_JARS_CHECK=true Change-Id: Ic857c14c5c258b8f4d150cc71ce9eabce33d7d54
This commit is contained in:
@@ -294,6 +294,9 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries
|
||||
if library.buildStubs() {
|
||||
entries.SetBool("LOCAL_NO_NOTICE_FILE", true)
|
||||
}
|
||||
if library.apiListCoverageXmlPath.String() != "" {
|
||||
entries.SetString("SOONG_CC_API_XML", "$(SOONG_CC_API_XML) "+library.apiListCoverageXmlPath.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
// If a library providing a stub is included in an APEX, the private APIs of the library
|
||||
|
@@ -244,3 +244,19 @@ func coverageMutator(mctx android.BottomUpMutatorContext) {
|
||||
m[1].(Coverage).EnableCoverageIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
func parseSymbolFileForAPICoverage(ctx ModuleContext, symbolFile string) android.ModuleOutPath {
|
||||
apiLevelsJson := android.GetApiLevelsJson(ctx)
|
||||
symbolFilePath := android.PathForModuleSrc(ctx, symbolFile)
|
||||
outputFile := ctx.baseModuleName() + ".xml"
|
||||
parsedApiCoveragePath := android.PathForModuleOut(ctx, outputFile)
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
rule.Command().
|
||||
BuiltTool("ndk_api_coverage_parser").
|
||||
Input(symbolFilePath).
|
||||
Output(parsedApiCoveragePath).
|
||||
Implicit(apiLevelsJson).
|
||||
FlagWithArg("--api-map ", apiLevelsJson.String())
|
||||
rule.Build("native_library_api_list", "Generate native API list based on symbol files for coverage measurement")
|
||||
return parsedApiCoveragePath
|
||||
}
|
||||
|
@@ -550,6 +550,8 @@ type libraryDecorator struct {
|
||||
*baseInstaller
|
||||
|
||||
collectedSnapshotHeaders android.Paths
|
||||
|
||||
apiListCoverageXmlPath android.ModuleOutPath
|
||||
}
|
||||
|
||||
type ccLibraryBazelHandler struct {
|
||||
@@ -965,6 +967,12 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
|
||||
objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc)
|
||||
library.versionScriptPath = android.OptionalPathForPath(
|
||||
nativeAbiResult.versionScript)
|
||||
|
||||
// Parse symbol file to get API list for coverage
|
||||
if library.stubsVersion() == "current" && ctx.PrimaryArch() {
|
||||
library.apiListCoverageXmlPath = parseSymbolFileForAPICoverage(ctx, symbolFile)
|
||||
}
|
||||
|
||||
return objs
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,6 @@ import (
|
||||
|
||||
func init() {
|
||||
pctx.HostBinToolVariable("ndkStubGenerator", "ndkstubgen")
|
||||
pctx.HostBinToolVariable("ndk_api_coverage_parser", "ndk_api_coverage_parser")
|
||||
pctx.HostBinToolVariable("abidiff", "abidiff")
|
||||
pctx.HostBinToolVariable("abitidy", "abitidy")
|
||||
pctx.HostBinToolVariable("abidw", "abidw")
|
||||
@@ -43,12 +42,6 @@ var (
|
||||
CommandDeps: []string{"$ndkStubGenerator"},
|
||||
}, "arch", "apiLevel", "apiMap", "flags")
|
||||
|
||||
parseNdkApiRule = pctx.AndroidStaticRule("parseNdkApiRule",
|
||||
blueprint.RuleParams{
|
||||
Command: "$ndk_api_coverage_parser $in $out --api-map $apiMap",
|
||||
CommandDeps: []string{"$ndk_api_coverage_parser"},
|
||||
}, "apiMap")
|
||||
|
||||
abidw = pctx.AndroidStaticRule("abidw",
|
||||
blueprint.RuleParams{
|
||||
Command: "$abidw --type-id-style hash --no-corpus-path " +
|
||||
@@ -276,24 +269,6 @@ func compileStubLibrary(ctx ModuleContext, flags Flags, src android.Path) Object
|
||||
android.Paths{src}, nil, nil)
|
||||
}
|
||||
|
||||
func parseSymbolFileForCoverage(ctx ModuleContext, symbolFile string) android.ModuleOutPath {
|
||||
apiLevelsJson := android.GetApiLevelsJson(ctx)
|
||||
symbolFilePath := android.PathForModuleSrc(ctx, symbolFile)
|
||||
outputFileName := strings.Split(symbolFilePath.Base(), ".")[0]
|
||||
parsedApiCoveragePath := android.PathForModuleOut(ctx, outputFileName+".xml")
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: parseNdkApiRule,
|
||||
Description: "parse ndk api symbol file for api coverage: " + symbolFilePath.Rel(),
|
||||
Outputs: []android.WritablePath{parsedApiCoveragePath},
|
||||
Input: symbolFilePath,
|
||||
Implicits: []android.Path{apiLevelsJson},
|
||||
Args: map[string]string{
|
||||
"apiMap": apiLevelsJson.String(),
|
||||
},
|
||||
})
|
||||
return parsedApiCoveragePath
|
||||
}
|
||||
|
||||
func (this *stubDecorator) findImplementationLibrary(ctx ModuleContext) android.Path {
|
||||
dep := ctx.GetDirectDepWithTag(strings.TrimSuffix(ctx.ModuleName(), ndkLibrarySuffix),
|
||||
stubImplementation)
|
||||
@@ -454,7 +429,7 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O
|
||||
}
|
||||
}
|
||||
if c.apiLevel.IsCurrent() && ctx.PrimaryArch() {
|
||||
c.parsedCoverageXmlPath = parseSymbolFileForCoverage(ctx, symbolFile)
|
||||
c.parsedCoverageXmlPath = parseSymbolFileForAPICoverage(ctx, symbolFile)
|
||||
}
|
||||
return objs
|
||||
}
|
||||
|
Reference in New Issue
Block a user