Merge "Revert "androidmk: support cfi, diag, and misc_undefined properties""
This commit is contained in:
commit
e6d4cb3652
|
@ -33,8 +33,7 @@ var rewriteProperties = map[string](func(variableAssignmentContext) error){
|
|||
"LOCAL_MODULE_STEM": stem,
|
||||
"LOCAL_MODULE_HOST_OS": hostOs,
|
||||
"LOCAL_SRC_FILES": srcFiles,
|
||||
"LOCAL_SANITIZE": sanitize(""),
|
||||
"LOCAL_SANITIZE_DIAG": sanitize("diag."),
|
||||
"LOCAL_SANITIZE": sanitize,
|
||||
|
||||
// composite functions
|
||||
"LOCAL_MODULE_TAGS": includeVariableIf(bpVariable{"tags", bpparser.ListType}, not(valueDumpEquals("optional"))),
|
||||
|
@ -414,63 +413,60 @@ func srcFiles(ctx variableAssignmentContext) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func sanitize(sub string) func(ctx variableAssignmentContext) error {
|
||||
return func(ctx variableAssignmentContext) error {
|
||||
val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
lists, err := splitBpList(val, func(value bpparser.Expression) (string, bpparser.Expression, error) {
|
||||
switch v := value.(type) {
|
||||
case *bpparser.Variable:
|
||||
return "vars", value, nil
|
||||
case *bpparser.Operator:
|
||||
ctx.file.errorf(ctx.mkvalue, "unknown sanitize expression")
|
||||
return "unknown", value, nil
|
||||
case *bpparser.String:
|
||||
switch v.Value {
|
||||
case "never", "address", "coverage", "integer", "thread", "undefined", "cfi":
|
||||
bpTrue := &bpparser.Bool{
|
||||
Value: true,
|
||||
}
|
||||
return v.Value, bpTrue, nil
|
||||
default:
|
||||
return "misc_undefined", v, nil
|
||||
}
|
||||
default:
|
||||
return "", nil, fmt.Errorf("sanitize expected a string, got %s", value.Type())
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for k, v := range lists {
|
||||
if emptyList(v) {
|
||||
continue
|
||||
}
|
||||
|
||||
switch k {
|
||||
case "never", "address", "coverage", "integer", "thread", "undefined", "cfi":
|
||||
err = setVariable(ctx.file, false, ctx.prefix, "sanitize."+sub+k, lists[k].(*bpparser.List).Values[0], true)
|
||||
case "misc_undefined":
|
||||
err = setVariable(ctx.file, false, ctx.prefix, "sanitize."+sub+"misc_undefined", lists[k].(*bpparser.List), true)
|
||||
case "unknown":
|
||||
// Nothing, we already added the error above
|
||||
case "vars":
|
||||
fallthrough
|
||||
default:
|
||||
err = setVariable(ctx.file, true, ctx.prefix, "sanitize", v, true)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func sanitize(ctx variableAssignmentContext) error {
|
||||
val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
lists, err := splitBpList(val, func(value bpparser.Expression) (string, bpparser.Expression, error) {
|
||||
switch v := value.(type) {
|
||||
case *bpparser.Variable:
|
||||
return "vars", value, nil
|
||||
case *bpparser.Operator:
|
||||
ctx.file.errorf(ctx.mkvalue, "unknown sanitize expression")
|
||||
return "unknown", value, nil
|
||||
case *bpparser.String:
|
||||
switch v.Value {
|
||||
case "never", "address", "coverage", "integer", "thread", "undefined":
|
||||
bpTrue := &bpparser.Bool{
|
||||
Value: true,
|
||||
}
|
||||
return v.Value, bpTrue, nil
|
||||
default:
|
||||
ctx.file.errorf(ctx.mkvalue, "unknown sanitize argument: %s", v.Value)
|
||||
return "unknown", value, nil
|
||||
}
|
||||
default:
|
||||
return "", nil, fmt.Errorf("sanitize expected a string, got %s", value.Type())
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for k, v := range lists {
|
||||
if emptyList(v) {
|
||||
continue
|
||||
}
|
||||
|
||||
switch k {
|
||||
case "never", "address", "coverage", "integer", "thread", "undefined":
|
||||
err = setVariable(ctx.file, false, ctx.prefix, "sanitize."+k, lists[k].(*bpparser.List).Values[0], true)
|
||||
case "unknown":
|
||||
// Nothing, we already added the error above
|
||||
case "vars":
|
||||
fallthrough
|
||||
default:
|
||||
err = setVariable(ctx.file, true, ctx.prefix, "sanitize", v, true)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func prebuiltClass(ctx variableAssignmentContext) error {
|
||||
|
|
|
@ -285,21 +285,17 @@ cc_library_shared {
|
|||
desc: "LOCAL_SANITIZE unknown parameter",
|
||||
in: `
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_SANITIZE := integer cfi asdf
|
||||
LOCAL_SANITIZE_DIAG := cfi
|
||||
LOCAL_SANITIZE := integer asdf
|
||||
LOCAL_SANITIZE_RECOVER := qwert
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
`,
|
||||
expected: `
|
||||
cc_library_shared {
|
||||
// ANDROIDMK TRANSLATION ERROR: unknown sanitize argument: asdf
|
||||
// integer asdf
|
||||
sanitize: {
|
||||
integer: true,
|
||||
cfi: true,
|
||||
misc_undefined: ["asdf"],
|
||||
diag: {
|
||||
cfi: true,
|
||||
},
|
||||
recover: ["qwert"],
|
||||
integer: true,
|
||||
recover: ["qwert"],
|
||||
},
|
||||
}
|
||||
`,
|
||||
|
|
Loading…
Reference in New Issue