Add support for .proto files in java modules
Test: m -j checkbuild Change-Id: Ia03429948baebff85164a91a34507866c97a08ef
This commit is contained in:
@@ -153,10 +153,9 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||
srcFiles[i] = cppFile
|
||||
genLex(ctx, srcFile, cppFile)
|
||||
case ".proto":
|
||||
protoFiles := android.GenProto(ctx, srcFile, buildFlags.protoFlags,
|
||||
"--cpp_out", "", []string{"pb.cc", "pb.h"})
|
||||
srcFiles[i] = protoFiles[0]
|
||||
deps = append(deps, protoFiles[1])
|
||||
ccFile, headerFile := genProto(ctx, srcFile, buildFlags.protoFlags)
|
||||
srcFiles[i] = ccFile
|
||||
deps = append(deps, headerFile)
|
||||
case ".aidl":
|
||||
cppFile := android.GenPathWithExt(ctx, "aidl", srcFile, "cpp")
|
||||
srcFiles[i] = cppFile
|
||||
|
35
cc/proto.go
35
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
|
||||
|
||||
|
Reference in New Issue
Block a user