Merge "export neverallow include dir list to Bazel" am: 775f2cb3cd
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2302771 Change-Id: I37de03d396e32015aece499219e8ef3e33056ea9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -25,7 +25,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pctx = NewPackageContext("android/soong/android")
|
pctx = NewPackageContext("android/soong/android")
|
||||||
|
exportedVars = NewExportedVariables(pctx)
|
||||||
|
|
||||||
cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks",
|
cpPreserveSymlinks = pctx.VariableConfigMethod("cpPreserveSymlinks",
|
||||||
Config.CpPreserveSymlinksFlags)
|
Config.CpPreserveSymlinksFlags)
|
||||||
@@ -128,6 +129,13 @@ func init() {
|
|||||||
pctx.VariableFunc("RBEWrapper", func(ctx PackageVarContext) string {
|
pctx.VariableFunc("RBEWrapper", func(ctx PackageVarContext) string {
|
||||||
return ctx.Config().RBEWrapper()
|
return ctx.Config().RBEWrapper()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
exportedVars.ExportStringList("NeverAllowNotInIncludeDir", neverallowNotInIncludeDir)
|
||||||
|
exportedVars.ExportStringList("NeverAllowNoUseIncludeDir", neverallowNoUseIncludeDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
func BazelCcToolchainVars(config Config) string {
|
||||||
|
return BazelToolchainVars(config, exportedVars)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@@ -74,8 +74,8 @@ func createBp2BuildRule() Rule {
|
|||||||
"supported for custom conversion, use allowlists.go instead.")
|
"supported for custom conversion, use allowlists.go instead.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func createIncludeDirsRules() []Rule {
|
var (
|
||||||
notInIncludeDir := []string{
|
neverallowNotInIncludeDir = []string{
|
||||||
"art",
|
"art",
|
||||||
"art/libnativebridge",
|
"art/libnativebridge",
|
||||||
"art/libnativeloader",
|
"art/libnativeloader",
|
||||||
@@ -91,7 +91,7 @@ func createIncludeDirsRules() []Rule {
|
|||||||
"external/vixl",
|
"external/vixl",
|
||||||
"external/wycheproof",
|
"external/wycheproof",
|
||||||
}
|
}
|
||||||
noUseIncludeDir := []string{
|
neverallowNoUseIncludeDir = []string{
|
||||||
"frameworks/av/apex",
|
"frameworks/av/apex",
|
||||||
"frameworks/av/tools",
|
"frameworks/av/tools",
|
||||||
"frameworks/native/cmds",
|
"frameworks/native/cmds",
|
||||||
@@ -103,10 +103,12 @@ func createIncludeDirsRules() []Rule {
|
|||||||
"system/libfmq",
|
"system/libfmq",
|
||||||
"system/libvintf",
|
"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 :=
|
rule :=
|
||||||
NeverAllow().
|
NeverAllow().
|
||||||
WithMatcher("include_dirs", StartsWith(path+"/")).
|
WithMatcher("include_dirs", StartsWith(path+"/")).
|
||||||
@@ -116,7 +118,7 @@ func createIncludeDirsRules() []Rule {
|
|||||||
rules = append(rules, rule)
|
rules = append(rules, rule)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range noUseIncludeDir {
|
for _, path := range neverallowNoUseIncludeDir {
|
||||||
rule := NeverAllow().In(path+"/").WithMatcher("include_dirs", isSetMatcherInstance).
|
rule := NeverAllow().In(path+"/").WithMatcher("include_dirs", isSetMatcherInstance).
|
||||||
Because("include_dirs is deprecated, all usages of them in '" + path + "' have been migrated" +
|
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.")
|
" to use alternate mechanisms and so can no longer be used.")
|
||||||
|
@@ -23,6 +23,9 @@ type BazelFile struct {
|
|||||||
func CreateSoongInjectionFiles(cfg android.Config, metrics CodegenMetrics) []BazelFile {
|
func CreateSoongInjectionFiles(cfg android.Config, metrics CodegenMetrics) []BazelFile {
|
||||||
var files []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", GeneratedBuildFileName, "")) // Creates a //cc_toolchain package.
|
||||||
files = append(files, newFile("cc_toolchain", "constants.bzl", cc_config.BazelCcToolchainVars(cfg)))
|
files = append(files, newFile("cc_toolchain", "constants.bzl", cc_config.BazelCcToolchainVars(cfg)))
|
||||||
|
|
||||||
|
@@ -87,6 +87,14 @@ func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) {
|
|||||||
files := CreateSoongInjectionFiles(testConfig, CreateCodegenMetrics())
|
files := CreateSoongInjectionFiles(testConfig, CreateCodegenMetrics())
|
||||||
|
|
||||||
expectedFilePaths := []bazelFilepath{
|
expectedFilePaths := []bazelFilepath{
|
||||||
|
{
|
||||||
|
dir: "android",
|
||||||
|
basename: GeneratedBuildFileName,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dir: "android",
|
||||||
|
basename: "constants.bzl",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
dir: "cc_toolchain",
|
dir: "cc_toolchain",
|
||||||
basename: GeneratedBuildFileName,
|
basename: GeneratedBuildFileName,
|
||||||
|
Reference in New Issue
Block a user