diff options
author | 2023-09-27 16:47:56 +0000 | |
---|---|---|
committer | 2023-10-10 14:31:03 +0000 | |
commit | f7a1027c6bf0c661f8f89b6a84e8fe22f2fc44fe (patch) | |
tree | 9b6ad234349e61480b15e3908a41c42c7c514865 /java/aar.go | |
parent | 3fb5c15adf5bca630f6d90df071e5fcfad00acf9 (diff) |
Use an option struct in aapt.buildActions & manifestMerger
Change-Id: Ia056ab321e1fd146ed0cdb98fc2d4455601f648c
Test: Treehugger
Diffstat (limited to 'java/aar.go')
-rw-r--r-- | java/aar.go | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/java/aar.go b/java/aar.go index 44496dc57..e53653a92 100644 --- a/java/aar.go +++ b/java/aar.go @@ -301,23 +301,29 @@ var extractAssetsRule = pctx.AndroidStaticRule("extractAssets", CommandDeps: []string{"${config.Zip2ZipCmd}"}, }) -func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext android.SdkContext, - classLoaderContexts dexpreopt.ClassLoaderContextMap, excludedLibs []string, - enforceDefaultTargetSdkVersion bool, extraLinkFlags ...string) { +type aaptBuildActionOptions struct { + sdkContext android.SdkContext + classLoaderContexts dexpreopt.ClassLoaderContextMap + excludedLibs []string + enforceDefaultTargetSdkVersion bool + extraLinkFlags []string +} + +func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptions) { staticResourcesNodesDepSet, staticRRODirsDepSet, staticManifestsDepSet, sharedDeps, libFlags := - aaptLibs(ctx, sdkContext, classLoaderContexts) + aaptLibs(ctx, opts.sdkContext, opts.classLoaderContexts) // Exclude any libraries from the supplied list. - classLoaderContexts = classLoaderContexts.ExcludeLibs(excludedLibs) + opts.classLoaderContexts = opts.classLoaderContexts.ExcludeLibs(opts.excludedLibs) // App manifest file manifestFile := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml") manifestSrcPath := android.PathForModuleSrc(ctx, manifestFile) manifestPath := ManifestFixer(ctx, manifestSrcPath, ManifestFixerParams{ - SdkContext: sdkContext, - ClassLoaderContexts: classLoaderContexts, + SdkContext: opts.sdkContext, + ClassLoaderContexts: opts.classLoaderContexts, IsLibrary: a.isLibrary, DefaultManifestVersion: a.defaultManifestVersion, UseEmbeddedNativeLibs: a.useEmbeddedNativeLibs, @@ -325,7 +331,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext android.SdkCon UseEmbeddedDex: a.useEmbeddedDex, HasNoCode: a.hasNoCode, LoggingParent: a.LoggingParent, - EnforceDefaultTargetSdkVersion: enforceDefaultTargetSdkVersion, + EnforceDefaultTargetSdkVersion: opts.enforceDefaultTargetSdkVersion, }) staticDeps := transitiveAarDeps(staticResourcesNodesDepSet.ToList()) @@ -341,7 +347,10 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext android.SdkCon transitiveManifestPaths = append(transitiveManifestPaths, staticManifestsDepSet.ToList()...) if len(transitiveManifestPaths) > 1 && !Bool(a.aaptProperties.Dont_merge_manifests) { - a.mergedManifestFile = manifestMerger(ctx, transitiveManifestPaths[0], transitiveManifestPaths[1:], a.isLibrary) + manifestMergerParams := ManifestMergerParams{ + staticLibManifests: transitiveManifestPaths[1:], + isLibrary: a.isLibrary} + a.mergedManifestFile = manifestMerger(ctx, transitiveManifestPaths[0], manifestMergerParams) if !a.isLibrary { // Only use the merged manifest for applications. For libraries, the transitive closure of manifests // will be propagated to the final application and merged there. The merged manifest for libraries is @@ -352,12 +361,12 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext android.SdkCon a.mergedManifestFile = manifestPath } - compileFlags, linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resZips := a.aapt2Flags(ctx, sdkContext, manifestPath) + compileFlags, linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resZips := a.aapt2Flags(ctx, opts.sdkContext, manifestPath) linkFlags = append(linkFlags, libFlags...) linkDeps = append(linkDeps, sharedDeps...) linkDeps = append(linkDeps, staticDeps.resPackages()...) - linkFlags = append(linkFlags, extraLinkFlags...) + linkFlags = append(linkFlags, opts.extraLinkFlags...) if a.isLibrary { linkFlags = append(linkFlags, "--static-lib") } @@ -729,7 +738,13 @@ func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.aapt.isLibrary = true a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx) - a.aapt.buildActions(ctx, android.SdkContext(a), a.classLoaderContexts, nil, false) + a.aapt.buildActions(ctx, + aaptBuildActionOptions{ + sdkContext: android.SdkContext(a), + classLoaderContexts: a.classLoaderContexts, + enforceDefaultTargetSdkVersion: false, + }, + ) a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() |