From 63d687989dee282f79f8922c5365890a05cdad6e Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Tue, 30 Jun 2020 14:37:22 -0700 Subject: Add soong cc and java deps to general-tests dist Test: m SOONG_COLLECT_CC_DEPS=true SOONG_COLLECT_JAVA_DEPS=true dist general-tests and verify module_bp_java_deps.json and module_bp_cc_deps.json is in out/dist Test: m SOONG_COLLECT_CC_DEPS=true SOONG_COLLECT_JAVA_DEPS=true checkbuild dist general-tests Bug: 154845369 Merged-In: I683fe1d7e17f7abaab40206770d09db705493ffb Change-Id: I683fe1d7e17f7abaab40206770d09db705493ffb --- cc/ccdeps.go | 18 ++++++++++++++++++ java/jdeps.go | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/cc/ccdeps.go b/cc/ccdeps.go index 225405cb..b96d8b00 100644 --- a/cc/ccdeps.go +++ b/cc/ccdeps.go @@ -38,8 +38,11 @@ func ccDepsGeneratorSingleton() android.Singleton { } type ccdepsGeneratorSingleton struct { + outputPath android.Path } +var _ android.SingletonMakeVarsProvider = (*ccdepsGeneratorSingleton)(nil) + const ( // Environment variables used to control the behavior of this singleton. envVariableCollectCCDeps = "SOONG_COLLECT_CC_DEPS" @@ -110,6 +113,21 @@ func (c *ccdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCon if err != nil { ctx.Errorf(err.Error()) } + c.outputPath = ccfpath + + // This is necessary to satisfy the dangling rules check as this file is written by Soong rather than a rule. + ctx.Build(pctx, android.BuildParams{ + Rule: android.Touch, + Output: ccfpath, + }) +} + +func (c *ccdepsGeneratorSingleton) MakeVars(ctx android.MakeVarsContext) { + if c.outputPath == nil { + return + } + + ctx.DistForGoal("general-tests", c.outputPath) } func parseCompilerCCParameters(ctx android.SingletonContext, params []string) ccParameters { diff --git a/java/jdeps.go b/java/jdeps.go index 49e3de3c..4f636a59 100644 --- a/java/jdeps.go +++ b/java/jdeps.go @@ -34,8 +34,11 @@ func jDepsGeneratorSingleton() android.Singleton { } type jdepsGeneratorSingleton struct { + outputPath android.Path } +var _ android.SingletonMakeVarsProvider = (*jdepsGeneratorSingleton)(nil) + const ( // Environment variables used to modify behavior of this singleton. envVariableCollectJavaDeps = "SOONG_COLLECT_JAVA_DEPS" @@ -96,6 +99,21 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont if err != nil { ctx.Errorf(err.Error()) } + j.outputPath = jfpath + + // This is necessary to satisfy the dangling rules check as this file is written by Soong rather than a rule. + ctx.Build(pctx, android.BuildParams{ + Rule: android.Touch, + Output: jfpath, + }) +} + +func (j *jdepsGeneratorSingleton) MakeVars(ctx android.MakeVarsContext) { + if j.outputPath == nil { + return + } + + ctx.DistForGoal("general-tests", j.outputPath) } func createJsonFile(moduleInfos map[string]android.IdeInfo, jfpath android.WritablePath) error { -- cgit v1.2.3 From 03f3a9c1466f85105d3eba813a2b3ebbb96b402f Mon Sep 17 00:00:00 2001 From: Chris Gross Date: Wed, 1 Jul 2020 13:21:14 +0000 Subject: Use a default exclude filter for JaCoCo in Soong. Instrumented builds should exclude certain classes from instrumenation by default. (e.g. JaCoCo itself) Leverage the existing DefaultJacocoExclusionFilter to do this. Note: Two different default filters exist now (one for Make and one for Soong), as they have different wildcard rules. Test: EMMA_INSTRUMENT=true EMMA_INSTRUMENT_STATIC=true m -j32 TeleService and inspected the resulting temporary jar that was instrumented to confirm that anything from org/jacoco was excluded. Bug: 159748844 Change-Id: I5466b0a03957edfbe53971d5d1a7729fdb8337db Merged-In: I5466b0a03957edfbe53971d5d1a7729fdb8337db --- android/config.go | 2 +- java/config/config.go | 3 ++- java/config/makevars.go | 2 +- java/jacoco.go | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/android/config.go b/android/config.go index b6ef2684..3541f831 100644 --- a/android/config.go +++ b/android/config.go @@ -1053,7 +1053,7 @@ func (c *deviceConfig) SamplingPGO() bool { // represents any path. func (c *deviceConfig) JavaCoverageEnabledForPath(path string) bool { coverage := false - if c.config.productVariables.JavaCoveragePaths == nil || + if len(c.config.productVariables.JavaCoveragePaths) == 0 || InList("*", c.config.productVariables.JavaCoveragePaths) || HasAnyPrefix(path, c.config.productVariables.JavaCoveragePaths) { coverage = true diff --git a/java/config/config.go b/java/config/config.go index 337355d8..95add017 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -34,7 +34,8 @@ var ( DefaultLambdaStubsLibrary = "core-lambda-stubs" SdkLambdaStubsPath = "prebuilts/sdk/tools/core-lambda-stubs.jar" - DefaultJacocoExcludeFilter = []string{"org.junit.*", "org.jacoco.*", "org.mockito.*"} + DefaultMakeJacocoExcludeFilter = []string{"org.junit.*", "org.jacoco.*", "org.mockito.*"} + DefaultJacocoExcludeFilter = []string{"org.junit.**", "org.jacoco.**", "org.mockito.**"} InstrumentFrameworkModules = []string{ "framework", diff --git a/java/config/makevars.go b/java/config/makevars.go index 981a7363..b355fad8 100644 --- a/java/config/makevars.go +++ b/java/config/makevars.go @@ -64,7 +64,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) { ctx.Strict("ZIPSYNC", "${ZipSyncCmd}") ctx.Strict("JACOCO_CLI_JAR", "${JacocoCLIJar}") - ctx.Strict("DEFAULT_JACOCO_EXCLUDE_FILTER", strings.Join(DefaultJacocoExcludeFilter, ",")) + ctx.Strict("DEFAULT_JACOCO_EXCLUDE_FILTER", strings.Join(DefaultMakeJacocoExcludeFilter, ",")) ctx.Strict("EXTRACT_JAR_PACKAGES", "${ExtractJarPackagesCmd}") diff --git a/java/jacoco.go b/java/jacoco.go index bce9822f..9162161d 100644 --- a/java/jacoco.go +++ b/java/jacoco.go @@ -25,6 +25,7 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" + "android/soong/java/config" ) var ( @@ -76,7 +77,8 @@ func (j *Module) jacocoModuleToZipCommand(ctx android.ModuleContext) string { if err != nil { ctx.PropertyErrorf("jacoco.include_filter", "%s", err.Error()) } - excludes, err := jacocoFiltersToSpecs(j.properties.Jacoco.Exclude_filter) + // Also include the default list of classes to exclude from instrumentation. + excludes, err := jacocoFiltersToSpecs(append(j.properties.Jacoco.Exclude_filter, config.DefaultJacocoExcludeFilter...)) if err != nil { ctx.PropertyErrorf("jacoco.exclude_filter", "%s", err.Error()) } -- cgit v1.2.3