Convert Soong `licenses` attribute to Bazel's `applicable_licenses` attribute
Add it to the `CommonAttributes` struct and handle it in fillCommonBp2BuildModuleAttrs
Bug: 190817312
Test: treehugger
Change-Id: I7b21056e680384d4046372ee844512029721026e
diff --git a/bp2build/build_conversion_test.go b/bp2build/build_conversion_test.go
index d29eb9c..d513d04 100644
--- a/bp2build/build_conversion_test.go
+++ b/bp2build/build_conversion_test.go
@@ -1821,3 +1821,30 @@
})
}
}
+
+func TestLicensesAttrConversion(t *testing.T) {
+ RunBp2BuildTestCase(t,
+ func(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("license", android.LicenseFactory)
+ },
+ Bp2buildTestCase{
+ Description: "Test that licenses: attribute is converted",
+ ModuleTypeUnderTest: "filegroup",
+ ModuleTypeUnderTestFactory: android.FileGroupFactory,
+ Blueprint: `
+license {
+ name: "my_license",
+}
+filegroup {
+ name: "my_filegroup",
+ licenses: ["my_license"],
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTargetNoRestrictions("filegroup", "my_filegroup", AttrNameToString{
+ "applicable_licenses": `[":my_license"]`,
+ }),
+ MakeBazelTargetNoRestrictions("android_license", "my_license", AttrNameToString{}),
+ },
+ })
+}