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

Commit e5eb5786 authored by Liz Kammer's avatar Liz Kammer Committed by Gerrit Code Review
Browse files

Merge "Don't add apex_set deps in nondeterministic order"

parents 0bf4ea53 2dc7244a
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -5281,7 +5281,16 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		apex_set {
			name: "myapex",
			set: "myapex.apks",
			exported_java_libs: ["myjavalib"],
			exported_bootclasspath_fragments: ["my-bootclasspath-fragment"],
			exported_systemserverclasspath_fragments: ["my-systemserverclasspath-fragment"],
		}

		java_import {
			name: "myjavalib",
			jars: ["myjavalib.jar"],
			apex_available: ["myapex"],
			permitted_packages: ["javalib"],
		}

		prebuilt_bootclasspath_fragment {
@@ -5298,6 +5307,12 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
			},
		}

		prebuilt_systemserverclasspath_fragment {
			name: "my-systemserverclasspath-fragment",
			contents: ["libbaz"],
			apex_available: ["myapex"],
		}

		java_import {
			name: "libfoo",
			jars: ["libfoo.jar"],
@@ -5314,6 +5329,16 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
			shared_library: false,
			permitted_packages: ["bar"],
		}

		java_sdk_library_import {
			name: "libbaz",
			public: {
				jars: ["libbaz.jar"],
			},
			apex_available: ["myapex"],
			shared_library: false,
			permitted_packages: ["baz"],
		}
	`

		ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
@@ -5326,6 +5351,24 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
			my-bootclasspath-fragment/index.csv
			out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
		`)

		myApex := ctx.ModuleForTests("myapex", "android_common_myapex").Module()

		overrideNames := []string{
			"",
			"myjavalib.myapex",
			"libfoo.myapex",
			"libbar.myapex",
			"libbaz.myapex",
		}
		mkEntries := android.AndroidMkEntriesForTest(t, ctx, myApex)
		for i, e := range mkEntries {
			g := e.OverrideName
			if w := overrideNames[i]; w != g {
				t.Errorf("Expected override name %q, got %q", w, g)
			}
		}

	})

	t.Run("prebuilt with source library preferred", func(t *testing.T) {
+15 −17
Original line number Diff line number Diff line
@@ -316,31 +316,29 @@ func prebuiltApexModuleCreatorMutator(ctx android.TopDownMutatorContext) {
	}
}

func (p *prebuiltCommon) getExportedDependencies() map[string]exportedDependencyTag {
	dependencies := make(map[string]exportedDependencyTag)
func (p *prebuiltCommon) hasExportedDeps() bool {
	return len(p.prebuiltCommonProperties.Exported_java_libs) > 0 ||
		len(p.prebuiltCommonProperties.Exported_bootclasspath_fragments) > 0 ||
		len(p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments) > 0
}

// prebuiltApexContentsDeps adds dependencies onto the prebuilt apex module's contents.
func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) {
	module := ctx.Module()

	for _, dep := range p.prebuiltCommonProperties.Exported_java_libs {
		dependencies[dep] = exportedJavaLibTag
		prebuiltDep := android.PrebuiltNameFromSource(dep)
		ctx.AddDependency(module, exportedJavaLibTag, prebuiltDep)
	}

	for _, dep := range p.prebuiltCommonProperties.Exported_bootclasspath_fragments {
		dependencies[dep] = exportedBootclasspathFragmentTag
		prebuiltDep := android.PrebuiltNameFromSource(dep)
		ctx.AddDependency(module, exportedBootclasspathFragmentTag, prebuiltDep)
	}

	for _, dep := range p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments {
		dependencies[dep] = exportedSystemserverclasspathFragmentTag
	}

	return dependencies
}

// prebuiltApexContentsDeps adds dependencies onto the prebuilt apex module's contents.
func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) {
	module := ctx.Module()

	for dep, tag := range p.getExportedDependencies() {
		prebuiltDep := android.PrebuiltNameFromSource(dep)
		ctx.AddDependency(module, tag, prebuiltDep)
		ctx.AddDependency(module, exportedSystemserverclasspathFragmentTag, prebuiltDep)
	}
}

@@ -608,7 +606,7 @@ func createApexSelectorModule(ctx android.TopDownMutatorContext, name string, ap
// the listed modules need access to files from within the prebuilt .apex file.
func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerName string, apexFileSource string) {
	// Only create the deapexer module if it is needed.
	if len(p.getExportedDependencies()) == 0 {
	if !p.hasExportedDeps() {
		return
	}