Merge changes from topics "soong_logtags", "droiddoc_srcjars"
* changes: Fix genrules depending on Go tools Use logtags without merged file Export extract-srcjars.sh to Make Remove partial javastream proto support Add support for .srcjar files from genrules and srcs Fix java AIDL properties to match C/C++ Fix proto flags in java
This commit is contained in:
commit
6dfde48ba1
9 changed files with 49 additions and 28 deletions
|
@ -108,6 +108,7 @@ type ModuleContext interface {
|
||||||
|
|
||||||
ModuleSubDir() string
|
ModuleSubDir() string
|
||||||
|
|
||||||
|
VisitDirectDepsBlueprint(visit func(blueprint.Module))
|
||||||
VisitDirectDeps(visit func(Module))
|
VisitDirectDeps(visit func(Module))
|
||||||
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
||||||
VisitDepsDepthFirst(visit func(Module))
|
VisitDepsDepthFirst(visit func(Module))
|
||||||
|
@ -686,6 +687,10 @@ func (a *androidModuleContext) validateAndroidModule(module blueprint.Module) Mo
|
||||||
return aModule
|
return aModule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *androidModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
|
||||||
|
a.ModuleContext.VisitDirectDeps(visit)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *androidModuleContext) VisitDirectDeps(visit func(Module)) {
|
func (a *androidModuleContext) VisitDirectDeps(visit func(Module)) {
|
||||||
a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
||||||
if aModule := a.validateAndroidModule(module); aModule != nil {
|
if aModule := a.validateAndroidModule(module); aModule != nil {
|
||||||
|
|
|
@ -158,7 +158,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
tools := map[string]android.Path{}
|
tools := map[string]android.Path{}
|
||||||
|
|
||||||
if len(g.properties.Tools) > 0 {
|
if len(g.properties.Tools) > 0 {
|
||||||
ctx.VisitDirectDeps(func(module android.Module) {
|
ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
||||||
switch ctx.OtherModuleDependencyTag(module) {
|
switch ctx.OtherModuleDependencyTag(module) {
|
||||||
case android.SourceDepTag:
|
case android.SourceDepTag:
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
|
@ -167,6 +167,14 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
var path android.OptionalPath
|
var path android.OptionalPath
|
||||||
|
|
||||||
if t, ok := module.(HostToolProvider); ok {
|
if t, ok := module.(HostToolProvider); ok {
|
||||||
|
if !t.(android.Module).Enabled() {
|
||||||
|
if ctx.AConfig().AllowMissingDependencies() {
|
||||||
|
ctx.AddMissingDependencies([]string{tool})
|
||||||
|
} else {
|
||||||
|
ctx.ModuleErrorf("depends on disabled module %q", tool)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
path = t.HostToolPath()
|
path = t.HostToolPath()
|
||||||
} else if t, ok := module.(bootstrap.GoBinaryTool); ok {
|
} else if t, ok := module.(bootstrap.GoBinaryTool); ok {
|
||||||
if s, err := filepath.Rel(android.PathForOutput(ctx).String(), t.InstallPath()); err == nil {
|
if s, err := filepath.Rel(android.PathForOutput(ctx).String(), t.InstallPath()); err == nil {
|
||||||
|
|
|
@ -186,7 +186,7 @@ type javaBuilderFlags struct {
|
||||||
kotlincFlags string
|
kotlincFlags string
|
||||||
kotlincClasspath classpath
|
kotlincClasspath classpath
|
||||||
|
|
||||||
protoFlags string
|
protoFlags []string
|
||||||
protoOutFlag string
|
protoOutFlag string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ func init() {
|
||||||
pctx.SourcePathVariable("JrtFsJar", "${JavaHome}/lib/jrt-fs.jar")
|
pctx.SourcePathVariable("JrtFsJar", "${JavaHome}/lib/jrt-fs.jar")
|
||||||
pctx.SourcePathVariable("Ziptime", "prebuilts/build-tools/${hostPrebuiltTag}/bin/ziptime")
|
pctx.SourcePathVariable("Ziptime", "prebuilts/build-tools/${hostPrebuiltTag}/bin/ziptime")
|
||||||
|
|
||||||
pctx.SourcePathVariable("ExtractSrcJarsCmd", "build/soong/scripts/extract-src-jars.sh")
|
pctx.SourcePathVariable("ExtractSrcJarsCmd", "build/soong/scripts/extract-srcjars.sh")
|
||||||
pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh")
|
pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh")
|
||||||
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
|
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
|
||||||
pctx.HostBinToolVariable("MergeZipsCmd", "merge_zips")
|
pctx.HostBinToolVariable("MergeZipsCmd", "merge_zips")
|
||||||
|
|
|
@ -61,4 +61,5 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Strict("SOONG_JAVAC_WRAPPER", "${SoongJavacWrapper}")
|
ctx.Strict("SOONG_JAVAC_WRAPPER", "${SoongJavacWrapper}")
|
||||||
|
ctx.Strict("EXTRACT_SRCJARS", "${ExtractSrcJarsCmd}")
|
||||||
}
|
}
|
||||||
|
|
12
java/gen.go
12
java/gen.go
|
@ -42,7 +42,7 @@ var (
|
||||||
|
|
||||||
logtags = pctx.AndroidStaticRule("logtags",
|
logtags = pctx.AndroidStaticRule("logtags",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$logtagsCmd -o $out $in $allLogtagsFile",
|
Command: "$logtagsCmd -o $out $in",
|
||||||
CommandDeps: []string{"$logtagsCmd"},
|
CommandDeps: []string{"$logtagsCmd"},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ func genLogtags(ctx android.ModuleContext, logtagsFile android.Path) android.Pat
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||||
flags javaBuilderFlags) (android.Paths, android.Paths) {
|
flags javaBuilderFlags) android.Paths {
|
||||||
|
|
||||||
var protoFiles android.Paths
|
var protoFiles android.Paths
|
||||||
outSrcFiles := make(android.Paths, 0, len(srcFiles))
|
outSrcFiles := make(android.Paths, 0, len(srcFiles))
|
||||||
|
@ -106,17 +106,15 @@ func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var outSrcJars android.Paths
|
|
||||||
|
|
||||||
if len(protoFiles) > 0 {
|
if len(protoFiles) > 0 {
|
||||||
protoSrcJar := android.PathForModuleGen(ctx, "proto.src.jar")
|
protoSrcJar := android.PathForModuleGen(ctx, "proto.srcjar")
|
||||||
genProto(ctx, protoSrcJar, protoFiles,
|
genProto(ctx, protoSrcJar, protoFiles,
|
||||||
flags.protoFlags, flags.protoOutFlag, "")
|
flags.protoFlags, flags.protoOutFlag, "")
|
||||||
|
|
||||||
outSrcJars = append(outSrcJars, protoSrcJar)
|
outSrcFiles = append(outSrcFiles, protoSrcJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
return outSrcFiles, outSrcJars
|
return outSrcFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
func LogtagsSingleton() blueprint.Singleton {
|
func LogtagsSingleton() blueprint.Singleton {
|
||||||
|
|
30
java/java.go
30
java/java.go
|
@ -136,12 +136,17 @@ type CompilerDeviceProperties struct {
|
||||||
// if not blank, set to the version of the sdk to compile against
|
// if not blank, set to the version of the sdk to compile against
|
||||||
Sdk_version *string
|
Sdk_version *string
|
||||||
|
|
||||||
// directories to pass to aidl tool
|
Aidl struct {
|
||||||
Aidl_includes []string
|
// Top level directories to pass to aidl tool
|
||||||
|
Include_dirs []string
|
||||||
|
|
||||||
// directories that should be added as include directories
|
// Directories rooted at the Android.bp file to pass to aidl tool
|
||||||
// for any aidl sources of modules that depend on this module
|
Local_include_dirs []string
|
||||||
Export_aidl_include_dirs []string
|
|
||||||
|
// directories that should be added as include directories for any aidl sources of modules
|
||||||
|
// that depend on this module, as well as to aidl for this module.
|
||||||
|
Export_include_dirs []string
|
||||||
|
}
|
||||||
|
|
||||||
// If true, export a copy of the module as a -hostdex module for host testing.
|
// If true, export a copy of the module as a -hostdex module for host testing.
|
||||||
Hostdex *bool
|
Hostdex *bool
|
||||||
|
@ -377,7 +382,11 @@ func (j *Module) hasSrcExt(ext string) bool {
|
||||||
func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
|
func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
|
||||||
aidlIncludeDirs android.Paths) []string {
|
aidlIncludeDirs android.Paths) []string {
|
||||||
|
|
||||||
localAidlIncludes := android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl_includes)
|
aidlIncludes := android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Local_include_dirs)
|
||||||
|
aidlIncludes = append(aidlIncludes,
|
||||||
|
android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs)...)
|
||||||
|
aidlIncludes = append(aidlIncludes,
|
||||||
|
android.PathsForSource(ctx, j.deviceProperties.Aidl.Include_dirs)...)
|
||||||
|
|
||||||
var flags []string
|
var flags []string
|
||||||
if aidlPreprocess.Valid() {
|
if aidlPreprocess.Valid() {
|
||||||
|
@ -387,7 +396,7 @@ func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Opt
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
|
flags = append(flags, android.JoinWithPrefix(j.exportAidlIncludeDirs.Strings(), "-I"))
|
||||||
flags = append(flags, android.JoinWithPrefix(localAidlIncludes.Strings(), "-I"))
|
flags = append(flags, android.JoinWithPrefix(aidlIncludes.Strings(), "-I"))
|
||||||
flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
|
flags = append(flags, "-I"+android.PathForModuleSrc(ctx).String())
|
||||||
if src := android.ExistentPathForSource(ctx, "", ctx.ModuleDir(), "src"); src.Valid() {
|
if src := android.ExistentPathForSource(ctx, "", ctx.ModuleDir(), "src"); src.Valid() {
|
||||||
flags = append(flags, "-I"+src.String())
|
flags = append(flags, "-I"+src.String())
|
||||||
|
@ -528,7 +537,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
|
||||||
|
|
||||||
func (j *Module) compile(ctx android.ModuleContext) {
|
func (j *Module) compile(ctx android.ModuleContext) {
|
||||||
|
|
||||||
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Export_aidl_include_dirs)
|
j.exportAidlIncludeDirs = android.PathsForModuleSrc(ctx, j.deviceProperties.Aidl.Export_include_dirs)
|
||||||
|
|
||||||
deps := j.collectDeps(ctx)
|
deps := j.collectDeps(ctx)
|
||||||
flags := j.collectBuilderFlags(ctx, deps)
|
flags := j.collectBuilderFlags(ctx, deps)
|
||||||
|
@ -541,8 +550,9 @@ func (j *Module) compile(ctx android.ModuleContext) {
|
||||||
flags = protoFlags(ctx, &j.protoProperties, flags)
|
flags = protoFlags(ctx, &j.protoProperties, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
var srcJars android.Paths
|
srcFiles = j.genSources(ctx, srcFiles, flags)
|
||||||
srcFiles, srcJars = j.genSources(ctx, srcFiles, flags)
|
|
||||||
|
srcJars := srcFiles.FilterByExt(".srcjar")
|
||||||
srcJars = append(srcJars, deps.srcJars...)
|
srcJars = append(srcJars, deps.srcJars...)
|
||||||
srcJars = append(srcJars, j.ExtraSrcJars...)
|
srcJars = append(srcJars, j.ExtraSrcJars...)
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
package java
|
package java
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
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, protoOutFlags string) {
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: proto,
|
Rule: proto,
|
||||||
|
@ -50,7 +52,7 @@ func genProto(ctx android.ModuleContext, outputSrcJar android.WritablePath,
|
||||||
"outDir": android.ProtoDir(ctx).String(),
|
"outDir": android.ProtoDir(ctx).String(),
|
||||||
"protoOut": protoOut,
|
"protoOut": protoOut,
|
||||||
"protoOutFlags": protoOutFlags,
|
"protoOutFlags": protoOutFlags,
|
||||||
"protoFlags": protoFlags,
|
"protoFlags": strings.Join(protoFlags, " "),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -61,10 +63,6 @@ func protoDeps(ctx android.BottomUpMutatorContext, p *android.ProtoProperties) {
|
||||||
ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-micro")
|
ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-micro")
|
||||||
case "nano":
|
case "nano":
|
||||||
ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-nano")
|
ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-nano")
|
||||||
case "stream":
|
|
||||||
// TODO(ccross): add dependency on protoc-gen-java-stream binary
|
|
||||||
ctx.PropertyErrorf("proto.type", `"stream" not supported yet`)
|
|
||||||
// No library for stream protobufs
|
|
||||||
case "lite", "":
|
case "lite", "":
|
||||||
ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-lite")
|
ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-lite")
|
||||||
case "full":
|
case "full":
|
||||||
|
@ -85,13 +83,14 @@ func protoFlags(ctx android.ModuleContext, p *android.ProtoProperties, flags jav
|
||||||
flags.protoOutFlag = "--javamicro_out"
|
flags.protoOutFlag = "--javamicro_out"
|
||||||
case "nano":
|
case "nano":
|
||||||
flags.protoOutFlag = "--javanano_out"
|
flags.protoOutFlag = "--javanano_out"
|
||||||
case "stream":
|
|
||||||
flags.protoOutFlag = "--javastream_out"
|
|
||||||
case "lite", "full", "":
|
case "lite", "full", "":
|
||||||
flags.protoOutFlag = "--java_out"
|
flags.protoOutFlag = "--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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flags.protoFlags = android.ProtoFlags(ctx, p)
|
||||||
|
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue