Merge "Allow stubs implementation to be omitted"
This commit is contained in:
@@ -59,6 +59,7 @@ func init() {
|
||||
AddNeverAllowRules(createInitFirstStageRules()...)
|
||||
AddNeverAllowRules(createProhibitFrameworkAccessRules()...)
|
||||
AddNeverAllowRules(createBp2BuildRule())
|
||||
AddNeverAllowRules(createCcStubsRule())
|
||||
}
|
||||
|
||||
// Add a NeverAllow rule to the set of rules to apply.
|
||||
@@ -214,6 +215,17 @@ func createCcSdkVariantRules() []Rule {
|
||||
}
|
||||
}
|
||||
|
||||
func createCcStubsRule() Rule {
|
||||
ccStubsImplementationInstallableProjectsAllowedList := []string{
|
||||
"packages/modules/Virtualization/vm_payload",
|
||||
}
|
||||
|
||||
return NeverAllow().
|
||||
NotIn(ccStubsImplementationInstallableProjectsAllowedList...).
|
||||
WithMatcher("stubs.implementation_installable", isSetMatcherInstance).
|
||||
Because("implementation_installable can only be used in allowed projects.")
|
||||
}
|
||||
|
||||
func createUncompressDexRules() []Rule {
|
||||
return []Rule{
|
||||
NeverAllow().
|
||||
|
@@ -367,6 +367,22 @@ var neverallowTests = []struct {
|
||||
"framework can't be used when building against SDK",
|
||||
},
|
||||
},
|
||||
// Test for the rule restricting use of implementation_installable
|
||||
{
|
||||
name: `"implementation_installable" outside allowed list`,
|
||||
fs: map[string][]byte{
|
||||
"Android.bp": []byte(`
|
||||
cc_library {
|
||||
name: "outside_allowed_list",
|
||||
stubs: {
|
||||
implementation_installable: true,
|
||||
},
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "outside_allowed_list": violates neverallow`,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var prepareForNeverAllowTest = GroupFixturePreparers(
|
||||
@@ -419,6 +435,10 @@ type mockCcLibraryProperties struct {
|
||||
Platform struct {
|
||||
Shared_libs []string
|
||||
}
|
||||
|
||||
Stubs struct {
|
||||
Implementation_installable *bool
|
||||
}
|
||||
}
|
||||
|
||||
type mockCcLibraryModule struct {
|
||||
|
Reference in New Issue
Block a user