aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaewoong Jung2019-05-13 11:23:20 -0500
committerJaewoong Jung2019-05-15 17:46:26 -0500
commita24af3ba207d0b5e965aad8a65689bf9a29db393 (patch)
tree939456f90e51915eea8f041a8b5cca5ce99666f5
parentbc975e8b897eaff7e5729fc362c31d35e838526a (diff)
downloadplatform-build-soong-a24af3ba207d0b5e965aad8a65689bf9a29db393.tar.gz
platform-build-soong-a24af3ba207d0b5e965aad8a65689bf9a29db393.tar.xz
platform-build-soong-a24af3ba207d0b5e965aad8a65689bf9a29db393.zip
Turn off dex actions for sourceless modules.
Test: dexpreopt_test.go Fixes: 129370564 Change-Id: Ic292f37c4f782b14fce625b85817b58c31d3f276
-rw-r--r--java/dexpreopt_test.go20
-rw-r--r--java/java.go21
2 files changed, 31 insertions, 10 deletions
diff --git a/java/dexpreopt_test.go b/java/dexpreopt_test.go
index 4af2f5c3..7d0109fd 100644
--- a/java/dexpreopt_test.go
+++ b/java/dexpreopt_test.go
@@ -52,14 +52,26 @@ func TestDexpreoptEnabled(t *testing.T) {
52 }`, 52 }`,
53 enabled: true, 53 enabled: true,
54 }, 54 },
55
56 { 55 {
57 name: "app without sources", 56 name: "app without sources",
58 bp: ` 57 bp: `
59 android_app { 58 android_app {
60 name: "foo", 59 name: "foo",
61 }`, 60 }`,
62 // TODO(ccross): this should probably be false 61 enabled: false,
62 },
63 {
64 name: "app with libraries",
65 bp: `
66 android_app {
67 name: "foo",
68 static_libs: ["lib"],
69 }
70
71 java_library {
72 name: "lib",
73 srcs: ["a.java"],
74 }`,
63 enabled: true, 75 enabled: true,
64 }, 76 },
65 { 77 {
@@ -69,10 +81,8 @@ func TestDexpreoptEnabled(t *testing.T) {
69 name: "foo", 81 name: "foo",
70 installable: true, 82 installable: true,
71 }`, 83 }`,
72 // TODO(ccross): this should probably be false 84 enabled: false,
73 enabled: true,
74 }, 85 },
75
76 { 86 {
77 name: "static java library", 87 name: "static java library",
78 bp: ` 88 bp: `
diff --git a/java/java.go b/java/java.go
index 866b33c0..69195c80 100644
--- a/java/java.go
+++ b/java/java.go
@@ -962,7 +962,9 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
962 return flags 962 return flags
963} 963}
964 964
965func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path) { 965func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
966
967 hasSrcs := false
966 968
967 j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs) 969 j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs)
968 970
@@ -978,10 +980,15 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
978 } 980 }
979 981
980 srcFiles = j.genSources(ctx, srcFiles, flags) 982 srcFiles = j.genSources(ctx, srcFiles, flags)
983 if len(srcFiles) > 0 {
984 hasSrcs = true
985 }
981 986
982 srcJars := srcFiles.FilterByExt(".srcjar") 987 srcJars := srcFiles.FilterByExt(".srcjar")
983 srcJars = append(srcJars, deps.srcJars...) 988 srcJars = append(srcJars, deps.srcJars...)
984 srcJars = append(srcJars, extraSrcJars...) 989 if aaptSrcJar != nil {
990 srcJars = append(srcJars, aaptSrcJar)
991 }
985 992
986 // Collect source files from compiledJavaSrcs, compiledSrcJars and filter out Exclude_srcs 993 // Collect source files from compiledJavaSrcs, compiledSrcJars and filter out Exclude_srcs
987 // that IDEInfo struct will use 994 // that IDEInfo struct will use
@@ -1170,7 +1177,10 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
1170 j.resourceJar = resourceJars[0] 1177 j.resourceJar = resourceJars[0]
1171 } 1178 }
1172 1179
1173 jars = append(jars, deps.staticJars...) 1180 if len(deps.staticJars) > 0 {
1181 jars = append(jars, deps.staticJars...)
1182 hasSrcs = true
1183 }
1174 1184
1175 manifest := j.overrideManifest 1185 manifest := j.overrideManifest
1176 if !manifest.Valid() && j.properties.Manifest != nil { 1186 if !manifest.Valid() && j.properties.Manifest != nil {
@@ -1281,7 +1291,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
1281 1291
1282 j.implementationAndResourcesJar = implementationAndResourcesJar 1292 j.implementationAndResourcesJar = implementationAndResourcesJar
1283 1293
1284 if ctx.Device() && (Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) { 1294 if ctx.Device() && hasSrcs &&
1295 (Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) {
1285 // Dex compilation 1296 // Dex compilation
1286 var dexOutputFile android.ModuleOutPath 1297 var dexOutputFile android.ModuleOutPath
1287 dexOutputFile = j.compileDex(ctx, flags, outputFile, jarName) 1298 dexOutputFile = j.compileDex(ctx, flags, outputFile, jarName)
@@ -1514,7 +1525,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
1514 j.dexpreopter.isInstallable = Bool(j.properties.Installable) 1525 j.dexpreopter.isInstallable = Bool(j.properties.Installable)
1515 j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter) 1526 j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter)
1516 j.deviceProperties.UncompressDex = j.dexpreopter.uncompressedDex 1527 j.deviceProperties.UncompressDex = j.dexpreopter.uncompressedDex
1517 j.compile(ctx) 1528 j.compile(ctx, nil)
1518 1529
1519 if (Bool(j.properties.Installable) || ctx.Host()) && !android.DirectlyInAnyApex(ctx, ctx.ModuleName()) { 1530 if (Bool(j.properties.Installable) || ctx.Host()) && !android.DirectlyInAnyApex(ctx, ctx.ModuleName()) {
1520 j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), 1531 j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),