Use jars containg sources for java generators
srcFileLists was an ill-fated attempt to deal with generators that
produce a set of java sources that is not known ahead of time.
For example, the list of files produced by protoc depends on the
package statement in the .proto file. srcFileLists put the list
of generated files into a file, which was then passed to javac
using the @file syntax. This worked, but it was too easy to cause
missing dependencies, and will not work well in a future distributed
build environment.
Switch to putting generated sources into a jar, and then pass them
jar to javac using -sourcepath.
Test: m checkbuild
Change-Id: Iaab7a588a6c1239f7bf46e4f1b102b3ef517619b
diff --git a/java/gen.go b/java/gen.go
index e55be91..e12a71c 100644
--- a/java/gen.go
+++ b/java/gen.go
@@ -85,7 +85,7 @@
}
func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
- flags javaBuilderFlags) (android.Paths, android.Paths) {
+ flags javaBuilderFlags) (android.Paths, classpath) {
var protoFiles android.Paths
outSrcFiles := make(android.Paths, 0, len(srcFiles))
@@ -106,16 +106,17 @@
}
}
- var outSrcFileLists android.Paths
+ var outSrcJars classpath
if len(protoFiles) > 0 {
- protoFileList := genProto(ctx, protoFiles,
+ protoSrcJar := android.PathForModuleGen(ctx, "proto.src.jar")
+ genProto(ctx, protoSrcJar, protoFiles,
flags.protoFlags, flags.protoOutFlag, "")
- outSrcFileLists = append(outSrcFileLists, protoFileList)
+ outSrcJars = append(outSrcJars, protoSrcJar)
}
- return outSrcFiles, outSrcFileLists
+ return outSrcFiles, outSrcJars
}
func LogtagsSingleton() blueprint.Singleton {