diff options
author | 2016-10-20 16:11:43 -0700 | |
---|---|---|
committer | 2016-10-27 15:28:09 -0700 | |
commit | 0c461f1f6e2a1663b426eec2247e5a26f2822970 (patch) | |
tree | 394e04c7672fc47f46e40d9447717aa381b3b541 /cc/compiler.go | |
parent | 4f6fc9c1d81687914cc77bf06b10af8022f64198 (diff) |
Add support for .proto files
.proto files are translated to .pb.cc and .pb.h files, which are then
compiled normally.
Bug: 32286026
Test: mmma -j system/extras/perfprofd
Change-Id: I538071424d667aacf35b4b8bfebe217f5f092726
Diffstat (limited to 'cc/compiler.go')
-rw-r--r-- | cc/compiler.go | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/cc/compiler.go b/cc/compiler.go index 32d98e4a8..0184ee9f4 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -100,6 +100,7 @@ func NewBaseCompiler() *baseCompiler { type baseCompiler struct { Properties BaseCompilerProperties + Proto ProtoProperties deps android.Paths } @@ -123,6 +124,10 @@ func (compiler *baseCompiler) compilerDeps(ctx BaseModuleContext, deps Deps) Dep deps.GeneratedSources = append(deps.GeneratedSources, compiler.Properties.Generated_sources...) deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers...) + if compiler.hasProto() { + deps = protoDeps(ctx, deps, &compiler.Proto) + } + return deps } @@ -160,11 +165,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag "${config.CommonNativehelperInclude}") } - flags.GlobalFlags = append(flags.GlobalFlags, []string{ - "-I" + android.PathForModuleSrc(ctx).String(), - "-I" + android.PathForModuleOut(ctx).String(), - "-I" + android.PathForModuleGen(ctx).String(), - }...) + flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String()) } if ctx.sdk() { @@ -321,9 +322,23 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag flags.CFlags = append(flags.CFlags, "-DANDROID_STRICT") } + if compiler.hasProto() { + flags = protoFlags(ctx, flags, &compiler.Proto) + } + return flags } +func (compiler *baseCompiler) hasProto() bool { + for _, src := range compiler.Properties.Srcs { + if filepath.Ext(src) == ".proto" { + return true + } + } + + return false +} + var gnuToCReplacer = strings.NewReplacer("gnu", "c") func ndkPathDeps(ctx ModuleContext) android.Paths { |