Merge "Basic bp2build converter for java_import." am: ea64e62dab
am: bf670bc2c5
am: 9fcbe2509a
am: fb012b7baa
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1965379 Change-Id: Ib1139bd6914423c79b45e7d673a2264e070d91b5
This commit is contained in:
commit
05169e81cc
3 changed files with 79 additions and 5 deletions
|
@ -217,7 +217,6 @@ var (
|
|||
"external/bazelbuild-rules_android":/* recursive = */ true,
|
||||
"external/bazel-skylib":/* recursive = */ true,
|
||||
"external/guava":/* recursive = */ true,
|
||||
"external/error_prone":/* recursive = */ true,
|
||||
"external/jsr305":/* recursive = */ true,
|
||||
"frameworks/ex/common":/* recursive = */ true,
|
||||
|
||||
|
@ -292,6 +291,7 @@ var (
|
|||
"external/bouncycastle": Bp2BuildDefaultTrue,
|
||||
"external/brotli": Bp2BuildDefaultTrue,
|
||||
"external/conscrypt": Bp2BuildDefaultTrue,
|
||||
"external/error_prone": Bp2BuildDefaultTrue,
|
||||
"external/fmtlib": Bp2BuildDefaultTrueRecursively,
|
||||
"external/google-benchmark": Bp2BuildDefaultTrueRecursively,
|
||||
"external/googletest": Bp2BuildDefaultTrueRecursively,
|
||||
|
@ -341,6 +341,7 @@ var (
|
|||
"packages/screensavers/Basic": Bp2BuildDefaultTrue,
|
||||
"packages/services/Car/tests/SampleRearViewCamera": Bp2BuildDefaultTrue,
|
||||
"prebuilts/clang/host/linux-x86": Bp2BuildDefaultTrueRecursively,
|
||||
"prebuilts/tools/common/m2": Bp2BuildDefaultTrue,
|
||||
"system/apex": Bp2BuildDefaultFalse, // TODO(b/207466993): flaky failures
|
||||
"system/apex/proto": Bp2BuildDefaultTrueRecursively,
|
||||
"system/apex/libs": Bp2BuildDefaultTrueRecursively,
|
||||
|
@ -469,10 +470,11 @@ var (
|
|||
"libdexfiled", // depends on unconverted modules: dexfile_operator_srcs, libartbased, libartpalette
|
||||
|
||||
// go deps:
|
||||
"apex-protos", // depends on soong_zip, a go binary
|
||||
"robolectric_tzdata", // depends on soong_zip, a go binary
|
||||
"host_bionic_linker_asm", // depends on extract_linker, a go binary.
|
||||
"host_bionic_linker_script", // depends on extract_linker, a go binary.
|
||||
"apex-protos", // depends on soong_zip, a go binary
|
||||
"robolectric_tzdata", // depends on soong_zip, a go binary
|
||||
"robolectric-sqlite4java-native", // depends on soong_zip, a go binary
|
||||
"host_bionic_linker_asm", // depends on extract_linker, a go binary.
|
||||
"host_bionic_linker_script", // depends on extract_linker, a go binary.
|
||||
|
||||
// java deps
|
||||
"bin2c_fastdeployagent", // depends on deployagent, a java binary
|
||||
|
|
52
bp2build/java_import_conversion_test.go
Normal file
52
bp2build/java_import_conversion_test.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
// Copyright 2022 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 (
|
||||
"android/soong/android"
|
||||
"android/soong/java"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runJavaImportTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, registerJavaImportModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerJavaImportModuleTypes(ctx android.RegistrationContext) {
|
||||
}
|
||||
|
||||
func TestMinimalJavaImport(t *testing.T) {
|
||||
runJavaImportTestCase(t, bp2buildTestCase{
|
||||
description: "Java import - simple example",
|
||||
moduleTypeUnderTest: "java_import",
|
||||
moduleTypeUnderTestFactory: java.ImportFactory,
|
||||
filesystem: map[string]string{
|
||||
"import.jar": "",
|
||||
},
|
||||
blueprint: `
|
||||
java_import {
|
||||
name: "example_import",
|
||||
jars: ["import.jar"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_import", "example_import", attrNameToString{
|
||||
"jars": `["import.jar"]`,
|
||||
}),
|
||||
}})
|
||||
}
|
20
java/java.go
20
java/java.go
|
@ -1328,6 +1328,7 @@ type Import struct {
|
|||
android.ModuleBase
|
||||
android.DefaultableModuleBase
|
||||
android.ApexModuleBase
|
||||
android.BazelModuleBase
|
||||
prebuilt android.Prebuilt
|
||||
android.SdkBase
|
||||
|
||||
|
@ -1683,6 +1684,7 @@ func ImportFactory() android.Module {
|
|||
android.InitPrebuiltModule(module, &module.properties.Jars)
|
||||
android.InitApexModule(module)
|
||||
android.InitSdkAwareModule(module)
|
||||
android.InitBazelModule(module)
|
||||
InitJavaModule(module, android.HostAndDeviceSupported)
|
||||
return module
|
||||
}
|
||||
|
@ -2101,3 +2103,21 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) {
|
|||
// Create the BazelTargetModule.
|
||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
|
||||
}
|
||||
|
||||
type bazelJavaImportAttributes struct {
|
||||
Jars bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
// java_import bp2Build converter.
|
||||
func (i *Import) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||
//TODO(b/209577426): Support multiple arch variants
|
||||
jars := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrcExcludes(ctx, i.properties.Jars, []string(nil)))
|
||||
|
||||
attrs := &bazelJavaImportAttributes{
|
||||
Jars: jars,
|
||||
}
|
||||
props := bazel.BazelTargetModuleProperties{Rule_class: "java_import"}
|
||||
|
||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: android.RemoveOptionalPrebuiltPrefix(i.Name())}, attrs)
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue