Merge "Revert^2 "bp2build converter for android_test_helper_app."" into main am: a56002a473
am: f7566167dd
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2759108 Change-Id: I718a02e4d41559347cbf6ec6c7032a6fd691503c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
7204781c24
4 changed files with 134 additions and 0 deletions
|
@ -1690,6 +1690,9 @@ var (
|
||||||
"MtsTimeZoneDataTestCases",
|
"MtsTimeZoneDataTestCases",
|
||||||
"NanoAndroidTest",
|
"NanoAndroidTest",
|
||||||
"MtsLibnativehelperTestCases",
|
"MtsLibnativehelperTestCases",
|
||||||
|
|
||||||
|
// android_test_helper_app from allowlisted packages, but with unconverted deps
|
||||||
|
"SharedLibraryInfoTestApp",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bazel prod-mode allowlist. Modules in this list are built by Bazel
|
// Bazel prod-mode allowlist. Modules in this list are built by Bazel
|
||||||
|
|
|
@ -44,6 +44,7 @@ bootstrap_go_package {
|
||||||
"aidl_library_conversion_test.go",
|
"aidl_library_conversion_test.go",
|
||||||
"android_app_certificate_conversion_test.go",
|
"android_app_certificate_conversion_test.go",
|
||||||
"android_app_conversion_test.go",
|
"android_app_conversion_test.go",
|
||||||
|
"android_test_conversion_test.go",
|
||||||
"apex_conversion_test.go",
|
"apex_conversion_test.go",
|
||||||
"apex_key_conversion_test.go",
|
"apex_key_conversion_test.go",
|
||||||
"build_conversion_test.go",
|
"build_conversion_test.go",
|
||||||
|
|
103
bp2build/android_test_conversion_test.go
Normal file
103
bp2build/android_test_conversion_test.go
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
// 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 (
|
||||||
|
"android/soong/android"
|
||||||
|
"android/soong/java"
|
||||||
|
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func runAndroidTestTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||||
|
t.Helper()
|
||||||
|
RunBp2BuildTestCase(t, registerAndroidTestModuleTypes, tc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func registerAndroidTestModuleTypes(ctx android.RegistrationContext) {
|
||||||
|
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
||||||
|
ctx.RegisterModuleType("java_library", java.LibraryFactory)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMinimalAndroidTest(t *testing.T) {
|
||||||
|
runAndroidAppTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "Android test - simple example",
|
||||||
|
ModuleTypeUnderTest: "android_test",
|
||||||
|
ModuleTypeUnderTestFactory: java.AndroidTestFactory,
|
||||||
|
Filesystem: map[string]string{
|
||||||
|
"app.java": "",
|
||||||
|
"res/res.png": "",
|
||||||
|
"AndroidManifest.xml": "",
|
||||||
|
"assets/asset.png": "",
|
||||||
|
},
|
||||||
|
Blueprint: `
|
||||||
|
android_test {
|
||||||
|
name: "TestApp",
|
||||||
|
srcs: ["app.java"],
|
||||||
|
sdk_version: "current",
|
||||||
|
optimize: {
|
||||||
|
shrink: true,
|
||||||
|
optimize: true,
|
||||||
|
obfuscate: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
MakeBazelTarget("android_test", "TestApp", AttrNameToString{
|
||||||
|
"srcs": `["app.java"]`,
|
||||||
|
"manifest": `"AndroidManifest.xml"`,
|
||||||
|
"resource_files": `["res/res.png"]`,
|
||||||
|
"sdk_version": `"current"`,
|
||||||
|
"assets": `["assets/asset.png"]`,
|
||||||
|
"assets_dir": `"assets"`,
|
||||||
|
}),
|
||||||
|
}})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMinimalAndroidTestHelperApp(t *testing.T) {
|
||||||
|
runAndroidAppTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "Android test helper app - simple example",
|
||||||
|
ModuleTypeUnderTest: "android_test_helper_app",
|
||||||
|
ModuleTypeUnderTestFactory: java.AndroidTestHelperAppFactory,
|
||||||
|
Filesystem: map[string]string{
|
||||||
|
"app.java": "",
|
||||||
|
"res/res.png": "",
|
||||||
|
"AndroidManifest.xml": "",
|
||||||
|
"assets/asset.png": "",
|
||||||
|
},
|
||||||
|
Blueprint: `
|
||||||
|
android_test_helper_app {
|
||||||
|
name: "TestApp",
|
||||||
|
srcs: ["app.java"],
|
||||||
|
sdk_version: "current",
|
||||||
|
optimize: {
|
||||||
|
shrink: true,
|
||||||
|
optimize: true,
|
||||||
|
obfuscate: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
ExpectedBazelTargets: []string{
|
||||||
|
MakeBazelTarget("android_binary", "TestApp", AttrNameToString{
|
||||||
|
"srcs": `["app.java"]`,
|
||||||
|
"manifest": `"AndroidManifest.xml"`,
|
||||||
|
"resource_files": `["res/res.png"]`,
|
||||||
|
"sdk_version": `"current"`,
|
||||||
|
"assets": `["assets/asset.png"]`,
|
||||||
|
"assets_dir": `"assets"`,
|
||||||
|
"testonly": `True`,
|
||||||
|
}),
|
||||||
|
}})
|
||||||
|
}
|
27
java/app.go
27
java/app.go
|
@ -1258,6 +1258,8 @@ type AndroidTestHelperApp struct {
|
||||||
AndroidApp
|
AndroidApp
|
||||||
|
|
||||||
appTestHelperAppProperties appTestHelperAppProperties
|
appTestHelperAppProperties appTestHelperAppProperties
|
||||||
|
|
||||||
|
android.BazelModuleBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidTestHelperApp) InstallInTestcases() bool {
|
func (a *AndroidTestHelperApp) InstallInTestcases() bool {
|
||||||
|
@ -1289,6 +1291,7 @@ func AndroidTestHelperAppFactory() android.Module {
|
||||||
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
||||||
android.InitDefaultableModule(module)
|
android.InitDefaultableModule(module)
|
||||||
android.InitApexModule(module)
|
android.InitApexModule(module)
|
||||||
|
android.InitBazelModule(module)
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1799,3 +1802,27 @@ func (at *AndroidTest) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (atha *AndroidTestHelperApp) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
||||||
|
if ok, commonAttrs, appAttrs := convertWithBp2build(ctx, &atha.AndroidApp); ok {
|
||||||
|
// an android_test_helper_app is an android_binary with testonly = True
|
||||||
|
commonAttrs.Testonly = proptools.BoolPtr(true)
|
||||||
|
|
||||||
|
// additionally, it sets default values differently to android_app,
|
||||||
|
// https://cs.android.com/android/platform/superproject/main/+/main:build/soong/java/app.go;l=1273-1279;drc=e12c083198403ec694af6c625aed11327eb2bf7f
|
||||||
|
//
|
||||||
|
// installable: true (settable prop)
|
||||||
|
// use_embedded_native_libs: true (settable prop)
|
||||||
|
// lint.test: true (settable prop)
|
||||||
|
// optimize EnabledByDefault: true (blueprint mutated prop)
|
||||||
|
// AlwaysPackageNativeLibs: true (blueprint mutated prop)
|
||||||
|
// dexpreopt isTest: true (not prop)
|
||||||
|
|
||||||
|
props := bazel.BazelTargetModuleProperties{
|
||||||
|
Rule_class: "android_binary",
|
||||||
|
Bzl_load_location: "//build/bazel/rules/android:android_binary.bzl",
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.CreateBazelTargetModule(props, commonAttrs, appAttrs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue