Make select statements work on path properties

Fixes: 329711542
Test: go test
Change-Id: I71f489c26c535174e226e4a9ab449cc2b4bee83a
This commit is contained in:
Cole Faust
2024-03-14 14:33:02 -07:00
parent ed9005b556
commit bdd8aeeb58
4 changed files with 84 additions and 39 deletions

View File

@@ -21,7 +21,6 @@ import (
"strings"
"github.com/google/blueprint"
"github.com/google/blueprint/parser"
"github.com/google/blueprint/proptools"
)
@@ -213,10 +212,6 @@ type ModuleContext interface {
// GenerateAndroidBuildActions. If it is called then the struct will be written out and included in
// the module-info.json generated by Make, and Make will not generate its own data for this module.
ModuleInfoJSON() *ModuleInfoJSON
// EvaluateConfiguration makes ModuleContext a valid proptools.ConfigurableEvaluator, so this context
// can be used to evaluate the final value of Configurable properties.
EvaluateConfiguration(parser.SelectType, string) (string, bool)
}
type moduleContext struct {
@@ -719,32 +714,3 @@ func (m *moduleContext) HostRequiredModuleNames() []string {
func (m *moduleContext) TargetRequiredModuleNames() []string {
return m.module.TargetRequiredModuleNames()
}
func (m *moduleContext) EvaluateConfiguration(ty parser.SelectType, condition string) (string, bool) {
switch ty {
case parser.SelectTypeReleaseVariable:
if v, ok := m.Config().productVariables.BuildFlags[condition]; ok {
return v, true
}
return "", false
case parser.SelectTypeProductVariable:
// TODO: Might add these on a case-by-case basis
m.ModuleErrorf("TODO(b/323382414): Product variables are not yet supported in selects")
return "", false
case parser.SelectTypeSoongConfigVariable:
parts := strings.Split(condition, ":")
namespace := parts[0]
variable := parts[1]
if n, ok := m.Config().productVariables.VendorVars[namespace]; ok {
if v, ok := n[variable]; ok {
return v, true
}
}
return "", false
case parser.SelectTypeVariant:
m.ModuleErrorf("TODO(b/323382414): Variants are not yet supported in selects")
return "", false
default:
panic("Should be unreachable")
}
}