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
This commit is contained in:
parent
3d4d88d68e
commit
6c0df88809
8 changed files with 10 additions and 69 deletions
|
@ -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 {
|
func (k SdkKind) DefaultJavaLibraryName() string {
|
||||||
switch k {
|
switch k {
|
||||||
case SdkPublic:
|
case SdkPublic:
|
||||||
|
|
|
@ -479,8 +479,6 @@ func (b *BootclasspathFragmentModule) DepsMutator(ctx android.BottomUpMutatorCon
|
||||||
for _, apiScope := range hiddenAPISdkLibrarySupportedScopes {
|
for _, apiScope := range hiddenAPISdkLibrarySupportedScopes {
|
||||||
// Add a dependency onto a possibly scope specific stub library.
|
// Add a dependency onto a possibly scope specific stub library.
|
||||||
scopeSpecificDependency := apiScope.scopeSpecificStubModule(ctx, additionalStubModule)
|
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}
|
tag := hiddenAPIStubsDependencyTag{apiScope: apiScope, fromAdditionalDependency: true}
|
||||||
ctx.AddVariationDependencies(nil, tag, scopeSpecificDependency)
|
ctx.AddVariationDependencies(nil, tag, scopeSpecificDependency)
|
||||||
}
|
}
|
||||||
|
|
|
@ -432,39 +432,3 @@ func TestBootclasspathFragment_Test(t *testing.T) {
|
||||||
fragment = result.Module("a_test_fragment", "android_common").(*BootclasspathFragmentModule)
|
fragment = result.Module("a_test_fragment", "android_common").(*BootclasspathFragmentModule)
|
||||||
android.AssertBoolEquals(t, "is a test fragment by type", true, fragment.isTestFragment())
|
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")
|
|
||||||
}
|
|
||||||
|
|
|
@ -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):
|
// 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",
|
ctx.Strict("LEGACY_CORE_PLATFORM_BOOTCLASSPATH_LIBRARIES",
|
||||||
strings.Join(android.JavaApiLibraryNames(ctx.Config(), LegacyCorePlatformBootclasspathLibraries), " "))
|
strings.Join(LegacyCorePlatformBootclasspathLibraries, " "))
|
||||||
ctx.Strict("LEGACY_CORE_PLATFORM_SYSTEM_MODULES",
|
ctx.Strict("LEGACY_CORE_PLATFORM_SYSTEM_MODULES", LegacyCorePlatformSystemModules)
|
||||||
android.JavaApiLibraryName(ctx.Config(), LegacyCorePlatformSystemModules),
|
|
||||||
)
|
|
||||||
|
|
||||||
ctx.Strict("ANDROID_JAVA_HOME", "${JavaHome}")
|
ctx.Strict("ANDROID_JAVA_HOME", "${JavaHome}")
|
||||||
ctx.Strict("ANDROID_JAVA8_HOME", "prebuilts/jdk/jdk8/${hostPrebuiltTag}")
|
ctx.Strict("ANDROID_JAVA8_HOME", "prebuilts/jdk/jdk8/${hostPrebuiltTag}")
|
||||||
|
|
|
@ -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
|
// 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
|
// 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.
|
// 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
|
// Treat all *android-non-updatable* modules as if they were part of an android-non-updatable
|
||||||
// java_sdk_library.
|
// java_sdk_library.
|
||||||
// TODO(b/192067200): Remove once android-non-updatable is a java_sdk_library or equivalent.
|
// TODO(b/192067200): Remove once android-non-updatable is a java_sdk_library or equivalent.
|
||||||
|
|
|
@ -459,7 +459,7 @@ func sdkDeps(ctx android.BottomUpMutatorContext, sdkContext android.SdkContext,
|
||||||
ctx.AddVariationDependencies(nil, sdkLibTag, sdkDep.classpath...)
|
ctx.AddVariationDependencies(nil, sdkLibTag, sdkDep.classpath...)
|
||||||
if d.effectiveOptimizeEnabled() && sdkDep.hasStandardLibs() {
|
if d.effectiveOptimizeEnabled() && sdkDep.hasStandardLibs() {
|
||||||
ctx.AddVariationDependencies(nil, proguardRaiseTag,
|
ctx.AddVariationDependencies(nil, proguardRaiseTag,
|
||||||
android.JavaApiLibraryNames(ctx.Config(), config.LegacyCorePlatformBootclasspathLibraries)...,
|
config.LegacyCorePlatformBootclasspathLibraries...,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if d.effectiveOptimizeEnabled() && sdkDep.hasFrameworkLibs() {
|
if d.effectiveOptimizeEnabled() && sdkDep.hasFrameworkLibs() {
|
||||||
|
|
|
@ -93,16 +93,16 @@ func useLegacyCorePlatformApi(ctx android.EarlyModuleContext, moduleName string)
|
||||||
|
|
||||||
func corePlatformSystemModules(ctx android.EarlyModuleContext) string {
|
func corePlatformSystemModules(ctx android.EarlyModuleContext) string {
|
||||||
if useLegacyCorePlatformApi(ctx, ctx.ModuleName()) {
|
if useLegacyCorePlatformApi(ctx, ctx.ModuleName()) {
|
||||||
return android.JavaApiLibraryName(ctx.Config(), config.LegacyCorePlatformSystemModules)
|
return config.LegacyCorePlatformSystemModules
|
||||||
} else {
|
} else {
|
||||||
return android.JavaApiLibraryName(ctx.Config(), config.StableCorePlatformSystemModules)
|
return config.StableCorePlatformSystemModules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func corePlatformBootclasspathLibraries(ctx android.EarlyModuleContext) []string {
|
func corePlatformBootclasspathLibraries(ctx android.EarlyModuleContext) []string {
|
||||||
if useLegacyCorePlatformApi(ctx, ctx.ModuleName()) {
|
if useLegacyCorePlatformApi(ctx, ctx.ModuleName()) {
|
||||||
return android.JavaApiLibraryNames(ctx.Config(), config.LegacyCorePlatformBootclasspathLibraries)
|
return config.LegacyCorePlatformBootclasspathLibraries
|
||||||
} else {
|
} else {
|
||||||
return android.JavaApiLibraryNames(ctx.Config(), config.StableCorePlatformBootclasspathLibraries)
|
return config.StableCorePlatformBootclasspathLibraries
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
|
||||||
toModule := func(module string, aidl android.Path) sdkDep {
|
toModule := func(module string, aidl android.Path) sdkDep {
|
||||||
// Select the kind of system modules needed for the sdk version.
|
// Select the kind of system modules needed for the sdk version.
|
||||||
systemModulesKind := systemModuleKind(sdkVersion.Kind, android.FutureApiLevel)
|
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{
|
return sdkDep{
|
||||||
useModule: true,
|
useModule: true,
|
||||||
bootclasspath: []string{module, config.DefaultLambdaStubsLibrary},
|
bootclasspath: []string{module, config.DefaultLambdaStubsLibrary},
|
||||||
|
@ -198,7 +198,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
|
||||||
return sdkDep{
|
return sdkDep{
|
||||||
useModule: true,
|
useModule: true,
|
||||||
bootclasspath: []string{android.SdkCore.DefaultJavaLibraryName(), config.DefaultLambdaStubsLibrary},
|
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,
|
noFrameworksLibs: true,
|
||||||
}
|
}
|
||||||
case android.SdkModule:
|
case android.SdkModule:
|
||||||
|
|
Loading…
Reference in a new issue