Turn off dex actions for sourceless modules.
Test: dexpreopt_test.go Fixes: 129370564 Change-Id: Ic292f37c4f782b14fce625b85817b58c31d3f276
This commit is contained in:
@@ -52,14 +52,26 @@ func TestDexpreoptEnabled(t *testing.T) {
|
|||||||
}`,
|
}`,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "app without sources",
|
name: "app without sources",
|
||||||
bp: `
|
bp: `
|
||||||
android_app {
|
android_app {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
}`,
|
}`,
|
||||||
// TODO(ccross): this should probably be false
|
enabled: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "app with libraries",
|
||||||
|
bp: `
|
||||||
|
android_app {
|
||||||
|
name: "foo",
|
||||||
|
static_libs: ["lib"],
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library {
|
||||||
|
name: "lib",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
}`,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -69,10 +81,8 @@ func TestDexpreoptEnabled(t *testing.T) {
|
|||||||
name: "foo",
|
name: "foo",
|
||||||
installable: true,
|
installable: true,
|
||||||
}`,
|
}`,
|
||||||
// TODO(ccross): this should probably be false
|
enabled: false,
|
||||||
enabled: true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "static java library",
|
name: "static java library",
|
||||||
bp: `
|
bp: `
|
||||||
|
19
java/java.go
19
java/java.go
@@ -962,7 +962,9 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
|
|||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path) {
|
func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
||||||
|
|
||||||
|
hasSrcs := false
|
||||||
|
|
||||||
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs)
|
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs)
|
||||||
|
|
||||||
@@ -978,10 +980,15 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
|||||||
}
|
}
|
||||||
|
|
||||||
srcFiles = j.genSources(ctx, srcFiles, flags)
|
srcFiles = j.genSources(ctx, srcFiles, flags)
|
||||||
|
if len(srcFiles) > 0 {
|
||||||
|
hasSrcs = true
|
||||||
|
}
|
||||||
|
|
||||||
srcJars := srcFiles.FilterByExt(".srcjar")
|
srcJars := srcFiles.FilterByExt(".srcjar")
|
||||||
srcJars = append(srcJars, deps.srcJars...)
|
srcJars = append(srcJars, deps.srcJars...)
|
||||||
srcJars = append(srcJars, extraSrcJars...)
|
if aaptSrcJar != nil {
|
||||||
|
srcJars = append(srcJars, aaptSrcJar)
|
||||||
|
}
|
||||||
|
|
||||||
// Collect source files from compiledJavaSrcs, compiledSrcJars and filter out Exclude_srcs
|
// Collect source files from compiledJavaSrcs, compiledSrcJars and filter out Exclude_srcs
|
||||||
// that IDEInfo struct will use
|
// that IDEInfo struct will use
|
||||||
@@ -1170,7 +1177,10 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
|||||||
j.resourceJar = resourceJars[0]
|
j.resourceJar = resourceJars[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(deps.staticJars) > 0 {
|
||||||
jars = append(jars, deps.staticJars...)
|
jars = append(jars, deps.staticJars...)
|
||||||
|
hasSrcs = true
|
||||||
|
}
|
||||||
|
|
||||||
manifest := j.overrideManifest
|
manifest := j.overrideManifest
|
||||||
if !manifest.Valid() && j.properties.Manifest != nil {
|
if !manifest.Valid() && j.properties.Manifest != nil {
|
||||||
@@ -1281,7 +1291,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
|
|||||||
|
|
||||||
j.implementationAndResourcesJar = implementationAndResourcesJar
|
j.implementationAndResourcesJar = implementationAndResourcesJar
|
||||||
|
|
||||||
if ctx.Device() && (Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) {
|
if ctx.Device() && hasSrcs &&
|
||||||
|
(Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) {
|
||||||
// Dex compilation
|
// Dex compilation
|
||||||
var dexOutputFile android.ModuleOutPath
|
var dexOutputFile android.ModuleOutPath
|
||||||
dexOutputFile = j.compileDex(ctx, flags, outputFile, jarName)
|
dexOutputFile = j.compileDex(ctx, flags, outputFile, jarName)
|
||||||
@@ -1514,7 +1525,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
j.dexpreopter.isInstallable = Bool(j.properties.Installable)
|
j.dexpreopter.isInstallable = Bool(j.properties.Installable)
|
||||||
j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter)
|
j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter)
|
||||||
j.deviceProperties.UncompressDex = j.dexpreopter.uncompressedDex
|
j.deviceProperties.UncompressDex = j.dexpreopter.uncompressedDex
|
||||||
j.compile(ctx)
|
j.compile(ctx, nil)
|
||||||
|
|
||||||
if (Bool(j.properties.Installable) || ctx.Host()) && !android.DirectlyInAnyApex(ctx, ctx.ModuleName()) {
|
if (Bool(j.properties.Installable) || ctx.Host()) && !android.DirectlyInAnyApex(ctx, ctx.ModuleName()) {
|
||||||
j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
|
j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
|
||||||
|
Reference in New Issue
Block a user