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

Commit 3b21c9ca authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "The androidmk supports converting "LOCAL_PROTOC_FLAGS"" into main

parents 936a57d3 65e0963e
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"],
    },
}
`,