aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2018-06-26 17:59:05 -0700
committerColin Cross <ccross@android.com>2018-07-11 05:35:59 +0000
commit9ae1b927d46cab40a3d42945c46199471f2d541e (patch)
tree7c2c241451dd7f6ac675af06fdc439e057338ca5
parentf33dca0ada3908edd2db76c0f5a00be44b14d70c (diff)
downloadbuild_soong-9ae1b927d46cab40a3d42945c46199471f2d541e.tar.gz
build_soong-9ae1b927d46cab40a3d42945c46199471f2d541e.tar.bz2
build_soong-9ae1b927d46cab40a3d42945c46199471f2d541e.zip
Don't install java libraries by default
Very few java libraries need to be installed, most are statically included in other modules. Device modules that are not installed also don't need to be dexed, saving checkbuild time. Change the default for java_library to not be installed, and allow libraries that should be installed to specify installed: true. This makes java_libary and java_library_static identical. It also simplifies some corner cases when converting from Make to Soong if a module is built for the host (which doesn't differentiate between static and non-static/installable) and statically for the device, which couldn't be represented in a single java_library in soong. Bug: 110885583 Test: m checkbuild, compare presubmit target files Change-Id: Idc0841c39a17cebd7bac3559c9408596d167a393
-rw-r--r--java/aar.go1
-rw-r--r--java/androidmk.go4
-rw-r--r--java/app.go2
-rw-r--r--java/java.go53
-rw-r--r--java/java_test.go2
-rw-r--r--java/sdk_library.go6
6 files changed, 34 insertions, 34 deletions
diff --git a/java/aar.go b/java/aar.go
index a4069bb8..91e2f7f0 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -323,7 +323,6 @@ func AndroidLibraryFactory() android.Module {
&module.androidLibraryProperties)
module.androidLibraryProperties.BuildAAR = true
- module.properties.Installable = proptools.BoolPtr(false)
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
return module
diff --git a/java/androidmk.go b/java/androidmk.go
index 79cf3175..5740eca9 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -37,7 +37,7 @@ func (library *Library) AndroidMk() android.AndroidMkData {
fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(logtags, " "))
}
- if library.properties.Installable != nil && *library.properties.Installable == false {
+ if library.installFile == nil {
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
}
if library.dexJarFile != nil {
@@ -85,7 +85,7 @@ func (library *Library) AndroidMk() android.AndroidMkData {
fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES")
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.implementationJarFile.String())
- if library.properties.Installable != nil && *library.properties.Installable == false {
+ if library.installFile == nil {
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
}
if library.dexJarFile != nil {
diff --git a/java/app.go b/java/app.go
index f4de419b..a6a06fd3 100644
--- a/java/app.go
+++ b/java/app.go
@@ -187,6 +187,7 @@ func AndroidAppFactory() android.Module {
module.Module.deviceProperties.Optimize.Shrink = proptools.BoolPtr(true)
module.Module.properties.Instrument = true
+ module.Module.properties.Installable = proptools.BoolPtr(true)
module.AddProperties(
&module.Module.properties,
@@ -225,6 +226,7 @@ func AndroidTestFactory() android.Module {
module := &AndroidTest{}
module.Module.deviceProperties.Optimize.Enabled = proptools.BoolPtr(true)
+ module.Module.properties.Installable = proptools.BoolPtr(true)
module.AddProperties(
&module.Module.properties,
diff --git a/java/java.go b/java/java.go
index 5d75b1fc..9ae05f3c 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
@@ -1182,13 +1183,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
}
}
@@ -1250,14 +1251,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 +1286,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 +1296,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 +1315,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 +1356,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 +1371,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 +1442,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 +1457,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
diff --git a/java/java_test.go b/java/java_test.go
index 572db2f7..537bdb92 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -74,7 +74,7 @@ func testContext(config android.Config, bp string,
ctx.RegisterModuleType("android_app", android.ModuleFactoryAdaptor(AndroidAppFactory))
ctx.RegisterModuleType("android_library", android.ModuleFactoryAdaptor(AndroidLibraryFactory))
ctx.RegisterModuleType("java_binary_host", android.ModuleFactoryAdaptor(BinaryHostFactory))
- ctx.RegisterModuleType("java_library", android.ModuleFactoryAdaptor(LibraryFactory(true)))
+ ctx.RegisterModuleType("java_library", android.ModuleFactoryAdaptor(LibraryFactory))
ctx.RegisterModuleType("java_library_host", android.ModuleFactoryAdaptor(LibraryHostFactory))
ctx.RegisterModuleType("java_import", android.ModuleFactoryAdaptor(ImportFactory))
ctx.RegisterModuleType("java_defaults", android.ModuleFactoryAdaptor(defaultsFactory))
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 5dfc32f6..e4cfd417 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -331,7 +331,7 @@ func (module *sdkLibrary) createStubsLibrary(mctx android.TopDownMutatorContext,
props.Product_specific = proptools.BoolPtr(true)
}
- mctx.CreateModule(android.ModuleFactoryAdaptor(LibraryFactory(false)), &props)
+ mctx.CreateModule(android.ModuleFactoryAdaptor(LibraryFactory), &props)
}
// Creates a droiddoc module that creates stubs source files from the given full source
@@ -453,6 +453,7 @@ func (module *sdkLibrary) createImplLibrary(mctx android.TopDownMutatorContext)
Soc_specific *bool
Device_specific *bool
Product_specific *bool
+ Installable *bool
Required []string
Errorprone struct {
Javacflags []string
@@ -463,6 +464,7 @@ func (module *sdkLibrary) createImplLibrary(mctx android.TopDownMutatorContext)
props.Srcs = module.properties.Srcs
props.Libs = module.properties.Libs
props.Static_libs = module.properties.Static_libs
+ props.Installable = proptools.BoolPtr(true)
// XML file is installed along with the impl lib
props.Required = []string{module.xmlFileName()}
props.Errorprone.Javacflags = module.properties.Errorprone.Javacflags
@@ -475,7 +477,7 @@ func (module *sdkLibrary) createImplLibrary(mctx android.TopDownMutatorContext)
props.Product_specific = proptools.BoolPtr(true)
}
- mctx.CreateModule(android.ModuleFactoryAdaptor(LibraryFactory(true)), &props, &module.deviceProperties)
+ mctx.CreateModule(android.ModuleFactoryAdaptor(LibraryFactory), &props, &module.deviceProperties)
}
// Creates the xml file that publicizes the runtime library