Merge "start eating include_dirs from both ends" am: ac9dc817b8 am: 294019346e am: 0cac14f204

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1687472

Change-Id: Id6a353e4e697c2ed783b0b83e8361ee34a263e9a
This commit is contained in:
Steven Moreland
2021-04-27 17:42:41 +00:00
committed by Automerger Merge Worker
2 changed files with 28 additions and 8 deletions

View File

@@ -63,8 +63,7 @@ func AddNeverAllowRules(rules ...Rule) {
}
func createIncludeDirsRules() []Rule {
// The list of paths that cannot be referenced using include_dirs
paths := []string{
notInIncludeDir := []string{
"art",
"art/libnativebridge",
"art/libnativeloader",
@@ -80,12 +79,13 @@ func createIncludeDirsRules() []Rule {
"external/vixl",
"external/wycheproof",
}
noUseIncludeDir := []string{
"system/libfmq",
}
// Create a composite matcher that will match if the value starts with any of the restricted
// paths. A / is appended to the prefix to ensure that restricting path X does not affect paths
// XY.
rules := make([]Rule, 0, len(paths))
for _, path := range paths {
rules := make([]Rule, 0, len(notInIncludeDir)+len(noUseIncludeDir))
for _, path := range notInIncludeDir {
rule :=
NeverAllow().
WithMatcher("include_dirs", StartsWith(path+"/")).
@@ -95,6 +95,13 @@ func createIncludeDirsRules() []Rule {
rules = append(rules, rule)
}
for _, path := range noUseIncludeDir {
rule := NeverAllow().In(path+"/").WithMatcher("include_dirs", isSetMatcherInstance).
Because("include_dirs is deprecated, all usages of them in '" + path + "' have been migrated" +
" to use alternate mechanisms and so can no longer be used.")
rules = append(rules, rule)
}
return rules
}

View File

@@ -76,7 +76,20 @@ var neverallowTests = []struct {
},
},
{
name: "include_dir can reference another location",
name: "include_dir not allowed to reference art",
fs: map[string][]byte{
"system/libfmq/Android.bp": []byte(`
cc_library {
name: "libother",
include_dirs: ["any/random/file"],
}`),
},
expectedErrors: []string{
"all usages of them in 'system/libfmq' have been migrated",
},
},
{
name: "include_dir can work",
fs: map[string][]byte{
"other/Android.bp": []byte(`
cc_library {