Merge "Use protoc-gen-javalite for java lite protos"
This commit is contained in:
@@ -351,6 +351,10 @@ func (c *config) BlueprintToolLocation() string {
|
|||||||
|
|
||||||
var _ bootstrap.ConfigBlueprintToolLocation = (*config)(nil)
|
var _ bootstrap.ConfigBlueprintToolLocation = (*config)(nil)
|
||||||
|
|
||||||
|
func (c *config) HostToolPath(ctx PathContext, tool string) Path {
|
||||||
|
return PathForOutput(ctx, "host", c.PrebuiltOS(), "bin", tool)
|
||||||
|
}
|
||||||
|
|
||||||
// HostSystemTool looks for non-hermetic tools from the system we're running on.
|
// HostSystemTool looks for non-hermetic tools from the system we're running on.
|
||||||
// Generally shouldn't be used, but useful to find the XCode SDK, etc.
|
// Generally shouldn't be used, but useful to find the XCode SDK, etc.
|
||||||
func (c *config) HostSystemTool(name string) string {
|
func (c *config) HostSystemTool(name string) string {
|
||||||
|
@@ -161,6 +161,7 @@ type javaBuilderFlags struct {
|
|||||||
kotlincClasspath classpath
|
kotlincClasspath classpath
|
||||||
|
|
||||||
protoFlags []string
|
protoFlags []string
|
||||||
|
protoDeps android.Paths
|
||||||
protoOutTypeFlag string // The flag itself: --java_out
|
protoOutTypeFlag string // The flag itself: --java_out
|
||||||
protoOutParams string // Parameters to that flag: --java_out=$protoOutParams:$outDir
|
protoOutParams string // Parameters to that flag: --java_out=$protoOutParams:$outDir
|
||||||
protoRoot bool
|
protoRoot bool
|
||||||
|
@@ -59,6 +59,7 @@ func genProto(ctx android.ModuleContext, protoFile android.Path, flags javaBuild
|
|||||||
Description: "protoc " + protoFile.Rel(),
|
Description: "protoc " + protoFile.Rel(),
|
||||||
Output: srcJarFile,
|
Output: srcJarFile,
|
||||||
Input: protoFile,
|
Input: protoFile,
|
||||||
|
Implicits: flags.protoDeps,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"protoBase": protoBase,
|
"protoBase": protoBase,
|
||||||
"protoOut": flags.protoOutTypeFlag,
|
"protoOut": flags.protoOutTypeFlag,
|
||||||
@@ -93,14 +94,16 @@ func protoDeps(ctx android.BottomUpMutatorContext, p *android.ProtoProperties) {
|
|||||||
func protoFlags(ctx android.ModuleContext, j *CompilerProperties, p *android.ProtoProperties,
|
func protoFlags(ctx android.ModuleContext, j *CompilerProperties, p *android.ProtoProperties,
|
||||||
flags javaBuilderFlags) javaBuilderFlags {
|
flags javaBuilderFlags) javaBuilderFlags {
|
||||||
|
|
||||||
|
var plugin string
|
||||||
|
|
||||||
switch String(p.Proto.Type) {
|
switch String(p.Proto.Type) {
|
||||||
case "micro":
|
case "micro":
|
||||||
flags.protoOutTypeFlag = "--javamicro_out"
|
flags.protoOutTypeFlag = "--javamicro_out"
|
||||||
case "nano":
|
case "nano":
|
||||||
flags.protoOutTypeFlag = "--javanano_out"
|
flags.protoOutTypeFlag = "--javanano_out"
|
||||||
case "lite":
|
case "lite":
|
||||||
flags.protoOutTypeFlag = "--java_out"
|
plugin = "protoc-gen-javalite"
|
||||||
flags.protoOutParams = "lite"
|
flags.protoOutTypeFlag = "--javalite_out"
|
||||||
case "full", "":
|
case "full", "":
|
||||||
flags.protoOutTypeFlag = "--java_out"
|
flags.protoOutTypeFlag = "--java_out"
|
||||||
default:
|
default:
|
||||||
@@ -108,15 +111,15 @@ func protoFlags(ctx android.ModuleContext, j *CompilerProperties, p *android.Pro
|
|||||||
String(p.Proto.Type))
|
String(p.Proto.Type))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(j.Proto.Output_params) > 0 {
|
flags.protoOutParams = strings.Join(j.Proto.Output_params, ",")
|
||||||
if flags.protoOutParams != "" {
|
|
||||||
flags.protoOutParams += ","
|
|
||||||
}
|
|
||||||
flags.protoOutParams += strings.Join(j.Proto.Output_params, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
flags.protoFlags = android.ProtoFlags(ctx, p)
|
flags.protoFlags = android.ProtoFlags(ctx, p)
|
||||||
flags.protoRoot = android.ProtoCanonicalPathFromRoot(ctx, p)
|
flags.protoRoot = android.ProtoCanonicalPathFromRoot(ctx, p)
|
||||||
|
|
||||||
|
if plugin != "" {
|
||||||
|
path := ctx.Config().HostToolPath(ctx, plugin)
|
||||||
|
flags.protoDeps = append(flags.protoDeps, path)
|
||||||
|
flags.protoFlags = append(flags.protoFlags, "--plugin="+path.String())
|
||||||
|
}
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user