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:
@@ -242,6 +242,7 @@ type builderFlags struct {
|
|||||||
libFlags string
|
libFlags string
|
||||||
yaccFlags string
|
yaccFlags string
|
||||||
protoFlags string
|
protoFlags string
|
||||||
|
protoOutParams string
|
||||||
tidyFlags string
|
tidyFlags string
|
||||||
sAbiFlags string
|
sAbiFlags string
|
||||||
yasmFlags string
|
yasmFlags 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
|
ToolingCppFlags []string // Flags that apply to C++ source files parsed by clang LibTooling tools
|
||||||
YaccFlags []string // Flags that apply to Yacc source files
|
YaccFlags []string // Flags that apply to Yacc source files
|
||||||
protoFlags []string // Flags that apply to proto 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
|
aidlFlags []string // Flags that apply to aidl source files
|
||||||
rsFlags []string // Flags that apply to renderscript source files
|
rsFlags []string // Flags that apply to renderscript source files
|
||||||
LdFlags []string // Flags that apply to linker command lines
|
LdFlags []string // Flags that apply to linker command lines
|
||||||
|
@@ -153,7 +153,8 @@ func genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
|||||||
srcFiles[i] = cppFile
|
srcFiles[i] = cppFile
|
||||||
genLex(ctx, srcFile, cppFile)
|
genLex(ctx, srcFile, cppFile)
|
||||||
case ".proto":
|
case ".proto":
|
||||||
ccFile, headerFile := genProto(ctx, srcFile, buildFlags.protoFlags)
|
ccFile, headerFile := genProto(ctx, srcFile, buildFlags.protoFlags,
|
||||||
|
buildFlags.protoOutParams)
|
||||||
srcFiles[i] = ccFile
|
srcFiles[i] = ccFile
|
||||||
deps = append(deps, headerFile)
|
deps = append(deps, headerFile)
|
||||||
case ".aidl":
|
case ".aidl":
|
||||||
|
12
cc/proto.go
12
cc/proto.go
@@ -16,6 +16,7 @@ package cc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
@@ -27,15 +28,15 @@ func init() {
|
|||||||
var (
|
var (
|
||||||
proto = pctx.AndroidStaticRule("protoc",
|
proto = pctx.AndroidStaticRule("protoc",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$protocCmd --cpp_out=$outDir $protoFlags $in",
|
Command: "$protocCmd --cpp_out=$protoOutParams:$outDir $protoFlags $in",
|
||||||
CommandDeps: []string{"$protocCmd"},
|
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
|
// 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.
|
// the paths to the generated files.
|
||||||
func genProto(ctx android.ModuleContext, protoFile android.Path,
|
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")
|
ccFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.cc")
|
||||||
headerFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.h")
|
headerFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.h")
|
||||||
@@ -48,6 +49,7 @@ func genProto(ctx android.ModuleContext, protoFile android.Path,
|
|||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"outDir": android.ProtoDir(ctx).String(),
|
"outDir": android.ProtoDir(ctx).String(),
|
||||||
"protoFlags": protoFlags,
|
"protoFlags": protoFlags,
|
||||||
|
"protoOutParams": protoOutParams,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -97,5 +99,9 @@ func protoFlags(ctx ModuleContext, flags Flags, p *android.ProtoProperties) Flag
|
|||||||
|
|
||||||
flags.protoFlags = android.ProtoFlags(ctx, p)
|
flags.protoFlags = android.ProtoFlags(ctx, p)
|
||||||
|
|
||||||
|
if proptools.String(p.Proto.Type) == "lite" {
|
||||||
|
flags.protoOutParams = []string{"lite"}
|
||||||
|
}
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
@@ -106,6 +106,7 @@ func flagsToBuilderFlags(in Flags) builderFlags {
|
|||||||
cppFlags: strings.Join(in.CppFlags, " "),
|
cppFlags: strings.Join(in.CppFlags, " "),
|
||||||
yaccFlags: strings.Join(in.YaccFlags, " "),
|
yaccFlags: strings.Join(in.YaccFlags, " "),
|
||||||
protoFlags: strings.Join(in.protoFlags, " "),
|
protoFlags: strings.Join(in.protoFlags, " "),
|
||||||
|
protoOutParams: strings.Join(in.protoOutParams, ":"),
|
||||||
aidlFlags: strings.Join(in.aidlFlags, " "),
|
aidlFlags: strings.Join(in.aidlFlags, " "),
|
||||||
rsFlags: strings.Join(in.rsFlags, " "),
|
rsFlags: strings.Join(in.rsFlags, " "),
|
||||||
ldFlags: strings.Join(in.LdFlags, " "),
|
ldFlags: strings.Join(in.LdFlags, " "),
|
||||||
|
@@ -201,7 +201,8 @@ type javaBuilderFlags struct {
|
|||||||
kotlincClasspath classpath
|
kotlincClasspath classpath
|
||||||
|
|
||||||
protoFlags []string
|
protoFlags []string
|
||||||
protoOutFlag 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,
|
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 {
|
if len(protoFiles) > 0 {
|
||||||
protoSrcJar := android.PathForModuleGen(ctx, "proto.srcjar")
|
protoSrcJar := android.PathForModuleGen(ctx, "proto.srcjar")
|
||||||
genProto(ctx, protoSrcJar, protoFiles,
|
genProto(ctx, protoSrcJar, protoFiles,
|
||||||
flags.protoFlags, flags.protoOutFlag, "")
|
flags.protoFlags, flags.protoOutTypeFlag, flags.protoOutParams)
|
||||||
|
|
||||||
outSrcFiles = append(outSrcFiles, protoSrcJar)
|
outSrcFiles = append(outSrcFiles, protoSrcJar)
|
||||||
}
|
}
|
||||||
|
@@ -31,17 +31,17 @@ var (
|
|||||||
proto = pctx.AndroidStaticRule("protoc",
|
proto = pctx.AndroidStaticRule("protoc",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `rm -rf $outDir && mkdir -p $outDir && ` +
|
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`,
|
`${config.SoongZipCmd} -jar -o $out -C $outDir -D $outDir`,
|
||||||
CommandDeps: []string{
|
CommandDeps: []string{
|
||||||
"$protocCmd",
|
"$protocCmd",
|
||||||
"${config.SoongZipCmd}",
|
"${config.SoongZipCmd}",
|
||||||
},
|
},
|
||||||
}, "protoFlags", "protoOut", "protoOutFlags", "outDir")
|
}, "protoFlags", "protoOut", "protoOutParams", "outDir")
|
||||||
)
|
)
|
||||||
|
|
||||||
func genProto(ctx android.ModuleContext, outputSrcJar android.WritablePath,
|
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{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: proto,
|
Rule: proto,
|
||||||
@@ -51,7 +51,7 @@ func genProto(ctx android.ModuleContext, outputSrcJar android.WritablePath,
|
|||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"outDir": android.ProtoDir(ctx).String(),
|
"outDir": android.ProtoDir(ctx).String(),
|
||||||
"protoOut": protoOut,
|
"protoOut": protoOut,
|
||||||
"protoOutFlags": protoOutFlags,
|
"protoOutParams": protoOutParams,
|
||||||
"protoFlags": strings.Join(protoFlags, " "),
|
"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 {
|
func protoFlags(ctx android.ModuleContext, p *android.ProtoProperties, flags javaBuilderFlags) javaBuilderFlags {
|
||||||
switch proptools.String(p.Proto.Type) {
|
switch proptools.String(p.Proto.Type) {
|
||||||
case "micro":
|
case "micro":
|
||||||
flags.protoOutFlag = "--javamicro_out"
|
flags.protoOutTypeFlag = "--javamicro_out"
|
||||||
case "nano":
|
case "nano":
|
||||||
flags.protoOutFlag = "--javanano_out"
|
flags.protoOutTypeFlag = "--javanano_out"
|
||||||
case "lite", "full", "":
|
case "lite":
|
||||||
flags.protoOutFlag = "--java_out"
|
flags.protoOutTypeFlag = "--java_out"
|
||||||
|
flags.protoOutParams = "lite"
|
||||||
|
case "full", "":
|
||||||
|
flags.protoOutTypeFlag = "--java_out"
|
||||||
default:
|
default:
|
||||||
ctx.PropertyErrorf("proto.type", "unknown proto type %q",
|
ctx.PropertyErrorf("proto.type", "unknown proto type %q",
|
||||||
proptools.String(p.Proto.Type))
|
proptools.String(p.Proto.Type))
|
||||||
|
Reference in New Issue
Block a user