Merge "export common bp2build testing functions"
This commit is contained in:
@@ -94,6 +94,10 @@ func (ll *LabelList) IsNil() bool {
|
||||
return ll.Includes == nil && ll.Excludes == nil
|
||||
}
|
||||
|
||||
func (ll *LabelList) IsEmpty() bool {
|
||||
return len(ll.Includes) == 0 && len(ll.Excludes) == 0
|
||||
}
|
||||
|
||||
func (ll *LabelList) deepCopy() LabelList {
|
||||
return LabelList{
|
||||
Includes: ll.Includes[:],
|
||||
|
@@ -21,28 +21,28 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runAndroidAppCertificateTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runAndroidAppCertificateTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, registerAndroidAppCertificateModuleTypes, tc)
|
||||
RunBp2BuildTestCase(t, registerAndroidAppCertificateModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerAndroidAppCertificateModuleTypes(ctx android.RegistrationContext) {
|
||||
}
|
||||
|
||||
func TestAndroidAppCertificateSimple(t *testing.T) {
|
||||
runAndroidAppCertificateTestCase(t, bp2buildTestCase{
|
||||
description: "Android app certificate - simple example",
|
||||
moduleTypeUnderTest: "android_app_certificate",
|
||||
moduleTypeUnderTestFactory: java.AndroidAppCertificateFactory,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runAndroidAppCertificateTestCase(t, Bp2buildTestCase{
|
||||
Description: "Android app certificate - simple example",
|
||||
ModuleTypeUnderTest: "android_app_certificate",
|
||||
ModuleTypeUnderTestFactory: java.AndroidAppCertificateFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
android_app_certificate {
|
||||
name: "com.android.apogee.cert",
|
||||
certificate: "chamber_of_secrets_dir",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTargetNoRestrictions("android_app_certificate", "com.android.apogee.cert", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("android_app_certificate", "com.android.apogee.cert", AttrNameToString{
|
||||
"certificate": `"chamber_of_secrets_dir"`,
|
||||
}),
|
||||
}})
|
||||
|
@@ -21,33 +21,33 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runAndroidAppTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runAndroidAppTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, registerAndroidAppModuleTypes, tc)
|
||||
RunBp2BuildTestCase(t, registerAndroidAppModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerAndroidAppModuleTypes(ctx android.RegistrationContext) {
|
||||
}
|
||||
|
||||
func TestMinimalAndroidApp(t *testing.T) {
|
||||
runAndroidAppTestCase(t, bp2buildTestCase{
|
||||
description: "Android app - simple example",
|
||||
moduleTypeUnderTest: "android_app",
|
||||
moduleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||
filesystem: map[string]string{
|
||||
runAndroidAppTestCase(t, Bp2buildTestCase{
|
||||
Description: "Android app - simple example",
|
||||
ModuleTypeUnderTest: "android_app",
|
||||
ModuleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||
Filesystem: map[string]string{
|
||||
"app.java": "",
|
||||
"res/res.png": "",
|
||||
"AndroidManifest.xml": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
android_app {
|
||||
name: "TestApp",
|
||||
srcs: ["app.java"],
|
||||
sdk_version: "current",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("android_binary", "TestApp", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("android_binary", "TestApp", AttrNameToString{
|
||||
"srcs": `["app.java"]`,
|
||||
"manifest": `"AndroidManifest.xml"`,
|
||||
"resource_files": `["res/res.png"]`,
|
||||
@@ -56,17 +56,17 @@ android_app {
|
||||
}
|
||||
|
||||
func TestAndroidAppAllSupportedFields(t *testing.T) {
|
||||
runAndroidAppTestCase(t, bp2buildTestCase{
|
||||
description: "Android app - all supported fields",
|
||||
moduleTypeUnderTest: "android_app",
|
||||
moduleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||
filesystem: map[string]string{
|
||||
runAndroidAppTestCase(t, Bp2buildTestCase{
|
||||
Description: "Android app - all supported fields",
|
||||
ModuleTypeUnderTest: "android_app",
|
||||
ModuleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||
Filesystem: map[string]string{
|
||||
"app.java": "",
|
||||
"resa/res.png": "",
|
||||
"resb/res.png": "",
|
||||
"manifest/AndroidManifest.xml": "",
|
||||
},
|
||||
blueprint: simpleModuleDoNotConvertBp2build("android_app", "static_lib_dep") + `
|
||||
Blueprint: simpleModuleDoNotConvertBp2build("android_app", "static_lib_dep") + `
|
||||
android_app {
|
||||
name: "TestApp",
|
||||
srcs: ["app.java"],
|
||||
@@ -78,8 +78,8 @@ android_app {
|
||||
java_version: "7",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("android_binary", "TestApp", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("android_binary", "TestApp", AttrNameToString{
|
||||
"srcs": `["app.java"]`,
|
||||
"manifest": `"manifest/AndroidManifest.xml"`,
|
||||
"resource_files": `[
|
||||
@@ -94,17 +94,17 @@ android_app {
|
||||
}
|
||||
|
||||
func TestAndroidAppArchVariantSrcs(t *testing.T) {
|
||||
runAndroidAppTestCase(t, bp2buildTestCase{
|
||||
description: "Android app - arch variant srcs",
|
||||
moduleTypeUnderTest: "android_app",
|
||||
moduleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||
filesystem: map[string]string{
|
||||
runAndroidAppTestCase(t, Bp2buildTestCase{
|
||||
Description: "Android app - arch variant srcs",
|
||||
ModuleTypeUnderTest: "android_app",
|
||||
ModuleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||
Filesystem: map[string]string{
|
||||
"arm.java": "",
|
||||
"x86.java": "",
|
||||
"res/res.png": "",
|
||||
"AndroidManifest.xml": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
android_app {
|
||||
name: "TestApp",
|
||||
sdk_version: "current",
|
||||
@@ -118,8 +118,8 @@ android_app {
|
||||
}
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("android_binary", "TestApp", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("android_binary", "TestApp", AttrNameToString{
|
||||
"srcs": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["arm.java"],
|
||||
"//build/bazel/platforms/arch:x86": ["x86.java"],
|
||||
|
@@ -25,9 +25,9 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runApexTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runApexTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, registerApexModuleTypes, tc)
|
||||
RunBp2BuildTestCase(t, registerApexModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerApexModuleTypes(ctx android.RegistrationContext) {
|
||||
@@ -43,9 +43,9 @@ func registerApexModuleTypes(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("prebuilt_etc", etc.PrebuiltEtcFactory)
|
||||
}
|
||||
|
||||
func runOverrideApexTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runOverrideApexTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, registerOverrideApexModuleTypes, tc)
|
||||
RunBp2BuildTestCase(t, registerOverrideApexModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerOverrideApexModuleTypes(ctx android.RegistrationContext) {
|
||||
@@ -63,12 +63,12 @@ func registerOverrideApexModuleTypes(ctx android.RegistrationContext) {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple(t *testing.T) {
|
||||
runApexTestCase(t, bp2buildTestCase{
|
||||
description: "apex - example with all props, file_context is a module in same Android.bp",
|
||||
moduleTypeUnderTest: "apex",
|
||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "apex - example with all props, file_context is a module in same Android.bp",
|
||||
ModuleTypeUnderTest: "apex",
|
||||
ModuleTypeUnderTestFactory: apex.BundleFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
apex_key {
|
||||
name: "com.android.apogee.key",
|
||||
public_key: "com.android.apogee.avbpubkey",
|
||||
@@ -140,8 +140,8 @@ apex {
|
||||
logging_parent: "logging.parent",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", AttrNameToString{
|
||||
"android_manifest": `"ApogeeAndroidManifest.xml"`,
|
||||
"binaries": `[
|
||||
":cc_binary_1",
|
||||
@@ -181,11 +181,11 @@ apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_fileContextsInAnotherAndroidBp(t *testing.T) {
|
||||
runApexTestCase(t, bp2buildTestCase{
|
||||
description: "apex - file contexts is a module in another Android.bp",
|
||||
moduleTypeUnderTest: "apex",
|
||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||
filesystem: map[string]string{
|
||||
runApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "apex - file contexts is a module in another Android.bp",
|
||||
ModuleTypeUnderTest: "apex",
|
||||
ModuleTypeUnderTestFactory: apex.BundleFactory,
|
||||
Filesystem: map[string]string{
|
||||
"a/b/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -196,14 +196,14 @@ filegroup {
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
apex {
|
||||
name: "com.android.apogee",
|
||||
file_contexts: ":com.android.apogee-file_contexts",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//a/b:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"apex_manifest.json"`,
|
||||
}),
|
||||
@@ -211,19 +211,19 @@ apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_fileContextsIsFile(t *testing.T) {
|
||||
runApexTestCase(t, bp2buildTestCase{
|
||||
description: "apex - file contexts is a file",
|
||||
moduleTypeUnderTest: "apex",
|
||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "apex - file contexts is a file",
|
||||
ModuleTypeUnderTest: "apex",
|
||||
ModuleTypeUnderTestFactory: apex.BundleFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
apex {
|
||||
name: "com.android.apogee",
|
||||
file_contexts: "file_contexts_file",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"file_contexts_file"`,
|
||||
"manifest": `"apex_manifest.json"`,
|
||||
}),
|
||||
@@ -231,11 +231,11 @@ apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_fileContextsIsNotSpecified(t *testing.T) {
|
||||
runApexTestCase(t, bp2buildTestCase{
|
||||
description: "apex - file contexts is not specified",
|
||||
moduleTypeUnderTest: "apex",
|
||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||
filesystem: map[string]string{
|
||||
runApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "apex - file contexts is not specified",
|
||||
ModuleTypeUnderTest: "apex",
|
||||
ModuleTypeUnderTestFactory: apex.BundleFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -246,13 +246,13 @@ filegroup {
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
apex {
|
||||
name: "com.android.apogee",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"apex_manifest.json"`,
|
||||
}),
|
||||
@@ -260,11 +260,11 @@ apex {
|
||||
}
|
||||
|
||||
func TestApexBundleCompileMultilibBoth(t *testing.T) {
|
||||
runApexTestCase(t, bp2buildTestCase{
|
||||
description: "apex - example with compile_multilib=both",
|
||||
moduleTypeUnderTest: "apex",
|
||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||
filesystem: map[string]string{
|
||||
runApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "apex - example with compile_multilib=both",
|
||||
ModuleTypeUnderTest: "apex",
|
||||
ModuleTypeUnderTestFactory: apex.BundleFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -273,9 +273,9 @@ filegroup {
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: createMultilibBlueprint("both"),
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", attrNameToString{
|
||||
Blueprint: createMultilibBlueprint("both"),
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", AttrNameToString{
|
||||
"native_shared_libs_32": `[
|
||||
":native_shared_lib_1",
|
||||
":native_shared_lib_3",
|
||||
@@ -304,11 +304,11 @@ filegroup {
|
||||
}
|
||||
|
||||
func TestApexBundleCompileMultilibFirst(t *testing.T) {
|
||||
runApexTestCase(t, bp2buildTestCase{
|
||||
description: "apex - example with compile_multilib=first",
|
||||
moduleTypeUnderTest: "apex",
|
||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||
filesystem: map[string]string{
|
||||
runApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "apex - example with compile_multilib=first",
|
||||
ModuleTypeUnderTest: "apex",
|
||||
ModuleTypeUnderTestFactory: apex.BundleFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -317,9 +317,9 @@ filegroup {
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: createMultilibBlueprint("first"),
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", attrNameToString{
|
||||
Blueprint: createMultilibBlueprint("first"),
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", AttrNameToString{
|
||||
"native_shared_libs_32": `select({
|
||||
"//build/bazel/platforms/arch:arm": [
|
||||
":native_shared_lib_1",
|
||||
@@ -353,11 +353,11 @@ filegroup {
|
||||
}
|
||||
|
||||
func TestApexBundleCompileMultilib32(t *testing.T) {
|
||||
runApexTestCase(t, bp2buildTestCase{
|
||||
description: "apex - example with compile_multilib=32",
|
||||
moduleTypeUnderTest: "apex",
|
||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||
filesystem: map[string]string{
|
||||
runApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "apex - example with compile_multilib=32",
|
||||
ModuleTypeUnderTest: "apex",
|
||||
ModuleTypeUnderTestFactory: apex.BundleFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -366,9 +366,9 @@ filegroup {
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: createMultilibBlueprint("32"),
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", attrNameToString{
|
||||
Blueprint: createMultilibBlueprint("32"),
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", AttrNameToString{
|
||||
"native_shared_libs_32": `[
|
||||
":native_shared_lib_1",
|
||||
":native_shared_lib_3",
|
||||
@@ -384,11 +384,11 @@ filegroup {
|
||||
}
|
||||
|
||||
func TestApexBundleCompileMultilib64(t *testing.T) {
|
||||
runApexTestCase(t, bp2buildTestCase{
|
||||
description: "apex - example with compile_multilib=64",
|
||||
moduleTypeUnderTest: "apex",
|
||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||
filesystem: map[string]string{
|
||||
runApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "apex - example with compile_multilib=64",
|
||||
ModuleTypeUnderTest: "apex",
|
||||
ModuleTypeUnderTestFactory: apex.BundleFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -397,9 +397,9 @@ filegroup {
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: createMultilibBlueprint("64"),
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", attrNameToString{
|
||||
Blueprint: createMultilibBlueprint("64"),
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.android.apogee", AttrNameToString{
|
||||
"native_shared_libs_64": `select({
|
||||
"//build/bazel/platforms/arch:arm64": [
|
||||
":native_shared_lib_1",
|
||||
@@ -420,11 +420,11 @@ filegroup {
|
||||
}
|
||||
|
||||
func TestApexBundleDefaultPropertyValues(t *testing.T) {
|
||||
runApexTestCase(t, bp2buildTestCase{
|
||||
description: "apex - default property values",
|
||||
moduleTypeUnderTest: "apex",
|
||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||
filesystem: map[string]string{
|
||||
runApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "apex - default property values",
|
||||
ModuleTypeUnderTest: "apex",
|
||||
ModuleTypeUnderTestFactory: apex.BundleFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -433,13 +433,13 @@ filegroup {
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
apex {
|
||||
name: "com.android.apogee",
|
||||
manifest: "apogee_manifest.json",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{makeBazelTarget("apex", "com.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{makeBazelTarget("apex", "com.android.apogee", AttrNameToString{
|
||||
"manifest": `"apogee_manifest.json"`,
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
}),
|
||||
@@ -447,11 +447,11 @@ apex {
|
||||
}
|
||||
|
||||
func TestApexBundleHasBazelModuleProps(t *testing.T) {
|
||||
runApexTestCase(t, bp2buildTestCase{
|
||||
description: "apex - has bazel module props",
|
||||
moduleTypeUnderTest: "apex",
|
||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||
filesystem: map[string]string{
|
||||
runApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "apex - has bazel module props",
|
||||
ModuleTypeUnderTest: "apex",
|
||||
ModuleTypeUnderTestFactory: apex.BundleFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "apogee-file_contexts",
|
||||
@@ -460,14 +460,14 @@ filegroup {
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
apex {
|
||||
name: "apogee",
|
||||
manifest: "manifest.json",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{makeBazelTarget("apex", "apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{makeBazelTarget("apex", "apogee", AttrNameToString{
|
||||
"manifest": `"manifest.json"`,
|
||||
"file_contexts": `"//system/sepolicy/apex:apogee-file_contexts"`,
|
||||
}),
|
||||
@@ -525,12 +525,12 @@ apex {
|
||||
}
|
||||
|
||||
func TestBp2BuildOverrideApex(t *testing.T) {
|
||||
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||
description: "override_apex",
|
||||
moduleTypeUnderTest: "override_apex",
|
||||
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runOverrideApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "override_apex",
|
||||
ModuleTypeUnderTest: "override_apex",
|
||||
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
apex_key {
|
||||
name: "com.android.apogee.key",
|
||||
public_key: "com.android.apogee.avbpubkey",
|
||||
@@ -623,8 +623,8 @@ override_apex {
|
||||
compressible: true,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
|
||||
"android_manifest": `"ApogeeAndroidManifest.xml"`,
|
||||
"binaries": `[
|
||||
":cc_binary_1",
|
||||
@@ -659,11 +659,11 @@ override_apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) {
|
||||
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||
description: "override_apex - manifest of base apex is empty, base apex and override_apex is in different Android.bp",
|
||||
moduleTypeUnderTest: "override_apex",
|
||||
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
filesystem: map[string]string{
|
||||
runOverrideApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in different Android.bp",
|
||||
ModuleTypeUnderTest: "override_apex",
|
||||
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -677,14 +677,14 @@ apex {
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
override_apex {
|
||||
name: "com.google.android.apogee",
|
||||
base: ":com.android.apogee",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"//a/b:apex_manifest.json"`,
|
||||
}),
|
||||
@@ -692,11 +692,11 @@ override_apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInDifferentAndroidBp(t *testing.T) {
|
||||
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||
description: "override_apex - manifest of base apex is set, base apex and override_apex is in different Android.bp",
|
||||
moduleTypeUnderTest: "override_apex",
|
||||
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
filesystem: map[string]string{
|
||||
runOverrideApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "override_apex - manifest of base apex is set, base apex and override_apex is in different Android.bp",
|
||||
ModuleTypeUnderTest: "override_apex",
|
||||
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -711,14 +711,14 @@ apex {
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
override_apex {
|
||||
name: "com.google.android.apogee",
|
||||
base: ":com.android.apogee",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"//a/b:apogee_manifest.json"`,
|
||||
}),
|
||||
@@ -726,11 +726,11 @@ override_apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_manifestIsEmpty_baseApexOverrideApexInSameAndroidBp(t *testing.T) {
|
||||
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||
description: "override_apex - manifest of base apex is empty, base apex and override_apex is in same Android.bp",
|
||||
moduleTypeUnderTest: "override_apex",
|
||||
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
filesystem: map[string]string{
|
||||
runOverrideApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "override_apex - manifest of base apex is empty, base apex and override_apex is in same Android.bp",
|
||||
ModuleTypeUnderTest: "override_apex",
|
||||
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -738,7 +738,7 @@ filegroup {
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
apex {
|
||||
name: "com.android.apogee",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -749,8 +749,8 @@ override_apex {
|
||||
base: ":com.android.apogee",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"apex_manifest.json"`,
|
||||
}),
|
||||
@@ -758,11 +758,11 @@ override_apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_manifestIsSet_baseApexOverrideApexInSameAndroidBp(t *testing.T) {
|
||||
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||
description: "override_apex - manifest of base apex is set, base apex and override_apex is in same Android.bp",
|
||||
moduleTypeUnderTest: "override_apex",
|
||||
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
filesystem: map[string]string{
|
||||
runOverrideApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "override_apex - manifest of base apex is set, base apex and override_apex is in same Android.bp",
|
||||
ModuleTypeUnderTest: "override_apex",
|
||||
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -770,7 +770,7 @@ filegroup {
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
apex {
|
||||
name: "com.android.apogee",
|
||||
manifest: "apogee_manifest.json",
|
||||
@@ -782,8 +782,8 @@ override_apex {
|
||||
base: ":com.android.apogee",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"apogee_manifest.json"`,
|
||||
}),
|
||||
@@ -791,11 +791,11 @@ override_apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_packageNameOverride(t *testing.T) {
|
||||
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||
description: "override_apex - override package name",
|
||||
moduleTypeUnderTest: "override_apex",
|
||||
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
filesystem: map[string]string{
|
||||
runOverrideApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "override_apex - override package name",
|
||||
ModuleTypeUnderTest: "override_apex",
|
||||
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -803,7 +803,7 @@ filegroup {
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
apex {
|
||||
name: "com.android.apogee",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -815,8 +815,8 @@ override_apex {
|
||||
package_name: "com.google.android.apogee",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"apex_manifest.json"`,
|
||||
"package_name": `"com.google.android.apogee"`,
|
||||
@@ -825,11 +825,11 @@ override_apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_NoPrebuiltsOverride(t *testing.T) {
|
||||
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||
description: "override_apex - no override",
|
||||
moduleTypeUnderTest: "override_apex",
|
||||
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
filesystem: map[string]string{
|
||||
runOverrideApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "override_apex - no override",
|
||||
ModuleTypeUnderTest: "override_apex",
|
||||
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -837,7 +837,7 @@ filegroup {
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
prebuilt_etc {
|
||||
name: "prebuilt_file",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -854,8 +854,8 @@ override_apex {
|
||||
base: ":com.android.apogee",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"apex_manifest.json"`,
|
||||
"prebuilts": `[":prebuilt_file"]`,
|
||||
@@ -864,11 +864,11 @@ override_apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_PrebuiltsOverride(t *testing.T) {
|
||||
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||
description: "override_apex - ooverride",
|
||||
moduleTypeUnderTest: "override_apex",
|
||||
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
filesystem: map[string]string{
|
||||
runOverrideApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "override_apex - ooverride",
|
||||
ModuleTypeUnderTest: "override_apex",
|
||||
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -876,7 +876,7 @@ filegroup {
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
prebuilt_etc {
|
||||
name: "prebuilt_file",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -899,8 +899,8 @@ override_apex {
|
||||
prebuilts: ["prebuilt_file2"]
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"apex_manifest.json"`,
|
||||
"prebuilts": `[":prebuilt_file2"]`,
|
||||
@@ -909,11 +909,11 @@ override_apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_PrebuiltsOverrideEmptyList(t *testing.T) {
|
||||
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||
description: "override_apex - override with empty list",
|
||||
moduleTypeUnderTest: "override_apex",
|
||||
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
filesystem: map[string]string{
|
||||
runOverrideApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "override_apex - override with empty list",
|
||||
ModuleTypeUnderTest: "override_apex",
|
||||
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -921,7 +921,7 @@ filegroup {
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
prebuilt_etc {
|
||||
name: "prebuilt_file",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -939,8 +939,8 @@ override_apex {
|
||||
prebuilts: [],
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"apex_manifest.json"`,
|
||||
"prebuilts": `[]`,
|
||||
@@ -949,11 +949,11 @@ override_apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_NoLoggingParentOverride(t *testing.T) {
|
||||
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||
description: "override_apex - logging_parent - no override",
|
||||
moduleTypeUnderTest: "override_apex",
|
||||
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
filesystem: map[string]string{
|
||||
runOverrideApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "override_apex - logging_parent - no override",
|
||||
ModuleTypeUnderTest: "override_apex",
|
||||
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -961,7 +961,7 @@ filegroup {
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
apex {
|
||||
name: "com.android.apogee",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -973,8 +973,8 @@ override_apex {
|
||||
base: ":com.android.apogee",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"apex_manifest.json"`,
|
||||
"logging_parent": `"foo.bar.baz"`,
|
||||
@@ -983,11 +983,11 @@ override_apex {
|
||||
}
|
||||
|
||||
func TestApexBundleSimple_LoggingParentOverride(t *testing.T) {
|
||||
runOverrideApexTestCase(t, bp2buildTestCase{
|
||||
description: "override_apex - logging_parent - override",
|
||||
moduleTypeUnderTest: "override_apex",
|
||||
moduleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
filesystem: map[string]string{
|
||||
runOverrideApexTestCase(t, Bp2buildTestCase{
|
||||
Description: "override_apex - logging_parent - override",
|
||||
ModuleTypeUnderTest: "override_apex",
|
||||
ModuleTypeUnderTestFactory: apex.OverrideApexFactory,
|
||||
Filesystem: map[string]string{
|
||||
"system/sepolicy/apex/Android.bp": `
|
||||
filegroup {
|
||||
name: "com.android.apogee-file_contexts",
|
||||
@@ -995,7 +995,7 @@ filegroup {
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
apex {
|
||||
name: "com.android.apogee",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -1008,8 +1008,8 @@ override_apex {
|
||||
logging_parent: "foo.bar.baz.override",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{
|
||||
"file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`,
|
||||
"manifest": `"apex_manifest.json"`,
|
||||
"logging_parent": `"foo.bar.baz.override"`,
|
||||
|
@@ -21,28 +21,28 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runApexKeyTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runApexKeyTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, registerApexKeyModuleTypes, tc)
|
||||
RunBp2BuildTestCase(t, registerApexKeyModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerApexKeyModuleTypes(ctx android.RegistrationContext) {
|
||||
}
|
||||
|
||||
func TestApexKeySimple(t *testing.T) {
|
||||
runApexKeyTestCase(t, bp2buildTestCase{
|
||||
description: "apex key - simple example",
|
||||
moduleTypeUnderTest: "apex_key",
|
||||
moduleTypeUnderTestFactory: apex.ApexKeyFactory,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runApexKeyTestCase(t, Bp2buildTestCase{
|
||||
Description: "apex key - simple example",
|
||||
ModuleTypeUnderTest: "apex_key",
|
||||
ModuleTypeUnderTestFactory: apex.ApexKeyFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
apex_key {
|
||||
name: "com.android.apogee.key",
|
||||
public_key: "com.android.apogee.avbpubkey",
|
||||
private_key: "com.android.apogee.pem",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{makeBazelTargetNoRestrictions("apex_key", "com.android.apogee.key", attrNameToString{
|
||||
ExpectedBazelTargets: []string{MakeBazelTargetNoRestrictions("apex_key", "com.android.apogee.key", AttrNameToString{
|
||||
"private_key": `"com.android.apogee.pem"`,
|
||||
"public_key": `"com.android.apogee.avbpubkey"`,
|
||||
}),
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,7 @@ const (
|
||||
type testBazelTarget struct {
|
||||
typ string
|
||||
name string
|
||||
attrs attrNameToString
|
||||
attrs AttrNameToString
|
||||
}
|
||||
|
||||
func generateBazelTargetsForTest(targets []testBazelTarget, hod android.HostOrDeviceSupported) []string {
|
||||
@@ -73,12 +73,12 @@ func runCcBinaryTestCase(t *testing.T, testCase ccBinaryBp2buildTestCase) {
|
||||
description := fmt.Sprintf("%s %s", moduleTypeUnderTest, testCase.description)
|
||||
t.Run(description, func(t *testing.T) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, registerCcBinaryModuleTypes, bp2buildTestCase{
|
||||
expectedBazelTargets: generateBazelTargetsForTest(testCase.targets, android.DeviceSupported),
|
||||
moduleTypeUnderTest: moduleTypeUnderTest,
|
||||
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
description: description,
|
||||
blueprint: binaryReplacer.Replace(testCase.blueprint),
|
||||
RunBp2BuildTestCase(t, registerCcBinaryModuleTypes, Bp2buildTestCase{
|
||||
ExpectedBazelTargets: generateBazelTargetsForTest(testCase.targets, android.DeviceSupported),
|
||||
ModuleTypeUnderTest: moduleTypeUnderTest,
|
||||
ModuleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
Description: description,
|
||||
Blueprint: binaryReplacer.Replace(testCase.blueprint),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -88,12 +88,12 @@ func runCcHostBinaryTestCase(t *testing.T, testCase ccBinaryBp2buildTestCase) {
|
||||
moduleTypeUnderTest := "cc_binary_host"
|
||||
description := fmt.Sprintf("%s %s", moduleTypeUnderTest, testCase.description)
|
||||
t.Run(description, func(t *testing.T) {
|
||||
runBp2BuildTestCase(t, registerCcBinaryModuleTypes, bp2buildTestCase{
|
||||
expectedBazelTargets: generateBazelTargetsForTest(testCase.targets, android.HostSupported),
|
||||
moduleTypeUnderTest: moduleTypeUnderTest,
|
||||
moduleTypeUnderTestFactory: cc.BinaryHostFactory,
|
||||
description: description,
|
||||
blueprint: hostBinaryReplacer.Replace(testCase.blueprint),
|
||||
RunBp2BuildTestCase(t, registerCcBinaryModuleTypes, Bp2buildTestCase{
|
||||
ExpectedBazelTargets: generateBazelTargetsForTest(testCase.targets, android.HostSupported),
|
||||
ModuleTypeUnderTest: moduleTypeUnderTest,
|
||||
ModuleTypeUnderTestFactory: cc.BinaryHostFactory,
|
||||
Description: description,
|
||||
Blueprint: hostBinaryReplacer.Replace(testCase.blueprint),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func TestBasicCcBinary(t *testing.T) {
|
||||
}
|
||||
`,
|
||||
targets: []testBazelTarget{
|
||||
{"cc_binary", "foo", attrNameToString{
|
||||
{"cc_binary", "foo", AttrNameToString{
|
||||
"absolute_includes": `["absolute_dir"]`,
|
||||
"asflags": `["-Dasflag"]`,
|
||||
"conlyflags": `["-Dconlyflag"]`,
|
||||
@@ -166,7 +166,7 @@ func TestCcBinaryWithSharedLdflagDisableFeature(t *testing.T) {
|
||||
}
|
||||
`,
|
||||
targets: []testBazelTarget{
|
||||
{"cc_binary", "foo", attrNameToString{
|
||||
{"cc_binary", "foo", AttrNameToString{
|
||||
"features": `["-static_flag"]`,
|
||||
"linkopts": `["-shared"]`,
|
||||
},
|
||||
@@ -186,7 +186,7 @@ func TestCcBinaryWithLinkStatic(t *testing.T) {
|
||||
}
|
||||
`,
|
||||
targets: []testBazelTarget{
|
||||
{"cc_binary", "foo", attrNameToString{
|
||||
{"cc_binary", "foo", AttrNameToString{
|
||||
"linkshared": `False`,
|
||||
},
|
||||
},
|
||||
@@ -205,7 +205,7 @@ func TestCcBinaryVersionScript(t *testing.T) {
|
||||
}
|
||||
`,
|
||||
targets: []testBazelTarget{
|
||||
{"cc_binary", "foo", attrNameToString{
|
||||
{"cc_binary", "foo", AttrNameToString{
|
||||
"additional_linker_inputs": `["vs"]`,
|
||||
"linkopts": `["-Wl,--version-script,$(location vs)"]`,
|
||||
},
|
||||
@@ -230,7 +230,7 @@ func TestCcBinarySplitSrcsByLang(t *testing.T) {
|
||||
}
|
||||
` + simpleModuleDoNotConvertBp2build("filegroup", "fg_foo"),
|
||||
targets: []testBazelTarget{
|
||||
{"cc_binary", "foo", attrNameToString{
|
||||
{"cc_binary", "foo", AttrNameToString{
|
||||
"srcs": `[
|
||||
"cpponly.cpp",
|
||||
":fg_foo_cpp_srcs",
|
||||
@@ -285,7 +285,7 @@ genrule {
|
||||
simpleModuleDoNotConvertBp2build("cc_library", "shared_dep") +
|
||||
simpleModuleDoNotConvertBp2build("cc_library", "implementation_shared_dep"),
|
||||
targets: []testBazelTarget{
|
||||
{"cc_binary", "foo", attrNameToString{
|
||||
{"cc_binary", "foo", AttrNameToString{
|
||||
"deps": `[
|
||||
":implementation_static_dep",
|
||||
":static_dep",
|
||||
@@ -314,21 +314,21 @@ func TestCcBinaryNocrtTests(t *testing.T) {
|
||||
baseTestCases := []struct {
|
||||
description string
|
||||
soongProperty string
|
||||
bazelAttr attrNameToString
|
||||
bazelAttr AttrNameToString
|
||||
}{
|
||||
{
|
||||
description: "nocrt: true",
|
||||
soongProperty: `nocrt: true,`,
|
||||
bazelAttr: attrNameToString{"link_crt": `False`},
|
||||
bazelAttr: AttrNameToString{"link_crt": `False`},
|
||||
},
|
||||
{
|
||||
description: "nocrt: false",
|
||||
soongProperty: `nocrt: false,`,
|
||||
bazelAttr: attrNameToString{},
|
||||
bazelAttr: AttrNameToString{},
|
||||
},
|
||||
{
|
||||
description: "nocrt: not set",
|
||||
bazelAttr: attrNameToString{},
|
||||
bazelAttr: AttrNameToString{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -357,21 +357,21 @@ func TestCcBinaryNo_libcrtTests(t *testing.T) {
|
||||
baseTestCases := []struct {
|
||||
description string
|
||||
soongProperty string
|
||||
bazelAttr attrNameToString
|
||||
bazelAttr AttrNameToString
|
||||
}{
|
||||
{
|
||||
description: "no_libcrt: true",
|
||||
soongProperty: `no_libcrt: true,`,
|
||||
bazelAttr: attrNameToString{"use_libcrt": `False`},
|
||||
bazelAttr: AttrNameToString{"use_libcrt": `False`},
|
||||
},
|
||||
{
|
||||
description: "no_libcrt: false",
|
||||
soongProperty: `no_libcrt: false,`,
|
||||
bazelAttr: attrNameToString{"use_libcrt": `True`},
|
||||
bazelAttr: AttrNameToString{"use_libcrt": `True`},
|
||||
},
|
||||
{
|
||||
description: "no_libcrt: not set",
|
||||
bazelAttr: attrNameToString{},
|
||||
bazelAttr: AttrNameToString{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -400,35 +400,35 @@ func TestCcBinaryPropertiesToFeatures(t *testing.T) {
|
||||
baseTestCases := []struct {
|
||||
description string
|
||||
soongProperty string
|
||||
bazelAttr attrNameToString
|
||||
bazelAttr AttrNameToString
|
||||
}{
|
||||
{
|
||||
description: "pack_relocation: true",
|
||||
soongProperty: `pack_relocations: true,`,
|
||||
bazelAttr: attrNameToString{},
|
||||
bazelAttr: AttrNameToString{},
|
||||
},
|
||||
{
|
||||
description: "pack_relocations: false",
|
||||
soongProperty: `pack_relocations: false,`,
|
||||
bazelAttr: attrNameToString{"features": `["disable_pack_relocations"]`},
|
||||
bazelAttr: AttrNameToString{"features": `["disable_pack_relocations"]`},
|
||||
},
|
||||
{
|
||||
description: "pack_relocations: not set",
|
||||
bazelAttr: attrNameToString{},
|
||||
bazelAttr: AttrNameToString{},
|
||||
},
|
||||
{
|
||||
description: "pack_relocation: true",
|
||||
soongProperty: `allow_undefined_symbols: true,`,
|
||||
bazelAttr: attrNameToString{"features": `["-no_undefined_symbols"]`},
|
||||
bazelAttr: AttrNameToString{"features": `["-no_undefined_symbols"]`},
|
||||
},
|
||||
{
|
||||
description: "allow_undefined_symbols: false",
|
||||
soongProperty: `allow_undefined_symbols: false,`,
|
||||
bazelAttr: attrNameToString{},
|
||||
bazelAttr: AttrNameToString{},
|
||||
},
|
||||
{
|
||||
description: "allow_undefined_symbols: not set",
|
||||
bazelAttr: attrNameToString{},
|
||||
bazelAttr: AttrNameToString{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -462,11 +462,11 @@ func TestCcBinarySharedProto(t *testing.T) {
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
targets: []testBazelTarget{
|
||||
{"proto_library", "foo_proto", attrNameToString{
|
||||
{"proto_library", "foo_proto", AttrNameToString{
|
||||
"srcs": `["foo.proto"]`,
|
||||
}}, {"cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
|
||||
}}, {"cc_lite_proto_library", "foo_cc_proto_lite", AttrNameToString{
|
||||
"deps": `[":foo_proto"]`,
|
||||
}}, {"cc_binary", "foo", attrNameToString{
|
||||
}}, {"cc_binary", "foo", AttrNameToString{
|
||||
"dynamic_deps": `[":libprotobuf-cpp-lite"]`,
|
||||
"whole_archive_deps": `[":foo_cc_proto_lite"]`,
|
||||
}},
|
||||
@@ -485,11 +485,11 @@ func TestCcBinaryStaticProto(t *testing.T) {
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
targets: []testBazelTarget{
|
||||
{"proto_library", "foo_proto", attrNameToString{
|
||||
{"proto_library", "foo_proto", AttrNameToString{
|
||||
"srcs": `["foo.proto"]`,
|
||||
}}, {"cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
|
||||
}}, {"cc_lite_proto_library", "foo_cc_proto_lite", AttrNameToString{
|
||||
"deps": `[":foo_proto"]`,
|
||||
}}, {"cc_binary", "foo", attrNameToString{
|
||||
}}, {"cc_binary", "foo", AttrNameToString{
|
||||
"deps": `[":libprotobuf-cpp-lite"]`,
|
||||
"whole_archive_deps": `[":foo_cc_proto_lite"]`,
|
||||
"linkshared": `False`,
|
||||
@@ -510,7 +510,7 @@ func TestCcBinaryConvertLex(t *testing.T) {
|
||||
}
|
||||
`,
|
||||
targets: []testBazelTarget{
|
||||
{"genlex", "foo_genlex_l", attrNameToString{
|
||||
{"genlex", "foo_genlex_l", AttrNameToString{
|
||||
"srcs": `[
|
||||
"foo1.l",
|
||||
"foo2.l",
|
||||
@@ -520,7 +520,7 @@ func TestCcBinaryConvertLex(t *testing.T) {
|
||||
"--bar_opt",
|
||||
]`,
|
||||
}},
|
||||
{"genlex", "foo_genlex_ll", attrNameToString{
|
||||
{"genlex", "foo_genlex_ll", AttrNameToString{
|
||||
"srcs": `[
|
||||
"bar1.ll",
|
||||
"bar2.ll",
|
||||
@@ -530,7 +530,7 @@ func TestCcBinaryConvertLex(t *testing.T) {
|
||||
"--bar_opt",
|
||||
]`,
|
||||
}},
|
||||
{"cc_binary", "foo", attrNameToString{
|
||||
{"cc_binary", "foo", AttrNameToString{
|
||||
"srcs": `[
|
||||
"bar.cc",
|
||||
":foo_genlex_ll",
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -59,17 +59,17 @@ func registerCcLibraryHeadersModuleTypes(ctx android.RegistrationContext) {
|
||||
cc.RegisterCCBuildComponents(ctx)
|
||||
}
|
||||
|
||||
func runCcLibraryHeadersTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runCcLibraryHeadersTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, registerCcLibraryHeadersModuleTypes, tc)
|
||||
RunBp2BuildTestCase(t, registerCcLibraryHeadersModuleTypes, tc)
|
||||
}
|
||||
|
||||
func TestCcLibraryHeadersSimple(t *testing.T) {
|
||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_headers test",
|
||||
moduleTypeUnderTest: "cc_library_headers",
|
||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
filesystem: map[string]string{
|
||||
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_headers test",
|
||||
ModuleTypeUnderTest: "cc_library_headers",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
Filesystem: map[string]string{
|
||||
"lib-1/lib1a.h": "",
|
||||
"lib-1/lib1b.h": "",
|
||||
"lib-2/lib2a.h": "",
|
||||
@@ -82,7 +82,7 @@ func TestCcLibraryHeadersSimple(t *testing.T) {
|
||||
"arch_x86_exported_include_dir/b.h": "",
|
||||
"arch_x86_64_exported_include_dir/c.h": "",
|
||||
},
|
||||
blueprint: soongCcLibraryHeadersPreamble + `
|
||||
Blueprint: soongCcLibraryHeadersPreamble + `
|
||||
cc_library_headers {
|
||||
name: "foo_headers",
|
||||
export_include_dirs: ["dir-1", "dir-2"],
|
||||
@@ -105,8 +105,8 @@ cc_library_headers {
|
||||
|
||||
// TODO: Also support export_header_lib_headers
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
|
||||
"export_includes": `[
|
||||
"dir-1",
|
||||
"dir-2",
|
||||
@@ -124,12 +124,12 @@ cc_library_headers {
|
||||
}
|
||||
|
||||
func TestCcLibraryHeadersOsSpecificHeader(t *testing.T) {
|
||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_headers test with os-specific header_libs props",
|
||||
moduleTypeUnderTest: "cc_library_headers",
|
||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_headers test with os-specific header_libs props",
|
||||
ModuleTypeUnderTest: "cc_library_headers",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: soongCcLibraryPreamble + `
|
||||
cc_library_headers {
|
||||
name: "android-lib",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -182,8 +182,8 @@ cc_library_headers {
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
|
||||
"deps": `[":base-lib"] + select({
|
||||
"//build/bazel/platforms/os:android": [":android-lib"],
|
||||
"//build/bazel/platforms/os:darwin": [":darwin-lib"],
|
||||
@@ -198,12 +198,12 @@ cc_library_headers {
|
||||
}
|
||||
|
||||
func TestCcLibraryHeadersOsSpecficHeaderLibsExportHeaderLibHeaders(t *testing.T) {
|
||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_headers test with os-specific header_libs and export_header_lib_headers props",
|
||||
moduleTypeUnderTest: "cc_library_headers",
|
||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_headers test with os-specific header_libs and export_header_lib_headers props",
|
||||
ModuleTypeUnderTest: "cc_library_headers",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: soongCcLibraryPreamble + `
|
||||
cc_library_headers {
|
||||
name: "android-lib",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -222,8 +222,8 @@ cc_library_headers {
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
|
||||
"deps": `select({
|
||||
"//build/bazel/platforms/os:android": [":exported-lib"],
|
||||
"//conditions:default": [],
|
||||
@@ -234,12 +234,12 @@ cc_library_headers {
|
||||
}
|
||||
|
||||
func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
|
||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_headers test with arch-specific and target-specific export_system_include_dirs props",
|
||||
moduleTypeUnderTest: "cc_library_headers",
|
||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryPreamble + `cc_library_headers {
|
||||
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_headers test with arch-specific and target-specific export_system_include_dirs props",
|
||||
ModuleTypeUnderTest: "cc_library_headers",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: soongCcLibraryPreamble + `cc_library_headers {
|
||||
name: "foo_headers",
|
||||
export_system_include_dirs: [
|
||||
"shared_include_dir",
|
||||
@@ -275,8 +275,8 @@ func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
|
||||
"export_system_includes": `["shared_include_dir"] + select({
|
||||
"//build/bazel/platforms/arch:arm": ["arm_include_dir"],
|
||||
"//build/bazel/platforms/arch:x86_64": ["x86_64_include_dir"],
|
||||
@@ -293,11 +293,11 @@ func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCcLibraryHeadersNoCrtIgnored(t *testing.T) {
|
||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_headers test",
|
||||
moduleTypeUnderTest: "cc_library_headers",
|
||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
filesystem: map[string]string{
|
||||
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_headers test",
|
||||
ModuleTypeUnderTest: "cc_library_headers",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
Filesystem: map[string]string{
|
||||
"lib-1/lib1a.h": "",
|
||||
"lib-1/lib1b.h": "",
|
||||
"lib-2/lib2a.h": "",
|
||||
@@ -310,15 +310,15 @@ func TestCcLibraryHeadersNoCrtIgnored(t *testing.T) {
|
||||
"arch_x86_exported_include_dir/b.h": "",
|
||||
"arch_x86_64_exported_include_dir/c.h": "",
|
||||
},
|
||||
blueprint: soongCcLibraryHeadersPreamble + `
|
||||
Blueprint: soongCcLibraryHeadersPreamble + `
|
||||
cc_library_headers {
|
||||
name: "lib-1",
|
||||
export_include_dirs: ["lib-1"],
|
||||
no_libcrt: true,
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "lib-1", AttrNameToString{
|
||||
"export_includes": `["lib-1"]`,
|
||||
}),
|
||||
},
|
||||
@@ -326,12 +326,12 @@ cc_library_headers {
|
||||
}
|
||||
|
||||
func TestCcLibraryHeadersExportedStaticLibHeadersReexported(t *testing.T) {
|
||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_headers exported_static_lib_headers is reexported",
|
||||
moduleTypeUnderTest: "cc_library_headers",
|
||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryHeadersPreamble + `
|
||||
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_headers exported_static_lib_headers is reexported",
|
||||
ModuleTypeUnderTest: "cc_library_headers",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: soongCcLibraryHeadersPreamble + `
|
||||
cc_library_headers {
|
||||
name: "foo_headers",
|
||||
export_static_lib_headers: ["foo_export"],
|
||||
@@ -339,8 +339,8 @@ cc_library_headers {
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
` + simpleModuleDoNotConvertBp2build("cc_library_headers", "foo_export"),
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
|
||||
"deps": `[":foo_export"]`,
|
||||
}),
|
||||
},
|
||||
@@ -348,12 +348,12 @@ cc_library_headers {
|
||||
}
|
||||
|
||||
func TestCcLibraryHeadersExportedSharedLibHeadersReexported(t *testing.T) {
|
||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_headers exported_shared_lib_headers is reexported",
|
||||
moduleTypeUnderTest: "cc_library_headers",
|
||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryHeadersPreamble + `
|
||||
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_headers exported_shared_lib_headers is reexported",
|
||||
ModuleTypeUnderTest: "cc_library_headers",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: soongCcLibraryHeadersPreamble + `
|
||||
cc_library_headers {
|
||||
name: "foo_headers",
|
||||
export_shared_lib_headers: ["foo_export"],
|
||||
@@ -361,8 +361,8 @@ cc_library_headers {
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
` + simpleModuleDoNotConvertBp2build("cc_library_headers", "foo_export"),
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
|
||||
"deps": `[":foo_export"]`,
|
||||
}),
|
||||
},
|
||||
@@ -370,12 +370,12 @@ cc_library_headers {
|
||||
}
|
||||
|
||||
func TestCcLibraryHeadersExportedHeaderLibHeadersReexported(t *testing.T) {
|
||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_headers exported_header_lib_headers is reexported",
|
||||
moduleTypeUnderTest: "cc_library_headers",
|
||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryHeadersPreamble + `
|
||||
runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_headers exported_header_lib_headers is reexported",
|
||||
ModuleTypeUnderTest: "cc_library_headers",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: soongCcLibraryHeadersPreamble + `
|
||||
cc_library_headers {
|
||||
name: "foo_headers",
|
||||
export_header_lib_headers: ["foo_export"],
|
||||
@@ -383,8 +383,8 @@ cc_library_headers {
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
` + simpleModuleDoNotConvertBp2build("cc_library_headers", "foo_export"),
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
|
||||
"deps": `[":foo_export"]`,
|
||||
}),
|
||||
},
|
||||
|
@@ -35,17 +35,17 @@ func registerCcLibrarySharedModuleTypes(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
||||
}
|
||||
|
||||
func runCcLibrarySharedTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runCcLibrarySharedTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "cc_library_shared"
|
||||
(&tc).moduleTypeUnderTestFactory = cc.LibrarySharedFactory
|
||||
runBp2BuildTestCase(t, registerCcLibrarySharedModuleTypes, tc)
|
||||
(&tc).ModuleTypeUnderTest = "cc_library_shared"
|
||||
(&tc).ModuleTypeUnderTestFactory = cc.LibrarySharedFactory
|
||||
RunBp2BuildTestCase(t, registerCcLibrarySharedModuleTypes, tc)
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedSimple(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared simple overall test",
|
||||
filesystem: map[string]string{
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared simple overall test",
|
||||
Filesystem: map[string]string{
|
||||
// NOTE: include_dir headers *should not* appear in Bazel hdrs later (?)
|
||||
"include_dir_1/include_dir_1_a.h": "",
|
||||
"include_dir_1/include_dir_1_b.h": "",
|
||||
@@ -65,7 +65,7 @@ func TestCcLibrarySharedSimple(t *testing.T) {
|
||||
"implicit_include_1.h": "",
|
||||
"implicit_include_2.h": "",
|
||||
},
|
||||
blueprint: soongCcLibrarySharedPreamble + `
|
||||
Blueprint: soongCcLibrarySharedPreamble + `
|
||||
cc_library_headers {
|
||||
name: "header_lib_1",
|
||||
export_include_dirs: ["header_lib_1"],
|
||||
@@ -141,8 +141,8 @@ cc_library_shared {
|
||||
|
||||
// TODO: Also support export_header_lib_headers
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||
"absolute_includes": `[
|
||||
"include_dir_1",
|
||||
"include_dir_2",
|
||||
@@ -184,10 +184,10 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedArchSpecificSharedLib(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared arch-specific shared_libs with whole_static_libs",
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibrarySharedPreamble + `
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared arch-specific shared_libs with whole_static_libs",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: soongCcLibrarySharedPreamble + `
|
||||
cc_library_static {
|
||||
name: "static_dep",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -201,8 +201,8 @@ cc_library_shared {
|
||||
arch: { arm64: { shared_libs: ["shared_dep"], whole_static_libs: ["static_dep"] } },
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||
"implementation_dynamic_deps": `select({
|
||||
"//build/bazel/platforms/arch:arm64": [":shared_dep"],
|
||||
"//conditions:default": [],
|
||||
@@ -217,10 +217,10 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedOsSpecificSharedLib(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared os-specific shared_libs",
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibrarySharedPreamble + `
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared os-specific shared_libs",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: soongCcLibrarySharedPreamble + `
|
||||
cc_library_shared {
|
||||
name: "shared_dep",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -230,8 +230,8 @@ cc_library_shared {
|
||||
target: { android: { shared_libs: ["shared_dep"], } },
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||
"implementation_dynamic_deps": `select({
|
||||
"//build/bazel/platforms/os:android": [":shared_dep"],
|
||||
"//conditions:default": [],
|
||||
@@ -242,10 +242,10 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedBaseArchOsSpecificSharedLib(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared base, arch, and os-specific shared_libs",
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibrarySharedPreamble + `
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared base, arch, and os-specific shared_libs",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: soongCcLibrarySharedPreamble + `
|
||||
cc_library_shared {
|
||||
name: "shared_dep",
|
||||
bazel_module: { bp2build_available: false },
|
||||
@@ -265,8 +265,8 @@ cc_library_shared {
|
||||
arch: { arm64: { shared_libs: ["shared_dep3"] } },
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||
"implementation_dynamic_deps": `[":shared_dep"] + select({
|
||||
"//build/bazel/platforms/arch:arm64": [":shared_dep3"],
|
||||
"//conditions:default": [],
|
||||
@@ -280,22 +280,22 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedSimpleExcludeSrcs(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared simple exclude_srcs",
|
||||
filesystem: map[string]string{
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared simple exclude_srcs",
|
||||
Filesystem: map[string]string{
|
||||
"common.c": "",
|
||||
"foo-a.c": "",
|
||||
"foo-excluded.c": "",
|
||||
},
|
||||
blueprint: soongCcLibrarySharedPreamble + `
|
||||
Blueprint: soongCcLibrarySharedPreamble + `
|
||||
cc_library_shared {
|
||||
name: "foo_shared",
|
||||
srcs: ["common.c", "foo-*.c"],
|
||||
exclude_srcs: ["foo-excluded.c"],
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||
"srcs_c": `[
|
||||
"common.c",
|
||||
"foo-a.c",
|
||||
@@ -306,10 +306,10 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedStrip(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared stripping",
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibrarySharedPreamble + `
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared stripping",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: soongCcLibrarySharedPreamble + `
|
||||
cc_library_shared {
|
||||
name: "foo_shared",
|
||||
strip: {
|
||||
@@ -321,8 +321,8 @@ cc_library_shared {
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||
"strip": `{
|
||||
"all": True,
|
||||
"keep_symbols": False,
|
||||
@@ -339,19 +339,19 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedVersionScript(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared version script",
|
||||
filesystem: map[string]string{
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared version script",
|
||||
Filesystem: map[string]string{
|
||||
"version_script": "",
|
||||
},
|
||||
blueprint: soongCcLibrarySharedPreamble + `
|
||||
Blueprint: soongCcLibrarySharedPreamble + `
|
||||
cc_library_shared {
|
||||
name: "foo_shared",
|
||||
version_script: "version_script",
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||
"additional_linker_inputs": `["version_script"]`,
|
||||
"linkopts": `["-Wl,--version-script,$(location version_script)"]`,
|
||||
}),
|
||||
@@ -360,12 +360,12 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedNoCrtTrue(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared - nocrt: true emits attribute",
|
||||
filesystem: map[string]string{
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared - nocrt: true emits attribute",
|
||||
Filesystem: map[string]string{
|
||||
"impl.cpp": "",
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
Blueprint: soongCcLibraryPreamble + `
|
||||
cc_library_shared {
|
||||
name: "foo_shared",
|
||||
srcs: ["impl.cpp"],
|
||||
@@ -373,8 +373,8 @@ cc_library_shared {
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||
"link_crt": `False`,
|
||||
"srcs": `["impl.cpp"]`,
|
||||
}),
|
||||
@@ -383,12 +383,12 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedNoCrtFalse(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared - nocrt: false doesn't emit attribute",
|
||||
filesystem: map[string]string{
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared - nocrt: false doesn't emit attribute",
|
||||
Filesystem: map[string]string{
|
||||
"impl.cpp": "",
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
Blueprint: soongCcLibraryPreamble + `
|
||||
cc_library_shared {
|
||||
name: "foo_shared",
|
||||
srcs: ["impl.cpp"],
|
||||
@@ -396,8 +396,8 @@ cc_library_shared {
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
|
||||
"srcs": `["impl.cpp"]`,
|
||||
}),
|
||||
},
|
||||
@@ -405,12 +405,12 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedNoCrtArchVariant(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared - nocrt in select",
|
||||
filesystem: map[string]string{
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared - nocrt in select",
|
||||
Filesystem: map[string]string{
|
||||
"impl.cpp": "",
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
Blueprint: soongCcLibraryPreamble + `
|
||||
cc_library_shared {
|
||||
name: "foo_shared",
|
||||
srcs: ["impl.cpp"],
|
||||
@@ -425,13 +425,13 @@ cc_library_shared {
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedErr: fmt.Errorf("module \"foo_shared\": nocrt is not supported for arch variants"),
|
||||
ExpectedErr: fmt.Errorf("module \"foo_shared\": nocrt is not supported for arch variants"),
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedProto(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
blueprint: soongCcProtoPreamble + `cc_library_shared {
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: soongCcProtoPreamble + `cc_library_shared {
|
||||
name: "foo",
|
||||
srcs: ["foo.proto"],
|
||||
proto: {
|
||||
@@ -439,12 +439,12 @@ func TestCcLibrarySharedProto(t *testing.T) {
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("proto_library", "foo_proto", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("proto_library", "foo_proto", AttrNameToString{
|
||||
"srcs": `["foo.proto"]`,
|
||||
}), makeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
|
||||
}), makeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", AttrNameToString{
|
||||
"deps": `[":foo_proto"]`,
|
||||
}), makeBazelTarget("cc_library_shared", "foo", attrNameToString{
|
||||
}), makeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||
"dynamic_deps": `[":libprotobuf-cpp-lite"]`,
|
||||
"whole_archive_deps": `[":foo_cc_proto_lite"]`,
|
||||
}),
|
||||
@@ -453,14 +453,14 @@ func TestCcLibrarySharedProto(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedUseVersionLib(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
blueprint: soongCcProtoPreamble + `cc_library_shared {
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: soongCcProtoPreamble + `cc_library_shared {
|
||||
name: "foo",
|
||||
use_version_lib: true,
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||
"use_version_lib": "True",
|
||||
}),
|
||||
},
|
||||
@@ -468,12 +468,12 @@ func TestCcLibrarySharedUseVersionLib(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedStubs(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared stubs",
|
||||
moduleTypeUnderTest: "cc_library_shared",
|
||||
moduleTypeUnderTestFactory: cc.LibrarySharedFactory,
|
||||
dir: "foo/bar",
|
||||
filesystem: map[string]string{
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared stubs",
|
||||
ModuleTypeUnderTest: "cc_library_shared",
|
||||
ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
|
||||
Dir: "foo/bar",
|
||||
Filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": `
|
||||
cc_library_shared {
|
||||
name: "a",
|
||||
@@ -483,8 +483,8 @@ cc_library_shared {
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{makeBazelTarget("cc_library_shared", "a", attrNameToString{
|
||||
Blueprint: soongCcLibraryPreamble,
|
||||
ExpectedBazelTargets: []string{makeBazelTarget("cc_library_shared", "a", AttrNameToString{
|
||||
"stubs_symbol_file": `"a.map.txt"`,
|
||||
"stubs_versions": `[
|
||||
"28",
|
||||
@@ -498,11 +498,11 @@ cc_library_shared {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedSystemSharedLibsSharedEmpty(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared system_shared_libs empty shared default",
|
||||
moduleTypeUnderTest: "cc_library_shared",
|
||||
moduleTypeUnderTestFactory: cc.LibrarySharedFactory,
|
||||
blueprint: soongCcLibrarySharedPreamble + `
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared system_shared_libs empty shared default",
|
||||
ModuleTypeUnderTest: "cc_library_shared",
|
||||
ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
|
||||
Blueprint: soongCcLibrarySharedPreamble + `
|
||||
cc_defaults {
|
||||
name: "empty_defaults",
|
||||
shared: {
|
||||
@@ -515,18 +515,18 @@ cc_library_shared {
|
||||
defaults: ["empty_defaults"],
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{makeBazelTarget("cc_library_shared", "empty", attrNameToString{
|
||||
ExpectedBazelTargets: []string{makeBazelTarget("cc_library_shared", "empty", AttrNameToString{
|
||||
"system_dynamic_deps": "[]",
|
||||
})},
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedConvertLex(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_shared with lex files",
|
||||
moduleTypeUnderTest: "cc_library_shared",
|
||||
moduleTypeUnderTestFactory: cc.LibrarySharedFactory,
|
||||
filesystem: map[string]string{
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared with lex files",
|
||||
ModuleTypeUnderTest: "cc_library_shared",
|
||||
ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
|
||||
Filesystem: map[string]string{
|
||||
"foo.c": "",
|
||||
"bar.cc": "",
|
||||
"foo1.l": "",
|
||||
@@ -534,29 +534,29 @@ func TestCcLibrarySharedConvertLex(t *testing.T) {
|
||||
"foo2.l": "",
|
||||
"bar2.ll": "",
|
||||
},
|
||||
blueprint: `cc_library_shared {
|
||||
Blueprint: `cc_library_shared {
|
||||
name: "foo_lib",
|
||||
srcs: ["foo.c", "bar.cc", "foo1.l", "foo2.l", "bar1.ll", "bar2.ll"],
|
||||
lex: { flags: ["--foo_flags"] },
|
||||
include_build_directory: false,
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("genlex", "foo_lib_genlex_l", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("genlex", "foo_lib_genlex_l", AttrNameToString{
|
||||
"srcs": `[
|
||||
"foo1.l",
|
||||
"foo2.l",
|
||||
]`,
|
||||
"lexopts": `["--foo_flags"]`,
|
||||
}),
|
||||
makeBazelTarget("genlex", "foo_lib_genlex_ll", attrNameToString{
|
||||
makeBazelTarget("genlex", "foo_lib_genlex_ll", AttrNameToString{
|
||||
"srcs": `[
|
||||
"bar1.ll",
|
||||
"bar2.ll",
|
||||
]`,
|
||||
"lexopts": `["--foo_flags"]`,
|
||||
}),
|
||||
makeBazelTarget("cc_library_shared", "foo_lib", attrNameToString{
|
||||
makeBazelTarget("cc_library_shared", "foo_lib", AttrNameToString{
|
||||
"srcs": `[
|
||||
"bar.cc",
|
||||
":foo_lib_genlex_ll",
|
||||
@@ -571,8 +571,8 @@ func TestCcLibrarySharedConvertLex(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedClangUnknownFlags(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
blueprint: soongCcProtoPreamble + `cc_library_shared {
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: soongCcProtoPreamble + `cc_library_shared {
|
||||
name: "foo",
|
||||
conlyflags: ["-a", "-finline-functions"],
|
||||
cflags: ["-b","-finline-functions"],
|
||||
@@ -580,8 +580,8 @@ func TestCcLibrarySharedClangUnknownFlags(t *testing.T) {
|
||||
ldflags: ["-d","-finline-functions", "-e"],
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||
"conlyflags": `["-a"]`,
|
||||
"copts": `["-b"]`,
|
||||
"cppflags": `["-c"]`,
|
||||
@@ -595,8 +595,8 @@ func TestCcLibrarySharedClangUnknownFlags(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCCLibraryFlagSpaceSplitting(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
blueprint: soongCcProtoPreamble + `cc_library_shared {
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: soongCcProtoPreamble + `cc_library_shared {
|
||||
name: "foo",
|
||||
conlyflags: [ "-include header.h"],
|
||||
cflags: ["-include header.h"],
|
||||
@@ -604,8 +604,8 @@ func TestCCLibraryFlagSpaceSplitting(t *testing.T) {
|
||||
version_script: "version_script",
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||
"additional_linker_inputs": `["version_script"]`,
|
||||
"conlyflags": `[
|
||||
"-include",
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -26,23 +26,23 @@ func registerCcObjectModuleTypes(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("cc_defaults", func() android.Module { return cc.DefaultsFactory() })
|
||||
}
|
||||
|
||||
func runCcObjectTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runCcObjectTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "cc_object"
|
||||
(&tc).moduleTypeUnderTestFactory = cc.ObjectFactory
|
||||
runBp2BuildTestCase(t, registerCcObjectModuleTypes, tc)
|
||||
(&tc).ModuleTypeUnderTest = "cc_object"
|
||||
(&tc).ModuleTypeUnderTestFactory = cc.ObjectFactory
|
||||
RunBp2BuildTestCase(t, registerCcObjectModuleTypes, tc)
|
||||
}
|
||||
|
||||
func TestCcObjectSimple(t *testing.T) {
|
||||
runCcObjectTestCase(t, bp2buildTestCase{
|
||||
description: "simple cc_object generates cc_object with include header dep",
|
||||
filesystem: map[string]string{
|
||||
runCcObjectTestCase(t, Bp2buildTestCase{
|
||||
Description: "simple cc_object generates cc_object with include header dep",
|
||||
Filesystem: map[string]string{
|
||||
"a/b/foo.h": "",
|
||||
"a/b/bar.h": "",
|
||||
"a/b/exclude.c": "",
|
||||
"a/b/c.c": "",
|
||||
},
|
||||
blueprint: `cc_object {
|
||||
Blueprint: `cc_object {
|
||||
name: "foo",
|
||||
local_include_dirs: ["include"],
|
||||
system_shared_libs: [],
|
||||
@@ -59,8 +59,8 @@ func TestCcObjectSimple(t *testing.T) {
|
||||
min_sdk_version: "29",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", AttrNameToString{
|
||||
"copts": `[
|
||||
"-fno-addrsig",
|
||||
"-Wno-gcc-compat",
|
||||
@@ -73,16 +73,16 @@ func TestCcObjectSimple(t *testing.T) {
|
||||
]`,
|
||||
"srcs": `["a/b/c.c"]`,
|
||||
"system_dynamic_deps": `[]`,
|
||||
"sdk_version": `"current"`,
|
||||
"min_sdk_version": `"29"`,
|
||||
"sdk_version": `"current"`,
|
||||
"min_sdk_version": `"29"`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcObjectDefaults(t *testing.T) {
|
||||
runCcObjectTestCase(t, bp2buildTestCase{
|
||||
blueprint: `cc_object {
|
||||
runCcObjectTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: `cc_object {
|
||||
name: "foo",
|
||||
system_shared_libs: [],
|
||||
srcs: [
|
||||
@@ -105,8 +105,8 @@ cc_defaults {
|
||||
],
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", AttrNameToString{
|
||||
"copts": `[
|
||||
"-Werror",
|
||||
"-fno-addrsig",
|
||||
@@ -119,13 +119,13 @@ cc_defaults {
|
||||
}
|
||||
|
||||
func TestCcObjectCcObjetDepsInObjs(t *testing.T) {
|
||||
runCcObjectTestCase(t, bp2buildTestCase{
|
||||
description: "cc_object with cc_object deps in objs props",
|
||||
filesystem: map[string]string{
|
||||
runCcObjectTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_object with cc_object deps in objs props",
|
||||
Filesystem: map[string]string{
|
||||
"a/b/c.c": "",
|
||||
"x/y/z.c": "",
|
||||
},
|
||||
blueprint: `cc_object {
|
||||
Blueprint: `cc_object {
|
||||
name: "foo",
|
||||
system_shared_libs: [],
|
||||
srcs: ["a/b/c.c"],
|
||||
@@ -140,12 +140,12 @@ cc_object {
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "bar", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "bar", AttrNameToString{
|
||||
"copts": `["-fno-addrsig"]`,
|
||||
"srcs": `["x/y/z.c"]`,
|
||||
"system_dynamic_deps": `[]`,
|
||||
}), makeBazelTarget("cc_object", "foo", attrNameToString{
|
||||
}), makeBazelTarget("cc_object", "foo", AttrNameToString{
|
||||
"copts": `["-fno-addrsig"]`,
|
||||
"deps": `[":bar"]`,
|
||||
"srcs": `["a/b/c.c"]`,
|
||||
@@ -156,21 +156,21 @@ cc_object {
|
||||
}
|
||||
|
||||
func TestCcObjectIncludeBuildDirFalse(t *testing.T) {
|
||||
runCcObjectTestCase(t, bp2buildTestCase{
|
||||
description: "cc_object with include_build_dir: false",
|
||||
filesystem: map[string]string{
|
||||
runCcObjectTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_object with include_build_dir: false",
|
||||
Filesystem: map[string]string{
|
||||
"a/b/c.c": "",
|
||||
"x/y/z.c": "",
|
||||
},
|
||||
blueprint: `cc_object {
|
||||
Blueprint: `cc_object {
|
||||
name: "foo",
|
||||
system_shared_libs: [],
|
||||
srcs: ["a/b/c.c"],
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", AttrNameToString{
|
||||
"copts": `["-fno-addrsig"]`,
|
||||
"srcs": `["a/b/c.c"]`,
|
||||
"system_dynamic_deps": `[]`,
|
||||
@@ -180,9 +180,9 @@ func TestCcObjectIncludeBuildDirFalse(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCcObjectProductVariable(t *testing.T) {
|
||||
runCcObjectTestCase(t, bp2buildTestCase{
|
||||
description: "cc_object with product variable",
|
||||
blueprint: `cc_object {
|
||||
runCcObjectTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_object with product variable",
|
||||
Blueprint: `cc_object {
|
||||
name: "foo",
|
||||
system_shared_libs: [],
|
||||
include_build_directory: false,
|
||||
@@ -194,8 +194,8 @@ func TestCcObjectProductVariable(t *testing.T) {
|
||||
srcs: ["src.S"],
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", AttrNameToString{
|
||||
"asflags": `select({
|
||||
"//build/bazel/product_variables:platform_sdk_version": ["-DPLATFORM_SDK_VERSION=$(Platform_sdk_version)"],
|
||||
"//conditions:default": [],
|
||||
@@ -209,9 +209,9 @@ func TestCcObjectProductVariable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCcObjectCflagsOneArch(t *testing.T) {
|
||||
runCcObjectTestCase(t, bp2buildTestCase{
|
||||
description: "cc_object setting cflags for one arch",
|
||||
blueprint: `cc_object {
|
||||
runCcObjectTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_object setting cflags for one arch",
|
||||
Blueprint: `cc_object {
|
||||
name: "foo",
|
||||
system_shared_libs: [],
|
||||
srcs: ["a.cpp"],
|
||||
@@ -226,8 +226,8 @@ func TestCcObjectCflagsOneArch(t *testing.T) {
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", AttrNameToString{
|
||||
"copts": `["-fno-addrsig"] + select({
|
||||
"//build/bazel/platforms/arch:x86": ["-fPIC"],
|
||||
"//conditions:default": [],
|
||||
@@ -243,9 +243,9 @@ func TestCcObjectCflagsOneArch(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCcObjectCflagsFourArch(t *testing.T) {
|
||||
runCcObjectTestCase(t, bp2buildTestCase{
|
||||
description: "cc_object setting cflags for 4 architectures",
|
||||
blueprint: `cc_object {
|
||||
runCcObjectTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_object setting cflags for 4 architectures",
|
||||
Blueprint: `cc_object {
|
||||
name: "foo",
|
||||
system_shared_libs: [],
|
||||
srcs: ["base.cpp"],
|
||||
@@ -270,8 +270,8 @@ func TestCcObjectCflagsFourArch(t *testing.T) {
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", AttrNameToString{
|
||||
"copts": `["-fno-addrsig"] + select({
|
||||
"//build/bazel/platforms/arch:arm": ["-Wall"],
|
||||
"//build/bazel/platforms/arch:arm64": ["-Wall"],
|
||||
@@ -293,17 +293,17 @@ func TestCcObjectCflagsFourArch(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCcObjectLinkerScript(t *testing.T) {
|
||||
runCcObjectTestCase(t, bp2buildTestCase{
|
||||
description: "cc_object setting linker_script",
|
||||
blueprint: `cc_object {
|
||||
runCcObjectTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_object setting linker_script",
|
||||
Blueprint: `cc_object {
|
||||
name: "foo",
|
||||
srcs: ["base.cpp"],
|
||||
linker_script: "bunny.lds",
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", AttrNameToString{
|
||||
"copts": `["-fno-addrsig"]`,
|
||||
"linker_script": `"bunny.lds"`,
|
||||
"srcs": `["base.cpp"]`,
|
||||
@@ -313,9 +313,9 @@ func TestCcObjectLinkerScript(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCcObjectDepsAndLinkerScriptSelects(t *testing.T) {
|
||||
runCcObjectTestCase(t, bp2buildTestCase{
|
||||
description: "cc_object setting deps and linker_script across archs",
|
||||
blueprint: `cc_object {
|
||||
runCcObjectTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_object setting deps and linker_script across archs",
|
||||
Blueprint: `cc_object {
|
||||
name: "foo",
|
||||
srcs: ["base.cpp"],
|
||||
arch: {
|
||||
@@ -359,8 +359,8 @@ cc_object {
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", AttrNameToString{
|
||||
"copts": `["-fno-addrsig"]`,
|
||||
"deps": `select({
|
||||
"//build/bazel/platforms/arch:arm": [":arm_obj"],
|
||||
@@ -381,9 +381,9 @@ cc_object {
|
||||
}
|
||||
|
||||
func TestCcObjectSelectOnLinuxAndBionicArchs(t *testing.T) {
|
||||
runCcObjectTestCase(t, bp2buildTestCase{
|
||||
description: "cc_object setting srcs based on linux and bionic archs",
|
||||
blueprint: `cc_object {
|
||||
runCcObjectTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_object setting srcs based on linux and bionic archs",
|
||||
Blueprint: `cc_object {
|
||||
name: "foo",
|
||||
srcs: ["base.cpp"],
|
||||
target: {
|
||||
@@ -400,8 +400,8 @@ func TestCcObjectSelectOnLinuxAndBionicArchs(t *testing.T) {
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("cc_object", "foo", AttrNameToString{
|
||||
"copts": `["-fno-addrsig"]`,
|
||||
"srcs": `["base.cpp"] + select({
|
||||
"//build/bazel/platforms/os_arch:android_arm64": [
|
||||
|
@@ -22,24 +22,24 @@ import (
|
||||
|
||||
func TestPrebuiltLibraryStaticAndSharedSimple(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library static and shared simple",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library static and shared simple",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
}),
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `"libf.so"`,
|
||||
}),
|
||||
},
|
||||
@@ -48,15 +48,15 @@ cc_prebuilt_library {
|
||||
|
||||
func TestPrebuiltLibraryWithArchVariance(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library with arch variance",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library with arch variance",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library {
|
||||
name: "libtest",
|
||||
arch: {
|
||||
@@ -65,15 +65,15 @@ cc_prebuilt_library {
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", AttrNameToString{
|
||||
"static_library": `select({
|
||||
"//build/bazel/platforms/arch:arm": "libg.so",
|
||||
"//build/bazel/platforms/arch:arm64": "libf.so",
|
||||
"//conditions:default": None,
|
||||
})`,
|
||||
}),
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `select({
|
||||
"//build/bazel/platforms/arch:arm": "libg.so",
|
||||
"//build/bazel/platforms/arch:arm64": "libf.so",
|
||||
@@ -86,16 +86,16 @@ cc_prebuilt_library {
|
||||
|
||||
func TestPrebuiltLibraryAdditionalAttrs(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library additional attributes",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library additional attributes",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"testdir/1/": "",
|
||||
"testdir/2/": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
@@ -103,14 +103,14 @@ cc_prebuilt_library {
|
||||
export_system_include_dirs: ["testdir/2/"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
"export_includes": `["testdir/1/"]`,
|
||||
"export_system_includes": `["testdir/2/"]`,
|
||||
}),
|
||||
// TODO(b/229374533): When fixed, update this test
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `"libf.so"`,
|
||||
}),
|
||||
},
|
||||
@@ -119,15 +119,15 @@ cc_prebuilt_library {
|
||||
|
||||
func TestPrebuiltLibrarySharedStanzaFails(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library with shared stanza fails because multiple sources",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library with shared stanza fails because multiple sources",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
@@ -136,21 +136,21 @@ cc_prebuilt_library {
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedErr: fmt.Errorf("Expected at most one source file"),
|
||||
ExpectedErr: fmt.Errorf("Expected at most one source file"),
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibraryStaticStanzaFails(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library with static stanza fails because multiple sources",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library with static stanza fails because multiple sources",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
@@ -159,21 +159,21 @@ cc_prebuilt_library {
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedErr: fmt.Errorf("Expected at most one source file"),
|
||||
ExpectedErr: fmt.Errorf("Expected at most one source file"),
|
||||
})
|
||||
}
|
||||
|
||||
func TestPrebuiltLibrarySharedAndStaticStanzas(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library with both shared and static stanzas",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library with both shared and static stanzas",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library {
|
||||
name: "libtest",
|
||||
static: {
|
||||
@@ -184,11 +184,11 @@ cc_prebuilt_library {
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest_bp2build_cc_library_static", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
}),
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `"libg.so"`,
|
||||
}),
|
||||
},
|
||||
|
@@ -9,21 +9,21 @@ import (
|
||||
|
||||
func TestSharedPrebuiltLibrary(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library shared simple",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library_shared",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library shared simple",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library_shared",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_shared {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `"libf.so"`,
|
||||
}),
|
||||
},
|
||||
@@ -32,15 +32,15 @@ cc_prebuilt_library_shared {
|
||||
|
||||
func TestSharedPrebuiltLibraryWithArchVariance(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library shared with arch variance",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library_shared",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library shared with arch variance",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library_shared",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_shared {
|
||||
name: "libtest",
|
||||
arch: {
|
||||
@@ -49,8 +49,8 @@ cc_prebuilt_library_shared {
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_shared", "libtest", AttrNameToString{
|
||||
"shared_library": `select({
|
||||
"//build/bazel/platforms/arch:arm": "libg.so",
|
||||
"//build/bazel/platforms/arch:arm64": "libf.so",
|
||||
@@ -63,15 +63,15 @@ cc_prebuilt_library_shared {
|
||||
|
||||
func TestSharedPrebuiltLibrarySharedStanzaFails(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library shared with shared stanza fails because multiple sources",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library_shared",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library shared with shared stanza fails because multiple sources",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library_shared",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_shared {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
@@ -80,6 +80,6 @@ cc_prebuilt_library_shared {
|
||||
},
|
||||
bazel_module: { bp2build_available: true},
|
||||
}`,
|
||||
expectedErr: fmt.Errorf("Expected at most one source file"),
|
||||
ExpectedErr: fmt.Errorf("Expected at most one source file"),
|
||||
})
|
||||
}
|
||||
|
@@ -22,21 +22,21 @@ import (
|
||||
|
||||
func TestStaticPrebuiltLibrary(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library static simple",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library_static",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltStaticLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library static simple",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltStaticLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_static {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest", AttrNameToString{
|
||||
"static_library": `"libf.so"`,
|
||||
}),
|
||||
},
|
||||
@@ -45,15 +45,15 @@ cc_prebuilt_library_static {
|
||||
|
||||
func TestStaticPrebuiltLibraryWithArchVariance(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library static with arch variance",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library_static",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltStaticLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library static with arch variance",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltStaticLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_static {
|
||||
name: "libtest",
|
||||
arch: {
|
||||
@@ -62,8 +62,8 @@ cc_prebuilt_library_static {
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_library_static", "libtest", AttrNameToString{
|
||||
"static_library": `select({
|
||||
"//build/bazel/platforms/arch:arm": "libg.so",
|
||||
"//build/bazel/platforms/arch:arm64": "libf.so",
|
||||
@@ -76,15 +76,15 @@ cc_prebuilt_library_static {
|
||||
|
||||
func TestStaticPrebuiltLibraryStaticStanzaFails(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t,
|
||||
bp2buildTestCase{
|
||||
description: "prebuilt library with static stanza fails because multiple sources",
|
||||
moduleTypeUnderTest: "cc_prebuilt_library_static",
|
||||
moduleTypeUnderTestFactory: cc.PrebuiltStaticLibraryFactory,
|
||||
filesystem: map[string]string{
|
||||
Bp2buildTestCase{
|
||||
Description: "prebuilt library with static stanza fails because multiple sources",
|
||||
ModuleTypeUnderTest: "cc_prebuilt_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.PrebuiltStaticLibraryFactory,
|
||||
Filesystem: map[string]string{
|
||||
"libf.so": "",
|
||||
"libg.so": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
cc_prebuilt_library_static {
|
||||
name: "libtest",
|
||||
srcs: ["libf.so"],
|
||||
@@ -93,16 +93,16 @@ cc_prebuilt_library_static {
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedErr: fmt.Errorf("Expected at most one source file"),
|
||||
ExpectedErr: fmt.Errorf("Expected at most one source file"),
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryStaticConvertLex(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_static with lex files",
|
||||
moduleTypeUnderTest: "cc_library_static",
|
||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
filesystem: map[string]string{
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_static with lex files",
|
||||
ModuleTypeUnderTest: "cc_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
Filesystem: map[string]string{
|
||||
"foo.c": "",
|
||||
"bar.cc": "",
|
||||
"foo1.l": "",
|
||||
@@ -110,29 +110,29 @@ func TestCcLibraryStaticConvertLex(t *testing.T) {
|
||||
"foo2.l": "",
|
||||
"bar2.ll": "",
|
||||
},
|
||||
blueprint: `cc_library_static {
|
||||
Blueprint: `cc_library_static {
|
||||
name: "foo_lib",
|
||||
srcs: ["foo.c", "bar.cc", "foo1.l", "foo2.l", "bar1.ll", "bar2.ll"],
|
||||
lex: { flags: ["--foo_flags"] },
|
||||
include_build_directory: false,
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("genlex", "foo_lib_genlex_l", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("genlex", "foo_lib_genlex_l", AttrNameToString{
|
||||
"srcs": `[
|
||||
"foo1.l",
|
||||
"foo2.l",
|
||||
]`,
|
||||
"lexopts": `["--foo_flags"]`,
|
||||
}),
|
||||
makeBazelTarget("genlex", "foo_lib_genlex_ll", attrNameToString{
|
||||
makeBazelTarget("genlex", "foo_lib_genlex_ll", AttrNameToString{
|
||||
"srcs": `[
|
||||
"bar1.ll",
|
||||
"bar2.ll",
|
||||
]`,
|
||||
"lexopts": `["--foo_flags"]`,
|
||||
}),
|
||||
makeBazelTarget("cc_library_static", "foo_lib", attrNameToString{
|
||||
makeBazelTarget("cc_library_static", "foo_lib", AttrNameToString{
|
||||
"srcs": `[
|
||||
"bar.cc",
|
||||
":foo_lib_genlex_ll",
|
||||
|
@@ -21,38 +21,38 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runFilegroupTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runFilegroupTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "filegroup"
|
||||
(&tc).moduleTypeUnderTestFactory = android.FileGroupFactory
|
||||
runBp2BuildTestCase(t, registerFilegroupModuleTypes, tc)
|
||||
(&tc).ModuleTypeUnderTest = "filegroup"
|
||||
(&tc).ModuleTypeUnderTestFactory = android.FileGroupFactory
|
||||
RunBp2BuildTestCase(t, registerFilegroupModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerFilegroupModuleTypes(ctx android.RegistrationContext) {}
|
||||
|
||||
func TestFilegroupSameNameAsFile_OneFile(t *testing.T) {
|
||||
runFilegroupTestCase(t, bp2buildTestCase{
|
||||
description: "filegroup - same name as file, with one file",
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runFilegroupTestCase(t, Bp2buildTestCase{
|
||||
Description: "filegroup - same name as file, with one file",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
filegroup {
|
||||
name: "foo",
|
||||
srcs: ["foo"],
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{}})
|
||||
ExpectedBazelTargets: []string{}})
|
||||
}
|
||||
|
||||
func TestFilegroupSameNameAsFile_MultipleFiles(t *testing.T) {
|
||||
runFilegroupTestCase(t, bp2buildTestCase{
|
||||
description: "filegroup - same name as file, with multiple files",
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runFilegroupTestCase(t, Bp2buildTestCase{
|
||||
Description: "filegroup - same name as file, with multiple files",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
filegroup {
|
||||
name: "foo",
|
||||
srcs: ["foo", "bar"],
|
||||
}
|
||||
`,
|
||||
expectedErr: fmt.Errorf("filegroup 'foo' cannot contain a file with the same name"),
|
||||
ExpectedErr: fmt.Errorf("filegroup 'foo' cannot contain a file with the same name"),
|
||||
})
|
||||
}
|
||||
|
@@ -27,11 +27,11 @@ func registerGenruleModuleTypes(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("genrule_defaults", func() android.Module { return genrule.DefaultsFactory() })
|
||||
}
|
||||
|
||||
func runGenruleTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runGenruleTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "genrule"
|
||||
(&tc).moduleTypeUnderTestFactory = genrule.GenRuleFactory
|
||||
runBp2BuildTestCase(t, registerGenruleModuleTypes, tc)
|
||||
(&tc).ModuleTypeUnderTest = "genrule"
|
||||
(&tc).ModuleTypeUnderTestFactory = genrule.GenRuleFactory
|
||||
RunBp2BuildTestCase(t, registerGenruleModuleTypes, tc)
|
||||
}
|
||||
|
||||
func otherGenruleBp(genruleTarget string) map[string]string {
|
||||
@@ -101,7 +101,7 @@ func TestGenruleCliVariableReplacement(t *testing.T) {
|
||||
}`
|
||||
|
||||
for _, tc := range testCases {
|
||||
moduleAttrs := attrNameToString{
|
||||
moduleAttrs := AttrNameToString{
|
||||
"cmd": fmt.Sprintf(`"$(location :foo.tool) --genDir=%s arg $(SRCS) $(OUTS)"`, tc.genDir),
|
||||
"outs": `["foo.out"]`,
|
||||
"srcs": `["foo.in"]`,
|
||||
@@ -113,12 +113,12 @@ func TestGenruleCliVariableReplacement(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run(tc.moduleType, func(t *testing.T) {
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
bp2buildTestCase{
|
||||
moduleTypeUnderTest: tc.moduleType,
|
||||
moduleTypeUnderTestFactory: tc.factory,
|
||||
blueprint: fmt.Sprintf(bp, tc.moduleType, tc.moduleType),
|
||||
expectedBazelTargets: expectedBazelTargets,
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: tc.moduleType,
|
||||
ModuleTypeUnderTestFactory: tc.factory,
|
||||
Blueprint: fmt.Sprintf(bp, tc.moduleType, tc.moduleType),
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -169,13 +169,13 @@ func TestGenruleLocationsLabel(t *testing.T) {
|
||||
}`
|
||||
|
||||
for _, tc := range testCases {
|
||||
fooAttrs := attrNameToString{
|
||||
fooAttrs := AttrNameToString{
|
||||
"cmd": `"$(locations :foo.tools) -s $(OUTS) $(SRCS)"`,
|
||||
"outs": `["foo.out"]`,
|
||||
"srcs": `["foo.in"]`,
|
||||
"tools": `[":foo.tools"]`,
|
||||
}
|
||||
fooToolsAttrs := attrNameToString{
|
||||
fooToolsAttrs := AttrNameToString{
|
||||
"cmd": `"cp $(SRCS) $(OUTS)"`,
|
||||
"outs": `[
|
||||
"foo_tool.out",
|
||||
@@ -190,12 +190,12 @@ func TestGenruleLocationsLabel(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run(tc.moduleType, func(t *testing.T) {
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
bp2buildTestCase{
|
||||
moduleTypeUnderTest: tc.moduleType,
|
||||
moduleTypeUnderTestFactory: tc.factory,
|
||||
blueprint: fmt.Sprintf(bp, tc.moduleType, tc.moduleType),
|
||||
expectedBazelTargets: expectedBazelTargets,
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: tc.moduleType,
|
||||
ModuleTypeUnderTestFactory: tc.factory,
|
||||
Blueprint: fmt.Sprintf(bp, tc.moduleType, tc.moduleType),
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -238,7 +238,7 @@ func TestGenruleLocationsAbsoluteLabel(t *testing.T) {
|
||||
}`
|
||||
|
||||
for _, tc := range testCases {
|
||||
moduleAttrs := attrNameToString{
|
||||
moduleAttrs := AttrNameToString{
|
||||
"cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(SRCS)"`,
|
||||
"outs": `["foo.out"]`,
|
||||
"srcs": `["foo.in"]`,
|
||||
@@ -250,13 +250,13 @@ func TestGenruleLocationsAbsoluteLabel(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run(tc.moduleType, func(t *testing.T) {
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
bp2buildTestCase{
|
||||
moduleTypeUnderTest: tc.moduleType,
|
||||
moduleTypeUnderTestFactory: tc.factory,
|
||||
blueprint: fmt.Sprintf(bp, tc.moduleType),
|
||||
expectedBazelTargets: expectedBazelTargets,
|
||||
filesystem: otherGenruleBp(tc.moduleType),
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: tc.moduleType,
|
||||
ModuleTypeUnderTestFactory: tc.factory,
|
||||
Blueprint: fmt.Sprintf(bp, tc.moduleType),
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
Filesystem: otherGenruleBp(tc.moduleType),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -299,7 +299,7 @@ func TestGenruleSrcsLocationsAbsoluteLabel(t *testing.T) {
|
||||
}`
|
||||
|
||||
for _, tc := range testCases {
|
||||
moduleAttrs := attrNameToString{
|
||||
moduleAttrs := AttrNameToString{
|
||||
"cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(location //other:other.tool)"`,
|
||||
"outs": `["foo.out"]`,
|
||||
"srcs": `["//other:other.tool"]`,
|
||||
@@ -311,13 +311,13 @@ func TestGenruleSrcsLocationsAbsoluteLabel(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run(tc.moduleType, func(t *testing.T) {
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
bp2buildTestCase{
|
||||
moduleTypeUnderTest: tc.moduleType,
|
||||
moduleTypeUnderTestFactory: tc.factory,
|
||||
blueprint: fmt.Sprintf(bp, tc.moduleType),
|
||||
expectedBazelTargets: expectedBazelTargets,
|
||||
filesystem: otherGenruleBp(tc.moduleType),
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: tc.moduleType,
|
||||
ModuleTypeUnderTestFactory: tc.factory,
|
||||
Blueprint: fmt.Sprintf(bp, tc.moduleType),
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
Filesystem: otherGenruleBp(tc.moduleType),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -360,7 +360,7 @@ func TestGenruleLocationLabelShouldSubstituteFirstToolLabel(t *testing.T) {
|
||||
}`
|
||||
|
||||
for _, tc := range testCases {
|
||||
moduleAttrs := attrNameToString{
|
||||
moduleAttrs := AttrNameToString{
|
||||
"cmd": `"$(location //other:foo.tool) -s $(OUTS) $(SRCS)"`,
|
||||
"outs": `["foo.out"]`,
|
||||
"srcs": `["foo.in"]`,
|
||||
@@ -375,13 +375,13 @@ func TestGenruleLocationLabelShouldSubstituteFirstToolLabel(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run(tc.moduleType, func(t *testing.T) {
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
bp2buildTestCase{
|
||||
moduleTypeUnderTest: tc.moduleType,
|
||||
moduleTypeUnderTestFactory: tc.factory,
|
||||
blueprint: fmt.Sprintf(bp, tc.moduleType),
|
||||
expectedBazelTargets: expectedBazelTargets,
|
||||
filesystem: otherGenruleBp(tc.moduleType),
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: tc.moduleType,
|
||||
ModuleTypeUnderTestFactory: tc.factory,
|
||||
Blueprint: fmt.Sprintf(bp, tc.moduleType),
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
Filesystem: otherGenruleBp(tc.moduleType),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -424,7 +424,7 @@ func TestGenruleLocationsLabelShouldSubstituteFirstToolLabel(t *testing.T) {
|
||||
}`
|
||||
|
||||
for _, tc := range testCases {
|
||||
moduleAttrs := attrNameToString{
|
||||
moduleAttrs := AttrNameToString{
|
||||
"cmd": `"$(locations //other:foo.tool) -s $(OUTS) $(SRCS)"`,
|
||||
"outs": `["foo.out"]`,
|
||||
"srcs": `["foo.in"]`,
|
||||
@@ -439,13 +439,13 @@ func TestGenruleLocationsLabelShouldSubstituteFirstToolLabel(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run(tc.moduleType, func(t *testing.T) {
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
bp2buildTestCase{
|
||||
moduleTypeUnderTest: tc.moduleType,
|
||||
moduleTypeUnderTestFactory: tc.factory,
|
||||
blueprint: fmt.Sprintf(bp, tc.moduleType),
|
||||
expectedBazelTargets: expectedBazelTargets,
|
||||
filesystem: otherGenruleBp(tc.moduleType),
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: tc.moduleType,
|
||||
ModuleTypeUnderTestFactory: tc.factory,
|
||||
Blueprint: fmt.Sprintf(bp, tc.moduleType),
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
Filesystem: otherGenruleBp(tc.moduleType),
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -487,7 +487,7 @@ func TestGenruleWithoutToolsOrToolFiles(t *testing.T) {
|
||||
}`
|
||||
|
||||
for _, tc := range testCases {
|
||||
moduleAttrs := attrNameToString{
|
||||
moduleAttrs := AttrNameToString{
|
||||
"cmd": `"cp $(SRCS) $(OUTS)"`,
|
||||
"outs": `["foo.out"]`,
|
||||
"srcs": `["foo.in"]`,
|
||||
@@ -498,22 +498,22 @@ func TestGenruleWithoutToolsOrToolFiles(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run(tc.moduleType, func(t *testing.T) {
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
bp2buildTestCase{
|
||||
moduleTypeUnderTest: tc.moduleType,
|
||||
moduleTypeUnderTestFactory: tc.factory,
|
||||
blueprint: fmt.Sprintf(bp, tc.moduleType),
|
||||
expectedBazelTargets: expectedBazelTargets,
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: tc.moduleType,
|
||||
ModuleTypeUnderTestFactory: tc.factory,
|
||||
Blueprint: fmt.Sprintf(bp, tc.moduleType),
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenruleBp2BuildInlinesDefaults(t *testing.T) {
|
||||
testCases := []bp2buildTestCase{
|
||||
testCases := []Bp2buildTestCase{
|
||||
{
|
||||
description: "genrule applies properties from a genrule_defaults dependency if not specified",
|
||||
blueprint: `genrule_defaults {
|
||||
Description: "genrule applies properties from a genrule_defaults dependency if not specified",
|
||||
Blueprint: `genrule_defaults {
|
||||
name: "gen_defaults",
|
||||
cmd: "do-something $(in) $(out)",
|
||||
}
|
||||
@@ -525,8 +525,8 @@ genrule {
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTargetNoRestrictions("genrule", "gen", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("genrule", "gen", AttrNameToString{
|
||||
"cmd": `"do-something $(SRCS) $(OUTS)"`,
|
||||
"outs": `["out"]`,
|
||||
"srcs": `["in1"]`,
|
||||
@@ -534,8 +534,8 @@ genrule {
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "genrule does merges properties from a genrule_defaults dependency, latest-first",
|
||||
blueprint: `genrule_defaults {
|
||||
Description: "genrule does merges properties from a genrule_defaults dependency, latest-first",
|
||||
Blueprint: `genrule_defaults {
|
||||
name: "gen_defaults",
|
||||
out: ["out-from-defaults"],
|
||||
srcs: ["in-from-defaults"],
|
||||
@@ -550,8 +550,8 @@ genrule {
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTargetNoRestrictions("genrule", "gen", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("genrule", "gen", AttrNameToString{
|
||||
"cmd": `"do-something $(SRCS) $(OUTS)"`,
|
||||
"outs": `[
|
||||
"out-from-defaults",
|
||||
@@ -565,8 +565,8 @@ genrule {
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "genrule applies properties from list of genrule_defaults",
|
||||
blueprint: `genrule_defaults {
|
||||
Description: "genrule applies properties from list of genrule_defaults",
|
||||
Blueprint: `genrule_defaults {
|
||||
name: "gen_defaults1",
|
||||
cmd: "cp $(in) $(out)",
|
||||
}
|
||||
@@ -583,8 +583,8 @@ genrule {
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTargetNoRestrictions("genrule", "gen", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("genrule", "gen", AttrNameToString{
|
||||
"cmd": `"cp $(SRCS) $(OUTS)"`,
|
||||
"outs": `["out"]`,
|
||||
"srcs": `["in1"]`,
|
||||
@@ -592,8 +592,8 @@ genrule {
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "genrule applies properties from genrule_defaults transitively",
|
||||
blueprint: `genrule_defaults {
|
||||
Description: "genrule applies properties from genrule_defaults transitively",
|
||||
Blueprint: `genrule_defaults {
|
||||
name: "gen_defaults1",
|
||||
defaults: ["gen_defaults2"],
|
||||
cmd: "cmd1 $(in) $(out)", // overrides gen_defaults2's cmd property value.
|
||||
@@ -620,8 +620,8 @@ genrule {
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTargetNoRestrictions("genrule", "gen", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("genrule", "gen", AttrNameToString{
|
||||
"cmd": `"cmd1 $(SRCS) $(OUTS)"`,
|
||||
"outs": `[
|
||||
"out-from-3",
|
||||
@@ -638,7 +638,7 @@ genrule {
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.description, func(t *testing.T) {
|
||||
t.Run(testCase.Description, func(t *testing.T) {
|
||||
runGenruleTestCase(t, testCase)
|
||||
})
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ func TestGensrcs(t *testing.T) {
|
||||
testcases := []struct {
|
||||
name string
|
||||
bp string
|
||||
expectedBazelAttrs attrNameToString
|
||||
expectedBazelAttrs AttrNameToString
|
||||
}{
|
||||
{
|
||||
name: "gensrcs with common usage of properties",
|
||||
@@ -37,7 +37,7 @@ func TestGensrcs(t *testing.T) {
|
||||
output_extension: "out",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelAttrs: attrNameToString{
|
||||
expectedBazelAttrs: AttrNameToString{
|
||||
"srcs": `[
|
||||
"test/input.txt",
|
||||
":external_files__BP2BUILD__MISSING__DEP",
|
||||
@@ -56,7 +56,7 @@ func TestGensrcs(t *testing.T) {
|
||||
cmd: "cat $(in) > $(out)",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelAttrs: attrNameToString{
|
||||
expectedBazelAttrs: AttrNameToString{
|
||||
"srcs": `["input.txt"]`,
|
||||
"cmd": `"cat $(SRC) > $(OUT)"`,
|
||||
},
|
||||
@@ -65,15 +65,15 @@ func TestGensrcs(t *testing.T) {
|
||||
|
||||
for _, test := range testcases {
|
||||
expectedBazelTargets := []string{
|
||||
makeBazelTargetNoRestrictions("gensrcs", "foo", test.expectedBazelAttrs),
|
||||
MakeBazelTargetNoRestrictions("gensrcs", "foo", test.expectedBazelAttrs),
|
||||
}
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
bp2buildTestCase{
|
||||
moduleTypeUnderTest: "gensrcs",
|
||||
moduleTypeUnderTestFactory: genrule.GenSrcsFactory,
|
||||
blueprint: test.bp,
|
||||
expectedBazelTargets: expectedBazelTargets,
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: "gensrcs",
|
||||
ModuleTypeUnderTestFactory: genrule.GenSrcsFactory,
|
||||
Blueprint: test.bp,
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@@ -22,11 +22,11 @@ import (
|
||||
"android/soong/java"
|
||||
)
|
||||
|
||||
func runJavaBinaryHostTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runJavaBinaryHostTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "java_binary_host"
|
||||
(&tc).moduleTypeUnderTestFactory = java.BinaryHostFactory
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
|
||||
(&tc).ModuleTypeUnderTest = "java_binary_host"
|
||||
(&tc).ModuleTypeUnderTestFactory = java.BinaryHostFactory
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("cc_library_host_shared", cc.LibraryHostSharedFactory)
|
||||
ctx.RegisterModuleType("java_library", java.LibraryFactory)
|
||||
}, tc)
|
||||
@@ -41,10 +41,10 @@ var fs = map[string]string{
|
||||
}
|
||||
|
||||
func TestJavaBinaryHost(t *testing.T) {
|
||||
runJavaBinaryHostTestCase(t, bp2buildTestCase{
|
||||
description: "java_binary_host with srcs, exclude_srcs, jni_libs, javacflags, and manifest.",
|
||||
filesystem: fs,
|
||||
blueprint: `java_binary_host {
|
||||
runJavaBinaryHostTestCase(t, Bp2buildTestCase{
|
||||
Description: "java_binary_host with srcs, exclude_srcs, jni_libs, javacflags, and manifest.",
|
||||
Filesystem: fs,
|
||||
Blueprint: `java_binary_host {
|
||||
name: "java-binary-host-1",
|
||||
srcs: ["a.java", "b.java"],
|
||||
exclude_srcs: ["b.java"],
|
||||
@@ -54,8 +54,8 @@ func TestJavaBinaryHost(t *testing.T) {
|
||||
bazel_module: { bp2build_available: true },
|
||||
java_version: "8",
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_binary", "java-binary-host-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_binary", "java-binary-host-1", AttrNameToString{
|
||||
"srcs": `["a.java"]`,
|
||||
"main_class": `"com.android.test.MainClass"`,
|
||||
"deps": `["//other:jni-lib-1"]`,
|
||||
@@ -74,10 +74,10 @@ func TestJavaBinaryHost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJavaBinaryHostRuntimeDeps(t *testing.T) {
|
||||
runJavaBinaryHostTestCase(t, bp2buildTestCase{
|
||||
description: "java_binary_host with srcs, exclude_srcs, jni_libs, javacflags, and manifest.",
|
||||
filesystem: fs,
|
||||
blueprint: `java_binary_host {
|
||||
runJavaBinaryHostTestCase(t, Bp2buildTestCase{
|
||||
Description: "java_binary_host with srcs, exclude_srcs, jni_libs, javacflags, and manifest.",
|
||||
Filesystem: fs,
|
||||
Blueprint: `java_binary_host {
|
||||
name: "java-binary-host-1",
|
||||
static_libs: ["java-dep-1"],
|
||||
manifest: "test.mf",
|
||||
@@ -90,8 +90,8 @@ java_library {
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_binary", "java-binary-host-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_binary", "java-binary-host-1", AttrNameToString{
|
||||
"main_class": `"com.android.test.MainClass"`,
|
||||
"runtime_deps": `[":java-dep-1"]`,
|
||||
"target_compatible_with": `select({
|
||||
|
@@ -21,45 +21,45 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runJavaImportTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runJavaImportTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, registerJavaImportModuleTypes, tc)
|
||||
RunBp2BuildTestCase(t, registerJavaImportModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerJavaImportModuleTypes(ctx android.RegistrationContext) {
|
||||
}
|
||||
|
||||
func TestJavaImportMinimal(t *testing.T) {
|
||||
runJavaImportTestCase(t, bp2buildTestCase{
|
||||
description: "Java import - simple example",
|
||||
moduleTypeUnderTest: "java_import",
|
||||
moduleTypeUnderTestFactory: java.ImportFactory,
|
||||
filesystem: map[string]string{
|
||||
runJavaImportTestCase(t, Bp2buildTestCase{
|
||||
Description: "Java import - simple example",
|
||||
ModuleTypeUnderTest: "java_import",
|
||||
ModuleTypeUnderTestFactory: java.ImportFactory,
|
||||
Filesystem: map[string]string{
|
||||
"import.jar": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
java_import {
|
||||
name: "example_import",
|
||||
jars: ["import.jar"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_import", "example_import", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_import", "example_import", AttrNameToString{
|
||||
"jars": `["import.jar"]`,
|
||||
}),
|
||||
}})
|
||||
}
|
||||
|
||||
func TestJavaImportArchVariant(t *testing.T) {
|
||||
runJavaImportTestCase(t, bp2buildTestCase{
|
||||
description: "Java import - simple example",
|
||||
moduleTypeUnderTest: "java_import",
|
||||
moduleTypeUnderTestFactory: java.ImportFactory,
|
||||
filesystem: map[string]string{
|
||||
runJavaImportTestCase(t, Bp2buildTestCase{
|
||||
Description: "Java import - simple example",
|
||||
ModuleTypeUnderTest: "java_import",
|
||||
ModuleTypeUnderTestFactory: java.ImportFactory,
|
||||
Filesystem: map[string]string{
|
||||
"import.jar": "",
|
||||
},
|
||||
blueprint: `
|
||||
Blueprint: `
|
||||
java_import {
|
||||
name: "example_import",
|
||||
target: {
|
||||
@@ -73,8 +73,8 @@ java_import {
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_import", "example_import", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_import", "example_import", AttrNameToString{
|
||||
"jars": `select({
|
||||
"//build/bazel/platforms/os:android": ["android.jar"],
|
||||
"//build/bazel/platforms/os:linux": ["linux.jar"],
|
||||
|
@@ -22,22 +22,22 @@ import (
|
||||
"android/soong/java"
|
||||
)
|
||||
|
||||
func runJavaLibraryTestCaseWithRegistrationCtxFunc(t *testing.T, tc bp2buildTestCase, registrationCtxFunc func(ctx android.RegistrationContext)) {
|
||||
func runJavaLibraryTestCaseWithRegistrationCtxFunc(t *testing.T, tc Bp2buildTestCase, registrationCtxFunc func(ctx android.RegistrationContext)) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "java_library"
|
||||
(&tc).moduleTypeUnderTestFactory = java.LibraryFactory
|
||||
runBp2BuildTestCase(t, registrationCtxFunc, tc)
|
||||
(&tc).ModuleTypeUnderTest = "java_library"
|
||||
(&tc).ModuleTypeUnderTestFactory = java.LibraryFactory
|
||||
RunBp2BuildTestCase(t, registrationCtxFunc, tc)
|
||||
}
|
||||
|
||||
func runJavaLibraryTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runJavaLibraryTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {})
|
||||
}
|
||||
|
||||
func TestJavaLibrary(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
description: "java_library with srcs, exclude_srcs and libs",
|
||||
blueprint: `java_library {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Description: "java_library with srcs, exclude_srcs and libs",
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java", "b.java"],
|
||||
exclude_srcs: ["b.java"],
|
||||
@@ -50,12 +50,12 @@ java_library {
|
||||
srcs: ["b.java"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"srcs": `["a.java"]`,
|
||||
"deps": `[":java-lib-2"]`,
|
||||
}),
|
||||
makeBazelTarget("java_library", "java-lib-2", attrNameToString{
|
||||
makeBazelTarget("java_library", "java-lib-2", AttrNameToString{
|
||||
"srcs": `["b.java"]`,
|
||||
}),
|
||||
},
|
||||
@@ -63,8 +63,8 @@ java_library {
|
||||
}
|
||||
|
||||
func TestJavaLibraryConvertsStaticLibsToDepsAndExports(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
blueprint: `java_library {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
libs: ["java-lib-2"],
|
||||
@@ -83,8 +83,8 @@ java_library {
|
||||
srcs: ["c.java"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"srcs": `["a.java"]`,
|
||||
"deps": `[
|
||||
":java-lib-2",
|
||||
@@ -97,8 +97,8 @@ java_library {
|
||||
}
|
||||
|
||||
func TestJavaLibraryConvertsStaticLibsToExportsIfNoSrcs(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
blueprint: `java_library {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
static_libs: ["java-lib-2"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
@@ -109,8 +109,8 @@ java_library {
|
||||
srcs: ["a.java"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"exports": `[":java-lib-2"]`,
|
||||
}),
|
||||
},
|
||||
@@ -118,9 +118,9 @@ java_library {
|
||||
}
|
||||
|
||||
func TestJavaLibraryFailsToConvertLibsWithNoSrcs(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
expectedErr: fmt.Errorf("Module has direct dependencies but no sources. Bazel will not allow this."),
|
||||
blueprint: `java_library {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
ExpectedErr: fmt.Errorf("Module has direct dependencies but no sources. Bazel will not allow this."),
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
libs: ["java-lib-2"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
@@ -131,13 +131,13 @@ java_library {
|
||||
srcs: ["a.java"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
expectedBazelTargets: []string{},
|
||||
ExpectedBazelTargets: []string{},
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaLibraryPlugins(t *testing.T) {
|
||||
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, bp2buildTestCase{
|
||||
blueprint: `java_library {
|
||||
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, Bp2buildTestCase{
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
plugins: ["java-plugin-1"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
@@ -148,8 +148,8 @@ java_plugin {
|
||||
srcs: ["a.java"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"plugins": `[":java-plugin-1"]`,
|
||||
}),
|
||||
},
|
||||
@@ -159,14 +159,14 @@ java_plugin {
|
||||
}
|
||||
|
||||
func TestJavaLibraryJavaVersion(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
blueprint: `java_library {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
java_version: "11",
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"srcs": `["a.java"]`,
|
||||
"javacopts": `["-source 11 -target 11"]`,
|
||||
}),
|
||||
@@ -175,8 +175,8 @@ func TestJavaLibraryJavaVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJavaLibraryErrorproneJavacflagsEnabledManually(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
blueprint: `java_library {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
javacflags: ["-Xsuper-fast"],
|
||||
@@ -185,8 +185,8 @@ func TestJavaLibraryErrorproneJavacflagsEnabledManually(t *testing.T) {
|
||||
javacflags: ["-Xep:SpeedLimit:OFF"],
|
||||
},
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"javacopts": `[
|
||||
"-Xsuper-fast",
|
||||
"-Xep:SpeedLimit:OFF",
|
||||
@@ -198,8 +198,8 @@ func TestJavaLibraryErrorproneJavacflagsEnabledManually(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledByDefault(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
blueprint: `java_library {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
javacflags: ["-Xsuper-fast"],
|
||||
@@ -207,8 +207,8 @@ func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledByDefault(t *testing.T
|
||||
javacflags: ["-Xep:SpeedLimit:OFF"],
|
||||
},
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"javacopts": `["-Xsuper-fast"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
}),
|
||||
@@ -217,8 +217,8 @@ func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledByDefault(t *testing.T
|
||||
}
|
||||
|
||||
func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledManually(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
blueprint: `java_library {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
javacflags: ["-Xsuper-fast"],
|
||||
@@ -227,8 +227,8 @@ func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledManually(t *testing.T)
|
||||
javacflags: ["-Xep:SpeedLimit:OFF"],
|
||||
},
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"javacopts": `["-Xsuper-fast"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
}),
|
||||
@@ -237,11 +237,11 @@ func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledManually(t *testing.T)
|
||||
}
|
||||
|
||||
func TestJavaLibraryLogTags(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
description: "Java library - logtags creates separate dependency",
|
||||
moduleTypeUnderTest: "java_library",
|
||||
moduleTypeUnderTestFactory: java.LibraryFactory,
|
||||
blueprint: `java_library {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Description: "Java library - logtags creates separate dependency",
|
||||
ModuleTypeUnderTest: "java_library",
|
||||
ModuleTypeUnderTestFactory: java.LibraryFactory,
|
||||
Blueprint: `java_library {
|
||||
name: "example_lib",
|
||||
srcs: [
|
||||
"a.java",
|
||||
@@ -251,14 +251,14 @@ func TestJavaLibraryLogTags(t *testing.T) {
|
||||
],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("event_log_tags", "example_lib_logtags", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("event_log_tags", "example_lib_logtags", AttrNameToString{
|
||||
"srcs": `[
|
||||
"a.logtag",
|
||||
"b.logtag",
|
||||
]`,
|
||||
}),
|
||||
makeBazelTarget("java_library", "example_lib", attrNameToString{
|
||||
makeBazelTarget("java_library", "example_lib", AttrNameToString{
|
||||
"srcs": `[
|
||||
"a.java",
|
||||
"b.java",
|
||||
@@ -269,18 +269,18 @@ func TestJavaLibraryLogTags(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJavaLibraryResources(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
filesystem: map[string]string{
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Filesystem: map[string]string{
|
||||
"res/a.res": "",
|
||||
"res/b.res": "",
|
||||
"res/dir1/b.res": "",
|
||||
},
|
||||
blueprint: `java_library {
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
java_resources: ["res/a.res", "res/b.res"],
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"resources": `[
|
||||
"res/a.res",
|
||||
"res/b.res",
|
||||
@@ -291,18 +291,18 @@ func TestJavaLibraryResources(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJavaLibraryResourceDirs(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
filesystem: map[string]string{
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Filesystem: map[string]string{
|
||||
"res/a.res": "",
|
||||
"res/b.res": "",
|
||||
"res/dir1/b.res": "",
|
||||
},
|
||||
blueprint: `java_library {
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
java_resource_dirs: ["res"],
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"resource_strip_prefix": `"res"`,
|
||||
"resources": `[
|
||||
"res/a.res",
|
||||
@@ -315,18 +315,18 @@ func TestJavaLibraryResourceDirs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJavaLibraryResourcesExcludeDir(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
filesystem: map[string]string{
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Filesystem: map[string]string{
|
||||
"res/a.res": "",
|
||||
"res/exclude/b.res": "",
|
||||
},
|
||||
blueprint: `java_library {
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
java_resource_dirs: ["res"],
|
||||
exclude_java_resource_dirs: ["res/exclude"],
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"resource_strip_prefix": `"res"`,
|
||||
"resources": `["res/a.res"]`,
|
||||
}),
|
||||
@@ -335,19 +335,19 @@ func TestJavaLibraryResourcesExcludeDir(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJavaLibraryResourcesExcludeFile(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
filesystem: map[string]string{
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Filesystem: map[string]string{
|
||||
"res/a.res": "",
|
||||
"res/dir1/b.res": "",
|
||||
"res/dir1/exclude.res": "",
|
||||
},
|
||||
blueprint: `java_library {
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
java_resource_dirs: ["res"],
|
||||
exclude_java_resources: ["res/dir1/exclude.res"],
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"resource_strip_prefix": `"res"`,
|
||||
"resources": `[
|
||||
"res/a.res",
|
||||
@@ -359,16 +359,16 @@ func TestJavaLibraryResourcesExcludeFile(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJavaLibraryResourcesFailsWithMultipleDirs(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
filesystem: map[string]string{
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Filesystem: map[string]string{
|
||||
"res/a.res": "",
|
||||
"res1/a.res": "",
|
||||
},
|
||||
blueprint: `java_library {
|
||||
Blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
java_resource_dirs: ["res", "res1"],
|
||||
}`,
|
||||
expectedErr: fmt.Errorf("bp2build does not support more than one directory in java_resource_dirs (b/226423379)"),
|
||||
expectedBazelTargets: []string{},
|
||||
ExpectedErr: fmt.Errorf("bp2build does not support more than one directory in java_resource_dirs (b/226423379)"),
|
||||
ExpectedBazelTargets: []string{},
|
||||
})
|
||||
}
|
||||
|
@@ -21,17 +21,17 @@ import (
|
||||
"android/soong/java"
|
||||
)
|
||||
|
||||
func runJavaLibraryHostTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runJavaLibraryHostTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "java_library_host"
|
||||
(&tc).moduleTypeUnderTestFactory = java.LibraryHostFactory
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
|
||||
(&tc).ModuleTypeUnderTest = "java_library_host"
|
||||
(&tc).ModuleTypeUnderTestFactory = java.LibraryHostFactory
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
|
||||
}
|
||||
|
||||
func TestJavaLibraryHost(t *testing.T) {
|
||||
runJavaLibraryHostTestCase(t, bp2buildTestCase{
|
||||
description: "java_library_host with srcs, exclude_srcs and libs",
|
||||
blueprint: `java_library_host {
|
||||
runJavaLibraryHostTestCase(t, Bp2buildTestCase{
|
||||
Description: "java_library_host with srcs, exclude_srcs and libs",
|
||||
Blueprint: `java_library_host {
|
||||
name: "java-lib-host-1",
|
||||
srcs: ["a.java", "b.java"],
|
||||
exclude_srcs: ["b.java"],
|
||||
@@ -45,8 +45,8 @@ java_library_host {
|
||||
bazel_module: { bp2build_available: true },
|
||||
java_version: "9",
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-host-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-host-1", AttrNameToString{
|
||||
"srcs": `["a.java"]`,
|
||||
"deps": `[":java-lib-host-2"]`,
|
||||
"target_compatible_with": `select({
|
||||
@@ -54,7 +54,7 @@ java_library_host {
|
||||
"//conditions:default": [],
|
||||
})`,
|
||||
}),
|
||||
makeBazelTarget("java_library", "java-lib-host-2", attrNameToString{
|
||||
makeBazelTarget("java_library", "java-lib-host-2", AttrNameToString{
|
||||
"javacopts": `["-source 1.9 -target 1.9"]`,
|
||||
"srcs": `["c.java"]`,
|
||||
"target_compatible_with": `select({
|
||||
|
@@ -21,19 +21,19 @@ import (
|
||||
"android/soong/java"
|
||||
)
|
||||
|
||||
func runJavaPluginTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runJavaPluginTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "java_plugin"
|
||||
(&tc).moduleTypeUnderTestFactory = java.PluginFactory
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
|
||||
(&tc).ModuleTypeUnderTest = "java_plugin"
|
||||
(&tc).ModuleTypeUnderTestFactory = java.PluginFactory
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("java_library", java.LibraryFactory)
|
||||
}, tc)
|
||||
}
|
||||
|
||||
func TestJavaPlugin(t *testing.T) {
|
||||
runJavaPluginTestCase(t, bp2buildTestCase{
|
||||
description: "java_plugin with srcs, libs, static_libs",
|
||||
blueprint: `java_plugin {
|
||||
runJavaPluginTestCase(t, Bp2buildTestCase{
|
||||
Description: "java_plugin with srcs, libs, static_libs",
|
||||
Blueprint: `java_plugin {
|
||||
name: "java-plug-1",
|
||||
srcs: ["a.java", "b.java"],
|
||||
libs: ["java-lib-1"],
|
||||
@@ -53,8 +53,8 @@ java_library {
|
||||
srcs: ["c.java"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_plugin", "java-plug-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_plugin", "java-plug-1", AttrNameToString{
|
||||
"target_compatible_with": `select({
|
||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
@@ -74,9 +74,9 @@ java_library {
|
||||
}
|
||||
|
||||
func TestJavaPluginNoSrcs(t *testing.T) {
|
||||
runJavaPluginTestCase(t, bp2buildTestCase{
|
||||
description: "java_plugin without srcs converts (static) libs to deps",
|
||||
blueprint: `java_plugin {
|
||||
runJavaPluginTestCase(t, Bp2buildTestCase{
|
||||
Description: "java_plugin without srcs converts (static) libs to deps",
|
||||
Blueprint: `java_plugin {
|
||||
name: "java-plug-1",
|
||||
libs: ["java-lib-1"],
|
||||
static_libs: ["java-lib-2"],
|
||||
@@ -94,8 +94,8 @@ java_library {
|
||||
srcs: ["c.java"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_plugin", "java-plug-1", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("java_plugin", "java-plug-1", AttrNameToString{
|
||||
"target_compatible_with": `select({
|
||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||
"//conditions:default": [],
|
||||
|
@@ -22,11 +22,11 @@ import (
|
||||
"android/soong/java"
|
||||
)
|
||||
|
||||
func runJavaProtoTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runJavaProtoTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "java_library_static"
|
||||
(&tc).moduleTypeUnderTestFactory = java.LibraryFactory
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
|
||||
(&tc).ModuleTypeUnderTest = "java_library_static"
|
||||
(&tc).ModuleTypeUnderTestFactory = java.LibraryFactory
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
|
||||
}
|
||||
|
||||
func TestJavaProto(t *testing.T) {
|
||||
@@ -70,25 +70,25 @@ func TestJavaProto(t *testing.T) {
|
||||
srcs: ["a.proto"],
|
||||
}`
|
||||
|
||||
protoLibrary := makeBazelTarget("proto_library", "java-protos_proto", attrNameToString{
|
||||
protoLibrary := makeBazelTarget("proto_library", "java-protos_proto", AttrNameToString{
|
||||
"srcs": `["a.proto"]`,
|
||||
})
|
||||
|
||||
for _, tc := range testCases {
|
||||
javaLibraryName := fmt.Sprintf("java-protos_%s", tc.javaLibraryNameExtension)
|
||||
|
||||
runJavaProtoTestCase(t, bp2buildTestCase{
|
||||
description: fmt.Sprintf("java_proto %s", tc.protoType),
|
||||
blueprint: fmt.Sprintf(bp, tc.protoType),
|
||||
expectedBazelTargets: []string{
|
||||
runJavaProtoTestCase(t, Bp2buildTestCase{
|
||||
Description: fmt.Sprintf("java_proto %s", tc.protoType),
|
||||
Blueprint: fmt.Sprintf(bp, tc.protoType),
|
||||
ExpectedBazelTargets: []string{
|
||||
protoLibrary,
|
||||
makeBazelTarget(
|
||||
tc.javaLibraryType,
|
||||
javaLibraryName,
|
||||
attrNameToString{
|
||||
AttrNameToString{
|
||||
"deps": `[":java-protos_proto"]`,
|
||||
}),
|
||||
makeBazelTarget("java_library", "java-protos", attrNameToString{
|
||||
makeBazelTarget("java_library", "java-protos", AttrNameToString{
|
||||
"exports": fmt.Sprintf(`[":%s"]`, javaLibraryName),
|
||||
}),
|
||||
},
|
||||
@@ -97,25 +97,25 @@ func TestJavaProto(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestJavaProtoDefault(t *testing.T) {
|
||||
runJavaProtoTestCase(t, bp2buildTestCase{
|
||||
description: "java_library proto default",
|
||||
blueprint: `java_library_static {
|
||||
runJavaProtoTestCase(t, Bp2buildTestCase{
|
||||
Description: "java_library proto default",
|
||||
Blueprint: `java_library_static {
|
||||
name: "java-protos",
|
||||
srcs: ["a.proto"],
|
||||
java_version: "7",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("proto_library", "java-protos_proto", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("proto_library", "java-protos_proto", AttrNameToString{
|
||||
"srcs": `["a.proto"]`,
|
||||
}),
|
||||
makeBazelTarget(
|
||||
"java_lite_proto_library",
|
||||
"java-protos_java_proto_lite",
|
||||
attrNameToString{
|
||||
AttrNameToString{
|
||||
"deps": `[":java-protos_proto"]`,
|
||||
}),
|
||||
makeBazelTarget("java_library", "java-protos", attrNameToString{
|
||||
makeBazelTarget("java_library", "java-protos", AttrNameToString{
|
||||
"exports": `[":java-protos_java_proto_lite"]`,
|
||||
"javacopts": `["-source 1.7 -target 1.7"]`,
|
||||
}),
|
||||
|
@@ -21,23 +21,23 @@ import (
|
||||
"android/soong/linkerconfig"
|
||||
)
|
||||
|
||||
func runLinkerConfigTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runLinkerConfigTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "linker_config"
|
||||
(&tc).moduleTypeUnderTestFactory = linkerconfig.LinkerConfigFactory
|
||||
(&tc).ModuleTypeUnderTest = "linker_config"
|
||||
(&tc).ModuleTypeUnderTestFactory = linkerconfig.LinkerConfigFactory
|
||||
runBp2BuildTestCaseSimple(t, tc)
|
||||
}
|
||||
|
||||
func TestLinkerConfigConvertsSrc(t *testing.T) {
|
||||
runLinkerConfigTestCase(t,
|
||||
bp2buildTestCase{
|
||||
blueprint: `
|
||||
Bp2buildTestCase{
|
||||
Blueprint: `
|
||||
linker_config {
|
||||
name: "foo",
|
||||
src: "a.json",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{makeBazelTarget("linker_config", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{makeBazelTarget("linker_config", "foo", AttrNameToString{
|
||||
"src": `"a.json"`,
|
||||
})},
|
||||
})
|
||||
@@ -46,14 +46,14 @@ linker_config {
|
||||
|
||||
func TestLinkerConfigNoSrc(t *testing.T) {
|
||||
runLinkerConfigTestCase(t,
|
||||
bp2buildTestCase{
|
||||
blueprint: `
|
||||
Bp2buildTestCase{
|
||||
Blueprint: `
|
||||
linker_config {
|
||||
name: "foo",
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{},
|
||||
expectedErr: fmt.Errorf("Android.bp:2:1: module \"foo\": src: empty src is not supported"),
|
||||
ExpectedBazelTargets: []string{},
|
||||
ExpectedErr: fmt.Errorf("Android.bp:2:1: module \"foo\": src: empty src is not supported"),
|
||||
})
|
||||
|
||||
}
|
||||
|
@@ -21,21 +21,21 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runPrebuiltEtcTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runPrebuiltEtcTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "prebuilt_etc"
|
||||
(&tc).moduleTypeUnderTestFactory = etc.PrebuiltEtcFactory
|
||||
runBp2BuildTestCase(t, registerPrebuiltEtcModuleTypes, tc)
|
||||
(&tc).ModuleTypeUnderTest = "prebuilt_etc"
|
||||
(&tc).ModuleTypeUnderTestFactory = etc.PrebuiltEtcFactory
|
||||
RunBp2BuildTestCase(t, registerPrebuiltEtcModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerPrebuiltEtcModuleTypes(ctx android.RegistrationContext) {
|
||||
}
|
||||
|
||||
func TestPrebuiltEtcSimple(t *testing.T) {
|
||||
runPrebuiltEtcTestCase(t, bp2buildTestCase{
|
||||
description: "prebuilt_etc - simple example",
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runPrebuiltEtcTestCase(t, Bp2buildTestCase{
|
||||
Description: "prebuilt_etc - simple example",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
prebuilt_etc {
|
||||
name: "apex_tz_version",
|
||||
src: "version/tz_version",
|
||||
@@ -44,8 +44,8 @@ prebuilt_etc {
|
||||
installable: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_file", "apex_tz_version", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{
|
||||
"filename": `"tz_version"`,
|
||||
"installable": `False`,
|
||||
"src": `"version/tz_version"`,
|
||||
@@ -54,10 +54,10 @@ prebuilt_etc {
|
||||
}
|
||||
|
||||
func TestPrebuiltEtcArchVariant(t *testing.T) {
|
||||
runPrebuiltEtcTestCase(t, bp2buildTestCase{
|
||||
description: "prebuilt_etc - arch variant",
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runPrebuiltEtcTestCase(t, Bp2buildTestCase{
|
||||
Description: "prebuilt_etc - arch variant",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
prebuilt_etc {
|
||||
name: "apex_tz_version",
|
||||
src: "version/tz_version",
|
||||
@@ -74,8 +74,8 @@ prebuilt_etc {
|
||||
}
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_file", "apex_tz_version", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{
|
||||
"filename": `"tz_version"`,
|
||||
"installable": `False`,
|
||||
"src": `select({
|
||||
@@ -88,10 +88,10 @@ prebuilt_etc {
|
||||
}
|
||||
|
||||
func TestPrebuiltEtcArchAndTargetVariant(t *testing.T) {
|
||||
runPrebuiltEtcTestCase(t, bp2buildTestCase{
|
||||
description: "prebuilt_etc - arch variant",
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runPrebuiltEtcTestCase(t, Bp2buildTestCase{
|
||||
Description: "prebuilt_etc - arch variant",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
prebuilt_etc {
|
||||
name: "apex_tz_version",
|
||||
src: "version/tz_version",
|
||||
@@ -113,8 +113,8 @@ prebuilt_etc {
|
||||
},
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_file", "apex_tz_version", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{
|
||||
"filename": `"tz_version"`,
|
||||
"installable": `False`,
|
||||
"src": `select({
|
||||
@@ -129,21 +129,21 @@ prebuilt_etc {
|
||||
})}})
|
||||
}
|
||||
|
||||
func runPrebuiltUsrShareTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runPrebuiltUsrShareTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "prebuilt_usr_share"
|
||||
(&tc).moduleTypeUnderTestFactory = etc.PrebuiltUserShareFactory
|
||||
runBp2BuildTestCase(t, registerPrebuiltEtcModuleTypes, tc)
|
||||
(&tc).ModuleTypeUnderTest = "prebuilt_usr_share"
|
||||
(&tc).ModuleTypeUnderTestFactory = etc.PrebuiltUserShareFactory
|
||||
RunBp2BuildTestCase(t, registerPrebuiltEtcModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerPrebuiltUsrShareModuleTypes(ctx android.RegistrationContext) {
|
||||
}
|
||||
|
||||
func TestPrebuiltUsrShareSimple(t *testing.T) {
|
||||
runPrebuiltUsrShareTestCase(t, bp2buildTestCase{
|
||||
description: "prebuilt_usr_share - simple example",
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runPrebuiltUsrShareTestCase(t, Bp2buildTestCase{
|
||||
Description: "prebuilt_usr_share - simple example",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
prebuilt_usr_share {
|
||||
name: "apex_tz_version",
|
||||
src: "version/tz_version",
|
||||
@@ -152,8 +152,8 @@ prebuilt_usr_share {
|
||||
installable: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_file", "apex_tz_version", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{
|
||||
"filename": `"tz_version"`,
|
||||
"installable": `False`,
|
||||
"src": `"version/tz_version"`,
|
||||
@@ -162,10 +162,10 @@ prebuilt_usr_share {
|
||||
}
|
||||
|
||||
func TestPrebuiltEtcNoSubdir(t *testing.T) {
|
||||
runPrebuiltEtcTestCase(t, bp2buildTestCase{
|
||||
description: "prebuilt_etc - no subdir",
|
||||
filesystem: map[string]string{},
|
||||
blueprint: `
|
||||
runPrebuiltEtcTestCase(t, Bp2buildTestCase{
|
||||
Description: "prebuilt_etc - no subdir",
|
||||
Filesystem: map[string]string{},
|
||||
Blueprint: `
|
||||
prebuilt_etc {
|
||||
name: "apex_tz_version",
|
||||
src: "version/tz_version",
|
||||
@@ -173,8 +173,8 @@ prebuilt_etc {
|
||||
installable: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_file", "apex_tz_version", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{
|
||||
"filename": `"tz_version"`,
|
||||
"installable": `False`,
|
||||
"src": `"version/tz_version"`,
|
||||
|
@@ -7,27 +7,27 @@ import (
|
||||
"android/soong/python"
|
||||
)
|
||||
|
||||
func runBp2BuildTestCaseWithPythonLibraries(t *testing.T, tc bp2buildTestCase) {
|
||||
func runBp2BuildTestCaseWithPythonLibraries(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("python_library", python.PythonLibraryFactory)
|
||||
ctx.RegisterModuleType("python_library_host", python.PythonLibraryHostFactory)
|
||||
}, tc)
|
||||
}
|
||||
|
||||
func TestPythonBinaryHostSimple(t *testing.T) {
|
||||
runBp2BuildTestCaseWithPythonLibraries(t, bp2buildTestCase{
|
||||
description: "simple python_binary_host converts to a native py_binary",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
filesystem: map[string]string{
|
||||
runBp2BuildTestCaseWithPythonLibraries(t, Bp2buildTestCase{
|
||||
Description: "simple python_binary_host converts to a native py_binary",
|
||||
ModuleTypeUnderTest: "python_binary_host",
|
||||
ModuleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
Filesystem: map[string]string{
|
||||
"a.py": "",
|
||||
"b/c.py": "",
|
||||
"b/d.py": "",
|
||||
"b/e.py": "",
|
||||
"files/data.txt": "",
|
||||
},
|
||||
blueprint: `python_binary_host {
|
||||
Blueprint: `python_binary_host {
|
||||
name: "foo",
|
||||
main: "a.py",
|
||||
srcs: ["**/*.py"],
|
||||
@@ -41,8 +41,8 @@ func TestPythonBinaryHostSimple(t *testing.T) {
|
||||
srcs: ["b/e.py"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("py_binary", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("py_binary", "foo", AttrNameToString{
|
||||
"data": `["files/data.txt"]`,
|
||||
"deps": `[":bar"]`,
|
||||
"main": `"a.py"`,
|
||||
@@ -62,11 +62,11 @@ func TestPythonBinaryHostSimple(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPythonBinaryHostPy2(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
||||
description: "py2 python_binary_host",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
blueprint: `python_binary_host {
|
||||
runBp2BuildTestCaseSimple(t, Bp2buildTestCase{
|
||||
Description: "py2 python_binary_host",
|
||||
ModuleTypeUnderTest: "python_binary_host",
|
||||
ModuleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
Blueprint: `python_binary_host {
|
||||
name: "foo",
|
||||
srcs: ["a.py"],
|
||||
version: {
|
||||
@@ -81,8 +81,8 @@ func TestPythonBinaryHostPy2(t *testing.T) {
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("py_binary", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("py_binary", "foo", AttrNameToString{
|
||||
"python_version": `"PY2"`,
|
||||
"imports": `["."]`,
|
||||
"srcs": `["a.py"]`,
|
||||
@@ -96,11 +96,11 @@ func TestPythonBinaryHostPy2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPythonBinaryHostPy3(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
||||
description: "py3 python_binary_host",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
blueprint: `python_binary_host {
|
||||
runBp2BuildTestCaseSimple(t, Bp2buildTestCase{
|
||||
Description: "py3 python_binary_host",
|
||||
ModuleTypeUnderTest: "python_binary_host",
|
||||
ModuleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
Blueprint: `python_binary_host {
|
||||
name: "foo",
|
||||
srcs: ["a.py"],
|
||||
version: {
|
||||
@@ -115,9 +115,9 @@ func TestPythonBinaryHostPy3(t *testing.T) {
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
ExpectedBazelTargets: []string{
|
||||
// python_version is PY3 by default.
|
||||
makeBazelTarget("py_binary", "foo", attrNameToString{
|
||||
makeBazelTarget("py_binary", "foo", AttrNameToString{
|
||||
"imports": `["."]`,
|
||||
"srcs": `["a.py"]`,
|
||||
"target_compatible_with": `select({
|
||||
@@ -130,15 +130,15 @@ func TestPythonBinaryHostPy3(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPythonBinaryHostArchVariance(t *testing.T) {
|
||||
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
||||
description: "test arch variants",
|
||||
moduleTypeUnderTest: "python_binary_host",
|
||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
filesystem: map[string]string{
|
||||
runBp2BuildTestCaseSimple(t, Bp2buildTestCase{
|
||||
Description: "test arch variants",
|
||||
ModuleTypeUnderTest: "python_binary_host",
|
||||
ModuleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||
Filesystem: map[string]string{
|
||||
"dir/arm.py": "",
|
||||
"dir/x86.py": "",
|
||||
},
|
||||
blueprint: `python_binary_host {
|
||||
Blueprint: `python_binary_host {
|
||||
name: "foo-arm",
|
||||
arch: {
|
||||
arm: {
|
||||
@@ -149,8 +149,8 @@ func TestPythonBinaryHostArchVariance(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("py_binary", "foo-arm", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("py_binary", "foo-arm", AttrNameToString{
|
||||
"imports": `["."]`,
|
||||
"srcs": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["arm.py"],
|
||||
|
@@ -21,7 +21,7 @@ type pythonLibBp2BuildTestCase struct {
|
||||
expectedError error
|
||||
}
|
||||
|
||||
func convertPythonLibTestCaseToBp2build_Host(tc pythonLibBp2BuildTestCase) bp2buildTestCase {
|
||||
func convertPythonLibTestCaseToBp2build_Host(tc pythonLibBp2BuildTestCase) Bp2buildTestCase {
|
||||
for i := range tc.expectedBazelTargets {
|
||||
tc.expectedBazelTargets[i].attrs["target_compatible_with"] = `select({
|
||||
"//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
|
||||
@@ -32,7 +32,7 @@ func convertPythonLibTestCaseToBp2build_Host(tc pythonLibBp2BuildTestCase) bp2bu
|
||||
return convertPythonLibTestCaseToBp2build(tc)
|
||||
}
|
||||
|
||||
func convertPythonLibTestCaseToBp2build(tc pythonLibBp2BuildTestCase) bp2buildTestCase {
|
||||
func convertPythonLibTestCaseToBp2build(tc pythonLibBp2BuildTestCase) Bp2buildTestCase {
|
||||
var bp2BuildTargets []string
|
||||
for _, t := range tc.expectedBazelTargets {
|
||||
bp2BuildTargets = append(bp2BuildTargets, makeBazelTarget(t.typ, t.name, t.attrs))
|
||||
@@ -43,28 +43,28 @@ func convertPythonLibTestCaseToBp2build(tc pythonLibBp2BuildTestCase) bp2buildTe
|
||||
for k, v := range tc.filesystem {
|
||||
filesystemCopy[k] = v
|
||||
}
|
||||
return bp2buildTestCase{
|
||||
description: tc.description,
|
||||
filesystem: filesystemCopy,
|
||||
blueprint: tc.blueprint,
|
||||
expectedBazelTargets: bp2BuildTargets,
|
||||
dir: tc.dir,
|
||||
expectedErr: tc.expectedError,
|
||||
return Bp2buildTestCase{
|
||||
Description: tc.description,
|
||||
Filesystem: filesystemCopy,
|
||||
Blueprint: tc.blueprint,
|
||||
ExpectedBazelTargets: bp2BuildTargets,
|
||||
Dir: tc.dir,
|
||||
ExpectedErr: tc.expectedError,
|
||||
}
|
||||
}
|
||||
|
||||
func runPythonLibraryTestCase(t *testing.T, tc pythonLibBp2BuildTestCase) {
|
||||
t.Helper()
|
||||
testCase := convertPythonLibTestCaseToBp2build(tc)
|
||||
testCase.description = fmt.Sprintf(testCase.description, "python_library")
|
||||
testCase.blueprint = fmt.Sprintf(testCase.blueprint, "python_library")
|
||||
for name, contents := range testCase.filesystem {
|
||||
testCase.Description = fmt.Sprintf(testCase.Description, "python_library")
|
||||
testCase.Blueprint = fmt.Sprintf(testCase.Blueprint, "python_library")
|
||||
for name, contents := range testCase.Filesystem {
|
||||
if strings.HasSuffix(name, "Android.bp") {
|
||||
testCase.filesystem[name] = fmt.Sprintf(contents, "python_library")
|
||||
testCase.Filesystem[name] = fmt.Sprintf(contents, "python_library")
|
||||
}
|
||||
}
|
||||
testCase.moduleTypeUnderTest = "python_library"
|
||||
testCase.moduleTypeUnderTestFactory = python.PythonLibraryFactory
|
||||
testCase.ModuleTypeUnderTest = "python_library"
|
||||
testCase.ModuleTypeUnderTestFactory = python.PythonLibraryFactory
|
||||
|
||||
runBp2BuildTestCaseSimple(t, testCase)
|
||||
}
|
||||
@@ -72,16 +72,16 @@ func runPythonLibraryTestCase(t *testing.T, tc pythonLibBp2BuildTestCase) {
|
||||
func runPythonLibraryHostTestCase(t *testing.T, tc pythonLibBp2BuildTestCase) {
|
||||
t.Helper()
|
||||
testCase := convertPythonLibTestCaseToBp2build_Host(tc)
|
||||
testCase.description = fmt.Sprintf(testCase.description, "python_library_host")
|
||||
testCase.blueprint = fmt.Sprintf(testCase.blueprint, "python_library_host")
|
||||
for name, contents := range testCase.filesystem {
|
||||
testCase.Description = fmt.Sprintf(testCase.Description, "python_library_host")
|
||||
testCase.Blueprint = fmt.Sprintf(testCase.Blueprint, "python_library_host")
|
||||
for name, contents := range testCase.Filesystem {
|
||||
if strings.HasSuffix(name, "Android.bp") {
|
||||
testCase.filesystem[name] = fmt.Sprintf(contents, "python_library_host")
|
||||
testCase.Filesystem[name] = fmt.Sprintf(contents, "python_library_host")
|
||||
}
|
||||
}
|
||||
testCase.moduleTypeUnderTest = "python_library_host"
|
||||
testCase.moduleTypeUnderTestFactory = python.PythonLibraryHostFactory
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
|
||||
testCase.ModuleTypeUnderTest = "python_library_host"
|
||||
testCase.ModuleTypeUnderTestFactory = python.PythonLibraryHostFactory
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("python_library", python.PythonLibraryFactory)
|
||||
},
|
||||
testCase)
|
||||
@@ -121,7 +121,7 @@ func TestSimplePythonLib(t *testing.T) {
|
||||
{
|
||||
typ: "py_library",
|
||||
name: "foo",
|
||||
attrs: attrNameToString{
|
||||
attrs: AttrNameToString{
|
||||
"data": `["files/data.txt"]`,
|
||||
"deps": `[":bar"]`,
|
||||
"srcs": `[
|
||||
@@ -155,7 +155,7 @@ func TestSimplePythonLib(t *testing.T) {
|
||||
{
|
||||
typ: "py_library",
|
||||
name: "foo",
|
||||
attrs: attrNameToString{
|
||||
attrs: AttrNameToString{
|
||||
"srcs": `["a.py"]`,
|
||||
"srcs_version": `"PY2"`,
|
||||
"imports": `["."]`,
|
||||
@@ -183,7 +183,7 @@ func TestSimplePythonLib(t *testing.T) {
|
||||
{
|
||||
typ: "py_library",
|
||||
name: "foo",
|
||||
attrs: attrNameToString{
|
||||
attrs: AttrNameToString{
|
||||
"srcs": `["a.py"]`,
|
||||
"srcs_version": `"PY3"`,
|
||||
"imports": `["."]`,
|
||||
@@ -212,7 +212,7 @@ func TestSimplePythonLib(t *testing.T) {
|
||||
// srcs_version is PY2ANDPY3 by default.
|
||||
typ: "py_library",
|
||||
name: "foo",
|
||||
attrs: attrNameToString{
|
||||
attrs: AttrNameToString{
|
||||
"srcs": `["a.py"]`,
|
||||
"imports": `["."]`,
|
||||
},
|
||||
@@ -238,7 +238,7 @@ func TestSimplePythonLib(t *testing.T) {
|
||||
// srcs_version is PY2ANDPY3 by default.
|
||||
typ: "py_library",
|
||||
name: "foo",
|
||||
attrs: attrNameToString{
|
||||
attrs: AttrNameToString{
|
||||
"srcs": `["a.py"]`,
|
||||
"imports": `["../.."]`,
|
||||
"srcs_version": `"PY3"`,
|
||||
@@ -292,7 +292,7 @@ func TestPythonArchVariance(t *testing.T) {
|
||||
{
|
||||
typ: "py_library",
|
||||
name: "foo",
|
||||
attrs: attrNameToString{
|
||||
attrs: AttrNameToString{
|
||||
"srcs": `select({
|
||||
"//build/bazel/platforms/arch:arm": ["arm.py"],
|
||||
"//build/bazel/platforms/arch:x86": ["x86.py"],
|
||||
@@ -324,21 +324,21 @@ func TestPythonLibraryWithProtobufs(t *testing.T) {
|
||||
{
|
||||
typ: "proto_library",
|
||||
name: "foo_proto",
|
||||
attrs: attrNameToString{
|
||||
attrs: AttrNameToString{
|
||||
"srcs": `["dir/myproto.proto"]`,
|
||||
},
|
||||
},
|
||||
{
|
||||
typ: "py_proto_library",
|
||||
name: "foo_py_proto",
|
||||
attrs: attrNameToString{
|
||||
attrs: AttrNameToString{
|
||||
"deps": `[":foo_proto"]`,
|
||||
},
|
||||
},
|
||||
{
|
||||
typ: "py_library",
|
||||
name: "foo",
|
||||
attrs: attrNameToString{
|
||||
attrs: AttrNameToString{
|
||||
"srcs": `["dir/mylib.py"]`,
|
||||
"srcs_version": `"PY3"`,
|
||||
"imports": `["."]`,
|
||||
|
@@ -48,25 +48,25 @@ func TestShBinaryLoadStatement(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func runShBinaryTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runShBinaryTestCase(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
|
||||
}
|
||||
|
||||
func TestShBinarySimple(t *testing.T) {
|
||||
runShBinaryTestCase(t, bp2buildTestCase{
|
||||
description: "sh_binary test",
|
||||
moduleTypeUnderTest: "sh_binary",
|
||||
moduleTypeUnderTestFactory: sh.ShBinaryFactory,
|
||||
blueprint: `sh_binary {
|
||||
runShBinaryTestCase(t, Bp2buildTestCase{
|
||||
Description: "sh_binary test",
|
||||
ModuleTypeUnderTest: "sh_binary",
|
||||
ModuleTypeUnderTestFactory: sh.ShBinaryFactory,
|
||||
Blueprint: `sh_binary {
|
||||
name: "foo",
|
||||
src: "foo.sh",
|
||||
filename: "foo.exe",
|
||||
sub_dir: "sub",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("sh_binary", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("sh_binary", "foo", AttrNameToString{
|
||||
"srcs": `["foo.sh"]`,
|
||||
"filename": `"foo.exe"`,
|
||||
"sub_dir": `"sub"`,
|
||||
@@ -75,17 +75,17 @@ func TestShBinarySimple(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestShBinaryDefaults(t *testing.T) {
|
||||
runShBinaryTestCase(t, bp2buildTestCase{
|
||||
description: "sh_binary test",
|
||||
moduleTypeUnderTest: "sh_binary",
|
||||
moduleTypeUnderTestFactory: sh.ShBinaryFactory,
|
||||
blueprint: `sh_binary {
|
||||
runShBinaryTestCase(t, Bp2buildTestCase{
|
||||
Description: "sh_binary test",
|
||||
ModuleTypeUnderTest: "sh_binary",
|
||||
ModuleTypeUnderTestFactory: sh.ShBinaryFactory,
|
||||
Blueprint: `sh_binary {
|
||||
name: "foo",
|
||||
src: "foo.sh",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("sh_binary", "foo", attrNameToString{
|
||||
ExpectedBazelTargets: []string{
|
||||
makeBazelTarget("sh_binary", "foo", AttrNameToString{
|
||||
"srcs": `["foo.sh"]`,
|
||||
})},
|
||||
})
|
||||
|
@@ -20,9 +20,9 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runSoongConfigModuleTypeTest(t *testing.T, tc bp2buildTestCase) {
|
||||
func runSoongConfigModuleTypeTest(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, registerSoongConfigModuleTypes, tc)
|
||||
RunBp2BuildTestCase(t, registerSoongConfigModuleTypes, tc)
|
||||
}
|
||||
|
||||
func registerSoongConfigModuleTypes(ctx android.RegistrationContext) {
|
||||
@@ -61,12 +61,12 @@ custom_cc_library_static {
|
||||
}
|
||||
`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - soong_config_module_type is supported in bp2build",
|
||||
moduleTypeUnderTest: "cc_library_static",
|
||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
blueprint: bp,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - soong_config_module_type is supported in bp2build",
|
||||
ModuleTypeUnderTest: "cc_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
Blueprint: bp,
|
||||
ExpectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo",
|
||||
copts = select({
|
||||
"//build/bazel/product_variables:acme__feature1": ["-DFEATURE1"],
|
||||
@@ -107,15 +107,15 @@ custom_cc_library_static {
|
||||
}
|
||||
`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - soong_config_module_type_import is supported in bp2build",
|
||||
moduleTypeUnderTest: "cc_library_static",
|
||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
filesystem: map[string]string{
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - soong_config_module_type_import is supported in bp2build",
|
||||
ModuleTypeUnderTest: "cc_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
Filesystem: map[string]string{
|
||||
"foo/bar/SoongConfig.bp": configBp,
|
||||
},
|
||||
blueprint: bp,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
Blueprint: bp,
|
||||
ExpectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo",
|
||||
copts = select({
|
||||
"//build/bazel/product_variables:acme__feature1": ["-DFEATURE1"],
|
||||
@@ -161,12 +161,12 @@ custom_cc_library_static {
|
||||
}
|
||||
`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - generates selects for string vars",
|
||||
moduleTypeUnderTest: "cc_library_static",
|
||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
blueprint: bp,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - generates selects for string vars",
|
||||
ModuleTypeUnderTest: "cc_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
Blueprint: bp,
|
||||
ExpectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo",
|
||||
copts = select({
|
||||
"//build/bazel/product_variables:acme__board__soc_a": ["-DSOC_A"],
|
||||
@@ -232,12 +232,12 @@ custom_cc_library_static {
|
||||
},
|
||||
}`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - generates selects for multiple variable types",
|
||||
moduleTypeUnderTest: "cc_library_static",
|
||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
blueprint: bp,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - generates selects for multiple variable types",
|
||||
ModuleTypeUnderTest: "cc_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
Blueprint: bp,
|
||||
ExpectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo",
|
||||
copts = select({
|
||||
"//build/bazel/product_variables:acme__board__soc_a": ["-DSOC_A"],
|
||||
@@ -298,15 +298,15 @@ cc_library_static { name: "soc_b_dep", bazel_module: { bp2build_available: false
|
||||
cc_library_static { name: "soc_default_static_dep", bazel_module: { bp2build_available: false } }
|
||||
`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - generates selects for label list attributes",
|
||||
moduleTypeUnderTest: "cc_library_static",
|
||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
blueprint: bp,
|
||||
filesystem: map[string]string{
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - generates selects for label list attributes",
|
||||
ModuleTypeUnderTest: "cc_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
Blueprint: bp,
|
||||
Filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": otherDeps,
|
||||
},
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
ExpectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo",
|
||||
copts = select({
|
||||
"//build/bazel/product_variables:acme__board__soc_a": ["-DSOC_A"],
|
||||
@@ -365,12 +365,12 @@ cc_library_static {
|
||||
}
|
||||
`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - defaults with a single namespace",
|
||||
moduleTypeUnderTest: "cc_library_static",
|
||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
blueprint: bp,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - defaults with a single namespace",
|
||||
ModuleTypeUnderTest: "cc_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
Blueprint: bp,
|
||||
ExpectedBazelTargets: []string{`cc_library_static(
|
||||
name = "lib",
|
||||
copts = select({
|
||||
"//build/bazel/product_variables:vendor_foo__feature": [
|
||||
@@ -446,12 +446,12 @@ cc_library_static {
|
||||
}
|
||||
`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - multiple defaults with a single namespace",
|
||||
moduleTypeUnderTest: "cc_library_static",
|
||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
blueprint: bp,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - multiple defaults with a single namespace",
|
||||
ModuleTypeUnderTest: "cc_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
Blueprint: bp,
|
||||
ExpectedBazelTargets: []string{`cc_library_static(
|
||||
name = "lib",
|
||||
asflags = select({
|
||||
"//build/bazel/product_variables:acme__feature": ["-asflag_bar"],
|
||||
@@ -562,12 +562,12 @@ cc_library_static {
|
||||
}
|
||||
`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - defaults with multiple namespaces",
|
||||
moduleTypeUnderTest: "cc_library_static",
|
||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
blueprint: bp,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - defaults with multiple namespaces",
|
||||
ModuleTypeUnderTest: "cc_library_static",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||
Blueprint: bp,
|
||||
ExpectedBazelTargets: []string{`cc_library_static(
|
||||
name = "lib",
|
||||
copts = select({
|
||||
"//build/bazel/product_variables:vendor_bar__feature": ["-DVENDOR_BAR_FEATURE"],
|
||||
@@ -653,15 +653,15 @@ cc_library { name: "lib_b", bazel_module: { bp2build_available: false } }
|
||||
cc_library { name: "lib_default", bazel_module: { bp2build_available: false } }
|
||||
`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - generates selects for library_linking_strategy",
|
||||
moduleTypeUnderTest: "cc_binary",
|
||||
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
blueprint: bp,
|
||||
filesystem: map[string]string{
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - generates selects for library_linking_strategy",
|
||||
ModuleTypeUnderTest: "cc_binary",
|
||||
ModuleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
Blueprint: bp,
|
||||
Filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": otherDeps,
|
||||
},
|
||||
expectedBazelTargets: []string{`cc_binary(
|
||||
ExpectedBazelTargets: []string{`cc_binary(
|
||||
name = "library_linking_strategy_sample_binary",
|
||||
deps = select({
|
||||
"//build/bazel/product_variables:android__library_linking_strategy__prefer_static": [
|
||||
@@ -734,15 +734,15 @@ cc_library { name: "lib_a", bazel_module: { bp2build_available: false } }
|
||||
cc_library { name: "lib_b", bazel_module: { bp2build_available: false } }
|
||||
`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - generates selects for library_linking_strategy",
|
||||
moduleTypeUnderTest: "cc_binary",
|
||||
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
blueprint: bp,
|
||||
filesystem: map[string]string{
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - generates selects for library_linking_strategy",
|
||||
ModuleTypeUnderTest: "cc_binary",
|
||||
ModuleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
Blueprint: bp,
|
||||
Filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": otherDeps,
|
||||
},
|
||||
expectedBazelTargets: []string{`cc_binary(
|
||||
ExpectedBazelTargets: []string{`cc_binary(
|
||||
name = "library_linking_strategy_sample_binary",
|
||||
deps = select({
|
||||
"//build/bazel/product_variables:android__library_linking_strategy__prefer_static": [
|
||||
@@ -822,15 +822,15 @@ cc_library { name: "lib_b", bazel_module: { bp2build_available: false } }
|
||||
cc_library { name: "lib_default", bazel_module: { bp2build_available: false } }
|
||||
`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - generates selects for library_linking_strategy",
|
||||
moduleTypeUnderTest: "cc_binary",
|
||||
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
blueprint: bp,
|
||||
filesystem: map[string]string{
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - generates selects for library_linking_strategy",
|
||||
ModuleTypeUnderTest: "cc_binary",
|
||||
ModuleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
Blueprint: bp,
|
||||
Filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": otherDeps,
|
||||
},
|
||||
expectedBazelTargets: []string{`cc_binary(
|
||||
ExpectedBazelTargets: []string{`cc_binary(
|
||||
name = "alphabet_binary",
|
||||
deps = select({
|
||||
"//build/bazel/product_variables:android__alphabet__a": [],
|
||||
@@ -888,13 +888,13 @@ cc_binary {
|
||||
},
|
||||
}`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - generates selects for library_linking_strategy",
|
||||
moduleTypeUnderTest: "cc_binary",
|
||||
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
blueprint: bp,
|
||||
filesystem: map[string]string{},
|
||||
expectedBazelTargets: []string{`cc_binary(
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - generates selects for library_linking_strategy",
|
||||
ModuleTypeUnderTest: "cc_binary",
|
||||
ModuleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
Blueprint: bp,
|
||||
Filesystem: map[string]string{},
|
||||
ExpectedBazelTargets: []string{`cc_binary(
|
||||
name = "alphabet_binary",
|
||||
local_includes = ["."],
|
||||
srcs = ["main.cc"],
|
||||
@@ -941,13 +941,13 @@ cc_binary {
|
||||
enabled: false,
|
||||
}`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - generates selects for library_linking_strategy",
|
||||
moduleTypeUnderTest: "cc_binary",
|
||||
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
blueprint: bp,
|
||||
filesystem: map[string]string{},
|
||||
expectedBazelTargets: []string{`cc_binary(
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - generates selects for library_linking_strategy",
|
||||
ModuleTypeUnderTest: "cc_binary",
|
||||
ModuleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
Blueprint: bp,
|
||||
Filesystem: map[string]string{},
|
||||
ExpectedBazelTargets: []string{`cc_binary(
|
||||
name = "alphabet_binary",
|
||||
local_includes = ["."],
|
||||
srcs = ["main.cc"],
|
||||
@@ -985,13 +985,13 @@ cc_binary {
|
||||
defaults: ["alphabet_sample_cc_defaults"],
|
||||
}`
|
||||
|
||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||
description: "soong config variables - generates selects for library_linking_strategy",
|
||||
moduleTypeUnderTest: "cc_binary",
|
||||
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
blueprint: bp,
|
||||
filesystem: map[string]string{},
|
||||
expectedBazelTargets: []string{`cc_binary(
|
||||
runSoongConfigModuleTypeTest(t, Bp2buildTestCase{
|
||||
Description: "soong config variables - generates selects for library_linking_strategy",
|
||||
ModuleTypeUnderTest: "cc_binary",
|
||||
ModuleTypeUnderTestFactory: cc.BinaryFactory,
|
||||
Blueprint: bp,
|
||||
Filesystem: map[string]string{},
|
||||
ExpectedBazelTargets: []string{`cc_binary(
|
||||
name = "alphabet_binary",
|
||||
local_includes = ["."],
|
||||
srcs = ["main.cc"],
|
||||
|
@@ -53,16 +53,16 @@ func checkError(t *testing.T, errs []error, expectedErr error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func errored(t *testing.T, tc bp2buildTestCase, errs []error) bool {
|
||||
func errored(t *testing.T, tc Bp2buildTestCase, errs []error) bool {
|
||||
t.Helper()
|
||||
if tc.expectedErr != nil {
|
||||
if tc.ExpectedErr != nil {
|
||||
// Rely on checkErrors, as this test case is expected to have an error.
|
||||
return false
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
for _, err := range errs {
|
||||
t.Errorf("%s: %s", tc.description, err)
|
||||
t.Errorf("%s: %s", tc.Description, err)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -71,42 +71,42 @@ func errored(t *testing.T, tc bp2buildTestCase, errs []error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func runBp2BuildTestCaseSimple(t *testing.T, tc bp2buildTestCase) {
|
||||
func runBp2BuildTestCaseSimple(t *testing.T, tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
|
||||
}
|
||||
|
||||
type bp2buildTestCase struct {
|
||||
description string
|
||||
moduleTypeUnderTest string
|
||||
moduleTypeUnderTestFactory android.ModuleFactory
|
||||
blueprint string
|
||||
expectedBazelTargets []string
|
||||
filesystem map[string]string
|
||||
dir string
|
||||
type Bp2buildTestCase struct {
|
||||
Description string
|
||||
ModuleTypeUnderTest string
|
||||
ModuleTypeUnderTestFactory android.ModuleFactory
|
||||
Blueprint string
|
||||
ExpectedBazelTargets []string
|
||||
Filesystem map[string]string
|
||||
Dir string
|
||||
// An error with a string contained within the string of the expected error
|
||||
expectedErr error
|
||||
unconvertedDepsMode unconvertedDepsMode
|
||||
ExpectedErr error
|
||||
UnconvertedDepsMode unconvertedDepsMode
|
||||
}
|
||||
|
||||
func runBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.RegistrationContext), tc bp2buildTestCase) {
|
||||
func RunBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.RegistrationContext), tc Bp2buildTestCase) {
|
||||
t.Helper()
|
||||
dir := "."
|
||||
filesystem := make(map[string][]byte)
|
||||
toParse := []string{
|
||||
"Android.bp",
|
||||
}
|
||||
for f, content := range tc.filesystem {
|
||||
for f, content := range tc.Filesystem {
|
||||
if strings.HasSuffix(f, "Android.bp") {
|
||||
toParse = append(toParse, f)
|
||||
}
|
||||
filesystem[f] = []byte(content)
|
||||
}
|
||||
config := android.TestConfig(buildDir, nil, tc.blueprint, filesystem)
|
||||
config := android.TestConfig(buildDir, nil, tc.Blueprint, filesystem)
|
||||
ctx := android.NewTestContext(config)
|
||||
|
||||
registerModuleTypes(ctx)
|
||||
ctx.RegisterModuleType(tc.moduleTypeUnderTest, tc.moduleTypeUnderTestFactory)
|
||||
ctx.RegisterModuleType(tc.ModuleTypeUnderTest, tc.ModuleTypeUnderTestFactory)
|
||||
ctx.RegisterBp2BuildConfig(bp2buildConfig)
|
||||
ctx.RegisterForBazelConversion()
|
||||
|
||||
@@ -120,35 +120,35 @@ func runBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.Regi
|
||||
}
|
||||
|
||||
parseAndResolveErrs := append(parseErrs, resolveDepsErrs...)
|
||||
if tc.expectedErr != nil && checkError(t, parseAndResolveErrs, tc.expectedErr) {
|
||||
if tc.ExpectedErr != nil && checkError(t, parseAndResolveErrs, tc.ExpectedErr) {
|
||||
return
|
||||
}
|
||||
|
||||
checkDir := dir
|
||||
if tc.dir != "" {
|
||||
checkDir = tc.dir
|
||||
if tc.Dir != "" {
|
||||
checkDir = tc.Dir
|
||||
}
|
||||
codegenCtx := NewCodegenContext(config, *ctx.Context, Bp2Build)
|
||||
codegenCtx.unconvertedDepMode = tc.unconvertedDepsMode
|
||||
codegenCtx.unconvertedDepMode = tc.UnconvertedDepsMode
|
||||
bazelTargets, errs := generateBazelTargetsForDir(codegenCtx, checkDir)
|
||||
if tc.expectedErr != nil {
|
||||
if checkError(t, errs, tc.expectedErr) {
|
||||
if tc.ExpectedErr != nil {
|
||||
if checkError(t, errs, tc.ExpectedErr) {
|
||||
return
|
||||
} else {
|
||||
t.Errorf("Expected error: %q, got: %q and %q", tc.expectedErr, errs, parseAndResolveErrs)
|
||||
t.Errorf("Expected error: %q, got: %q and %q", tc.ExpectedErr, errs, parseAndResolveErrs)
|
||||
}
|
||||
} else {
|
||||
android.FailIfErrored(t, errs)
|
||||
}
|
||||
if actualCount, expectedCount := len(bazelTargets), len(tc.expectedBazelTargets); actualCount != expectedCount {
|
||||
if actualCount, expectedCount := len(bazelTargets), len(tc.ExpectedBazelTargets); actualCount != expectedCount {
|
||||
t.Errorf("%s: Expected %d bazel target (%s), got `%d`` (%s)",
|
||||
tc.description, expectedCount, tc.expectedBazelTargets, actualCount, bazelTargets)
|
||||
tc.Description, expectedCount, tc.ExpectedBazelTargets, actualCount, bazelTargets)
|
||||
} else {
|
||||
for i, target := range bazelTargets {
|
||||
if w, g := tc.expectedBazelTargets[i], target.content; w != g {
|
||||
if w, g := tc.ExpectedBazelTargets[i], target.content; w != g {
|
||||
t.Errorf(
|
||||
"%s: Expected generated Bazel target to be `%s`, got `%s`",
|
||||
tc.description, w, g)
|
||||
tc.Description, w, g)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -391,10 +391,10 @@ func simpleModuleDoNotConvertBp2build(typ, name string) string {
|
||||
}`, typ, name)
|
||||
}
|
||||
|
||||
type attrNameToString map[string]string
|
||||
type AttrNameToString map[string]string
|
||||
|
||||
func (a attrNameToString) clone() attrNameToString {
|
||||
newAttrs := make(attrNameToString, len(a))
|
||||
func (a AttrNameToString) clone() AttrNameToString {
|
||||
newAttrs := make(AttrNameToString, len(a))
|
||||
for k, v := range a {
|
||||
newAttrs[k] = v
|
||||
}
|
||||
@@ -403,7 +403,7 @@ func (a attrNameToString) clone() attrNameToString {
|
||||
|
||||
// makeBazelTargetNoRestrictions returns bazel target build file definition that can be host or
|
||||
// device specific, or independent of host/device.
|
||||
func makeBazelTargetHostOrDevice(typ, name string, attrs attrNameToString, hod android.HostOrDeviceSupported) string {
|
||||
func makeBazelTargetHostOrDevice(typ, name string, attrs AttrNameToString, hod android.HostOrDeviceSupported) string {
|
||||
if _, ok := attrs["target_compatible_with"]; !ok {
|
||||
switch hod {
|
||||
case android.HostSupported:
|
||||
@@ -426,15 +426,15 @@ func makeBazelTargetHostOrDevice(typ, name string, attrs attrNameToString, hod a
|
||||
)`, typ, strings.Join(attrStrings, "\n"))
|
||||
}
|
||||
|
||||
// makeBazelTargetNoRestrictions returns bazel target build file definition that does not add a
|
||||
// MakeBazelTargetNoRestrictions returns bazel target build file definition that does not add a
|
||||
// target_compatible_with. This is useful for module types like filegroup and genrule that arch not
|
||||
// arch variant
|
||||
func makeBazelTargetNoRestrictions(typ, name string, attrs attrNameToString) string {
|
||||
func MakeBazelTargetNoRestrictions(typ, name string, attrs AttrNameToString) string {
|
||||
return makeBazelTargetHostOrDevice(typ, name, attrs, android.HostAndDeviceDefault)
|
||||
}
|
||||
|
||||
// makeBazelTargetNoRestrictions returns bazel target build file definition that is device specific
|
||||
// as this is the most common default in Soong.
|
||||
func makeBazelTarget(typ, name string, attrs attrNameToString) string {
|
||||
func makeBazelTarget(typ, name string, attrs AttrNameToString) string {
|
||||
return makeBazelTargetHostOrDevice(typ, name, attrs, android.DeviceSupported)
|
||||
}
|
||||
|
Reference in New Issue
Block a user