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

Commit 936d1792 authored by Ulyana Trafimovich's avatar Ulyana Trafimovich Committed by Automerger Merge Worker
Browse files

Merge "Refactor function to reduce nestedness level. No functional changes."...

Merge "Refactor function to reduce nestedness level. No functional changes." am: 9cb1577a am: de136dec am: b7246725 am: a846cf70

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

Change-Id: I29ab6007d80a9564b3cd9457b4e2dc2c1c5f62e4
parents a5755c5b a846cf70
Loading
Loading
Loading
Loading
+33 −27
Original line number Diff line number Diff line
@@ -1245,23 +1245,32 @@ func replaceInList(list []string, oldstr, newstr string) {
	}
}

// Returns a map of module names of shared library dependencies to the paths
// to their dex jars on host and on device.
// Returns a map of module names of shared library dependencies to the paths to their dex jars on
// host and on device.
func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext) dexpreopt.ClassLoaderContextMap {
	clcMap := make(dexpreopt.ClassLoaderContextMap)
	// Skip when UnbundledBuild() is true, but UnbundledBuildImage() is false.
	// Added UnbundledBuildImage() condition to generate dexpreopt.config even though unbundled image is built.
	if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() {

	// Skip when UnbundledBuild() is true, but UnbundledBuildImage() is false. With
	// UnbundledBuildImage() it is necessary to generate dexpreopt.config for post-dexpreopting.
	if ctx.Config().UnbundledBuild() && !ctx.Config().UnbundledBuildImage() {
		return clcMap
	}

	ctx.VisitDirectDeps(func(m android.Module) {
			if tag, ok := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag); ok {
		tag, isUsesLibTag := ctx.OtherModuleDependencyTag(m).(usesLibraryDependencyTag)
		if !isUsesLibTag {
			return
		}

		dep := ctx.OtherModuleName(m)

		if lib, ok := m.(UsesLibraryDependency); ok {
			libName := android.RemoveOptionalPrebuiltPrefix(dep)
			if ulib, ok := m.(ProvidesUsesLib); ok && ulib.ProvidesUsesLib() != nil {
				libName = android.RemoveOptionalPrebuiltPrefix(*ulib.ProvidesUsesLib())
						// Replace module name with library name in `uses_libs`/`optional_uses_libs`
						// in order to pass verify_uses_libraries check (which compares these
						// properties against library names written in the manifest).
				// Replace module name with library name in `uses_libs`/`optional_uses_libs` in
				// order to pass verify_uses_libraries check (which compares these properties
				// against library names written in the manifest).
				replaceInList(u.usesLibraryProperties.Uses_libs, dep, libName)
				replaceInList(u.usesLibraryProperties.Optional_uses_libs, dep, libName)
			}
@@ -1272,10 +1281,7 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext
		} else {
			ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be a java library", dep)
		}
			}
	})
	}

	return clcMap
}