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

Commit 94427265 authored by Jiyong Park's avatar Jiyong Park
Browse files

Don't emit make rules for APEX files for non-installable APEX

When an APEX is non-installable, the make rules for the APEX files in
the APEX are not emitted as they will never get installed.

androidMkForType() is refactored so that make rules for the APEX files
are created in a separate function androidMkForFiles().

Test: m checkbuild tests
Bug: 123290268
Change-Id: Ibe8817d1e9c6312fb5c6f986dced8aa3e823664a
parent 47e4fcb6
Loading
Loading
Loading
Loading
+85 −75
Original line number Diff line number Diff line
@@ -954,20 +954,16 @@ func (a *apexBundle) AndroidMk() android.AndroidMkData {
		}}
}

func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkData {
	return android.AndroidMkData{
		Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
func (a *apexBundle) androidMkForFiles(w io.Writer, name, moduleDir string) []string {
	moduleNames := []string{}
			for _, fi := range a.filesInfo {
				if !android.InList(fi.moduleName, moduleNames) {
					moduleNames = append(moduleNames, fi.moduleName)
				}
			}

	for _, fi := range a.filesInfo {
		if cc, ok := fi.module.(*cc.Module); ok && cc.Properties.HideFromMake {
			continue
		}
		if !android.InList(fi.moduleName, moduleNames) {
			moduleNames = append(moduleNames, fi.moduleName)
		}
		fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
		fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
		fmt.Fprintln(w, "LOCAL_MODULE :=", fi.moduleName)
@@ -982,7 +978,6 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD
		}
		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())
		if fi.module != nil {
			archStr := fi.module.Target().Arch.ArchType.String()
			host := false
@@ -1033,12 +1028,25 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD
			fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
		}
	}
	return moduleNames
}

func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkData {
	return android.AndroidMkData{
		Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
			moduleNames := []string{}
			if a.installable() {
				a.androidMkForFiles(w, name, moduleDir)
			}

			if a.flattened && apexType.image() {
				// Only image APEXes can be flattened.
				fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
				fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
				fmt.Fprintln(w, "LOCAL_MODULE :=", name)
				if len(moduleNames) > 0 {
					fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
				}
				fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
			} else {
				// zip-apex is the less common type so have the name refer to the image-apex
@@ -1055,7 +1063,9 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD
				fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix())
				fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
				fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", String(a.properties.Key))
				if len(moduleNames) > 0 {
					fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(moduleNames, " "))
				}
				fmt.Fprintln(w, "include $(BUILD_PREBUILT)")

				if apexType == imageApex {