androidmk no longer escaping escaped quotes in CFLAGS
am: fd4ce1bb68
Change-Id: I884a50bd8d8053747ab5ff23d6e2671b3e983450
This commit is contained in:
@@ -35,6 +35,7 @@ var rewriteProperties = map[string](func(variableAssignmentContext) error){
|
|||||||
"LOCAL_SRC_FILES": srcFiles,
|
"LOCAL_SRC_FILES": srcFiles,
|
||||||
"LOCAL_SANITIZE": sanitize(""),
|
"LOCAL_SANITIZE": sanitize(""),
|
||||||
"LOCAL_SANITIZE_DIAG": sanitize("diag."),
|
"LOCAL_SANITIZE_DIAG": sanitize("diag."),
|
||||||
|
"LOCAL_CFLAGS": cflags,
|
||||||
|
|
||||||
// composite functions
|
// composite functions
|
||||||
"LOCAL_MODULE_TAGS": includeVariableIf(bpVariable{"tags", bpparser.ListType}, not(valueDumpEquals("optional"))),
|
"LOCAL_MODULE_TAGS": includeVariableIf(bpVariable{"tags", bpparser.ListType}, not(valueDumpEquals("optional"))),
|
||||||
@@ -83,7 +84,6 @@ func init() {
|
|||||||
"LOCAL_SYSTEM_SHARED_LIBRARIES": "system_shared_libs",
|
"LOCAL_SYSTEM_SHARED_LIBRARIES": "system_shared_libs",
|
||||||
"LOCAL_ASFLAGS": "asflags",
|
"LOCAL_ASFLAGS": "asflags",
|
||||||
"LOCAL_CLANG_ASFLAGS": "clang_asflags",
|
"LOCAL_CLANG_ASFLAGS": "clang_asflags",
|
||||||
"LOCAL_CFLAGS": "cflags",
|
|
||||||
"LOCAL_CONLYFLAGS": "conlyflags",
|
"LOCAL_CONLYFLAGS": "conlyflags",
|
||||||
"LOCAL_CPPFLAGS": "cppflags",
|
"LOCAL_CPPFLAGS": "cppflags",
|
||||||
"LOCAL_REQUIRED_MODULES": "required",
|
"LOCAL_REQUIRED_MODULES": "required",
|
||||||
@@ -532,6 +532,13 @@ func ldflags(ctx variableAssignmentContext) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cflags(ctx variableAssignmentContext) error {
|
||||||
|
// The Soong replacement for CFLAGS doesn't need the same extra escaped quotes that were present in Make
|
||||||
|
ctx.mkvalue = ctx.mkvalue.Clone()
|
||||||
|
ctx.mkvalue.ReplaceLiteral(`\"`, `"`)
|
||||||
|
return includeVariableNow(bpVariable{"cflags", bpparser.ListType}, ctx)
|
||||||
|
}
|
||||||
|
|
||||||
// given a conditional, returns a function that will insert a variable assignment or not, based on the conditional
|
// given a conditional, returns a function that will insert a variable assignment or not, based on the conditional
|
||||||
func includeVariableIf(bpVar bpVariable, conditional func(ctx variableAssignmentContext) bool) func(ctx variableAssignmentContext) error {
|
func includeVariableIf(bpVar bpVariable, conditional func(ctx variableAssignmentContext) bool) func(ctx variableAssignmentContext) error {
|
||||||
return func(ctx variableAssignmentContext) error {
|
return func(ctx variableAssignmentContext) error {
|
||||||
|
@@ -372,6 +372,25 @@ include $(BUILD_SHARED_LIBRARY)
|
|||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
tags: ["debug"],
|
tags: ["debug"],
|
||||||
}
|
}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
desc: "Input containing escaped quotes",
|
||||||
|
in: `
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_MODULE:= libsensorservice
|
||||||
|
LOCAL_CFLAGS:= -DLOG_TAG=\"-DDontEscapeMe\"
|
||||||
|
LOCAL_SRC_FILES := \"EscapeMe.cc\"
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
`,
|
||||||
|
|
||||||
|
expected: `
|
||||||
|
cc_library_shared {
|
||||||
|
name: "libsensorservice",
|
||||||
|
cflags: ["-DLOG_TAG=\"-DDontEscapeMe\""],
|
||||||
|
srcs: ["\\\"EscapeMe.cc\\\""],
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -29,6 +29,11 @@ func SimpleMakeString(s string, pos Pos) *MakeString {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ms *MakeString) Clone() (result *MakeString) {
|
||||||
|
clone := *ms
|
||||||
|
return &clone
|
||||||
|
}
|
||||||
|
|
||||||
func (ms *MakeString) Pos() Pos {
|
func (ms *MakeString) Pos() Pos {
|
||||||
return ms.StringPos
|
return ms.StringPos
|
||||||
}
|
}
|
||||||
@@ -164,6 +169,12 @@ func (ms *MakeString) EndsWith(ch rune) bool {
|
|||||||
return s[len(s)-1] == uint8(ch)
|
return s[len(s)-1] == uint8(ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ms *MakeString) ReplaceLiteral(input string, output string) {
|
||||||
|
for i := range ms.Strings {
|
||||||
|
ms.Strings[i] = strings.Replace(ms.Strings[i], input, output, -1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func splitAnyN(s, sep string, n int) []string {
|
func splitAnyN(s, sep string, n int) []string {
|
||||||
ret := []string{}
|
ret := []string{}
|
||||||
for n == -1 || n > 1 {
|
for n == -1 || n > 1 {
|
||||||
|
Reference in New Issue
Block a user