Convert apex_available (for supported modules) to bazel tags.
The tags will then be read by an aspect applied from apex attributes to validate that the deps are explicitly opt-in to the appropriate apex. The semantics of this is the same as the Soong apex_available property. This also adds the "base_apex_name" attr to override_apex conversion so that apex_available checks continue to work on the non-Google and non-Go apex names. Test: presubmits Fixes: 218841706 Change-Id: I19b3637da9aa47573b252d74f62b601fbdc3784d
This commit is contained in:
@@ -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": `["."]`,
|
||||
}),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user