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

Commit 3853562a authored by Jiakai Zhang's avatar Jiakai Zhang Committed by Automerger Merge Worker
Browse files

Merge "Extract the logic of setting Uncompress_dex to a common place." am:...

Merge "Extract the logic of setting Uncompress_dex to a common place." am: ae9ba1c9 am: c5e71ecc

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

Change-Id: I2ccb36ca226268dc647cf9b22b8b8b1aaaf309d2
parents 57fbf573 c5e71ecc
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -532,6 +532,14 @@ func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bo
	return false
}

// Sets `dexer.dexProperties.Uncompress_dex` to the proper value.
func setUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter, dexer *dexer) {
	if dexer.dexProperties.Uncompress_dex == nil {
		// If the value was not force-set by the user, use reasonable default based on the module.
		dexer.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, dexpreopter))
	}
}

func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	j.sdkVersion = j.SdkVersion(ctx)
	j.minSdkVersion = j.MinSdkVersion(ctx)
@@ -545,10 +553,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	j.dexpreopter.installPath = j.dexpreopter.getInstallPath(
		ctx, android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar"))
	j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary
	if j.dexProperties.Uncompress_dex == nil {
		// If the value was not force-set by the user, use reasonable default based on the module.
		j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
	}
	setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
	j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
	j.classLoaderContexts = j.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
	j.compile(ctx, nil)
@@ -1393,16 +1398,13 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
				installPath := android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(j.BaseModuleName()))
				j.dexJarInstallFile = installPath

				// Initialize the hiddenapi structure.
				j.initHiddenAPI(ctx, dexJarFile, outputFile, nil)

				j.dexpreopter.installPath = j.dexpreopter.getInstallPath(ctx, installPath)
				if j.dexProperties.Uncompress_dex == nil {
					// If the value was not force-set by the user, use reasonable default based on the module.
					j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
				}
				setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
				j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
				j.dexpreopt(ctx, dexOutputPath)

				// Initialize the hiddenapi structure.
				j.initHiddenAPI(ctx, dexJarFile, outputFile, j.dexProperties.Uncompress_dex)
			} else {
				// This should never happen as a variant for a prebuilt_apex is only created if the
				// prebuilt_apex has been configured to export the java library dex file.
@@ -1422,10 +1424,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {

			j.dexpreopter.installPath = j.dexpreopter.getInstallPath(
				ctx, android.PathForModuleInstall(ctx, "framework", jarName))
			if j.dexProperties.Uncompress_dex == nil {
				// If the value was not force-set by the user, use reasonable default based on the module.
				j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
			}
			setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
			j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex

			var dexOutputFile android.OutputPath