When compiling with the lite protobuf option, pass the option to aprotoc to force the lite runtime.
Test: make Merged-In: I450f89d144d496a6ddfccc6a6a5a679a05809595 Change-Id: I450f89d144d496a6ddfccc6a6a5a679a05809595
This commit is contained in:
@@ -231,27 +231,28 @@ func init() {
|
||||
}
|
||||
|
||||
type builderFlags struct {
|
||||
globalFlags string
|
||||
arFlags string
|
||||
asFlags string
|
||||
cFlags string
|
||||
toolingCFlags string // A separate set of Cflags for clang LibTooling tools
|
||||
conlyFlags string
|
||||
cppFlags string
|
||||
ldFlags string
|
||||
libFlags string
|
||||
yaccFlags string
|
||||
protoFlags string
|
||||
tidyFlags string
|
||||
sAbiFlags string
|
||||
yasmFlags string
|
||||
aidlFlags string
|
||||
rsFlags string
|
||||
toolchain config.Toolchain
|
||||
clang bool
|
||||
tidy bool
|
||||
coverage bool
|
||||
sAbiDump bool
|
||||
globalFlags string
|
||||
arFlags string
|
||||
asFlags string
|
||||
cFlags string
|
||||
toolingCFlags string // A separate set of Cflags for clang LibTooling tools
|
||||
conlyFlags string
|
||||
cppFlags string
|
||||
ldFlags string
|
||||
libFlags string
|
||||
yaccFlags string
|
||||
protoFlags string
|
||||
protoOutParams string
|
||||
tidyFlags string
|
||||
sAbiFlags string
|
||||
yasmFlags string
|
||||
aidlFlags string
|
||||
rsFlags string
|
||||
toolchain config.Toolchain
|
||||
clang bool
|
||||
tidy bool
|
||||
coverage bool
|
||||
sAbiDump bool
|
||||
|
||||
systemIncludeFlags string
|
||||
|
||||
|
1
cc/cc.go
1
cc/cc.go
@@ -116,6 +116,7 @@ type Flags struct {
|
||||
ToolingCppFlags []string // Flags that apply to C++ source files parsed by clang LibTooling tools
|
||||
YaccFlags []string // Flags that apply to Yacc source files
|
||||
protoFlags []string // Flags that apply to proto source files
|
||||
protoOutParams []string // Flags that modify the output of proto generated files
|
||||
aidlFlags []string // Flags that apply to aidl source files
|
||||
rsFlags []string // Flags that apply to renderscript source files
|
||||
LdFlags []string // Flags that apply to linker command lines
|
||||
|
@@ -153,7 +153,8 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||
srcFiles[i] = cppFile
|
||||
genLex(ctx, srcFile, cppFile)
|
||||
case ".proto":
|
||||
ccFile, headerFile := genProto(ctx, srcFile, buildFlags.protoFlags)
|
||||
ccFile, headerFile := genProto(ctx, srcFile, buildFlags.protoFlags,
|
||||
buildFlags.protoOutParams)
|
||||
srcFiles[i] = ccFile
|
||||
deps = append(deps, headerFile)
|
||||
case ".aidl":
|
||||
|
16
cc/proto.go
16
cc/proto.go
@@ -16,6 +16,7 @@ package cc
|
||||
|
||||
import (
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android"
|
||||
)
|
||||
@@ -27,15 +28,15 @@ func init() {
|
||||
var (
|
||||
proto = pctx.AndroidStaticRule("protoc",
|
||||
blueprint.RuleParams{
|
||||
Command: "$protocCmd --cpp_out=$outDir $protoFlags $in",
|
||||
Command: "$protocCmd --cpp_out=$protoOutParams:$outDir $protoFlags $in",
|
||||
CommandDeps: []string{"$protocCmd"},
|
||||
}, "protoFlags", "outDir")
|
||||
}, "protoFlags", "protoOutParams", "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) {
|
||||
protoFlags string, protoOutParams string) (ccFile, headerFile android.WritablePath) {
|
||||
|
||||
ccFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.cc")
|
||||
headerFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.h")
|
||||
@@ -46,8 +47,9 @@ func genProto(ctx android.ModuleContext, protoFile android.Path,
|
||||
Outputs: android.WritablePaths{ccFile, headerFile},
|
||||
Input: protoFile,
|
||||
Args: map[string]string{
|
||||
"outDir": android.ProtoDir(ctx).String(),
|
||||
"protoFlags": protoFlags,
|
||||
"outDir": android.ProtoDir(ctx).String(),
|
||||
"protoFlags": protoFlags,
|
||||
"protoOutParams": protoOutParams,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -97,5 +99,9 @@ func protoFlags(ctx ModuleContext, flags Flags, p *android.ProtoProperties) Flag
|
||||
|
||||
flags.protoFlags = android.ProtoFlags(ctx, p)
|
||||
|
||||
if proptools.String(p.Proto.Type) == "lite" {
|
||||
flags.protoOutParams = []string{"lite"}
|
||||
}
|
||||
|
||||
return flags
|
||||
}
|
||||
|
43
cc/util.go
43
cc/util.go
@@ -97,27 +97,28 @@ func moduleToLibName(module string) (string, error) {
|
||||
|
||||
func flagsToBuilderFlags(in Flags) builderFlags {
|
||||
return builderFlags{
|
||||
globalFlags: strings.Join(in.GlobalFlags, " "),
|
||||
arFlags: strings.Join(in.ArFlags, " "),
|
||||
asFlags: strings.Join(in.AsFlags, " "),
|
||||
cFlags: strings.Join(in.CFlags, " "),
|
||||
toolingCFlags: strings.Join(in.ToolingCFlags, " "),
|
||||
conlyFlags: strings.Join(in.ConlyFlags, " "),
|
||||
cppFlags: strings.Join(in.CppFlags, " "),
|
||||
yaccFlags: strings.Join(in.YaccFlags, " "),
|
||||
protoFlags: strings.Join(in.protoFlags, " "),
|
||||
aidlFlags: strings.Join(in.aidlFlags, " "),
|
||||
rsFlags: strings.Join(in.rsFlags, " "),
|
||||
ldFlags: strings.Join(in.LdFlags, " "),
|
||||
libFlags: strings.Join(in.libFlags, " "),
|
||||
tidyFlags: strings.Join(in.TidyFlags, " "),
|
||||
sAbiFlags: strings.Join(in.SAbiFlags, " "),
|
||||
yasmFlags: strings.Join(in.YasmFlags, " "),
|
||||
toolchain: in.Toolchain,
|
||||
clang: in.Clang,
|
||||
coverage: in.Coverage,
|
||||
tidy: in.Tidy,
|
||||
sAbiDump: in.SAbiDump,
|
||||
globalFlags: strings.Join(in.GlobalFlags, " "),
|
||||
arFlags: strings.Join(in.ArFlags, " "),
|
||||
asFlags: strings.Join(in.AsFlags, " "),
|
||||
cFlags: strings.Join(in.CFlags, " "),
|
||||
toolingCFlags: strings.Join(in.ToolingCFlags, " "),
|
||||
conlyFlags: strings.Join(in.ConlyFlags, " "),
|
||||
cppFlags: strings.Join(in.CppFlags, " "),
|
||||
yaccFlags: strings.Join(in.YaccFlags, " "),
|
||||
protoFlags: strings.Join(in.protoFlags, " "),
|
||||
protoOutParams: strings.Join(in.protoOutParams, ":"),
|
||||
aidlFlags: strings.Join(in.aidlFlags, " "),
|
||||
rsFlags: strings.Join(in.rsFlags, " "),
|
||||
ldFlags: strings.Join(in.LdFlags, " "),
|
||||
libFlags: strings.Join(in.libFlags, " "),
|
||||
tidyFlags: strings.Join(in.TidyFlags, " "),
|
||||
sAbiFlags: strings.Join(in.SAbiFlags, " "),
|
||||
yasmFlags: strings.Join(in.YasmFlags, " "),
|
||||
toolchain: in.Toolchain,
|
||||
clang: in.Clang,
|
||||
coverage: in.Coverage,
|
||||
tidy: in.Tidy,
|
||||
sAbiDump: in.SAbiDump,
|
||||
|
||||
systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "),
|
||||
|
||||
|
@@ -200,8 +200,9 @@ type javaBuilderFlags struct {
|
||||
kotlincFlags string
|
||||
kotlincClasspath classpath
|
||||
|
||||
protoFlags []string
|
||||
protoOutFlag string
|
||||
protoFlags []string
|
||||
protoOutTypeFlag string // The flag itself: --java_out
|
||||
protoOutParams string // Parameters to that flag: --java_out=$protoOutParams:$outDir
|
||||
}
|
||||
|
||||
func TransformKotlinToClasses(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||
|
@@ -107,7 +107,7 @@ func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||
if len(protoFiles) > 0 {
|
||||
protoSrcJar := android.PathForModuleGen(ctx, "proto.srcjar")
|
||||
genProto(ctx, protoSrcJar, protoFiles,
|
||||
flags.protoFlags, flags.protoOutFlag, "")
|
||||
flags.protoFlags, flags.protoOutTypeFlag, flags.protoOutParams)
|
||||
|
||||
outSrcFiles = append(outSrcFiles, protoSrcJar)
|
||||
}
|
||||
|
@@ -31,17 +31,17 @@ var (
|
||||
proto = pctx.AndroidStaticRule("protoc",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -rf $outDir && mkdir -p $outDir && ` +
|
||||
`$protocCmd $protoOut=$protoOutFlags:$outDir $protoFlags $in && ` +
|
||||
`$protocCmd $protoOut=$protoOutParams:$outDir $protoFlags $in && ` +
|
||||
`${config.SoongZipCmd} -jar -o $out -C $outDir -D $outDir`,
|
||||
CommandDeps: []string{
|
||||
"$protocCmd",
|
||||
"${config.SoongZipCmd}",
|
||||
},
|
||||
}, "protoFlags", "protoOut", "protoOutFlags", "outDir")
|
||||
}, "protoFlags", "protoOut", "protoOutParams", "outDir")
|
||||
)
|
||||
|
||||
func genProto(ctx android.ModuleContext, outputSrcJar android.WritablePath,
|
||||
protoFiles android.Paths, protoFlags []string, protoOut, protoOutFlags string) {
|
||||
protoFiles android.Paths, protoFlags []string, protoOut, protoOutParams string) {
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: proto,
|
||||
@@ -49,10 +49,10 @@ func genProto(ctx android.ModuleContext, outputSrcJar android.WritablePath,
|
||||
Output: outputSrcJar,
|
||||
Inputs: protoFiles,
|
||||
Args: map[string]string{
|
||||
"outDir": android.ProtoDir(ctx).String(),
|
||||
"protoOut": protoOut,
|
||||
"protoOutFlags": protoOutFlags,
|
||||
"protoFlags": strings.Join(protoFlags, " "),
|
||||
"outDir": android.ProtoDir(ctx).String(),
|
||||
"protoOut": protoOut,
|
||||
"protoOutParams": protoOutParams,
|
||||
"protoFlags": strings.Join(protoFlags, " "),
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -80,11 +80,14 @@ func protoDeps(ctx android.BottomUpMutatorContext, p *android.ProtoProperties) {
|
||||
func protoFlags(ctx android.ModuleContext, p *android.ProtoProperties, flags javaBuilderFlags) javaBuilderFlags {
|
||||
switch proptools.String(p.Proto.Type) {
|
||||
case "micro":
|
||||
flags.protoOutFlag = "--javamicro_out"
|
||||
flags.protoOutTypeFlag = "--javamicro_out"
|
||||
case "nano":
|
||||
flags.protoOutFlag = "--javanano_out"
|
||||
case "lite", "full", "":
|
||||
flags.protoOutFlag = "--java_out"
|
||||
flags.protoOutTypeFlag = "--javanano_out"
|
||||
case "lite":
|
||||
flags.protoOutTypeFlag = "--java_out"
|
||||
flags.protoOutParams = "lite"
|
||||
case "full", "":
|
||||
flags.protoOutTypeFlag = "--java_out"
|
||||
default:
|
||||
ctx.PropertyErrorf("proto.type", "unknown proto type %q",
|
||||
proptools.String(p.Proto.Type))
|
||||
|
Reference in New Issue
Block a user