diff options
author | 2017-09-20 12:59:05 -0700 | |
---|---|---|
committer | 2017-10-03 10:25:15 -0700 | |
commit | 6af17aa0228ce589914f93d3b48183bb356e52e5 (patch) | |
tree | 67dff285d69b0b2f484022a601ea4e62833d1462 /cc/proto.go | |
parent | 47ff2521c6479c44c5b7b0874948346b04c682df (diff) |
Add support for .proto files in java modules
Test: m -j checkbuild
Change-Id: Ia03429948baebff85164a91a34507866c97a08ef
Diffstat (limited to 'cc/proto.go')
-rw-r--r-- | cc/proto.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/cc/proto.go b/cc/proto.go index 6049d44ad..a01951fe6 100644 --- a/cc/proto.go +++ b/cc/proto.go @@ -15,11 +15,46 @@ package cc import ( + "github.com/google/blueprint" "github.com/google/blueprint/proptools" "android/soong/android" ) +func init() { + pctx.HostBinToolVariable("protocCmd", "aprotoc") +} + +var ( + proto = pctx.AndroidStaticRule("protoc", + blueprint.RuleParams{ + Command: "$protocCmd --cpp_out=$outDir $protoFlags $in", + CommandDeps: []string{"$protocCmd"}, + }, "protoFlags", "outDir") +) + +// genProto creates a rule to convert a .proto file to generated .pb.cc and .pb.h files and returns +// the paths to the generated files. +func genProto(ctx android.ModuleContext, protoFile android.Path, + protoFlags string) (ccFile, headerFile android.WritablePath) { + + ccFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.cc") + headerFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.h") + + ctx.ModuleBuild(pctx, android.ModuleBuildParams{ + Rule: proto, + Description: "protoc " + protoFile.Rel(), + Outputs: android.WritablePaths{ccFile, headerFile}, + Input: protoFile, + Args: map[string]string{ + "outDir": android.ProtoDir(ctx).String(), + "protoFlags": protoFlags, + }, + }) + + return ccFile, headerFile +} + func protoDeps(ctx BaseModuleContext, deps Deps, p *android.ProtoProperties, static bool) Deps { var lib string |