Loading android/mutator.go +22 −0 Original line number Diff line number Diff line Loading @@ -705,6 +705,28 @@ func (t *topDownMutatorContext) CreateBazelTargetModuleWithRestrictions( t.createBazelTargetModule(bazelProps, commonAttrs, attrs, enabledProperty) } // ApexAvailableTags converts the apex_available property value of an ApexModule // module and returns it as a list of keyed tags. func ApexAvailableTags(mod Module) bazel.StringListAttribute { attr := bazel.StringListAttribute{} tags := []string{} // Transform specific attributes into tags. if am, ok := mod.(ApexModule); ok { // TODO(b/218841706): hidl_interface has the apex_available prop, but it's // defined directly as a prop and not via ApexModule, so this doesn't // pick those props up. // TODO(b/260694842): This does not pick up aidl_interface.backend.ndk.apex_available. for _, a := range am.apexModuleBase().ApexAvailable() { tags = append(tags, "apex_available="+a) } } if len(tags) > 0 { // This avoids creating a tags attr with an empty list if there are no tags. attr.Value = tags } return attr } func (t *topDownMutatorContext) createBazelTargetModule( bazelProps bazel.BazelTargetModuleProperties, commonAttrs CommonAttributes, Loading apex/apex.go +5 −0 Original line number Diff line number Diff line Loading @@ -2676,6 +2676,10 @@ func (o *OverrideApex) ConvertWithBp2build(ctx android.TopDownMutatorContext) { } attrs, props := convertWithBp2build(a, ctx) // We just want the name, not module reference. baseApexName := strings.TrimPrefix(baseApexModuleName, ":") attrs.Base_apex_name = &baseApexName for _, p := range o.GetProperties() { overridableProperties, ok := p.(*overridableProperties) if !ok { Loading Loading @@ -3397,6 +3401,7 @@ type bazelApexBundleAttributes struct { Package_name *string Logging_parent *string Tests bazel.LabelListAttribute Base_apex_name *string } type convertedNativeSharedLibs struct { Loading bp2build/apex_conversion_test.go +39 −25 Original line number Diff line number Diff line Loading @@ -663,6 +663,7 @@ override_apex { ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "android_manifest": `"ApogeeAndroidManifest.xml"`, "base_apex_name": `"com.android.apogee"`, "binaries": `[ ":cc_binary_1", ":sh_binary_2", Loading Loading @@ -729,6 +730,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"//a/b:apex_manifest.json"`, }), Loading Loading @@ -763,6 +765,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"//a/b:apogee_manifest.json"`, }), Loading Loading @@ -795,6 +798,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, }), Loading Loading @@ -828,6 +832,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apogee_manifest.json"`, }), Loading Loading @@ -861,6 +866,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "package_name": `"com.google.android.apogee"`, Loading Loading @@ -900,6 +906,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "prebuilts": `[":prebuilt_file"]`, Loading Loading @@ -945,6 +952,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "prebuilts": `[":prebuilt_file2"]`, Loading Loading @@ -985,6 +993,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "prebuilts": `[]`, Loading Loading @@ -1019,6 +1028,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "logging_parent": `"foo.bar.baz"`, Loading Loading @@ -1054,6 +1064,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "logging_parent": `"foo.bar.baz.override"`, Loading Loading @@ -1099,6 +1110,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `":com.android.apogee-file_contexts"`, "manifest": `"apogee_manifest.json"`, }), Loading Loading @@ -1200,6 +1212,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `":com.android.apogee-file_contexts"`, "certificate": `":com.google.android.apogee.certificate"`, "manifest": `"apogee_manifest.json"`, Loading Loading @@ -1244,6 +1257,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `":com.android.apogee-file_contexts"`, "certificate_name": `"com.google.android.apogee.certificate"`, "manifest": `"apogee_manifest.json"`, Loading bp2build/cc_library_conversion_test.go +46 −0 Original line number Diff line number Diff line Loading @@ -3645,3 +3645,49 @@ func TestCcLibraryHeaderAbiChecker(t *testing.T) { }, }) } func TestCcLibraryApexAvailable(t *testing.T) { runCcLibraryTestCase(t, Bp2buildTestCase{ Description: "cc_library apex_available converted to tags", ModuleTypeUnderTest: "cc_library", ModuleTypeUnderTestFactory: cc.LibraryFactory, Blueprint: soongCcLibraryPreamble + ` cc_library { name: "a", srcs: ["a.cpp"], apex_available: ["com.android.foo"], } `, ExpectedBazelTargets: makeCcLibraryTargets("a", AttrNameToString{ "tags": `["apex_available=com.android.foo"]`, "srcs": `["a.cpp"]`, "local_includes": `["."]`, }), }, ) } func TestCcLibraryApexAvailableMultiple(t *testing.T) { runCcLibraryTestCase(t, Bp2buildTestCase{ Description: "cc_library apex_available converted to multiple tags", ModuleTypeUnderTest: "cc_library", ModuleTypeUnderTestFactory: cc.LibraryFactory, Blueprint: soongCcLibraryPreamble + ` cc_library { name: "a", srcs: ["a.cpp"], apex_available: ["com.android.foo", "//apex_available:platform", "com.android.bar"], } `, ExpectedBazelTargets: makeCcLibraryTargets("a", AttrNameToString{ "tags": `[ "apex_available=com.android.foo", "apex_available=//apex_available:platform", "apex_available=com.android.bar", ]`, "srcs": `["a.cpp"]`, "local_includes": `["."]`, }), }, ) } cc/binary.go +2 −1 Original line number Diff line number Diff line Loading @@ -655,11 +655,12 @@ func binaryBp2build(ctx android.TopDownMutatorContext, m *Module) { // shared with cc_test binaryAttrs := binaryBp2buildAttrs(ctx, m) tags := android.ApexAvailableTags(m) ctx.CreateBazelTargetModule(bazel.BazelTargetModuleProperties{ Rule_class: "cc_binary", Bzl_load_location: "//build/bazel/rules/cc:cc_binary.bzl", }, android.CommonAttributes{Name: m.Name()}, android.CommonAttributes{Name: m.Name(), Tags: tags}, &binaryAttrs) } Loading Loading
android/mutator.go +22 −0 Original line number Diff line number Diff line Loading @@ -705,6 +705,28 @@ func (t *topDownMutatorContext) CreateBazelTargetModuleWithRestrictions( t.createBazelTargetModule(bazelProps, commonAttrs, attrs, enabledProperty) } // ApexAvailableTags converts the apex_available property value of an ApexModule // module and returns it as a list of keyed tags. func ApexAvailableTags(mod Module) bazel.StringListAttribute { attr := bazel.StringListAttribute{} tags := []string{} // Transform specific attributes into tags. if am, ok := mod.(ApexModule); ok { // TODO(b/218841706): hidl_interface has the apex_available prop, but it's // defined directly as a prop and not via ApexModule, so this doesn't // pick those props up. // TODO(b/260694842): This does not pick up aidl_interface.backend.ndk.apex_available. for _, a := range am.apexModuleBase().ApexAvailable() { tags = append(tags, "apex_available="+a) } } if len(tags) > 0 { // This avoids creating a tags attr with an empty list if there are no tags. attr.Value = tags } return attr } func (t *topDownMutatorContext) createBazelTargetModule( bazelProps bazel.BazelTargetModuleProperties, commonAttrs CommonAttributes, Loading
apex/apex.go +5 −0 Original line number Diff line number Diff line Loading @@ -2676,6 +2676,10 @@ func (o *OverrideApex) ConvertWithBp2build(ctx android.TopDownMutatorContext) { } attrs, props := convertWithBp2build(a, ctx) // We just want the name, not module reference. baseApexName := strings.TrimPrefix(baseApexModuleName, ":") attrs.Base_apex_name = &baseApexName for _, p := range o.GetProperties() { overridableProperties, ok := p.(*overridableProperties) if !ok { Loading Loading @@ -3397,6 +3401,7 @@ type bazelApexBundleAttributes struct { Package_name *string Logging_parent *string Tests bazel.LabelListAttribute Base_apex_name *string } type convertedNativeSharedLibs struct { Loading
bp2build/apex_conversion_test.go +39 −25 Original line number Diff line number Diff line Loading @@ -663,6 +663,7 @@ override_apex { ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "android_manifest": `"ApogeeAndroidManifest.xml"`, "base_apex_name": `"com.android.apogee"`, "binaries": `[ ":cc_binary_1", ":sh_binary_2", Loading Loading @@ -729,6 +730,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"//a/b:apex_manifest.json"`, }), Loading Loading @@ -763,6 +765,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"//a/b:apogee_manifest.json"`, }), Loading Loading @@ -795,6 +798,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, }), Loading Loading @@ -828,6 +832,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apogee_manifest.json"`, }), Loading Loading @@ -861,6 +866,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "package_name": `"com.google.android.apogee"`, Loading Loading @@ -900,6 +906,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "prebuilts": `[":prebuilt_file"]`, Loading Loading @@ -945,6 +952,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "prebuilts": `[":prebuilt_file2"]`, Loading Loading @@ -985,6 +993,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "prebuilts": `[]`, Loading Loading @@ -1019,6 +1028,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "logging_parent": `"foo.bar.baz"`, Loading Loading @@ -1054,6 +1064,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `"//system/sepolicy/apex:com.android.apogee-file_contexts"`, "manifest": `"apex_manifest.json"`, "logging_parent": `"foo.bar.baz.override"`, Loading Loading @@ -1099,6 +1110,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `":com.android.apogee-file_contexts"`, "manifest": `"apogee_manifest.json"`, }), Loading Loading @@ -1200,6 +1212,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `":com.android.apogee-file_contexts"`, "certificate": `":com.google.android.apogee.certificate"`, "manifest": `"apogee_manifest.json"`, Loading Loading @@ -1244,6 +1257,7 @@ override_apex { `, ExpectedBazelTargets: []string{ MakeBazelTarget("apex", "com.google.android.apogee", AttrNameToString{ "base_apex_name": `"com.android.apogee"`, "file_contexts": `":com.android.apogee-file_contexts"`, "certificate_name": `"com.google.android.apogee.certificate"`, "manifest": `"apogee_manifest.json"`, Loading
bp2build/cc_library_conversion_test.go +46 −0 Original line number Diff line number Diff line Loading @@ -3645,3 +3645,49 @@ func TestCcLibraryHeaderAbiChecker(t *testing.T) { }, }) } func TestCcLibraryApexAvailable(t *testing.T) { runCcLibraryTestCase(t, Bp2buildTestCase{ Description: "cc_library apex_available converted to tags", ModuleTypeUnderTest: "cc_library", ModuleTypeUnderTestFactory: cc.LibraryFactory, Blueprint: soongCcLibraryPreamble + ` cc_library { name: "a", srcs: ["a.cpp"], apex_available: ["com.android.foo"], } `, ExpectedBazelTargets: makeCcLibraryTargets("a", AttrNameToString{ "tags": `["apex_available=com.android.foo"]`, "srcs": `["a.cpp"]`, "local_includes": `["."]`, }), }, ) } func TestCcLibraryApexAvailableMultiple(t *testing.T) { runCcLibraryTestCase(t, Bp2buildTestCase{ Description: "cc_library apex_available converted to multiple tags", ModuleTypeUnderTest: "cc_library", ModuleTypeUnderTestFactory: cc.LibraryFactory, Blueprint: soongCcLibraryPreamble + ` cc_library { name: "a", srcs: ["a.cpp"], apex_available: ["com.android.foo", "//apex_available:platform", "com.android.bar"], } `, ExpectedBazelTargets: makeCcLibraryTargets("a", AttrNameToString{ "tags": `[ "apex_available=com.android.foo", "apex_available=//apex_available:platform", "apex_available=com.android.bar", ]`, "srcs": `["a.cpp"]`, "local_includes": `["."]`, }), }, ) }
cc/binary.go +2 −1 Original line number Diff line number Diff line Loading @@ -655,11 +655,12 @@ func binaryBp2build(ctx android.TopDownMutatorContext, m *Module) { // shared with cc_test binaryAttrs := binaryBp2buildAttrs(ctx, m) tags := android.ApexAvailableTags(m) ctx.CreateBazelTargetModule(bazel.BazelTargetModuleProperties{ Rule_class: "cc_binary", Bzl_load_location: "//build/bazel/rules/cc:cc_binary.bzl", }, android.CommonAttributes{Name: m.Name()}, android.CommonAttributes{Name: m.Name(), Tags: tags}, &binaryAttrs) } Loading