diff options
author | 2024-10-04 00:21:43 +0000 | |
---|---|---|
committer | 2024-10-04 00:21:43 +0000 | |
commit | 989ee847c8307532aa51979d5b674c9984660cea (patch) | |
tree | f2079606bd06849ebd38067e922b4cfd996c0c4e | |
parent | 8bce3818334988d4ac7da979c7a8a529613c455b (diff) |
[Ravenwood] Allow sending additional args to Ravenizer
Provide a new property to send the "--strip-mockito" argument to the
Ravenizer tool through Android.bp.
Bug: 292141694
Flag: EXEMPT host test change only
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh
Change-Id: I88a11640244f02e9a02858245307f9ad887eedda
-rw-r--r-- | java/base.go | 26 | ||||
-rw-r--r-- | java/builder.go | 9 |
2 files changed, 21 insertions, 14 deletions
diff --git a/java/base.go b/java/base.go index 32bfc17f9..fc21c44e5 100644 --- a/java/base.go +++ b/java/base.go @@ -218,11 +218,15 @@ type CommonProperties struct { // the stubs via static libs. Is_stubs_module *bool - // If true, enable the "Ravenizer" tool on the output jar. - // "Ravenizer" is a tool for Ravenwood tests, but it can also be enabled on other kinds - // of java targets. Ravenizer struct { + // If true, enable the "Ravenizer" tool on the output jar. + // "Ravenizer" is a tool for Ravenwood tests, but it can also be enabled on other kinds + // of java targets. Enabled *bool + + // If true, the "Ravenizer" tool will remove all Mockito and DexMaker + // classes from the output jar. + Strip_mockito *bool } // Contributing api surface of the stub module. Is not visible to bp modules, and should @@ -1134,8 +1138,9 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs) - if re := proptools.Bool(j.properties.Ravenizer.Enabled); re { - j.ravenizer.enabled = re + // Only override the original value if explicitly set + if j.properties.Ravenizer.Enabled != nil { + j.ravenizer.enabled = *j.properties.Ravenizer.Enabled } deps := j.collectDeps(ctx) @@ -1624,12 +1629,11 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath if j.ravenizer.enabled { ravenizerInput := outputFile ravenizerOutput := android.PathForModuleOut(ctx, "ravenizer", jarName) - ctx.Build(pctx, android.BuildParams{ - Rule: ravenizer, - Description: "ravenizer", - Input: ravenizerInput, - Output: ravenizerOutput, - }) + ravenizerArgs := "" + if proptools.Bool(j.properties.Ravenizer.Strip_mockito) { + ravenizerArgs = "--strip-mockito" + } + TransformRavenizer(ctx, ravenizerOutput, ravenizerInput, ravenizerArgs) outputFile = ravenizerOutput localImplementationJars = android.Paths{ravenizerOutput} completeStaticLibsImplementationJars = android.NewDepSet(android.PREORDER, localImplementationJars, nil) diff --git a/java/builder.go b/java/builder.go index 81b0feb75..be1e0b389 100644 --- a/java/builder.go +++ b/java/builder.go @@ -260,10 +260,10 @@ var ( ravenizer = pctx.AndroidStaticRule("ravenizer", blueprint.RuleParams{ - Command: "rm -f $out && ${ravenizer} --in-jar $in --out-jar $out", + Command: "rm -f $out && ${ravenizer} --in-jar $in --out-jar $out $ravenizerArgs", CommandDeps: []string{"${ravenizer}"}, }, - ) + "ravenizerArgs") apimapper = pctx.AndroidStaticRule("apimapper", blueprint.RuleParams{ @@ -782,12 +782,15 @@ func TransformJetifier(ctx android.ModuleContext, outputFile android.WritablePat } func TransformRavenizer(ctx android.ModuleContext, outputFile android.WritablePath, - inputFile android.Path) { + inputFile android.Path, ravenizerArgs string) { ctx.Build(pctx, android.BuildParams{ Rule: ravenizer, Description: "ravenizer", Output: outputFile, Input: inputFile, + Args: map[string]string{ + "ravenizerArgs": ravenizerArgs, + }, }) } |