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

Commit 0b238755 authored by Jiyong Park's avatar Jiyong Park
Browse files

stem property of java modules are propagated to Make

62c7829595c0df53e96addcd347c11ac01012eee introduced the new stem
property to java modules, but it wasn't propagated to Make. Fixing the
problem.

This change also fixes a problem that (module name) == (file name) is
assumed in dexpreopt_config.go, which no longer is the case. A mutator
runs to build a map from module name to its stem. The map is then used
when filling up the file paths in the bootImageConfig struct.

Bug: 139391334
Bug: 143494499
Test: m
Test: BootImageProfileTest
Change-Id: Idbc894f877692401471130de6cbfe5e0dd129da9
parent 5d0b3b71
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ func (library *Library) AndroidMkHostDex(w io.Writer, name string, entries *andr
		if r := library.deviceProperties.Target.Hostdex.Required; len(r) > 0 {
			fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(r, " "))
		}
		fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", library.Stem()+"-hostdex")
		fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
	}
}
@@ -102,6 +103,7 @@ func (library *Library) AndroidMkEntries() android.AndroidMkEntries {
				if library.proguardDictionary != nil {
					entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary)
				}
				entries.SetString("LOCAL_MODULE_STEM", library.Stem())
			},
		},
		ExtraFooters: []android.AndroidMkExtraFootersFunc{
@@ -160,6 +162,7 @@ func (prebuilt *Import) AndroidMkEntries() android.AndroidMkEntries {
				entries.SetPath("LOCAL_SOONG_HEADER_JAR", prebuilt.combinedClasspathFile)
				entries.SetPath("LOCAL_SOONG_CLASSES_JAR", prebuilt.combinedClasspathFile)
				entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion())
				entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
			},
		},
	}
@@ -187,6 +190,7 @@ func (prebuilt *DexImport) AndroidMkEntries() android.AndroidMkEntries {
				if len(prebuilt.dexpreopter.builtInstalled) > 0 {
					entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", prebuilt.dexpreopter.builtInstalled)
				}
				entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
			},
		},
	}
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ func (image bootImageConfig) moduleFiles(ctx android.PathContext, dir android.Ou
	for i, m := range image.modules {
		name := image.name
		if i != 0 {
			name += "-" + m
			name += "-" + stemOf(m)
		}

		for _, ext := range exts {
+13 −3
Original line number Diff line number Diff line
@@ -96,6 +96,16 @@ func dexpreoptTargets(ctx android.PathContext) []android.Target {
	return targets
}

func stemOf(moduleName string) string {
	// b/139391334: the stem of framework-minus-apex is framework
	// This is hard coded here until we find a good way to query the stem
	// of a module before any other mutators are run
	if moduleName == "framework-minus-apex" {
		return "framework"
	}
	return moduleName
}

func getBootImageConfig(ctx android.PathContext, key android.OnceKey, name string,
	needZip bool) bootImageConfig {
	return ctx.Config().Once(key, func() interface{} {
@@ -110,18 +120,18 @@ func getBootImageConfig(ctx android.PathContext, key android.OnceKey, name strin

		for _, m := range artModules {
			bootLocations = append(bootLocations,
				filepath.Join("/apex/com.android.art/javalib", m+".jar"))
				filepath.Join("/apex/com.android.art/javalib", stemOf(m)+".jar"))
		}

		for _, m := range frameworkModules {
			bootLocations = append(bootLocations,
				filepath.Join("/system/framework", m+".jar"))
				filepath.Join("/system/framework", stemOf(m)+".jar"))
		}

		// The path to bootclasspath dex files needs to be known at module GenerateAndroidBuildAction time, before
		// the bootclasspath modules have been compiled.  Set up known paths for them, the singleton rules will copy
		// them there.
		// TODO: use module dependencies instead
		// TODO(b/143682396): use module dependencies instead
		var bootDexPaths android.WritablePaths
		for _, m := range imageModules {
			bootDexPaths = append(bootDexPaths,
+15 −5
Original line number Diff line number Diff line
@@ -1602,6 +1602,10 @@ func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
	return depTag == staticLibTag
}

func (j *Module) Stem() string {
	return proptools.StringDefault(j.deviceProperties.Stem, j.Name())
}

//
// Java libraries (.jar file)
//
@@ -1631,8 +1635,7 @@ func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bo
}

func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework",
		proptools.StringDefault(j.deviceProperties.Stem, ctx.ModuleName())+".jar")
	j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar")
	j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary
	j.dexpreopter.isInstallable = Bool(j.properties.Installable)
	j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter)
@@ -1994,6 +1997,10 @@ func (j *Import) Name() string {
	return j.prebuilt.Name(j.ModuleBase.Name())
}

func (j *Import) Stem() string {
	return proptools.StringDefault(j.properties.Stem, j.ModuleBase.Name())
}

func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
	ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
}
@@ -2001,7 +2008,7 @@ func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	jars := android.PathsForModuleSrc(ctx, j.properties.Jars)

	jarName := proptools.StringDefault(j.properties.Stem, ctx.ModuleName()) + ".jar"
	jarName := j.Stem() + ".jar"
	outputFile := android.PathForModuleOut(ctx, "combined", jarName)
	TransformJarsToJar(ctx, outputFile, "for prebuilts", jars, android.OptionalPath{},
		false, j.properties.Exclude_files, j.properties.Exclude_dirs)
@@ -2178,13 +2185,16 @@ func (j *DexImport) Name() string {
	return j.prebuilt.Name(j.ModuleBase.Name())
}

func (j *DexImport) Stem() string {
	return proptools.StringDefault(j.properties.Stem, j.ModuleBase.Name())
}

func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	if len(j.properties.Jars) != 1 {
		ctx.PropertyErrorf("jars", "exactly one jar must be provided")
	}

	j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework",
		proptools.StringDefault(j.properties.Stem, ctx.ModuleName())+".jar")
	j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar")
	j.dexpreopter.isInstallable = true
	j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter)