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
This commit is contained in:
31
cc/proto.go
31
cc/proto.go
@@ -16,6 +16,7 @@ package cc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
@@ -72,17 +73,25 @@ func protoSubDir(ctx android.ModuleContext) android.ModuleGenPath {
|
|||||||
type ProtoProperties struct {
|
type ProtoProperties struct {
|
||||||
Proto struct {
|
Proto struct {
|
||||||
// Proto generator type (full, lite)
|
// Proto generator type (full, lite)
|
||||||
Type string
|
Type *string `android:"arch_variant"`
|
||||||
|
|
||||||
// Link statically against the protobuf runtime
|
// 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 {
|
func protoDeps(ctx BaseModuleContext, deps Deps, p *ProtoProperties) Deps {
|
||||||
var lib string
|
var lib string
|
||||||
var static bool
|
var static bool
|
||||||
|
|
||||||
switch p.Proto.Type {
|
switch proptools.String(p.Proto.Type) {
|
||||||
case "full":
|
case "full":
|
||||||
if ctx.sdk() {
|
if ctx.sdk() {
|
||||||
lib = "libprotobuf-cpp-full-ndk"
|
lib = "libprotobuf-cpp-full-ndk"
|
||||||
@@ -101,7 +110,8 @@ func protoDeps(ctx BaseModuleContext, deps Deps, p *ProtoProperties) Deps {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
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 {
|
if static {
|
||||||
@@ -122,5 +132,16 @@ func protoFlags(ctx ModuleContext, flags Flags, p *ProtoProperties) Flags {
|
|||||||
"-I"+protoDir(ctx).String(),
|
"-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
|
return flags
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user