aboutsummaryrefslogtreecommitdiffstats
path: root/android/proto.go
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2018-02-14 13:58:34 -0800
committerDan Willemsen <dwillemsen@google.com>2018-02-22 16:48:35 -0800
commitab9f4268c01390b9d049c746e399b53a0f2c6dce (patch)
tree618eee4fd52d9e93ff04b1ae46a98765a9e65940 /android/proto.go
parent336ad7a6676515ec1f2a432ca176af62ff180155 (diff)
downloadbuild_soong-ab9f4268c01390b9d049c746e399b53a0f2c6dce.tar.gz
build_soong-ab9f4268c01390b9d049c746e399b53a0f2c6dce.tar.bz2
build_soong-ab9f4268c01390b9d049c746e399b53a0f2c6dce.zip
Add proto.canonical_path_from_root
Historically, we've always passed '-I .' as the first argument to protoc, essentially treating all proto file package names as their full path in the android source tree. This would make sense in a monorepo world, but it makes less sense when we're pulling in external projects with established package names. So keep the same default (for now), but allow individual builds to opt into using local paths as the default names with 'canonical_path_from_root: false'. A cleanup effort and/or large scale change in the future could change the default to false. As part of this, run protoc once per input proto file, since the flags may need to change per-file. We'll also need this in order to specify --dependency_out in the future. Bug: 70704330 Test: aosp/master build-aosp_arm.ninja is identical Test: aosp/master soong/build.ninja has expected changes Test: m Test: Build protobuf test Change-Id: I9d6de9fd630326bbcced1c62a4a7e9546429b0ce
Diffstat (limited to 'android/proto.go')
-rw-r--r--android/proto.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/android/proto.go b/android/proto.go
index 0cf7c26e..801837e0 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -23,8 +23,7 @@ package android
// generate the source.
func ProtoFlags(ctx ModuleContext, p *ProtoProperties) []string {
- // -I . must come first, it affects where protoc places the output files.
- protoFlags := []string{"-I ."}
+ protoFlags := []string{}
if len(p.Proto.Local_include_dirs) > 0 {
localProtoIncludeDirs := PathsForModuleSrc(ctx, p.Proto.Local_include_dirs)
@@ -38,6 +37,13 @@ func ProtoFlags(ctx ModuleContext, p *ProtoProperties) []string {
return protoFlags
}
+func ProtoCanonicalPathFromRoot(ctx ModuleContext, p *ProtoProperties) bool {
+ if p.Proto.Canonical_path_from_root == nil {
+ return true
+ }
+ return *p.Proto.Canonical_path_from_root
+}
+
// ProtoDir returns the module's "gen/proto" directory
func ProtoDir(ctx ModuleContext) ModuleGenPath {
return PathForModuleGen(ctx, "proto")
@@ -59,5 +65,14 @@ type ProtoProperties struct {
// list of directories relative to the bp file that will
// be added to the protoc include paths.
Local_include_dirs []string
+
+ // whether to identify the proto files from the root of the
+ // source tree (the original method in Android, useful for
+ // android-specific protos), or relative from where they were
+ // specified (useful for external/third party protos).
+ //
+ // This defaults to true today, but is expected to default to
+ // false in the future.
+ Canonical_path_from_root *bool
} `android:"arch_variant"`
}