The androidmk supports converting "LOCAL_PROTOC_FLAGS"

LOCAL_PROTOC_FLAGS can be converted as "proto.local_include_dirs" with
value "--proto_path".

Bug: 314862115
Test: 1. m androidmk
      2. go test
Change-Id: Id4e589623ffef50c2549720b1ef828cd38a940a0
This commit is contained in:
Herbert Xue
2024-01-17 11:24:59 +08:00
parent e317b15cea
commit 65e0963e4a
2 changed files with 17 additions and 0 deletions

View File

@@ -64,6 +64,7 @@ var rewriteProperties = map[string](func(variableAssignmentContext) error){
"LOCAL_SANITIZE_DIAG": sanitize("diag."),
"LOCAL_STRIP_MODULE": strip(),
"LOCAL_CFLAGS": cflags,
"LOCAL_PROTOC_FLAGS": protoLocalIncludeDirs,
"LOCAL_PROTO_JAVA_OUTPUT_PARAMS": protoOutputParams,
"LOCAL_UNINSTALLABLE_MODULE": invert("installable"),
"LOCAL_PROGUARD_ENABLED": proguardEnabled,
@@ -768,6 +769,20 @@ func protoOutputParams(ctx variableAssignmentContext) error {
return includeVariableNow(bpVariable{"proto.output_params", bpparser.ListType}, ctx)
}
func protoLocalIncludeDirs(ctx variableAssignmentContext) error {
// The Soong replacement for LOCAL_PROTOC_FLAGS includes "--proto_path=$(LOCAL_PATH)/..."
ctx.mkvalue = ctx.mkvalue.Clone()
if len(ctx.mkvalue.Strings) >= 1 && strings.Contains(ctx.mkvalue.Strings[0], "--proto_path=") {
ctx.mkvalue.Strings[0] = strings.Replace(ctx.mkvalue.Strings[0], "--proto_path=", "", 1)
paths, err := localizePaths(ctx)
if err == nil {
err = setVariable(ctx.file, ctx.append, ctx.prefix, "proto.local_include_dirs", paths, true)
}
return err
}
return fmt.Errorf("Currently LOCAL_PROTOC_FLAGS only support with value '--proto_path=$(LOCAL_PATH)/...'")
}
func proguardEnabled(ctx variableAssignmentContext) error {
val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)
if err != nil {

View File

@@ -1733,6 +1733,7 @@ android_test {
include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_PROTO_JAVA_OUTPUT_PARAMS := enum_style=java, parcelable_messages=true
LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos
include $(BUILD_PACKAGE)
`,
expected: `
@@ -1743,6 +1744,7 @@ android_app {
"enum_style=java",
"parcelable_messages=true",
],
local_include_dirs: ["protos"],
},
}
`,