androidbp: Handle local_include_dirs and fix export_include_dirs
The androidmk->androidbp translation strips $(LOCAL_PATH), add it back in the reverse path. Change-Id: I64ff213511c7dd6da0259746ea97677140ee5bf5
This commit is contained in:
@@ -113,6 +113,8 @@ func translateTargetConditionals(props []*bpparser.Property,
|
|||||||
if mkProp, ok := standardProperties[targetScopedProp.Name.Name]; ok {
|
if mkProp, ok := standardProperties[targetScopedProp.Name.Name]; ok {
|
||||||
scopedProps = append(scopedProps, fmt.Sprintf("%s += %s",
|
scopedProps = append(scopedProps, fmt.Sprintf("%s += %s",
|
||||||
mkProp.string, valueToString(targetScopedProp.Value)))
|
mkProp.string, valueToString(targetScopedProp.Value)))
|
||||||
|
} else if rwProp, ok := rewriteProperties[targetScopedProp.Name.Name]; ok {
|
||||||
|
scopedProps = append(scopedProps, rwProp.f(rwProp.string, targetScopedProp, nil)...)
|
||||||
} else if "disabled" == targetScopedProp.Name.Name {
|
} else if "disabled" == targetScopedProp.Name.Name {
|
||||||
if targetScopedProp.Value.BoolValue {
|
if targetScopedProp.Value.BoolValue {
|
||||||
disabledBuilds[target.Name.Name] = true
|
disabledBuilds[target.Name.Name] = true
|
||||||
@@ -139,6 +141,8 @@ func translateSuffixProperties(suffixProps []*bpparser.Property,
|
|||||||
for _, stdProp := range suffixProp.Value.MapValue {
|
for _, stdProp := range suffixProp.Value.MapValue {
|
||||||
if mkProp, ok := standardProperties[stdProp.Name.Name]; ok {
|
if mkProp, ok := standardProperties[stdProp.Name.Name]; ok {
|
||||||
computedProps = append(computedProps, fmt.Sprintf("%s_%s := %s", mkProp.string, suffix, valueToString(stdProp.Value)))
|
computedProps = append(computedProps, fmt.Sprintf("%s_%s := %s", mkProp.string, suffix, valueToString(stdProp.Value)))
|
||||||
|
} else if rwProp, ok := rewriteProperties[stdProp.Name.Name]; ok {
|
||||||
|
computedProps = append(computedProps, rwProp.f(rwProp.string, stdProp, &suffix)...)
|
||||||
} else {
|
} else {
|
||||||
computedProps = append(computedProps, fmt.Sprintf("# ERROR: unsupported property %s", stdProp.Name.Name))
|
computedProps = append(computedProps, fmt.Sprintf("# ERROR: unsupported property %s", stdProp.Name.Name))
|
||||||
}
|
}
|
||||||
@@ -148,6 +152,22 @@ func translateSuffixProperties(suffixProps []*bpparser.Property,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func prependLocalPath(name string, prop *bpparser.Property, suffix *string) (computedProps []string) {
|
||||||
|
includes := make([]string, 0, len(prop.Value.ListValue))
|
||||||
|
for _, tok := range prop.Value.ListValue {
|
||||||
|
if tok.Type == bpparser.String {
|
||||||
|
includes = append(includes, fmt.Sprintf(" $(LOCAL_PATH)/%s", tok.StringValue))
|
||||||
|
} else {
|
||||||
|
includes = append(includes, fmt.Sprintf("# ERROR: unsupported type %s in list",
|
||||||
|
tok.Type.String()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if suffix != nil {
|
||||||
|
name += "_" + *suffix
|
||||||
|
}
|
||||||
|
return append(computedProps, fmt.Sprintf("%s := \\\n%s\n", name, strings.Join(includes, " \\\n")))
|
||||||
|
}
|
||||||
|
|
||||||
func (w *androidMkWriter) lookupMap(parent bpparser.Value) (mapValue []*bpparser.Property) {
|
func (w *androidMkWriter) lookupMap(parent bpparser.Value) (mapValue []*bpparser.Property) {
|
||||||
if parent.Variable != "" {
|
if parent.Variable != "" {
|
||||||
mapValue = w.mapScope[parent.Variable]
|
mapValue = w.mapScope[parent.Variable]
|
||||||
@@ -194,6 +214,8 @@ func (w *androidMkWriter) handleModule(module *bpparser.Module) {
|
|||||||
for _, prop := range module.Properties {
|
for _, prop := range module.Properties {
|
||||||
if mkProp, ok := standardProperties[prop.Name.Name]; ok {
|
if mkProp, ok := standardProperties[prop.Name.Name]; ok {
|
||||||
standardProps = append(standardProps, fmt.Sprintf("%s := %s", mkProp.string, valueToString(prop.Value)))
|
standardProps = append(standardProps, fmt.Sprintf("%s := %s", mkProp.string, valueToString(prop.Value)))
|
||||||
|
} else if rwProp, ok := rewriteProperties[prop.Name.Name]; ok {
|
||||||
|
standardProps = append(standardProps, rwProp.f(rwProp.string, prop, nil)...)
|
||||||
} else if suffixMap, ok := suffixProperties[prop.Name.Name]; ok {
|
} else if suffixMap, ok := suffixProperties[prop.Name.Name]; ok {
|
||||||
suffixProps := w.lookupMap(prop.Value)
|
suffixProps := w.lookupMap(prop.Value)
|
||||||
standardProps = append(standardProps, translateSuffixProperties(suffixProps, suffixMap)...)
|
standardProps = append(standardProps, translateSuffixProperties(suffixProps, suffixMap)...)
|
||||||
|
@@ -23,32 +23,31 @@ var standardProperties = map[string]struct {
|
|||||||
//"name": "LOCAL_PACKAGE_NAME", TODO
|
//"name": "LOCAL_PACKAGE_NAME", TODO
|
||||||
|
|
||||||
// ==== LIST PROPERTIES ====
|
// ==== LIST PROPERTIES ====
|
||||||
"srcs": {"LOCAL_SRC_FILES", bpparser.List},
|
"srcs": {"LOCAL_SRC_FILES", bpparser.List},
|
||||||
"shared_libs": {"LOCAL_SHARED_LIBRARIES", bpparser.List},
|
"shared_libs": {"LOCAL_SHARED_LIBRARIES", bpparser.List},
|
||||||
"static_libs": {"LOCAL_STATIC_LIBRARIES", bpparser.List},
|
"static_libs": {"LOCAL_STATIC_LIBRARIES", bpparser.List},
|
||||||
"whole_static_libs": {"LOCAL_WHOLE_STATIC_LIBRARIES", bpparser.List},
|
"whole_static_libs": {"LOCAL_WHOLE_STATIC_LIBRARIES", bpparser.List},
|
||||||
"system_shared_libs": {"LOCAL_SYSTEM_SHARED_LIBRARIES", bpparser.List},
|
"system_shared_libs": {"LOCAL_SYSTEM_SHARED_LIBRARIES", bpparser.List},
|
||||||
"include_dirs": {"LOCAL_C_INCLUDES", bpparser.List},
|
"include_dirs": {"LOCAL_C_INCLUDES", bpparser.List},
|
||||||
"export_include_dirs": {"LOCAL_EXPORT_C_INCLUDE_DIRS", bpparser.List},
|
"asflags": {"LOCAL_ASFLAGS", bpparser.List},
|
||||||
"asflags": {"LOCAL_ASFLAGS", bpparser.List},
|
"clang_asflags": {"LOCAL_CLANG_ASFLAGS", bpparser.List},
|
||||||
"clang_asflags": {"LOCAL_CLANG_ASFLAGS", bpparser.List},
|
"cflags": {"LOCAL_CFLAGS", bpparser.List},
|
||||||
"cflags": {"LOCAL_CFLAGS", bpparser.List},
|
"conlyflags": {"LOCAL_CONLYFLAGS", bpparser.List},
|
||||||
"conlyflags": {"LOCAL_CONLYFLAGS", bpparser.List},
|
"cppflags": {"LOCAL_CPPFLAGS", bpparser.List},
|
||||||
"cppflags": {"LOCAL_CPPFLAGS", bpparser.List},
|
"ldflags": {"LOCAL_LDFLAGS", bpparser.List},
|
||||||
"ldflags": {"LOCAL_LDFLAGS", bpparser.List},
|
"required": {"LOCAL_REQUIRED_MODULES", bpparser.List},
|
||||||
"required": {"LOCAL_REQUIRED_MODULES", bpparser.List},
|
"tags": {"LOCAL_MODULE_TAGS", bpparser.List},
|
||||||
"tags": {"LOCAL_MODULE_TAGS", bpparser.List},
|
"host_ldlibs": {"LOCAL_LDLIBS", bpparser.List},
|
||||||
"host_ldlibs": {"LOCAL_LDLIBS", bpparser.List},
|
"clang_cflags": {"LOCAL_CLANG_CFLAGS", bpparser.List},
|
||||||
"clang_cflags": {"LOCAL_CLANG_CFLAGS", bpparser.List},
|
"yaccflags": {"LOCAL_YACCFLAGS", bpparser.List},
|
||||||
"yaccflags": {"LOCAL_YACCFLAGS", bpparser.List},
|
"java_resource_dirs": {"LOCAL_JAVA_RESOURCE_DIRS", bpparser.List},
|
||||||
"java_resource_dirs": {"LOCAL_JAVA_RESOURCE_DIRS", bpparser.List},
|
"javacflags": {"LOCAL_JAVACFLAGS", bpparser.List},
|
||||||
"javacflags": {"LOCAL_JAVACFLAGS", bpparser.List},
|
"dxflags": {"LOCAL_DX_FLAGS", bpparser.List},
|
||||||
"dxflags": {"LOCAL_DX_FLAGS", bpparser.List},
|
"java_libs": {"LOCAL_JAVA_LIBRARIES", bpparser.List},
|
||||||
"java_libs": {"LOCAL_JAVA_LIBRARIES", bpparser.List},
|
"java_static_libs": {"LOCAL_STATIC_JAVA_LIBRARIES", bpparser.List},
|
||||||
"java_static_libs": {"LOCAL_STATIC_JAVA_LIBRARIES", bpparser.List},
|
"aidl_includes": {"LOCAL_AIDL_INCLUDES", bpparser.List},
|
||||||
"aidl_includes": {"LOCAL_AIDL_INCLUDES", bpparser.List},
|
"aaptflags": {"LOCAL_AAPT_FLAGS", bpparser.List},
|
||||||
"aaptflags": {"LOCAL_AAPT_FLAGS", bpparser.List},
|
"package_splits": {"LOCAL_PACKAGE_SPLITS", bpparser.List},
|
||||||
"package_splits": {"LOCAL_PACKAGE_SPLITS", bpparser.List},
|
|
||||||
|
|
||||||
// ==== BOOL PROPERTIES ====
|
// ==== BOOL PROPERTIES ====
|
||||||
"host": {"LOCAL_IS_HOST_MODULE", bpparser.Bool},
|
"host": {"LOCAL_IS_HOST_MODULE", bpparser.Bool},
|
||||||
@@ -63,6 +62,14 @@ var standardProperties = map[string]struct {
|
|||||||
"export_package_resources": {"LOCAL_EXPORT_PACKAGE_RESOURCES", bpparser.Bool},
|
"export_package_resources": {"LOCAL_EXPORT_PACKAGE_RESOURCES", bpparser.Bool},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var rewriteProperties = map[string]struct {
|
||||||
|
string
|
||||||
|
f func(name string, prop *bpparser.Property, suffix *string) (computedProps []string)
|
||||||
|
}{
|
||||||
|
"local_include_dirs": {"LOCAL_C_INCLUDES", prependLocalPath},
|
||||||
|
"export_include_dirs": {"LOCAL_EXPORT_C_INCLUDE_DIRS", prependLocalPath},
|
||||||
|
}
|
||||||
|
|
||||||
var moduleTypeToRule = map[string]string{
|
var moduleTypeToRule = map[string]string{
|
||||||
"cc_library_shared": "BUILD_SHARED_LIBRARY",
|
"cc_library_shared": "BUILD_SHARED_LIBRARY",
|
||||||
"cc_library_static": "BUILD_STATIC_LIBRARY",
|
"cc_library_static": "BUILD_STATIC_LIBRARY",
|
||||||
|
Reference in New Issue
Block a user