Soong cc proto fix for grpc plugin
- Update output file names when using grpc plugin (grpc.pb instead of pb)
Change-Id: I702553713d1a667f90a5502291bd15b7cedd7eb7
Signed-off-by: Andrea Marchini <amarchini@google.com>
diff --git a/cc/proto.go b/cc/proto.go
index 4d72f26..93142b9 100644
--- a/cc/proto.go
+++ b/cc/proto.go
@@ -19,6 +19,8 @@
"github.com/google/blueprint/proptools"
"android/soong/android"
+
+ "strings"
)
const (
@@ -35,13 +37,21 @@
srcSuffix = ".c"
}
+ srcInfix := "pb"
+ for _, value := range flags.proto.Flags {
+ if strings.HasPrefix(value, "--plugin=") && strings.HasSuffix(value, "protoc-gen-grpc-cpp-plugin") {
+ srcInfix = "grpc.pb"
+ break
+ }
+ }
+
if flags.proto.CanonicalPathFromRoot {
- ccFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb"+srcSuffix)
- headerFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.h")
+ ccFile = android.GenPathWithExt(ctx, "proto", protoFile, srcInfix+srcSuffix)
+ headerFile = android.GenPathWithExt(ctx, "proto", protoFile, srcInfix+".h")
} else {
rel := protoFile.Rel()
- ccFile = android.PathForModuleGen(ctx, "proto", pathtools.ReplaceExtension(rel, "pb"+srcSuffix))
- headerFile = android.PathForModuleGen(ctx, "proto", pathtools.ReplaceExtension(rel, "pb.h"))
+ ccFile = android.PathForModuleGen(ctx, "proto", pathtools.ReplaceExtension(rel, srcInfix+srcSuffix))
+ headerFile = android.PathForModuleGen(ctx, "proto", pathtools.ReplaceExtension(rel, srcInfix+".h"))
}
protoDeps := flags.proto.Deps