androidbp: Improve target conditionals when host_supported
Properties need to be parsed twice to support different conditionals for target and host modules. Then add 'android' target support that will just be selected for target modules. Change-Id: I8970d5a0d132324ac7e2a7fffc2b07e7c0da33c0
This commit is contained in:
@@ -96,16 +96,22 @@ func translateTargetConditionals(props []*bpparser.Property,
|
|||||||
disabledBuilds map[string]bool, isHostRule bool) (computedProps []string) {
|
disabledBuilds map[string]bool, isHostRule bool) (computedProps []string) {
|
||||||
for _, target := range props {
|
for _, target := range props {
|
||||||
conditionals := targetScopedPropertyConditionals
|
conditionals := targetScopedPropertyConditionals
|
||||||
|
altConditionals := hostScopedPropertyConditionals
|
||||||
if isHostRule {
|
if isHostRule {
|
||||||
conditionals = hostScopedPropertyConditionals
|
conditionals, altConditionals = altConditionals, conditionals
|
||||||
}
|
}
|
||||||
|
|
||||||
conditional, ok := conditionals[target.Name.Name]
|
conditional, ok := conditionals[target.Name.Name]
|
||||||
if !ok {
|
if !ok {
|
||||||
// not found
|
if _, ok := altConditionals[target.Name.Name]; ok {
|
||||||
conditional = fmt.Sprintf(
|
// This is only for the other build type
|
||||||
"ifeq(true, true) # ERROR: unsupported conditional host [%s]",
|
continue
|
||||||
target.Name.Name)
|
} else {
|
||||||
|
// not found
|
||||||
|
conditional = fmt.Sprintf(
|
||||||
|
"ifeq(true, true) # ERROR: unsupported conditional [%s]",
|
||||||
|
target.Name.Name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var scopedProps []string
|
var scopedProps []string
|
||||||
@@ -125,9 +131,13 @@ func translateTargetConditionals(props []*bpparser.Property,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(scopedProps) > 0 {
|
if len(scopedProps) > 0 {
|
||||||
computedProps = append(computedProps, conditional)
|
if conditional != "" {
|
||||||
computedProps = append(computedProps, scopedProps...)
|
computedProps = append(computedProps, conditional)
|
||||||
computedProps = append(computedProps, "endif")
|
computedProps = append(computedProps, scopedProps...)
|
||||||
|
computedProps = append(computedProps, "endif")
|
||||||
|
} else {
|
||||||
|
computedProps = append(computedProps, scopedProps...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,14 +211,7 @@ func (w *androidMkWriter) writeModule(moduleRule string, props []string,
|
|||||||
fmt.Fprintf(w, "include $(%s)\n\n", moduleRule)
|
fmt.Fprintf(w, "include $(%s)\n\n", moduleRule)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *androidMkWriter) handleModule(module *bpparser.Module) {
|
func (w *androidMkWriter) parsePropsAndWriteModule(moduleRule string, isHostRule bool, module *bpparser.Module) (hostSupported bool) {
|
||||||
moduleRule := fmt.Sprintf(module.Type.Name)
|
|
||||||
if translation, ok := moduleTypeToRule[module.Type.Name]; ok {
|
|
||||||
moduleRule = translation
|
|
||||||
}
|
|
||||||
|
|
||||||
isHostRule := strings.Contains(moduleRule, "HOST")
|
|
||||||
hostSupported := false
|
|
||||||
standardProps := make([]string, 0, len(module.Properties))
|
standardProps := make([]string, 0, len(module.Properties))
|
||||||
disabledBuilds := make(map[string]bool)
|
disabledBuilds := make(map[string]bool)
|
||||||
for _, prop := range module.Properties {
|
for _, prop := range module.Properties {
|
||||||
@@ -231,13 +234,25 @@ func (w *androidMkWriter) handleModule(module *bpparser.Module) {
|
|||||||
|
|
||||||
// write out target build
|
// write out target build
|
||||||
w.writeModule(moduleRule, standardProps, disabledBuilds, isHostRule)
|
w.writeModule(moduleRule, standardProps, disabledBuilds, isHostRule)
|
||||||
if hostSupported {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *androidMkWriter) handleModule(module *bpparser.Module) {
|
||||||
|
moduleRule := fmt.Sprintf(module.Type.Name)
|
||||||
|
if translation, ok := moduleTypeToRule[module.Type.Name]; ok {
|
||||||
|
moduleRule = translation
|
||||||
|
}
|
||||||
|
|
||||||
|
isHostRule := strings.Contains(moduleRule, "HOST")
|
||||||
|
hostSupported := w.parsePropsAndWriteModule(moduleRule, isHostRule, module)
|
||||||
|
|
||||||
|
if !isHostRule && hostSupported {
|
||||||
hostModuleRule := "NO CORRESPONDING HOST RULE" + moduleRule
|
hostModuleRule := "NO CORRESPONDING HOST RULE" + moduleRule
|
||||||
if trans, ok := targetToHostModuleRule[moduleRule]; ok {
|
if trans, ok := targetToHostModuleRule[moduleRule]; ok {
|
||||||
hostModuleRule = trans
|
hostModuleRule = trans
|
||||||
}
|
}
|
||||||
w.writeModule(hostModuleRule, standardProps,
|
|
||||||
disabledBuilds, true)
|
w.parsePropsAndWriteModule(hostModuleRule, true, module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -106,6 +106,7 @@ var hostScopedPropertyConditionals = map[string]string{
|
|||||||
|
|
||||||
// TODO: host target?
|
// TODO: host target?
|
||||||
var targetScopedPropertyConditionals = map[string]string{
|
var targetScopedPropertyConditionals = map[string]string{
|
||||||
|
"android": "",
|
||||||
"android32": "ifneq($(TARGET_IS_64_BIT), true)",
|
"android32": "ifneq($(TARGET_IS_64_BIT), true)",
|
||||||
"not_android32": "ifeq($(TARGET_IS_64_BIT), true)",
|
"not_android32": "ifeq($(TARGET_IS_64_BIT), true)",
|
||||||
"android64": "ifeq($(TARGET_IS_64_BIT), true)",
|
"android64": "ifeq($(TARGET_IS_64_BIT), true)",
|
||||||
|
Reference in New Issue
Block a user