Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65e0963e authored by Herbert Xue's avatar Herbert Xue
Browse files

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
parent e317b15c
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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 {
+2 −0
Original line number Diff line number Diff line
@@ -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"],
    },
}
`,