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
This commit is contained in:
parent
f33dca0ada
commit
9ae1b927d4
6 changed files with 34 additions and 34 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
53
java/java.go
53
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{}
|
||||
func LibraryFactory() android.Module {
|
||||
module := &Library{}
|
||||
|
||||
if !installable {
|
||||
module.properties.Installable = proptools.BoolPtr(false)
|
||||
}
|
||||
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
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue