Create a new product variable to gate blueprint files
Users can use this feature by
1. Setting PRODUCT_INCLUDE_TAGS += <val> in their product mk files
2. Set
```
blueprint_packge_includes {
match_al: ["<val>"],
}
other_module_type {name: foo}
other_module_type {name: bar}
```
bar and foo will be included if and only if <val> is set
Test: Unit tests in blueprint
Test: TH
Change-Id: I32eed4e3b5ac47fb565c62d13d8881fa984c86f4
diff --git a/android/config.go b/android/config.go
index 4a64b5b..9d9ab30 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1111,6 +1111,10 @@
return append([]string(nil), c.productVariables.NamespacesToExport...)
}
+func (c *config) IncludeTags() []string {
+ return c.productVariables.IncludeTags
+}
+
func (c *config) HostStaticBinaries() bool {
return Bool(c.productVariables.HostStaticBinaries)
}
diff --git a/android/register.go b/android/register.go
index 6c69cc5..6cfc205 100644
--- a/android/register.go
+++ b/android/register.go
@@ -161,6 +161,7 @@
func NewContext(config Config) *Context {
ctx := &Context{blueprint.NewContext(), config}
ctx.SetSrcDir(absSrcDir)
+ ctx.AddIncludeTags(config.IncludeTags()...)
return ctx
}
diff --git a/android/variable.go b/android/variable.go
index 28f22c9..9725895 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -452,6 +452,8 @@
GenerateAidlNdkPlatformBackend bool `json:",omitempty"`
IgnorePrefer32OnDevice bool `json:",omitempty"`
+
+ IncludeTags []string `json:",omitempty"`
}
func boolPtr(v bool) *bool {
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index e7323dd..f4a63a4 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -114,6 +114,7 @@
ctx := android.NewContext(configuration)
ctx.SetNameInterface(newNameResolver(configuration))
ctx.SetAllowMissingDependencies(configuration.AllowMissingDependencies())
+ ctx.AddIncludeTags(configuration.IncludeTags()...)
return ctx
}
diff --git a/ui/build/config.go b/ui/build/config.go
index 7651a0f..ef2e87e 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -111,6 +111,8 @@
metricsUploader string
bazelForceEnabledModules string
+
+ includeTags []string
}
const srcDirFileCheck = "build/soong/root.bp"
@@ -1079,6 +1081,14 @@
return c.parallel
}
+func (c *configImpl) GetIncludeTags() []string {
+ return c.includeTags
+}
+
+func (c *configImpl) SetIncludeTags(i []string) {
+ c.includeTags = i
+}
+
func (c *configImpl) HighmemParallel() int {
if i, ok := c.environ.GetInt("NINJA_HIGHMEM_NUM_JOBS"); ok {
return i
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index b3b3866..1e3e547 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -139,6 +139,7 @@
var BannerVars = []string{
"PLATFORM_VERSION_CODENAME",
"PLATFORM_VERSION",
+ "PRODUCT_INCLUDE_TAGS",
"TARGET_PRODUCT",
"TARGET_BUILD_VARIANT",
"TARGET_BUILD_APPS",
@@ -289,4 +290,5 @@
config.SetBuildBrokenDupRules(makeVars["BUILD_BROKEN_DUP_RULES"] == "true")
config.SetBuildBrokenUsesNetwork(makeVars["BUILD_BROKEN_USES_NETWORK"] == "true")
config.SetBuildBrokenNinjaUsesEnvVars(strings.Fields(makeVars["BUILD_BROKEN_NINJA_USES_ENV_VARS"]))
+ config.SetIncludeTags(strings.Fields(makeVars["PRODUCT_INCLUDE_TAGS"]))
}
diff --git a/ui/build/soong.go b/ui/build/soong.go
index de3179a..b89ca20 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -403,6 +403,7 @@
}
blueprintCtx := blueprint.NewContext()
+ blueprintCtx.AddIncludeTags(config.GetIncludeTags()...)
blueprintCtx.SetIgnoreUnknownModuleTypes(true)
blueprintConfig := BlueprintConfig{
soongOutDir: config.SoongOutDir(),