Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6a8e0fe authored by Colin Cross's avatar Colin Cross Committed by Gerrit Code Review
Browse files

Merge "Don't install java libraries by default"

parents ff2af2c7 9ae1b927
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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 {
+2 −0
Original line number Diff line number Diff line
@@ -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,
+25 −28
Original line number Diff line number Diff line
@@ -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,14 +1296,9 @@ func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
	j.deps(ctx)
}

func LibraryFactory(installable bool) func() android.Module {
	return func() android.Module {
func LibraryFactory() android.Module {
	module := &Library{}

		if !installable {
			module.properties.Installable = proptools.BoolPtr(false)
		}

	module.AddProperties(
		&module.Module.properties,
		&module.Module.deviceProperties,
@@ -1319,7 +1307,6 @@ func LibraryFactory(installable bool) func() android.Module {
	InitJavaModule(module, android.HostAndDeviceSupported)
	return module
}
}

func LibraryHostFactory() android.Module {
	module := &Library{}
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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))
Loading