diff options
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/java/java.go b/java/java.go index d8bc0c2cb..bab77c5a6 100644 --- a/java/java.go +++ b/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 @@ -153,9 +153,6 @@ type Module struct { // output file containing classes.dex dexJarFile android.Path - // output files containing resources - resourceJarFiles android.Paths - // output file suitable for installing or running outputFile android.Path @@ -173,7 +170,6 @@ type Module struct { type Dependency interface { ClasspathFiles() android.Paths - ResourceJarFiles() android.Paths AidlIncludeDirs() android.Paths } @@ -285,9 +281,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module) } } else { - if j.deviceProperties.Dex { - ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...) - } + // TODO(ccross): add hostdex support } } ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...) @@ -296,6 +290,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, @@ -364,7 +376,6 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { case staticLibTag: deps.classpath = append(deps.classpath, dep.ClasspathFiles()...) deps.staticJars = append(deps.staticJars, dep.ClasspathFiles()...) - deps.staticJarResources = append(deps.staticJarResources, dep.ResourceJarFiles()...) case frameworkResTag: if ctx.ModuleName() == "framework" { // framework.jar has a one-off dependency on the R.java and Manifest.java files @@ -416,7 +427,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 +443,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 +455,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 } @@ -462,26 +481,20 @@ func (j *Module) compile(ctx android.ModuleContext) { resDeps = append(resDeps, fileDeps...) if proptools.Bool(j.properties.Include_srcs) { - srcArgs, srcDeps := ResourceFilesToJarArgs(ctx, j.properties.Srcs, j.properties.Exclude_srcs) + srcArgs, srcDeps := SourceFilesToJarArgs(ctx, j.properties.Srcs, j.properties.Exclude_srcs) resArgs = append(resArgs, srcArgs...) resDeps = append(resDeps, srcDeps...) } if len(resArgs) > 0 { - // Combine classes + resources into classes-full-debug.jar resourceJar := TransformResourcesToJar(ctx, resArgs, resDeps) if ctx.Failed() { return } - j.resourceJarFiles = append(j.resourceJarFiles, resourceJar) jars = append(jars, resourceJar) } - // Propagate the resources from the transitive closure of static dependencies for copying - // into dex jars - j.resourceJarFiles = append(j.resourceJarFiles, deps.staticJarResources...) - // static classpath jars have the resources in them, so the resource jars aren't necessary here jars = append(jars, deps.staticJars...) @@ -503,7 +516,7 @@ func (j *Module) compile(ctx android.ModuleContext) { j.classpathFile = outputFile // TODO(ccross): handle hostdex - if ctx.Device() && len(srcFiles) > 0 && j.installable() { + if ctx.Device() && j.installable() { dxFlags := j.deviceProperties.Dxflags if false /* emma enabled */ { // If you instrument class files that have local variable debug information in @@ -556,17 +569,12 @@ func (j *Module) compile(ctx android.ModuleContext) { return } - // Compile classes.jar into classes.dex - dexJarFile := TransformClassesJarToDexJar(ctx, desugarJar, flags) + // Compile classes.jar into classes.dex and then javalib.jar + outputFile = TransformClassesJarToDexJar(ctx, "javalib.jar", desugarJar, flags) if ctx.Failed() { return } - jars := android.Paths{dexJarFile} - jars = append(jars, j.resourceJarFiles...) - - outputFile = TransformJarsToJar(ctx, "javalib.jar", jars, android.OptionalPath{}, true) - j.dexJarFile = outputFile } ctx.CheckbuildFile(outputFile) @@ -583,10 +591,6 @@ func (j *Module) ClasspathFiles() android.Paths { return android.Paths{j.classpathFile} } -func (j *Module) ResourceJarFiles() android.Paths { - return j.resourceJarFiles -} - func (j *Module) AidlIncludeDirs() android.Paths { return j.exportAidlIncludeDirs } @@ -629,7 +633,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 +644,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 +692,7 @@ func BinaryFactory() android.Module { module.AddProperties( &module.Module.properties, &module.Module.deviceProperties, + &module.Module.protoProperties, &module.binaryProperties) InitJavaModule(module, android.HostAndDeviceSupported) @@ -697,6 +705,7 @@ func BinaryHostFactory() android.Module { module.AddProperties( &module.Module.properties, &module.Module.deviceProperties, + &module.Module.protoProperties, &module.binaryProperties) InitJavaModule(module, android.HostSupported) @@ -748,11 +757,6 @@ func (j *Import) ClasspathFiles() android.Paths { return j.classpathFiles } -func (j *Import) ResourceJarFiles() android.Paths { - // resources are in the ClasspathFiles - return nil -} - func (j *Import) AidlIncludeDirs() android.Paths { return nil } |