diff options
| author | 2022-11-16 20:52:17 +0000 | |
|---|---|---|
| committer | 2022-11-16 20:52:17 +0000 | |
| commit | 775f2cb3cd58800b446f13d8320fe4eedae61b47 (patch) | |
| tree | 46c0da57e419fc2efa4259e51435d621ab8417fc | |
| parent | b70f746eac73974fab6166cfdb79075c857af66f (diff) | |
| parent | 46d08b4e39d7e98abd6ee19dc0deb799be193177 (diff) | |
Merge "export neverallow include dir list to Bazel"
| -rw-r--r-- | android/defs.go | 10 | ||||
| -rw-r--r-- | android/neverallow.go | 14 | ||||
| -rw-r--r-- | bp2build/conversion.go | 3 | ||||
| -rw-r--r-- | bp2build/conversion_test.go | 8 |
4 files changed, 28 insertions, 7 deletions
diff --git a/android/defs.go b/android/defs.go index 2a28e98a6..9ae360e36 100644 --- a/android/defs.go +++ b/android/defs.go @@ -25,7 +25,8 @@ import ( ) var ( - pctx = NewPackageContext("android/soong/android") + pctx = NewPackageContext("android/soong/android") + exportedVars = NewExportedVariables(pctx) cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks", Config.CpPreserveSymlinksFlags) @@ -128,6 +129,13 @@ func init() { pctx.VariableFunc("RBEWrapper", func(ctx PackageVarContext) string { return ctx.Config().RBEWrapper() }) + + exportedVars.ExportStringList("NeverAllowNotInIncludeDir", neverallowNotInIncludeDir) + exportedVars.ExportStringList("NeverAllowNoUseIncludeDir", neverallowNoUseIncludeDir) +} + +func BazelCcToolchainVars(config Config) string { + return BazelToolchainVars(config, exportedVars) } var ( diff --git a/android/neverallow.go b/android/neverallow.go index d28843995..293bac865 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -74,8 +74,8 @@ func createBp2BuildRule() Rule { "supported for custom conversion, use allowlists.go instead.") } -func createIncludeDirsRules() []Rule { - notInIncludeDir := []string{ +var ( + neverallowNotInIncludeDir = []string{ "art", "art/libnativebridge", "art/libnativeloader", @@ -91,7 +91,7 @@ func createIncludeDirsRules() []Rule { "external/vixl", "external/wycheproof", } - noUseIncludeDir := []string{ + neverallowNoUseIncludeDir = []string{ "frameworks/av/apex", "frameworks/av/tools", "frameworks/native/cmds", @@ -103,10 +103,12 @@ func createIncludeDirsRules() []Rule { "system/libfmq", "system/libvintf", } +) - rules := make([]Rule, 0, len(notInIncludeDir)+len(noUseIncludeDir)) +func createIncludeDirsRules() []Rule { + rules := make([]Rule, 0, len(neverallowNotInIncludeDir)+len(neverallowNoUseIncludeDir)) - for _, path := range notInIncludeDir { + for _, path := range neverallowNotInIncludeDir { rule := NeverAllow(). WithMatcher("include_dirs", StartsWith(path+"/")). @@ -116,7 +118,7 @@ func createIncludeDirsRules() []Rule { rules = append(rules, rule) } - for _, path := range noUseIncludeDir { + for _, path := range neverallowNoUseIncludeDir { 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.") diff --git a/bp2build/conversion.go b/bp2build/conversion.go index 8ca13b8af..6eb93bcd5 100644 --- a/bp2build/conversion.go +++ b/bp2build/conversion.go @@ -23,6 +23,9 @@ type BazelFile struct { func CreateSoongInjectionFiles(cfg android.Config, metrics CodegenMetrics) []BazelFile { var files []BazelFile + files = append(files, newFile("android", GeneratedBuildFileName, "")) // Creates a //cc_toolchain package. + files = append(files, newFile("android", "constants.bzl", android.BazelCcToolchainVars(cfg))) + files = append(files, newFile("cc_toolchain", GeneratedBuildFileName, "")) // Creates a //cc_toolchain package. files = append(files, newFile("cc_toolchain", "constants.bzl", cc_config.BazelCcToolchainVars(cfg))) diff --git a/bp2build/conversion_test.go b/bp2build/conversion_test.go index cfd612815..8de2f83c0 100644 --- a/bp2build/conversion_test.go +++ b/bp2build/conversion_test.go @@ -88,6 +88,14 @@ func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) { expectedFilePaths := []bazelFilepath{ { + dir: "android", + basename: GeneratedBuildFileName, + }, + { + dir: "android", + basename: "constants.bzl", + }, + { dir: "cc_toolchain", basename: GeneratedBuildFileName, }, |