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 {
|
type builderFlags struct {
|
||||||
globalFlags string
|
globalFlags string
|
||||||
arFlags string
|
arFlags string
|
||||||
asFlags string
|
asFlags string
|
||||||
cFlags string
|
cFlags string
|
||||||
toolingCFlags string // A separate set of Cflags for clang LibTooling tools
|
toolingCFlags string // A separate set of Cflags for clang LibTooling tools
|
||||||
conlyFlags string
|
conlyFlags string
|
||||||
cppFlags string
|
cppFlags string
|
||||||
ldFlags string
|
ldFlags string
|
||||||
libFlags string
|
libFlags string
|
||||||
yaccFlags string
|
yaccFlags string
|
||||||
protoFlags string
|
protoFlags string
|
||||||
tidyFlags string
|
protoOutParams string
|
||||||
sAbiFlags string
|
tidyFlags string
|
||||||
yasmFlags string
|
sAbiFlags string
|
||||||
aidlFlags string
|
yasmFlags string
|
||||||
rsFlags string
|
aidlFlags string
|
||||||
toolchain config.Toolchain
|
rsFlags string
|
||||||
clang bool
|
toolchain config.Toolchain
|
||||||
tidy bool
|
clang bool
|
||||||
coverage bool
|
tidy bool
|
||||||
sAbiDump bool
|
coverage bool
|
||||||
|
sAbiDump bool
|
||||||
|
|
||||||
systemIncludeFlags string
|
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
|
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":
|
||||||
|
16
cc/proto.go
16
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")
|
||||||
@@ -46,8 +47,9 @@ func genProto(ctx android.ModuleContext, protoFile android.Path,
|
|||||||
Outputs: android.WritablePaths{ccFile, headerFile},
|
Outputs: android.WritablePaths{ccFile, headerFile},
|
||||||
Input: protoFile,
|
Input: protoFile,
|
||||||
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
|
||||||
}
|
}
|
||||||
|
43
cc/util.go
43
cc/util.go
@@ -97,27 +97,28 @@ func moduleToLibName(module string) (string, error) {
|
|||||||
|
|
||||||
func flagsToBuilderFlags(in Flags) builderFlags {
|
func flagsToBuilderFlags(in Flags) builderFlags {
|
||||||
return builderFlags{
|
return builderFlags{
|
||||||
globalFlags: strings.Join(in.GlobalFlags, " "),
|
globalFlags: strings.Join(in.GlobalFlags, " "),
|
||||||
arFlags: strings.Join(in.ArFlags, " "),
|
arFlags: strings.Join(in.ArFlags, " "),
|
||||||
asFlags: strings.Join(in.AsFlags, " "),
|
asFlags: strings.Join(in.AsFlags, " "),
|
||||||
cFlags: strings.Join(in.CFlags, " "),
|
cFlags: strings.Join(in.CFlags, " "),
|
||||||
toolingCFlags: strings.Join(in.ToolingCFlags, " "),
|
toolingCFlags: strings.Join(in.ToolingCFlags, " "),
|
||||||
conlyFlags: strings.Join(in.ConlyFlags, " "),
|
conlyFlags: strings.Join(in.ConlyFlags, " "),
|
||||||
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, " "),
|
||||||
aidlFlags: strings.Join(in.aidlFlags, " "),
|
protoOutParams: strings.Join(in.protoOutParams, ":"),
|
||||||
rsFlags: strings.Join(in.rsFlags, " "),
|
aidlFlags: strings.Join(in.aidlFlags, " "),
|
||||||
ldFlags: strings.Join(in.LdFlags, " "),
|
rsFlags: strings.Join(in.rsFlags, " "),
|
||||||
libFlags: strings.Join(in.libFlags, " "),
|
ldFlags: strings.Join(in.LdFlags, " "),
|
||||||
tidyFlags: strings.Join(in.TidyFlags, " "),
|
libFlags: strings.Join(in.libFlags, " "),
|
||||||
sAbiFlags: strings.Join(in.SAbiFlags, " "),
|
tidyFlags: strings.Join(in.TidyFlags, " "),
|
||||||
yasmFlags: strings.Join(in.YasmFlags, " "),
|
sAbiFlags: strings.Join(in.SAbiFlags, " "),
|
||||||
toolchain: in.Toolchain,
|
yasmFlags: strings.Join(in.YasmFlags, " "),
|
||||||
clang: in.Clang,
|
toolchain: in.Toolchain,
|
||||||
coverage: in.Coverage,
|
clang: in.Clang,
|
||||||
tidy: in.Tidy,
|
coverage: in.Coverage,
|
||||||
sAbiDump: in.SAbiDump,
|
tidy: in.Tidy,
|
||||||
|
sAbiDump: in.SAbiDump,
|
||||||
|
|
||||||
systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "),
|
systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "),
|
||||||
|
|
||||||
|
@@ -200,8 +200,9 @@ type javaBuilderFlags struct {
|
|||||||
kotlincFlags string
|
kotlincFlags string
|
||||||
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,
|
||||||
@@ -49,10 +49,10 @@ func genProto(ctx android.ModuleContext, outputSrcJar android.WritablePath,
|
|||||||
Output: outputSrcJar,
|
Output: outputSrcJar,
|
||||||
Inputs: protoFiles,
|
Inputs: protoFiles,
|
||||||
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