summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go98
1 files changed, 60 insertions, 38 deletions
diff --git a/java/java.go b/java/java.go
index 5d75b1fc0..99af2f5ab 100644
--- a/java/java.go
+++ b/java/java.go
@@ -34,8 +34,8 @@ import (
func init() {
android.RegisterModuleType("java_defaults", defaultsFactory)
- android.RegisterModuleType("java_library", LibraryFactory(true))
- android.RegisterModuleType("java_library_static", LibraryFactory(false))
+ android.RegisterModuleType("java_library", LibraryFactory)
+ android.RegisterModuleType("java_library_static", LibraryFactory)
android.RegisterModuleType("java_library_host", LibraryHostFactory)
android.RegisterModuleType("java_binary", BinaryFactory)
android.RegisterModuleType("java_binary_host", BinaryHostFactory)
@@ -107,7 +107,8 @@ type CompilerProperties struct {
// If not blank, set the java version passed to javac as -source and -target
Java_version *string
- // If set to false, don't allow this module to be installed. Defaults to true.
+ // If set to true, allow this module to be dexed and installed on devices. Has no
+ // effect on host modules, which are always considered installable.
Installable *bool
// If set to true, include sources used to compile the module in to the final jar
@@ -192,6 +193,9 @@ type CompilerDeviceProperties struct {
// whether to generate traces (for systrace) for this interface
Generate_traces *bool
+
+ // whether to generate Binder#GetTransaction name method.
+ Generate_get_transaction_name *bool
}
// If true, export a copy of the module as a -hostdex module for host testing.
@@ -309,6 +313,7 @@ type Dependency interface {
type SdkLibraryDependency interface {
HeaderJars(linkType linkType) android.Paths
+ ImplementationJars(linkType linkType) android.Paths
}
type SrcDependency interface {
@@ -644,6 +649,10 @@ func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Opt
flags = append(flags, "-t")
}
+ if Bool(j.deviceProperties.Aidl.Generate_get_transaction_name) {
+ flags = append(flags, "--transaction_names")
+ }
+
return flags
}
@@ -994,6 +1003,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
}
}
+ var stripFiles []string
+
if srcFiles.HasExt(".kt") {
// If there are kotlin files, compile them first but pass all the kotlin and java files
// kotlinc will use the java files to resolve types referenced by the kotlin files, but
@@ -1026,9 +1037,15 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
// Jar kotlin classes into the final jar after javac
jars = append(jars, kotlinJar)
- // Don't add kotlin-stdlib if using (on-device) renamed stdlib
- // (it's expected to be on device bootclasspath)
- if !Bool(j.properties.Renamed_kotlin_stdlib) {
+ if Bool(j.properties.Renamed_kotlin_stdlib) {
+ // Remove any kotlin-reflect related files
+ // TODO(pszczepaniak): Support kotlin-reflect
+ stripFiles = append(stripFiles,
+ "**/*.kotlin_module",
+ "**/*.kotlin_builtins")
+ } else {
+ // Only add kotlin-stdlib if not using (on-device) renamed stdlib
+ // (it's expected to be on device bootclasspath)
jars = append(jars, deps.kotlinStdlib...)
}
}
@@ -1142,7 +1159,8 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
outputFile = jars[0]
} else {
combinedJar := android.PathForModuleOut(ctx, "combined", jarName)
- TransformJarsToJar(ctx, combinedJar, "for javac", jars, manifest, false, nil)
+ TransformJarsToJar(ctx, combinedJar, "for javac", jars, manifest,
+ false, stripFiles, nil)
outputFile = combinedJar
}
@@ -1182,13 +1200,13 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
outputFile = j.instrument(ctx, flags, outputFile, jarName)
}
- if ctx.Device() && j.createDexRule() {
+ if ctx.Device() && (Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) {
var dexOutputFile android.Path
dexOutputFile = j.compileDex(ctx, flags, outputFile, jarName)
if ctx.Failed() {
return
}
- if j.installable() {
+ if Bool(j.properties.Installable) {
outputFile = dexOutputFile
}
}
@@ -1218,7 +1236,8 @@ func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars
// we cannot skip the combine step for now if there is only one jar
// since we have to strip META-INF/TRANSITIVE dir from turbine.jar
combinedJar := android.PathForModuleOut(ctx, "turbine-combined", jarName)
- TransformJarsToJar(ctx, combinedJar, "for turbine", jars, android.OptionalPath{}, false, []string{"META-INF"})
+ TransformJarsToJar(ctx, combinedJar, "for turbine", jars, android.OptionalPath{},
+ false, nil, []string{"META-INF"})
headerJar = combinedJar
if j.properties.Jarjar_rules != nil {
@@ -1250,14 +1269,6 @@ func (j *Module) instrument(ctx android.ModuleContext, flags javaBuilderFlags,
return instrumentedJar
}
-func (j *Module) installable() bool {
- return BoolDefault(j.properties.Installable, true)
-}
-
-func (j *Module) createDexRule() bool {
- return Bool(j.deviceProperties.Compile_dex) || j.installable()
-}
-
var _ Dependency = (*Library)(nil)
func (j *Module) HeaderJars() android.Paths {
@@ -1293,7 +1304,7 @@ type Library struct {
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.compile(ctx)
- if j.installable() {
+ if Bool(j.properties.Installable) || ctx.Host() {
j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
ctx.ModuleName()+".jar", j.outputFile)
}
@@ -1303,22 +1314,16 @@ func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
j.deps(ctx)
}
-func LibraryFactory(installable bool) func() android.Module {
- return func() android.Module {
- module := &Library{}
-
- if !installable {
- module.properties.Installable = proptools.BoolPtr(false)
- }
+func LibraryFactory() android.Module {
+ module := &Library{}
- module.AddProperties(
- &module.Module.properties,
- &module.Module.deviceProperties,
- &module.Module.protoProperties)
+ module.AddProperties(
+ &module.Module.properties,
+ &module.Module.deviceProperties,
+ &module.Module.protoProperties)
- InitJavaModule(module, android.HostAndDeviceSupported)
- return module
- }
+ InitJavaModule(module, android.HostAndDeviceSupported)
+ return module
}
func LibraryHostFactory() android.Module {
@@ -1328,6 +1333,8 @@ func LibraryHostFactory() android.Module {
&module.Module.properties,
&module.Module.protoProperties)
+ module.Module.properties.Installable = proptools.BoolPtr(true)
+
InitJavaModule(module, android.HostSupported)
return module
}
@@ -1367,6 +1374,8 @@ func TestFactory() android.Module {
&module.Module.protoProperties,
&module.testProperties)
+ module.Module.properties.Installable = proptools.BoolPtr(true)
+
InitJavaModule(module, android.HostAndDeviceSupported)
android.InitDefaultableModule(module)
return module
@@ -1380,6 +1389,8 @@ func TestHostFactory() android.Module {
&module.Module.protoProperties,
&module.testProperties)
+ module.Module.properties.Installable = proptools.BoolPtr(true)
+
InitJavaModule(module, android.HostSupported)
android.InitDefaultableModule(module)
return module
@@ -1449,6 +1460,8 @@ func BinaryFactory() android.Module {
&module.Module.protoProperties,
&module.binaryProperties)
+ module.Module.properties.Installable = proptools.BoolPtr(true)
+
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommonFirst)
android.InitDefaultableModule(module)
return module
@@ -1462,6 +1475,8 @@ func BinaryHostFactory() android.Module {
&module.Module.protoProperties,
&module.binaryProperties)
+ module.Module.properties.Installable = proptools.BoolPtr(true)
+
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommonFirst)
android.InitDefaultableModule(module)
return module
@@ -1480,6 +1495,12 @@ type ImportProperties struct {
// List of shared java libs that this module has dependencies to
Libs []string
+
+ // List of files to remove from the jar file(s)
+ Exclude_files []string
+
+ // List of directories to remove from the jar file(s)
+ Exclude_dirs []string
}
type Import struct {
@@ -1488,7 +1509,6 @@ type Import struct {
properties ImportProperties
- classpathFiles android.Paths
combinedClasspathFile android.Path
exportedSdkLibs []string
}
@@ -1514,14 +1534,16 @@ func (j *Import) Name() string {
}
func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
+ android.ExtractSourcesDeps(ctx, j.properties.Jars)
ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
}
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- j.classpathFiles = android.PathsForModuleSrc(ctx, j.properties.Jars)
+ jars := ctx.ExpandSources(j.properties.Jars, nil)
outputFile := android.PathForModuleOut(ctx, "classes.jar")
- TransformJarsToJar(ctx, outputFile, "for prebuilts", j.classpathFiles, android.OptionalPath{}, false, nil)
+ TransformJarsToJar(ctx, outputFile, "for prebuilts", jars, android.OptionalPath{},
+ false, j.properties.Exclude_files, j.properties.Exclude_dirs)
j.combinedClasspathFile = outputFile
ctx.VisitDirectDeps(func(module android.Module) {
@@ -1550,11 +1572,11 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
var _ Dependency = (*Import)(nil)
func (j *Import) HeaderJars() android.Paths {
- return j.classpathFiles
+ return android.Paths{j.combinedClasspathFile}
}
func (j *Import) ImplementationJars() android.Paths {
- return j.classpathFiles
+ return android.Paths{j.combinedClasspathFile}
}
func (j *Import) AidlIncludeDirs() android.Paths {