From 6c0df888094915e32955c2b175b29c020104d07c Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Wed, 14 Jun 2023 22:43:25 +0000 Subject: [PATCH] Cleanup remaining android.JavaApiLibraryName() references Since the name of the java_library generated from sdk_library per api scope does not depend on the build configuration anymore, all dependency switching "magic" via android.JavaApiLibraryName() can be removed. This change also removes from-text-build-specific test cases, as those test cases depend on build configurations. Test: m nothing && m nothing --build-from-text-stub Bug: 287340610 Change-Id: I3bac35259e0cbaa16432a46cb2b128951c9bc075 --- android/sdk_version.go | 19 -------------- java/bootclasspath_fragment.go | 2 -- java/bootclasspath_fragment_test.go | 36 -------------------------- java/config/makevars.go | 6 ++--- java/hiddenapi_modular.go | 2 +- java/java.go | 2 +- java/legacy_core_platform_api_usage.go | 8 +++--- java/sdk.go | 4 +-- 8 files changed, 10 insertions(+), 69 deletions(-) diff --git a/android/sdk_version.go b/android/sdk_version.go index 80aeb2e69..1fadda0ca 100644 --- a/android/sdk_version.go +++ b/android/sdk_version.go @@ -84,25 +84,6 @@ func (k SdkKind) String() string { } } -// JavaApiLibraryName returns the name of .txt equivalent of a java_library, but does -// not check if either module exists. -// TODO: Return .txt (single-tree or multi-tree equivalents) based on config -func JavaApiLibraryName(c Config, name string) string { - if c.BuildFromTextStub() { - return name + ".from-text" - } - return name -} - -// JavaApiLibraryNames applies JavaApiLibraryName to the list of java_library names. -func JavaApiLibraryNames(c Config, names []string) []string { - apiLibs := make([]string, len(names)) - for i, name := range names { - apiLibs[i] = JavaApiLibraryName(c, name) - } - return apiLibs -} - func (k SdkKind) DefaultJavaLibraryName() string { switch k { case SdkPublic: diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 108fdd483..50429b07a 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -479,8 +479,6 @@ func (b *BootclasspathFragmentModule) DepsMutator(ctx android.BottomUpMutatorCon for _, apiScope := range hiddenAPISdkLibrarySupportedScopes { // Add a dependency onto a possibly scope specific stub library. scopeSpecificDependency := apiScope.scopeSpecificStubModule(ctx, additionalStubModule) - // Use JavaApiLibraryName function to be redirected to stubs generated from .txt if applicable - scopeSpecificDependency = android.JavaApiLibraryName(ctx.Config(), scopeSpecificDependency) tag := hiddenAPIStubsDependencyTag{apiScope: apiScope, fromAdditionalDependency: true} ctx.AddVariationDependencies(nil, tag, scopeSpecificDependency) } diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go index 9bdef749b..2541f14ff 100644 --- a/java/bootclasspath_fragment_test.go +++ b/java/bootclasspath_fragment_test.go @@ -432,39 +432,3 @@ func TestBootclasspathFragment_Test(t *testing.T) { fragment = result.Module("a_test_fragment", "android_common").(*BootclasspathFragmentModule) android.AssertBoolEquals(t, "is a test fragment by type", true, fragment.isTestFragment()) } - -func TestBootclassFragment_LinkTextStub(t *testing.T) { - result := android.GroupFixturePreparers( - prepareForJavaTest, - prepareForTestWithBootclasspathFragment, - PrepareForTestWithJavaSdkLibraryFiles, - FixtureWithLastReleaseApis("mysdklibrary"), - android.FixtureModifyConfig(func(config android.Config) { - config.SetBuildFromTextStub(true) - }), - ).RunTestWithBp(t, ` - bootclasspath_fragment { - name: "myfragment", - contents: ["mysdklibrary"], - hidden_api: {split_packages: ["*"]}, - additional_stubs: [ - "android-non-updatable", - ], - } - java_sdk_library { - name: "mysdklibrary", - srcs: ["a.java"], - shared_library: false, - public: {enabled: true}, - system: {enabled: true}, - } - `) - - fragment := result.ModuleForTests("myfragment", "android_common") - ruleCommand := fragment.Rule("modularHiddenAPIStubFlagsFile").RuleParams.Command - android.AssertStringDoesContain(t, "Command expected to contain library as dependency stub dex", - ruleCommand, "--dependency-stub-dex=out/soong/.intermediates/default/java/android-non-updatable.stubs.module_lib.from-text/android_common/dex/android-non-updatable.stubs.module_lib.from-text.jar") - android.AssertStringDoesNotContain(t, - "Command not expected to contain multiple api_library as dependency stub dex", ruleCommand, - "--dependency-stub-dex=out/soong/.intermediates/default/java/android-non-updatable.stubs.from-text/android_common/dex/android-non-updatable.stubs.from-text.jar") -} diff --git a/java/config/makevars.go b/java/config/makevars.go index d383d9888..4e0919537 100644 --- a/java/config/makevars.go +++ b/java/config/makevars.go @@ -29,10 +29,8 @@ func makeVarsProvider(ctx android.MakeVarsContext) { // These are used by make when LOCAL_PRIVATE_PLATFORM_APIS is set (equivalent to platform_apis in blueprint): ctx.Strict("LEGACY_CORE_PLATFORM_BOOTCLASSPATH_LIBRARIES", - strings.Join(android.JavaApiLibraryNames(ctx.Config(), LegacyCorePlatformBootclasspathLibraries), " ")) - ctx.Strict("LEGACY_CORE_PLATFORM_SYSTEM_MODULES", - android.JavaApiLibraryName(ctx.Config(), LegacyCorePlatformSystemModules), - ) + strings.Join(LegacyCorePlatformBootclasspathLibraries, " ")) + ctx.Strict("LEGACY_CORE_PLATFORM_SYSTEM_MODULES", LegacyCorePlatformSystemModules) ctx.Strict("ANDROID_JAVA_HOME", "${JavaHome}") ctx.Strict("ANDROID_JAVA8_HOME", "prebuilts/jdk/jdk8/${hostPrebuiltTag}") diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index da9c9970a..c6b921bb2 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -647,7 +647,7 @@ func (s StubDexJarsByModule) addStubDexJar(ctx android.ModuleContext, module and // public version is provided by the art.module.public.api module. In those cases it is necessary // to treat all those modules as they were the same name, otherwise it will result in multiple // definitions of a single class being passed to hidden API processing which will cause an error. - if name == scope.nonUpdatablePrebuiltModule || name == android.JavaApiLibraryName(ctx.Config(), scope.nonUpdatableSourceModule) { + if name == scope.nonUpdatablePrebuiltModule || name == scope.nonUpdatableSourceModule { // Treat all *android-non-updatable* modules as if they were part of an android-non-updatable // java_sdk_library. // TODO(b/192067200): Remove once android-non-updatable is a java_sdk_library or equivalent. diff --git a/java/java.go b/java/java.go index a026610c2..454f42f7a 100644 --- a/java/java.go +++ b/java/java.go @@ -459,7 +459,7 @@ func sdkDeps(ctx android.BottomUpMutatorContext, sdkContext android.SdkContext, ctx.AddVariationDependencies(nil, sdkLibTag, sdkDep.classpath...) if d.effectiveOptimizeEnabled() && sdkDep.hasStandardLibs() { ctx.AddVariationDependencies(nil, proguardRaiseTag, - android.JavaApiLibraryNames(ctx.Config(), config.LegacyCorePlatformBootclasspathLibraries)..., + config.LegacyCorePlatformBootclasspathLibraries..., ) } if d.effectiveOptimizeEnabled() && sdkDep.hasFrameworkLibs() { diff --git a/java/legacy_core_platform_api_usage.go b/java/legacy_core_platform_api_usage.go index 04c6d05b1..6cb549eaf 100644 --- a/java/legacy_core_platform_api_usage.go +++ b/java/legacy_core_platform_api_usage.go @@ -93,16 +93,16 @@ func useLegacyCorePlatformApi(ctx android.EarlyModuleContext, moduleName string) func corePlatformSystemModules(ctx android.EarlyModuleContext) string { if useLegacyCorePlatformApi(ctx, ctx.ModuleName()) { - return android.JavaApiLibraryName(ctx.Config(), config.LegacyCorePlatformSystemModules) + return config.LegacyCorePlatformSystemModules } else { - return android.JavaApiLibraryName(ctx.Config(), config.StableCorePlatformSystemModules) + return config.StableCorePlatformSystemModules } } func corePlatformBootclasspathLibraries(ctx android.EarlyModuleContext) []string { if useLegacyCorePlatformApi(ctx, ctx.ModuleName()) { - return android.JavaApiLibraryNames(ctx.Config(), config.LegacyCorePlatformBootclasspathLibraries) + return config.LegacyCorePlatformBootclasspathLibraries } else { - return android.JavaApiLibraryNames(ctx.Config(), config.StableCorePlatformBootclasspathLibraries) + return config.StableCorePlatformBootclasspathLibraries } } diff --git a/java/sdk.go b/java/sdk.go index 7699aabe0..7c702c405 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -148,7 +148,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) toModule := func(module string, aidl android.Path) sdkDep { // Select the kind of system modules needed for the sdk version. systemModulesKind := systemModuleKind(sdkVersion.Kind, android.FutureApiLevel) - systemModules := android.JavaApiLibraryName(ctx.Config(), fmt.Sprintf("core-%s-stubs-system-modules", systemModulesKind)) + systemModules := fmt.Sprintf("core-%s-stubs-system-modules", systemModulesKind) return sdkDep{ useModule: true, bootclasspath: []string{module, config.DefaultLambdaStubsLibrary}, @@ -198,7 +198,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) return sdkDep{ useModule: true, bootclasspath: []string{android.SdkCore.DefaultJavaLibraryName(), config.DefaultLambdaStubsLibrary}, - systemModules: android.JavaApiLibraryName(ctx.Config(), "core-public-stubs-system-modules"), + systemModules: "core-public-stubs-system-modules", noFrameworksLibs: true, } case android.SdkModule: