aboutsummaryrefslogtreecommitdiffstats
path: root/androidmk/cmd
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2016-06-03 13:54:46 -0700
committerDan Willemsen <dwillemsen@google.com>2016-06-03 13:56:55 -0700
commit58f9bb1160074f06e2cea66f78dfdf4d42834c59 (patch)
treeed9e77a6a4a1218c56f5346a301f3606aff0292c /androidmk/cmd
parent0c236aba6e8b45ac0fde3c7db627f366e3caeaee (diff)
downloadbuild_soong-58f9bb1160074f06e2cea66f78dfdf4d42834c59.tar.gz
build_soong-58f9bb1160074f06e2cea66f78dfdf4d42834c59.tar.bz2
build_soong-58f9bb1160074f06e2cea66f78dfdf4d42834c59.zip
androidmk: Support version_script
This only translates the common case using $(LOCAL_PATH). If it doesn't match here, Soong will throw an error with a suggested fix. Change-Id: If64c8fca008a1a414fc12389e6b1bb40af0df899
Diffstat (limited to 'androidmk/cmd')
-rw-r--r--androidmk/cmd/androidmk/android.go52
-rw-r--r--androidmk/cmd/androidmk/test.go14
2 files changed, 65 insertions, 1 deletions
diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go
index eb89f19f..d4802744 100644
--- a/androidmk/cmd/androidmk/android.go
+++ b/androidmk/cmd/androidmk/android.go
@@ -42,7 +42,6 @@ var standardProperties = map[string]struct {
"LOCAL_CFLAGS": {"cflags", bpparser.List},
"LOCAL_CONLYFLAGS": {"conlyflags", bpparser.List},
"LOCAL_CPPFLAGS": {"cppflags", bpparser.List},
- "LOCAL_LDFLAGS": {"ldflags", bpparser.List},
"LOCAL_REQUIRED_MODULES": {"required", bpparser.List},
"LOCAL_MODULE_TAGS": {"tags", bpparser.List},
"LOCAL_LDLIBS": {"host_ldlibs", bpparser.List},
@@ -83,6 +82,7 @@ var rewriteProperties = map[string]struct {
"LOCAL_MODULE_HOST_OS": {hostOs},
"LOCAL_SRC_FILES": {srcFiles},
"LOCAL_SANITIZE": {sanitize},
+ "LOCAL_LDFLAGS": {ldflags},
}
type listSplitFunc func(bpparser.Value) (string, *bpparser.Value, error)
@@ -422,6 +422,56 @@ func sanitize(file *bpFile, prefix string, mkvalue *mkparser.MakeString, appendV
return err
}
+func ldflags(file *bpFile, prefix string, mkvalue *mkparser.MakeString, appendVariable bool) error {
+ val, err := makeVariableToBlueprint(file, mkvalue, bpparser.List)
+ if err != nil {
+ return err
+ }
+
+ lists, err := splitBpList(val, func(value bpparser.Value) (string, *bpparser.Value, error) {
+ // Anything other than "-Wl,--version_script," + LOCAL_PATH + "<path>" matches ldflags
+ if value.Variable != "" || value.Expression == nil {
+ return "ldflags", &value, nil
+ }
+
+ exp := value.Expression.Args[0]
+ if exp.Variable != "" || exp.Expression == nil || exp.Expression.Args[0].StringValue != "-Wl,--version-script," {
+ return "ldflags", &value, nil
+ }
+
+ if exp.Expression.Args[1].Variable != "LOCAL_PATH" {
+ file.errorf(mkvalue, "Unrecognized version-script")
+ return "ldflags", &value, nil
+ }
+
+ value.Expression.Args[1].StringValue = strings.TrimPrefix(value.Expression.Args[1].StringValue, "/")
+
+ return "version", &value.Expression.Args[1], nil
+ })
+ if err != nil {
+ return err
+ }
+
+ if ldflags, ok := lists["ldflags"]; ok && !emptyList(ldflags) {
+ err = setVariable(file, appendVariable, prefix, "ldflags", ldflags, true)
+ if err != nil {
+ return err
+ }
+ }
+
+ if version_script, ok := lists["version"]; ok && !emptyList(version_script) {
+ if len(version_script.ListValue) > 1 {
+ file.errorf(mkvalue, "multiple version scripts found?")
+ }
+ err = setVariable(file, false, prefix, "version_script", &version_script.ListValue[0], true)
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
var deleteProperties = map[string]struct{}{
"LOCAL_CPP_EXTENSION": struct{}{},
}
diff --git a/androidmk/cmd/androidmk/test.go b/androidmk/cmd/androidmk/test.go
index 579578e5..b3ce5d02 100644
--- a/androidmk/cmd/androidmk/test.go
+++ b/androidmk/cmd/androidmk/test.go
@@ -331,6 +331,20 @@ cc_library_shared {
}
`,
},
+ {
+ desc: "version_script in LOCAL_LDFLAGS",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_LDFLAGS := -Wl,--link-opt -Wl,--version-script,$(LOCAL_PATH)/exported32.map
+include $(BUILD_SHARED_LIBRARY)
+`,
+ expected: `
+cc_library_shared {
+ ldflags: ["-Wl,--link-opt"],
+ version_script: "exported32.map",
+}
+`,
+ },
}
func reformatBlueprint(input string) string {