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

Commit 1a62a36c authored by Jiakai Zhang's avatar Jiakai Zhang Committed by Automerger Merge Worker
Browse files

Merge "Install required deps for flattened APEX." am: 0407606c am: 1f7d72c5

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1999190

Change-Id: Idc03d0e3bf4630bb9278d096798ecd86df976865
parents 8483d249 1f7d72c5
Loading
Loading
Loading
Loading
+10 −12
Original line number Diff line number Diff line
@@ -309,7 +309,14 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
	return moduleNames
}

func (a *apexBundle) writeRequiredModules(w io.Writer) {
func (a *apexBundle) writeRequiredModules(w io.Writer, moduleNames []string) {
	if len(moduleNames) > 0 {
		fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(moduleNames, " "))
	}
	if len(a.requiredDeps) > 0 {
		fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(a.requiredDeps, " "))
	}

	var required []string
	var targetRequired []string
	var hostRequired []string
@@ -349,10 +356,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData {
				fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
				fmt.Fprintln(w, "LOCAL_MODULE :=", name+a.suffix)
				data.Entries.WriteLicenseVariables(w)
				if len(moduleNames) > 0 {
					fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
				}
				a.writeRequiredModules(w)
				a.writeRequiredModules(w, moduleNames)
				fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")

			} else {
@@ -388,13 +392,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData {
				if len(a.overridableProperties.Overrides) > 0 {
					fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(a.overridableProperties.Overrides, " "))
				}
				if len(moduleNames) > 0 {
					fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(moduleNames, " "))
				}
				if len(a.requiredDeps) > 0 {
					fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(a.requiredDeps, " "))
				}
				a.writeRequiredModules(w)
				a.writeRequiredModules(w, moduleNames)

				if a.mergedNotices.Merged.Valid() {
					fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", a.mergedNotices.Merged.Path().String())
+32 −0
Original line number Diff line number Diff line
@@ -8690,6 +8690,38 @@ func TestAndroidMk_RequiredModules(t *testing.T) {
	ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += otherapex")
}

func TestAndroidMk_RequiredDeps(t *testing.T) {
	ctx := testApex(t, `
		apex {
			name: "myapex",
			key: "myapex.key",
			updatable: false,
		}

		apex_key {
			name: "myapex.key",
			public_key: "testkey.avbpubkey",
			private_key: "testkey.pem",
		}
	`)

	bundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
	bundle.requiredDeps = append(bundle.requiredDeps, "foo")
	data := android.AndroidMkDataForTest(t, ctx, bundle)
	var builder strings.Builder
	data.Custom(&builder, bundle.BaseModuleName(), "TARGET_", "", data)
	androidMk := builder.String()
	ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += foo")

	flattenedBundle := ctx.ModuleForTests("myapex", "android_common_myapex_flattened").Module().(*apexBundle)
	flattenedBundle.requiredDeps = append(flattenedBundle.requiredDeps, "foo")
	flattenedData := android.AndroidMkDataForTest(t, ctx, flattenedBundle)
	var flattenedBuilder strings.Builder
	flattenedData.Custom(&flattenedBuilder, flattenedBundle.BaseModuleName(), "TARGET_", "", flattenedData)
	flattenedAndroidMk := flattenedBuilder.String()
	ensureContains(t, flattenedAndroidMk, "LOCAL_REQUIRED_MODULES += foo")
}

func TestApexOutputFileProducer(t *testing.T) {
	for _, tc := range []struct {
		name          string