androidmk no longer escaping escaped quotes in CFLAGS
Bug: 37547491 Test: m -j Change-Id: I2f406be477f3990bf109778eb9adc9c33db2f2ad
This commit is contained in:
parent
38d3d5d2e5
commit
fd4ce1bb68
3 changed files with 38 additions and 1 deletions
|
@ -35,6 +35,7 @@ var rewriteProperties = map[string](func(variableAssignmentContext) error){
|
|||
"LOCAL_SRC_FILES": srcFiles,
|
||||
"LOCAL_SANITIZE": sanitize(""),
|
||||
"LOCAL_SANITIZE_DIAG": sanitize("diag."),
|
||||
"LOCAL_CFLAGS": cflags,
|
||||
|
||||
// composite functions
|
||||
"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_ASFLAGS": "asflags",
|
||||
"LOCAL_CLANG_ASFLAGS": "clang_asflags",
|
||||
"LOCAL_CFLAGS": "cflags",
|
||||
"LOCAL_CONLYFLAGS": "conlyflags",
|
||||
"LOCAL_CPPFLAGS": "cppflags",
|
||||
"LOCAL_REQUIRED_MODULES": "required",
|
||||
|
@ -532,6 +532,13 @@ func ldflags(ctx variableAssignmentContext) error {
|
|||
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
|
||||
func includeVariableIf(bpVar bpVariable, conditional func(ctx variableAssignmentContext) bool) func(ctx variableAssignmentContext) error {
|
||||
return func(ctx variableAssignmentContext) error {
|
||||
|
|
|
@ -372,6 +372,25 @@ include $(BUILD_SHARED_LIBRARY)
|
|||
cc_library_shared {
|
||||
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 {
|
||||
return ms.StringPos
|
||||
}
|
||||
|
@ -164,6 +169,12 @@ func (ms *MakeString) EndsWith(ch rune) bool {
|
|||
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 {
|
||||
ret := []string{}
|
||||
for n == -1 || n > 1 {
|
||||
|
|
Loading…
Reference in a new issue