Add support for .proto files in java modules

Test: m -j checkbuild
Change-Id: Ia03429948baebff85164a91a34507866c97a08ef
This commit is contained in:
Colin Cross
2017-09-20 12:59:05 -07:00
parent 47ff2521c6
commit 6af17aa022
8 changed files with 211 additions and 60 deletions

View File

@@ -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