From e3d44b245b417964268ec7d722ee0354431e4fab Mon Sep 17 00:00:00 2001 From: Pete Gillin Date: Mon, 29 Jun 2020 11:28:51 +0100 Subject: [PATCH 1/2] Remove the concept of useDefaultLibs from Soong. This field in the java/sdk structure was used in two of the many possible configurations, so it wasn't really a "default". It also meant that, to understand those configurations, the reader had to know what was considered the default, which was only possibly by reading the code in java.go and droiddoc.go which implemented special code paths when useDefaultLibs was true. By eliminating that setting and explicitly setting the required values, the code is simpler and easier to understand. This change is a straight refactoring, in the sense that the output of the build should be unchanged. Regarding the changes to the proguardRaiseTag dependency in java.go: - This is a noop for anything which had sdkDep.useModule = true prior to this change, because they all had the same value for hasFrameworkLibs() and hasStandardLibs(). - This is a noop for anything which had sdkDep.useDefaultLibs = true prior to this change, because they do not use proguard settings. - Therefore, it is a noop overall. - Nevertheless, it is required to make sdkCorePlatform work. Without this change, such modules would pick up a dependency on framework libs via the (unused) proguardRaiseTag, which creates a circular dependency, because this is the sdk_version used when building framework libs themselves. Bug: 157640067 Test: m java docs droid Change-Id: I3a83b5edc1bd48c16b55f6f77e3e710fc8fbd8fa --- java/droiddoc.go | 9 ++------- java/java.go | 17 +++++++++-------- java/sdk.go | 9 +++++++-- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/java/droiddoc.go b/java/droiddoc.go index 61bdc8874..43fb96435 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -440,16 +440,11 @@ func (j *Javadoc) targetSdkVersion() sdkSpec { func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) { if ctx.Device() { sdkDep := decodeSdkDep(ctx, sdkContext(j)) - if sdkDep.useDefaultLibs { - ctx.AddVariationDependencies(nil, bootClasspathTag, config.LegacyCorePlatformBootclasspathLibraries...) - ctx.AddVariationDependencies(nil, systemModulesTag, config.LegacyCorePlatformSystemModules) - if sdkDep.hasFrameworkLibs() { - ctx.AddVariationDependencies(nil, libTag, config.FrameworkLibraries...) - } - } else if sdkDep.useModule { + if sdkDep.useModule { ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...) ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules) ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...) + ctx.AddVariationDependencies(nil, libTag, sdkDep.classpath...) } } diff --git a/java/java.go b/java/java.go index f9d939bf1..cb2ae2890 100644 --- a/java/java.go +++ b/java/java.go @@ -591,7 +591,7 @@ func IsStaticLibDepTag(depTag blueprint.DependencyTag) bool { } type sdkDep struct { - useModule, useFiles, useDefaultLibs, invalidVersion bool + useModule, useFiles, invalidVersion bool // The modules that will be added to the bootclasspath when targeting 1.8 or lower bootclasspath []string @@ -600,7 +600,11 @@ type sdkDep struct { // modules are to be used. systemModules string + // The modules that will be added to the classpath regardless of the Java language level targeted + classpath []string + // The modules that will be added ot the classpath when targeting 1.9 or higher + // (normally these will be on the bootclasspath when targeting 1.8 or lower) java9Classpath []string frameworkResModule string @@ -694,17 +698,14 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { j.linter.deps(ctx) sdkDep := decodeSdkDep(ctx, sdkContext(j)) - if sdkDep.useDefaultLibs { - ctx.AddVariationDependencies(nil, bootClasspathTag, config.LegacyCorePlatformBootclasspathLibraries...) - ctx.AddVariationDependencies(nil, systemModulesTag, config.LegacyCorePlatformSystemModules) - if sdkDep.hasFrameworkLibs() { - ctx.AddVariationDependencies(nil, libTag, config.FrameworkLibraries...) - } - } else if sdkDep.useModule { + if sdkDep.useModule { ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...) ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...) + ctx.AddVariationDependencies(nil, libTag, sdkDep.classpath...) if j.deviceProperties.EffectiveOptimizeEnabled() && sdkDep.hasStandardLibs() { ctx.AddVariationDependencies(nil, proguardRaiseTag, config.LegacyCorePlatformBootclasspathLibraries...) + } + if j.deviceProperties.EffectiveOptimizeEnabled() && sdkDep.hasFrameworkLibs() { ctx.AddVariationDependencies(nil, proguardRaiseTag, config.FrameworkLibraries...) } } diff --git a/java/sdk.go b/java/sdk.go index 2a08f329e..4fffd8634 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -412,7 +412,10 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep switch sdkVersion.kind { case sdkPrivate: return sdkDep{ - useDefaultLibs: true, + useModule: true, + systemModules: config.LegacyCorePlatformSystemModules, + bootclasspath: config.LegacyCorePlatformBootclasspathLibraries, + classpath: config.FrameworkLibraries, frameworkResModule: "framework-res", } case sdkNone: @@ -434,7 +437,9 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep } case sdkCorePlatform: return sdkDep{ - useDefaultLibs: true, + useModule: true, + systemModules: config.LegacyCorePlatformSystemModules, + bootclasspath: config.LegacyCorePlatformBootclasspathLibraries, frameworkResModule: "framework-res", noFrameworksLibs: true, } From 7b0bdce69eef1b950662a7b493b4cc350da718c0 Mon Sep 17 00:00:00 2001 From: Pete Gillin Date: Wed, 1 Jul 2020 13:05:32 +0100 Subject: [PATCH 2/2] Remove frameworkResModule from sdkCorePlatform. This seems unnecessary: modules using `sdk_version: "core_platform"` don't expect frameworks dependencies. Test: m framework Change-Id: Ib7ad715d1f4b4934c3c4a84839f4ead85a5abb29 --- java/sdk.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/java/sdk.go b/java/sdk.go index 4fffd8634..e3472cea3 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -437,11 +437,10 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep } case sdkCorePlatform: return sdkDep{ - useModule: true, - systemModules: config.LegacyCorePlatformSystemModules, - bootclasspath: config.LegacyCorePlatformBootclasspathLibraries, - frameworkResModule: "framework-res", - noFrameworksLibs: true, + useModule: true, + systemModules: config.LegacyCorePlatformSystemModules, + bootclasspath: config.LegacyCorePlatformBootclasspathLibraries, + noFrameworksLibs: true, } case sdkPublic: return toModule([]string{"android_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx))