Don't dexpreopt when compile_dex but not installable

Modules shouldn't be dexpreopted and possibly stripped when
compile_dex is set but installable is not set.  This matches the
previous behavior when the dexpreopt rules were in Make.

Bug: 121317615
Test: dexpreopt_test.go
Change-Id: I6f80b7b37a990c475b91aa5d98a19a3baa85eb1b
This commit is contained in:
Colin Cross
2019-01-05 22:13:05 -08:00
parent e302687ea4
commit dc2da916fb
3 changed files with 20 additions and 4 deletions

View File

@@ -32,6 +32,7 @@ type dexpreopter struct {
isPrivApp bool isPrivApp bool
isSDKLibrary bool isSDKLibrary bool
isTest bool isTest bool
isInstallable bool
builtInstalled []string builtInstalled []string
} }
@@ -74,6 +75,10 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.ModuleContext) bool {
return true return true
} }
if !d.isInstallable {
return true
}
// TODO: contains no java code // TODO: contains no java code
return false return false

View File

@@ -109,6 +109,16 @@ func TestDexpreoptEnabled(t *testing.T) {
}`, }`,
enabled: false, enabled: false,
}, },
{
name: "compile_dex",
bp: `
java_library {
name: "foo",
srcs: ["a.java"],
compile_dex: true,
}`,
enabled: false,
},
} }
for _, test := range tests { for _, test := range tests {

View File

@@ -1326,6 +1326,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
j.dexJarFile = dexOutputFile j.dexJarFile = dexOutputFile
j.dexpreopter.isInstallable = Bool(j.properties.Installable)
dexOutputFile = j.dexpreopt(ctx, dexOutputFile) dexOutputFile = j.dexpreopt(ctx, dexOutputFile)
j.maybeStrippedDexJarFile = dexOutputFile j.maybeStrippedDexJarFile = dexOutputFile