Add support for .proto files in java modules
Test: m -j checkbuild Change-Id: Ia03429948baebff85164a91a34507866c97a08ef
This commit is contained in:
45
java/java.go
45
java/java.go
@@ -49,7 +49,6 @@ func init() {
|
||||
|
||||
// TODO:
|
||||
// Autogenerated files:
|
||||
// Proto
|
||||
// Renderscript
|
||||
// Post-jar passes:
|
||||
// Proguard
|
||||
@@ -145,6 +144,7 @@ type Module struct {
|
||||
android.DefaultableModuleBase
|
||||
|
||||
properties CompilerProperties
|
||||
protoProperties android.ProtoProperties
|
||||
deviceProperties CompilerDeviceProperties
|
||||
|
||||
// output file suitable for inserting into the classpath of another compile
|
||||
@@ -296,6 +296,24 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||
|
||||
android.ExtractSourcesDeps(ctx, j.properties.Srcs)
|
||||
android.ExtractSourcesDeps(ctx, j.properties.Java_resources)
|
||||
|
||||
if j.hasSrcExt(".proto") {
|
||||
protoDeps(ctx, &j.protoProperties)
|
||||
}
|
||||
}
|
||||
|
||||
func hasSrcExt(srcs []string, ext string) bool {
|
||||
for _, src := range srcs {
|
||||
if filepath.Ext(src) == ext {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (j *Module) hasSrcExt(ext string) bool {
|
||||
return hasSrcExt(j.properties.Srcs, ext)
|
||||
}
|
||||
|
||||
func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.OptionalPath,
|
||||
@@ -416,7 +434,15 @@ func (j *Module) compile(ctx android.ModuleContext) {
|
||||
|
||||
srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
|
||||
|
||||
srcFiles = j.genSources(ctx, srcFiles, flags)
|
||||
if hasSrcExt(srcFiles.Strings(), ".proto") {
|
||||
flags = protoFlags(ctx, &j.protoProperties, flags)
|
||||
}
|
||||
|
||||
var srcFileLists android.Paths
|
||||
|
||||
srcFiles, srcFileLists = j.genSources(ctx, srcFiles, flags)
|
||||
|
||||
srcFileLists = append(srcFileLists, deps.srcFileLists...)
|
||||
|
||||
ctx.VisitDirectDeps(func(module blueprint.Module) {
|
||||
if gen, ok := module.(genrule.SourceFileGenerator); ok {
|
||||
@@ -424,7 +450,7 @@ func (j *Module) compile(ctx android.ModuleContext) {
|
||||
}
|
||||
})
|
||||
|
||||
deps.srcFileLists = append(deps.srcFileLists, j.ExtraSrcLists...)
|
||||
srcFileLists = append(srcFileLists, j.ExtraSrcLists...)
|
||||
|
||||
var jars android.Paths
|
||||
|
||||
@@ -436,12 +462,12 @@ func (j *Module) compile(ctx android.ModuleContext) {
|
||||
// a rebuild when error-prone is turned off).
|
||||
// TODO(ccross): Once we always compile with javac9 we may be able to conditionally
|
||||
// enable error-prone without affecting the output class files.
|
||||
errorprone := RunErrorProne(ctx, srcFiles, deps.srcFileLists, flags, nil)
|
||||
errorprone := RunErrorProne(ctx, srcFiles, srcFileLists, flags)
|
||||
extraJarDeps = append(extraJarDeps, errorprone)
|
||||
}
|
||||
|
||||
// Compile java sources into .class files
|
||||
classes := TransformJavaToClasses(ctx, srcFiles, deps.srcFileLists, flags, extraJarDeps)
|
||||
classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, extraJarDeps)
|
||||
if ctx.Failed() {
|
||||
return
|
||||
}
|
||||
@@ -629,7 +655,8 @@ func LibraryFactory(installable bool) func() android.Module {
|
||||
|
||||
module.AddProperties(
|
||||
&module.Module.properties,
|
||||
&module.Module.deviceProperties)
|
||||
&module.Module.deviceProperties,
|
||||
&module.Module.protoProperties)
|
||||
|
||||
InitJavaModule(module, android.HostAndDeviceSupported)
|
||||
return module
|
||||
@@ -639,7 +666,9 @@ func LibraryFactory(installable bool) func() android.Module {
|
||||
func LibraryHostFactory() android.Module {
|
||||
module := &Library{}
|
||||
|
||||
module.AddProperties(&module.Module.properties)
|
||||
module.AddProperties(
|
||||
&module.Module.properties,
|
||||
&module.Module.protoProperties)
|
||||
|
||||
InitJavaModule(module, android.HostSupported)
|
||||
return module
|
||||
@@ -685,6 +714,7 @@ func BinaryFactory() android.Module {
|
||||
module.AddProperties(
|
||||
&module.Module.properties,
|
||||
&module.Module.deviceProperties,
|
||||
&module.Module.protoProperties,
|
||||
&module.binaryProperties)
|
||||
|
||||
InitJavaModule(module, android.HostAndDeviceSupported)
|
||||
@@ -697,6 +727,7 @@ func BinaryHostFactory() android.Module {
|
||||
module.AddProperties(
|
||||
&module.Module.properties,
|
||||
&module.Module.deviceProperties,
|
||||
&module.Module.protoProperties,
|
||||
&module.binaryProperties)
|
||||
|
||||
InitJavaModule(module, android.HostSupported)
|
||||
|
Reference in New Issue
Block a user