aboutsummaryrefslogtreecommitdiffstats
path: root/cc/proto.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2017-05-02 13:34:32 -0700
committerColin Cross <ccross@android.com>2017-05-02 14:08:29 -0700
commit5ff51b5caab07ff1933081fb4f3ea1d3b010e98b (patch)
tree397ae2313f5453c43f50e81d97f1782be7a9e3d8 /cc/proto.go
parent0e409a2810f360595fe741ab33792e618caec378 (diff)
downloadbuild_soong-5ff51b5caab07ff1933081fb4f3ea1d3b010e98b.tar.gz
build_soong-5ff51b5caab07ff1933081fb4f3ea1d3b010e98b.tar.bz2
build_soong-5ff51b5caab07ff1933081fb4f3ea1d3b010e98b.zip
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
Diffstat (limited to 'cc/proto.go')
-rw-r--r--cc/proto.go31
1 files changed, 26 insertions, 5 deletions
diff --git a/cc/proto.go b/cc/proto.go
index 51f54489..10d3c624 100644
--- a/cc/proto.go
+++ b/cc/proto.go
@@ -16,6 +16,7 @@ package cc
import (
"github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
"android/soong/android"
)
@@ -72,17 +73,25 @@ func protoSubDir(ctx android.ModuleContext) android.ModuleGenPath {
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 @@ func protoDeps(ctx BaseModuleContext, deps Deps, p *ProtoProperties) Deps {
}
}
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 @@ func protoFlags(ctx ModuleContext, flags Flags, p *ProtoProperties) Flags {
"-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
}