Update protoc support for libplatformprotos
Allow properties to be overriden by arch variants.
Add include_dirs and local_include_dirs properties.
Pass -I . to fix:
frameworks/base/proto/src/metrics_constants.proto: File does not
reside within any path specified using --proto_path (or -I). You
must specify a --proto_path which encompasses this file. Note that
the proto_path must be an exact prefix of the .proto file names --
protoc is too dumb to figure out when two paths (e.g. absolute and
relative) are equivalent (it's harder than you think).
Test: m -j libplatformprotos
Change-Id: I3e02621ca25bfa7ca0a0e3b83377d70dd352668f
diff --git a/cc/proto.go b/cc/proto.go
index 51f5448..10d3c62 100644
--- a/cc/proto.go
+++ b/cc/proto.go
@@ -16,6 +16,7 @@
import (
"github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
"android/soong/android"
)
@@ -72,17 +73,25 @@
type ProtoProperties struct {
Proto struct {
// Proto generator type (full, lite)
- Type string
+ Type *string `android:"arch_variant"`
+
// Link statically against the protobuf runtime
- Static bool
- }
+ Static bool `android:"arch_variant"`
+
+ // list of directories that will be added to the protoc include paths.
+ Include_dirs []string
+
+ // list of directories relative to the Android.bp file that will
+ // be added to the protoc include paths.
+ Local_include_dirs []string
+ } `android:"arch_variant"`
}
func protoDeps(ctx BaseModuleContext, deps Deps, p *ProtoProperties) Deps {
var lib string
var static bool
- switch p.Proto.Type {
+ switch proptools.String(p.Proto.Type) {
case "full":
if ctx.sdk() {
lib = "libprotobuf-cpp-full-ndk"
@@ -101,7 +110,8 @@
}
}
default:
- ctx.PropertyErrorf("proto.type", "unknown proto type %q", p.Proto.Type)
+ ctx.PropertyErrorf("proto.type", "unknown proto type %q",
+ proptools.String(p.Proto.Type))
}
if static {
@@ -122,5 +132,16 @@
"-I"+protoDir(ctx).String(),
)
+ if len(p.Proto.Local_include_dirs) > 0 {
+ localProtoIncludeDirs := android.PathsForModuleSrc(ctx, p.Proto.Local_include_dirs)
+ flags.protoFlags = append(flags.protoFlags, includeDirsToFlags(localProtoIncludeDirs))
+ }
+ if len(p.Proto.Include_dirs) > 0 {
+ rootProtoIncludeDirs := android.PathsForSource(ctx, p.Proto.Include_dirs)
+ flags.protoFlags = append(flags.protoFlags, includeDirsToFlags(rootProtoIncludeDirs))
+ }
+
+ flags.protoFlags = append(flags.protoFlags, "-I .")
+
return flags
}