Merge changes I6f80b7b3,Ida8f046c

* changes:
  Don't dexpreopt when compile_dex but not installable
  Don't dexpreopt or strip java_test modules
This commit is contained in:
Colin Cross 2019-01-09 05:43:12 +00:00 committed by Gerrit Code Review
commit 1f8076b42d
3 changed files with 30 additions and 4 deletions

View File

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

View File

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

View File

@ -1326,6 +1326,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
j.dexJarFile = dexOutputFile
j.dexpreopter.isInstallable = Bool(j.properties.Installable)
dexOutputFile = j.dexpreopt(ctx, dexOutputFile)
j.maybeStrippedDexJarFile = dexOutputFile
@ -1601,6 +1602,7 @@ func TestFactory() android.Module {
&module.testProperties)
module.Module.properties.Installable = proptools.BoolPtr(true)
module.Module.dexpreopter.isTest = true
InitJavaModule(module, android.HostAndDeviceSupported)
return module