support PRODUCT_SOURCE_ROOT_DIRS product variable
Soong analyzes the entire source tree even though not every lunch target needs to know about every module. For example, OEM sources can be ignored for cuttlefish products. This functionality allows blueprint to ignore a list of undesired directories. Bug: 269457150 Change-Id: I1eec5d7b6a268cae4c633d8d89ed485598ebca45
This commit is contained in:
@@ -1179,6 +1179,10 @@ func (c *config) ExportedNamespaces() []string {
|
||||
return append([]string(nil), c.productVariables.NamespacesToExport...)
|
||||
}
|
||||
|
||||
func (c *config) SourceRootDirs() []string {
|
||||
return c.productVariables.SourceRootDirs
|
||||
}
|
||||
|
||||
func (c *config) IncludeTags() []string {
|
||||
return c.productVariables.IncludeTags
|
||||
}
|
||||
|
@@ -225,6 +225,10 @@ func (r *NameResolver) NewModule(ctx blueprint.NamespaceContext, moduleGroup blu
|
||||
return ns, nil
|
||||
}
|
||||
|
||||
func (r *NameResolver) NewSkippedModule(ctx blueprint.NamespaceContext, name string, skipInfo blueprint.SkippedModuleInfo) {
|
||||
r.rootNamespace.moduleContainer.NewSkippedModule(ctx, name, skipInfo)
|
||||
}
|
||||
|
||||
func (r *NameResolver) AllModules() []blueprint.ModuleGroup {
|
||||
childLists := [][]blueprint.ModuleGroup{}
|
||||
totalCount := 0
|
||||
@@ -300,7 +304,7 @@ func (r *NameResolver) FindNamespaceImports(namespace *Namespace) (err error) {
|
||||
for _, name := range namespace.importedNamespaceNames {
|
||||
imp, ok := r.namespaceAt(name)
|
||||
if !ok {
|
||||
return fmt.Errorf("namespace %v does not exist", name)
|
||||
return fmt.Errorf("namespace %v does not exist; Some necessary modules may have been skipped by Soong. Check if PRODUCT_SOURCE_ROOT_DIRS is pruning necessary Android.bp files.", name)
|
||||
}
|
||||
namespace.visibleNamespaces = append(namespace.visibleNamespaces, imp)
|
||||
}
|
||||
|
@@ -162,6 +162,7 @@ func NewContext(config Config) *Context {
|
||||
ctx := &Context{blueprint.NewContext(), config}
|
||||
ctx.SetSrcDir(absSrcDir)
|
||||
ctx.AddIncludeTags(config.IncludeTags()...)
|
||||
ctx.AddSourceRootDirs(config.SourceRootDirs()...)
|
||||
return ctx
|
||||
}
|
||||
|
||||
|
@@ -461,7 +461,8 @@ type productVariables struct {
|
||||
|
||||
IgnorePrefer32OnDevice bool `json:",omitempty"`
|
||||
|
||||
IncludeTags []string `json:",omitempty"`
|
||||
IncludeTags []string `json:",omitempty"`
|
||||
SourceRootDirs []string `json:",omitempty"`
|
||||
}
|
||||
|
||||
func boolPtr(v bool) *bool {
|
||||
|
@@ -104,6 +104,7 @@ func newContext(configuration android.Config) *android.Context {
|
||||
ctx.SetNameInterface(newNameResolver(configuration))
|
||||
ctx.SetAllowMissingDependencies(configuration.AllowMissingDependencies())
|
||||
ctx.AddIncludeTags(configuration.IncludeTags()...)
|
||||
ctx.AddSourceRootDirs(configuration.SourceRootDirs()...)
|
||||
return ctx
|
||||
}
|
||||
|
||||
|
@@ -117,7 +117,8 @@ type configImpl struct {
|
||||
|
||||
bazelForceEnabledModules string
|
||||
|
||||
includeTags []string
|
||||
includeTags []string
|
||||
sourceRootDirs []string
|
||||
|
||||
// Data source to write ninja weight list
|
||||
ninjaWeightListSource NinjaWeightListSource
|
||||
@@ -1185,6 +1186,14 @@ func (c *configImpl) Parallel() int {
|
||||
return c.parallel
|
||||
}
|
||||
|
||||
func (c *configImpl) GetSourceRootDirs() []string {
|
||||
return c.sourceRootDirs
|
||||
}
|
||||
|
||||
func (c *configImpl) SetSourceRootDirs(i []string) {
|
||||
c.sourceRootDirs = i
|
||||
}
|
||||
|
||||
func (c *configImpl) GetIncludeTags() []string {
|
||||
return c.includeTags
|
||||
}
|
||||
|
@@ -148,6 +148,7 @@ var BannerVars = []string{
|
||||
"PLATFORM_VERSION_CODENAME",
|
||||
"PLATFORM_VERSION",
|
||||
"PRODUCT_INCLUDE_TAGS",
|
||||
"PRODUCT_SOURCE_ROOT_DIRS",
|
||||
"TARGET_PRODUCT",
|
||||
"TARGET_BUILD_VARIANT",
|
||||
"TARGET_BUILD_APPS",
|
||||
@@ -299,4 +300,5 @@ func runMakeProductConfig(ctx Context, config Config) {
|
||||
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"]))
|
||||
config.SetSourceRootDirs(strings.Fields(makeVars["PRODUCT_SOURCE_ROOT_DIRS"]))
|
||||
}
|
||||
|
@@ -410,6 +410,7 @@ func bootstrapBlueprint(ctx Context, config Config) {
|
||||
|
||||
blueprintCtx := blueprint.NewContext()
|
||||
blueprintCtx.AddIncludeTags(config.GetIncludeTags()...)
|
||||
blueprintCtx.AddSourceRootDirs(config.GetSourceRootDirs()...)
|
||||
blueprintCtx.SetIgnoreUnknownModuleTypes(true)
|
||||
blueprintConfig := BlueprintConfig{
|
||||
soongOutDir: config.SoongOutDir(),
|
||||
|
Reference in New Issue
Block a user