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

Commit 92c0f9ce authored by Jiyong Park's avatar Jiyong Park
Browse files

Add installable property to apex module type

When set to false, the apex is built but not installed. Useful for not
polluting the system image with test APEXes when doing mma.

Bug: 120960303
Test: add 'installable: false' to apex.test under system/apex/tests/Android.bp
m; check that out/..../system/apex/apex.test.apex does not exist.

Change-Id: I383d5cdcc8aec705b6a5778dbd07233471d289d0
parent 1ee00b54
Loading
Loading
Loading
Loading
+22 −9
Original line number Diff line number Diff line
@@ -211,6 +211,9 @@ type apexBundleProperties struct {
	// or an android_app_certificate module name in the form ":module".
	Certificate *string

	// Whether this APEX is installable to one of the partitions. Default: true.
	Installable *bool

	Multilib struct {
		First struct {
			// List of native libraries whose compile_multilib is "first"
@@ -449,6 +452,10 @@ func (a *apexBundle) Srcs() android.Paths {
	return android.Paths{a.outputFiles[imageApex]}
}

func (a *apexBundle) installable() bool {
	return a.properties.Installable == nil || proptools.Bool(a.properties.Installable)
}

func getCopyManifestForNativeLibrary(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
	// Decide the APEX-local directory by the multilib of the library
	// In the future, we may query this to the module.
@@ -776,10 +783,13 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, keyFile and
	})

	// Install to $OUT/soong/{target,host}/.../apex
	if a.installable() {
		ctx.InstallFile(android.PathForModuleInstall(ctx, "apex"), ctx.ModuleName()+suffix, a.outputFiles[apexType])
	}
}

func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
	if a.installable() {
		// For flattened APEX, do nothing but make sure that apex_manifest.json file is also copied along
		// with other ordinary files.
		manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))
@@ -790,6 +800,7 @@ func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
			ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.builtFile.Base(), fi.builtFile)
		}
	}
}

func (a *apexBundle) AndroidMk() android.AndroidMkData {
	writers := []android.AndroidMkData{}
@@ -832,6 +843,7 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD
					fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", fi.builtFile.Base())
					fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String())
					fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.NameInMake())
					fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
					archStr := fi.archType.String()
					if archStr != "common" {
						fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
@@ -860,6 +872,7 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD
				fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFiles[apexType].String())
				fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString()))
				fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", name+apexType.suffix())
				fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
				fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", String(a.properties.Key))
				fmt.Fprintln(w, "include $(BUILD_PREBUILT)")