Merge changes I346ac9c0,I57352aa0 am: 57be76d9ac
am: 061abc7259
am: 49753eca77
am: 086a0913aa
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1875854 Change-Id: I189b0c63507e1d85a42aec7e546b5fa7d318915d
This commit is contained in:
@@ -93,6 +93,7 @@ bootstrap_go_package {
|
||||
"platform_bootclasspath_test.go",
|
||||
"platform_compat_config_test.go",
|
||||
"plugin_test.go",
|
||||
"prebuilt_apis_test.go",
|
||||
"rro_test.go",
|
||||
"sdk_test.go",
|
||||
"sdk_library_test.go",
|
||||
|
52
java/prebuilt_apis_test.go
Normal file
52
java/prebuilt_apis_test.go
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 2021 Google Inc. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package java
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
"github.com/google/blueprint"
|
||||
)
|
||||
|
||||
func TestPrebuiltApis_SystemModulesCreation(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForJavaTest,
|
||||
FixtureWithPrebuiltApis(map[string][]string{
|
||||
"31": {},
|
||||
"current": {},
|
||||
}),
|
||||
).RunTest(t)
|
||||
|
||||
sdkSystemModules := []string{}
|
||||
result.VisitAllModules(func(module blueprint.Module) {
|
||||
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
|
||||
if strings.HasPrefix(name, "sdk_") && strings.HasSuffix(name, "_system_modules") {
|
||||
sdkSystemModules = append(sdkSystemModules, name)
|
||||
}
|
||||
})
|
||||
sort.Strings(sdkSystemModules)
|
||||
expected := []string{
|
||||
// 31 only has public system modules.
|
||||
"sdk_public_31_system_modules",
|
||||
|
||||
// current only has public system modules.
|
||||
"sdk_public_current_system_modules",
|
||||
}
|
||||
sort.Strings(expected)
|
||||
android.AssertArrayString(t, "sdk system modules", expected, sdkSystemModules)
|
||||
}
|
@@ -60,6 +60,12 @@ func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpe
|
||||
}
|
||||
}
|
||||
|
||||
// systemModuleKind returns the kind of system modules to use.
|
||||
func systemModuleKind() android.SdkKind {
|
||||
// Currently, every sdk version uses the system modules for the public API.
|
||||
return android.SdkPublic
|
||||
}
|
||||
|
||||
func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) sdkDep {
|
||||
sdkVersion := sdkContext.SdkVersion(ctx)
|
||||
if !sdkVersion.Valid() {
|
||||
@@ -105,7 +111,8 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
|
||||
|
||||
var systemModules string
|
||||
if defaultJavaLanguageVersion(ctx, sdkVersion).usesJavaModules() {
|
||||
systemModules = "sdk_public_" + sdkVersion.ApiLevel.String() + "_system_modules"
|
||||
systemModuleKind := systemModuleKind()
|
||||
systemModules = fmt.Sprintf("sdk_%s_%s_system_modules", systemModuleKind, sdkVersion.ApiLevel)
|
||||
}
|
||||
|
||||
return sdkDep{
|
||||
|
@@ -159,8 +159,7 @@ func FixtureWithPrebuiltApis(release2Modules map[string][]string) android.Fixtur
|
||||
`, strings.Join(android.SortedStringKeys(release2Modules), `", "`))
|
||||
|
||||
for release, modules := range release2Modules {
|
||||
libs := append([]string{"android", "core-for-system-modules"}, modules...)
|
||||
mockFS.Merge(prebuiltApisFilesForLibs([]string{release}, libs))
|
||||
mockFS.Merge(prebuiltApisFilesForModules([]string{release}, modules))
|
||||
}
|
||||
return android.GroupFixturePreparers(
|
||||
android.FixtureAddTextFile(path, bp),
|
||||
@@ -168,16 +167,25 @@ func FixtureWithPrebuiltApis(release2Modules map[string][]string) android.Fixtur
|
||||
)
|
||||
}
|
||||
|
||||
func prebuiltApisFilesForLibs(apiLevels []string, sdkLibs []string) map[string][]byte {
|
||||
func prebuiltApisFilesForModules(apiLevels []string, modules []string) map[string][]byte {
|
||||
libs := append([]string{"android"}, modules...)
|
||||
|
||||
fs := make(map[string][]byte)
|
||||
for _, level := range apiLevels {
|
||||
for _, lib := range sdkLibs {
|
||||
for _, scope := range []string{"public", "system", "module-lib", "system-server", "test"} {
|
||||
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/%s.jar", level, scope, lib)] = nil
|
||||
for _, sdkKind := range []android.SdkKind{android.SdkPublic, android.SdkSystem, android.SdkModule, android.SdkSystemServer, android.SdkTest} {
|
||||
// A core-for-system-modules file must only be created for the sdk kind that supports it.
|
||||
if sdkKind == systemModuleKind() {
|
||||
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/core-for-system-modules.jar", level, sdkKind)] = nil
|
||||
}
|
||||
|
||||
for _, lib := range libs {
|
||||
// Create a jar file for every library.
|
||||
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/%s.jar", level, sdkKind, lib)] = nil
|
||||
|
||||
// No finalized API files for "current"
|
||||
if level != "current" {
|
||||
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s.txt", level, scope, lib)] = nil
|
||||
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s-removed.txt", level, scope, lib)] = nil
|
||||
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s.txt", level, sdkKind, lib)] = nil
|
||||
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s-removed.txt", level, sdkKind, lib)] = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user