Merge changes from topic "prebuilt-cc-shared-always" into main am: 9e12c78637
am: c4298a325d
am: 336739ca4a
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2755385 Change-Id: Ice624e4373955bb69aad86b5c0f7c5de8c08b173 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -931,6 +931,7 @@ var (
|
|||||||
"java_import",
|
"java_import",
|
||||||
"java_import_host",
|
"java_import_host",
|
||||||
"java_sdk_library",
|
"java_sdk_library",
|
||||||
|
"java_sdk_library_import",
|
||||||
"license",
|
"license",
|
||||||
"linker_config",
|
"linker_config",
|
||||||
"sysprop_library",
|
"sysprop_library",
|
||||||
|
@@ -74,6 +74,8 @@ bootstrap_go_package {
|
|||||||
"java_library_host_conversion_test.go",
|
"java_library_host_conversion_test.go",
|
||||||
"java_plugin_conversion_test.go",
|
"java_plugin_conversion_test.go",
|
||||||
"java_proto_conversion_test.go",
|
"java_proto_conversion_test.go",
|
||||||
|
"java_sdk_library_conversion_test.go",
|
||||||
|
"java_sdk_library_import_conversion_test.go",
|
||||||
"license_conversion_test.go",
|
"license_conversion_test.go",
|
||||||
"license_kind_conversion_test.go",
|
"license_kind_conversion_test.go",
|
||||||
"linker_config_conversion_test.go",
|
"linker_config_conversion_test.go",
|
||||||
|
84
bp2build/java_sdk_library_import_conversion_test.go
Normal file
84
bp2build/java_sdk_library_import_conversion_test.go
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
// Copyright 2023 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 bp2build
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"android/soong/java"
|
||||||
|
)
|
||||||
|
|
||||||
|
func runJavaSdkLibraryImportTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||||
|
t.Helper()
|
||||||
|
RunBp2BuildTestCase(t, java.RegisterSdkLibraryBuildComponents, tc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestJavaSdkLibraryImport(t *testing.T) {
|
||||||
|
runJavaSdkLibraryImportTestCase(t, Bp2buildTestCase{
|
||||||
|
Blueprint: `
|
||||||
|
java_sdk_library_import {
|
||||||
|
name : "foo",
|
||||||
|
public: {
|
||||||
|
current_api: "foo_current.txt",
|
||||||
|
},
|
||||||
|
system: {
|
||||||
|
current_api: "system_foo_current.txt",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
MakeBazelTarget("java_sdk_library", "foo", AttrNameToString{
|
||||||
|
"public": `"foo_current.txt"`,
|
||||||
|
"system": `"system_foo_current.txt"`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestJavaSdkLibraryImportPrebuiltPrefixRemoved(t *testing.T) {
|
||||||
|
runJavaSdkLibraryImportTestCase(t, Bp2buildTestCase{
|
||||||
|
Filesystem: map[string]string{
|
||||||
|
"foobar/Android.bp": `
|
||||||
|
java_sdk_library {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["**/*.java"],
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
"foobar/api/current.txt": "",
|
||||||
|
"foobar/api/system-current.txt": "",
|
||||||
|
"foobar/api/test-current.txt": "",
|
||||||
|
"foobar/api/removed.txt": "",
|
||||||
|
"foobar/api/system-removed.txt": "",
|
||||||
|
"foobar/api/test-removed.txt": "",
|
||||||
|
},
|
||||||
|
Blueprint: `
|
||||||
|
java_sdk_library_import {
|
||||||
|
name : "foo",
|
||||||
|
public: {
|
||||||
|
current_api: "foo_current.txt",
|
||||||
|
},
|
||||||
|
system: {
|
||||||
|
current_api: "system_foo_current.txt",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
MakeBazelTarget("java_sdk_library", "foo", AttrNameToString{
|
||||||
|
"public": `"foo_current.txt"`,
|
||||||
|
"system": `"system_foo_current.txt"`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
@@ -2276,11 +2276,11 @@ func SdkLibraryFactory() android.Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type bazelSdkLibraryAttributes struct {
|
type bazelSdkLibraryAttributes struct {
|
||||||
Public bazel.StringAttribute
|
Public *bazel.Label
|
||||||
System bazel.StringAttribute
|
System *bazel.Label
|
||||||
Test bazel.StringAttribute
|
Test *bazel.Label
|
||||||
Module_lib bazel.StringAttribute
|
Module_lib *bazel.Label
|
||||||
System_server bazel.StringAttribute
|
System_server *bazel.Label
|
||||||
}
|
}
|
||||||
|
|
||||||
// java_sdk_library bp2build converter
|
// java_sdk_library bp2build converter
|
||||||
@@ -2290,13 +2290,11 @@ func (module *SdkLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
nameToAttr := make(map[string]bazel.StringAttribute)
|
nameToAttr := make(map[string]*bazel.Label)
|
||||||
|
|
||||||
for _, scope := range module.getGeneratedApiScopes(ctx) {
|
for _, scope := range module.getGeneratedApiScopes(ctx) {
|
||||||
apiSurfaceFile := path.Join(module.getApiDir(), scope.apiFilePrefix+"current.txt")
|
apiSurfaceFile := android.BazelLabelForModuleSrcSingle(ctx, path.Join(module.getApiDir(), scope.apiFilePrefix+"current.txt"))
|
||||||
var scopeStringAttribute bazel.StringAttribute
|
nameToAttr[scope.name] = &apiSurfaceFile
|
||||||
scopeStringAttribute.SetValue(apiSurfaceFile)
|
|
||||||
nameToAttr[scope.name] = scopeStringAttribute
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs := bazelSdkLibraryAttributes{
|
attrs := bazelSdkLibraryAttributes{
|
||||||
@@ -2355,6 +2353,7 @@ type sdkLibraryImportProperties struct {
|
|||||||
type SdkLibraryImport struct {
|
type SdkLibraryImport struct {
|
||||||
android.ModuleBase
|
android.ModuleBase
|
||||||
android.DefaultableModuleBase
|
android.DefaultableModuleBase
|
||||||
|
android.BazelModuleBase
|
||||||
prebuilt android.Prebuilt
|
prebuilt android.Prebuilt
|
||||||
android.ApexModuleBase
|
android.ApexModuleBase
|
||||||
|
|
||||||
@@ -2438,6 +2437,7 @@ func sdkLibraryImportFactory() android.Module {
|
|||||||
|
|
||||||
android.InitPrebuiltModule(module, &[]string{""})
|
android.InitPrebuiltModule(module, &[]string{""})
|
||||||
android.InitApexModule(module)
|
android.InitApexModule(module)
|
||||||
|
android.InitBazelModule(module)
|
||||||
InitJavaModule(module, android.HostAndDeviceSupported)
|
InitJavaModule(module, android.HostAndDeviceSupported)
|
||||||
|
|
||||||
module.SetDefaultableHook(func(mctx android.DefaultableHookContext) {
|
module.SetDefaultableHook(func(mctx android.DefaultableHookContext) {
|
||||||
@@ -2448,6 +2448,33 @@ func sdkLibraryImportFactory() android.Module {
|
|||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// java_sdk_library bp2build converter
|
||||||
|
func (i *SdkLibraryImport) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
|
nameToAttr := make(map[string]*bazel.Label)
|
||||||
|
|
||||||
|
for scope, props := range i.scopeProperties {
|
||||||
|
if api := proptools.String(props.Current_api); api != "" {
|
||||||
|
apiSurfaceFile := android.BazelLabelForModuleSrcSingle(ctx, api)
|
||||||
|
nameToAttr[scope.name] = &apiSurfaceFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
attrs := bazelSdkLibraryAttributes{
|
||||||
|
Public: nameToAttr["public"],
|
||||||
|
System: nameToAttr["system"],
|
||||||
|
Test: nameToAttr["test"],
|
||||||
|
Module_lib: nameToAttr["module-lib"],
|
||||||
|
System_server: nameToAttr["system-server"],
|
||||||
|
}
|
||||||
|
props := bazel.BazelTargetModuleProperties{
|
||||||
|
Rule_class: "java_sdk_library",
|
||||||
|
Bzl_load_location: "//build/bazel/rules/java:sdk_library.bzl",
|
||||||
|
}
|
||||||
|
|
||||||
|
name := android.RemoveOptionalPrebuiltPrefix(i.Name())
|
||||||
|
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, &attrs)
|
||||||
|
}
|
||||||
|
|
||||||
var _ PermittedPackagesForUpdatableBootJars = (*SdkLibraryImport)(nil)
|
var _ PermittedPackagesForUpdatableBootJars = (*SdkLibraryImport)(nil)
|
||||||
|
|
||||||
func (module *SdkLibraryImport) PermittedPackagesForUpdatableBootJars() []string {
|
func (module *SdkLibraryImport) PermittedPackagesForUpdatableBootJars() []string {
|
||||||
|
Reference in New Issue
Block a user