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:
Dan Willemsen
2015-06-10 16:20:14 -07:00
parent 2c342afa88
commit 57ad08c15d
2 changed files with 55 additions and 26 deletions

View File

@@ -113,6 +113,8 @@ func translateTargetConditionals(props []*bpparser.Property,
if mkProp, ok := standardProperties[targetScopedProp.Name.Name]; ok {
scopedProps = append(scopedProps, fmt.Sprintf("%s += %s",
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 {
if targetScopedProp.Value.BoolValue {
disabledBuilds[target.Name.Name] = true
@@ -139,6 +141,8 @@ func translateSuffixProperties(suffixProps []*bpparser.Property,
for _, stdProp := range suffixProp.Value.MapValue {
if mkProp, ok := standardProperties[stdProp.Name.Name]; ok {
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 {
computedProps = append(computedProps, fmt.Sprintf("# ERROR: unsupported property %s", stdProp.Name.Name))
}
@@ -148,6 +152,22 @@ func translateSuffixProperties(suffixProps []*bpparser.Property,
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) {
if parent.Variable != "" {
mapValue = w.mapScope[parent.Variable]
@@ -194,6 +214,8 @@ func (w *androidMkWriter) handleModule(module *bpparser.Module) {
for _, prop := range module.Properties {
if mkProp, ok := standardProperties[prop.Name.Name]; ok {
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 {
suffixProps := w.lookupMap(prop.Value)
standardProps = append(standardProps, translateSuffixProperties(suffixProps, suffixMap)...)

View File

@@ -23,32 +23,31 @@ var standardProperties = map[string]struct {
//"name": "LOCAL_PACKAGE_NAME", TODO
// ==== LIST PROPERTIES ====
"srcs": {"LOCAL_SRC_FILES", bpparser.List},
"shared_libs": {"LOCAL_SHARED_LIBRARIES", bpparser.List},
"static_libs": {"LOCAL_STATIC_LIBRARIES", bpparser.List},
"whole_static_libs": {"LOCAL_WHOLE_STATIC_LIBRARIES", bpparser.List},
"system_shared_libs": {"LOCAL_SYSTEM_SHARED_LIBRARIES", bpparser.List},
"include_dirs": {"LOCAL_C_INCLUDES", bpparser.List},
"export_include_dirs": {"LOCAL_EXPORT_C_INCLUDE_DIRS", bpparser.List},
"asflags": {"LOCAL_ASFLAGS", bpparser.List},
"clang_asflags": {"LOCAL_CLANG_ASFLAGS", bpparser.List},
"cflags": {"LOCAL_CFLAGS", bpparser.List},
"conlyflags": {"LOCAL_CONLYFLAGS", bpparser.List},
"cppflags": {"LOCAL_CPPFLAGS", bpparser.List},
"ldflags": {"LOCAL_LDFLAGS", bpparser.List},
"required": {"LOCAL_REQUIRED_MODULES", bpparser.List},
"tags": {"LOCAL_MODULE_TAGS", bpparser.List},
"host_ldlibs": {"LOCAL_LDLIBS", bpparser.List},
"clang_cflags": {"LOCAL_CLANG_CFLAGS", bpparser.List},
"yaccflags": {"LOCAL_YACCFLAGS", bpparser.List},
"java_resource_dirs": {"LOCAL_JAVA_RESOURCE_DIRS", bpparser.List},
"javacflags": {"LOCAL_JAVACFLAGS", bpparser.List},
"dxflags": {"LOCAL_DX_FLAGS", bpparser.List},
"java_libs": {"LOCAL_JAVA_LIBRARIES", bpparser.List},
"java_static_libs": {"LOCAL_STATIC_JAVA_LIBRARIES", bpparser.List},
"aidl_includes": {"LOCAL_AIDL_INCLUDES", bpparser.List},
"aaptflags": {"LOCAL_AAPT_FLAGS", bpparser.List},
"package_splits": {"LOCAL_PACKAGE_SPLITS", bpparser.List},
"srcs": {"LOCAL_SRC_FILES", bpparser.List},
"shared_libs": {"LOCAL_SHARED_LIBRARIES", bpparser.List},
"static_libs": {"LOCAL_STATIC_LIBRARIES", bpparser.List},
"whole_static_libs": {"LOCAL_WHOLE_STATIC_LIBRARIES", bpparser.List},
"system_shared_libs": {"LOCAL_SYSTEM_SHARED_LIBRARIES", bpparser.List},
"include_dirs": {"LOCAL_C_INCLUDES", bpparser.List},
"asflags": {"LOCAL_ASFLAGS", bpparser.List},
"clang_asflags": {"LOCAL_CLANG_ASFLAGS", bpparser.List},
"cflags": {"LOCAL_CFLAGS", bpparser.List},
"conlyflags": {"LOCAL_CONLYFLAGS", bpparser.List},
"cppflags": {"LOCAL_CPPFLAGS", bpparser.List},
"ldflags": {"LOCAL_LDFLAGS", bpparser.List},
"required": {"LOCAL_REQUIRED_MODULES", bpparser.List},
"tags": {"LOCAL_MODULE_TAGS", bpparser.List},
"host_ldlibs": {"LOCAL_LDLIBS", bpparser.List},
"clang_cflags": {"LOCAL_CLANG_CFLAGS", bpparser.List},
"yaccflags": {"LOCAL_YACCFLAGS", bpparser.List},
"java_resource_dirs": {"LOCAL_JAVA_RESOURCE_DIRS", bpparser.List},
"javacflags": {"LOCAL_JAVACFLAGS", bpparser.List},
"dxflags": {"LOCAL_DX_FLAGS", bpparser.List},
"java_libs": {"LOCAL_JAVA_LIBRARIES", bpparser.List},
"java_static_libs": {"LOCAL_STATIC_JAVA_LIBRARIES", bpparser.List},
"aidl_includes": {"LOCAL_AIDL_INCLUDES", bpparser.List},
"aaptflags": {"LOCAL_AAPT_FLAGS", bpparser.List},
"package_splits": {"LOCAL_PACKAGE_SPLITS", bpparser.List},
// ==== BOOL PROPERTIES ====
"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},
}
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{
"cc_library_shared": "BUILD_SHARED_LIBRARY",
"cc_library_static": "BUILD_STATIC_LIBRARY",