diff options
| author | mosimchah <mosimchah@gmail.com> | 2025-12-02 09:27:38 -0500 |
|---|---|---|
| committer | mosimchah <mosimchah@gmail.com> | 2025-12-02 09:27:38 -0500 |
| commit | c7bade461dc55726f62997d13a48582f7c4b4655 (patch) | |
| tree | ea0588da76060a2038f54f67efd046ca77634b10 /java/aar.go | |
| parent | 0f5414d19317805e8bbbe7c4db5f0fd78769bad5 (diff) | |
| parent | 89d78cff8b00d3b20a90074635c3fe5a2ee49474 (diff) | |
Merge branch 'lineage-23.1' of https://github.com/LineageOS/android_build_soong into HEADw16.1
* 'lineage-23.1' of https://github.com/LineageOS/android_build_soong: (528 commits)
Revert "install_symlink: Make symlink target configurable"
Reapply "Clear as much of cc.Module as possible after GenerateBuildActions"
Revert "rust: config: Fix missing CPU variant LD flags in Rust"
Rename build-flag in outdir
Revert^4 "cipd: Default CIPD proxy server to on, add opt-out"
Convert check-vintf-all to phony with actions
Create a partial implementation of check-vintf-all for soong-only
Configure RBE rust pool based on build variant
Revert^3 "Add sdk version check to arr"
Add jdk.internal.invoke to the allowlist
Make droid always depend on symbols zip
Import Device and Odm skus
Don't install gob_gen in Soong
Remove bazel reference from run_integration_tests.sh
Fix bootstrap_test.sh
Don't panic in aconfig libraries when AllowMissingDependencies is set
Avoid returning nil paths from PathForModuleSrc
Revert "Flag controled clang version"
Rework module target dependencies on required deps
Revert^2 "Add sdk version check to arr"
...
Change-Id: I6e9a63fa14fda917a42e426e5dcebbad7f67e1de
Diffstat (limited to 'java/aar.go')
| -rw-r--r-- | java/aar.go | 67 |
1 files changed, 62 insertions, 5 deletions
diff --git a/java/aar.go b/java/aar.go index ad080aa62..c1129f0c8 100644 --- a/java/aar.go +++ b/java/aar.go @@ -108,6 +108,9 @@ type aaptProperties struct { // Names of aconfig_declarations modules that specify aconfig flags that the module depends on. Flags_packages []string + + // The package name of this app. May not be used if `manifest` or `additional_manifests` are provided. + Package_name proptools.Configurable[string] } type aapt struct { @@ -144,6 +147,10 @@ type aapt struct { manifestValues struct { applicationId string } + + // Fields written to jdeps + assetDirs android.Paths + resourceDirs android.Paths } type split struct { @@ -263,6 +270,13 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext android.SdkConte linkFlags = append(linkFlags, a.aaptProperties.Aaptflags...) linkFlags = append(linkFlags, "--enable-compact-entries") + if ctx.Config().ReleaseUseSparseEncoding() { + linkFlags = append(linkFlags, "--enable-sparse-encoding") + } + + if ctx.Config().ReleaseUseUncompressedFonts() { + linkFlags = append(linkFlags, "--no-compress-fonts") + } // Find implicit or explicit asset and resource dirs assets := android.PathsRelativeToModuleSourceDir(android.SourceInput{ @@ -276,7 +290,10 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext android.SdkConte } else { assetDirs = android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Asset_dirs, "assets") } + a.assetDirs = assetDirs + resourceDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Resource_dirs.GetOrDefault(ctx, nil), "res") + a.resourceDirs = resourceDirs resourceZips := android.PathsForModuleSrc(ctx, a.aaptProperties.Resource_zips) // Glob directories into lists of paths @@ -452,9 +469,21 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio opts.classLoaderContexts = opts.classLoaderContexts.ExcludeLibs(opts.excludedLibs) // App manifest file + packageNameProp := a.aaptProperties.Package_name.Get(ctx) var manifestFilePath android.Path if opts.manifestForAapt != nil { manifestFilePath = opts.manifestForAapt + } else if a.isLibrary && packageNameProp.IsPresent() && a.aaptProperties.Manifest == nil && a.aaptProperties.Additional_manifests == nil { + // If the only reason that a library needs a manifest file is to give the package name, allow them to do that in + // the module declaration. If they are already supplying a manifest, then do not autogenerate a manifest file. + generatedManifestPath := android.PathForModuleOut(ctx, "GeneratedManifest.xml") + manifestString := `<?xml version="1.0" encoding="utf-8"?> +<!-- Automatically generated by Soong. --> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="` + packageNameProp.Get() + `" /> +` + android.WriteFileRule(ctx, generatedManifestPath, manifestString) + ctx.SetOutputFiles([]android.Path{generatedManifestPath}, ".gen_xml") + manifestFilePath = generatedManifestPath } else { manifestFile := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml") manifestFilePath = android.PathForModuleSrc(ctx, manifestFile) @@ -975,6 +1004,17 @@ func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { } func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { + packageNameProp := a.aaptProperties.Package_name.Get(ctx) + if packageNameProp.IsPresent() { + if a.aaptProperties.Manifest != nil { + ctx.PropertyErrorf("package_name", "cannot be used with `manifest`") + return + } + if a.aaptProperties.Additional_manifests != nil { + ctx.PropertyErrorf("package_name", "cannot be used with `additional_manifests`") + return + } + } a.aapt.isLibrary = true a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx) if a.usesLibrary.shouldDisableDexpreopt { @@ -1042,6 +1082,7 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) var res android.Paths if a.androidLibraryProperties.BuildAAR { BuildAAR(ctx, a.aarFile, a.outputFile, a.manifestPath, a.rTxt, res) + android.SetProvider(ctx, AARProvider, AARInfo{Aar: a.aarFile}) } prebuiltJniPackages := android.Paths{} @@ -1070,6 +1111,11 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) a.setOutputFiles(ctx) buildComplianceMetadata(ctx) + + moduleInfoJSON := ctx.ModuleInfoJSON() + moduleInfoJSON.Class = []string{"JAVA_LIBRARIES"} + moduleInfoJSON.ClassesJar = []string{a.Library.implementationAndResourcesJar.String()} + moduleInfoJSON.SystemSharedLibs = []string{"none"} } func (a *AndroidLibrary) setOutputFiles(ctx android.ModuleContext) { @@ -1086,6 +1132,8 @@ func (a *aapt) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { if a.rJar != nil { dpInfo.Jars = append(dpInfo.Jars, a.rJar.String()) } + dpInfo.Asset_dirs = append(dpInfo.Asset_dirs, a.assetDirs.Strings()...) + dpInfo.Resource_dirs = append(dpInfo.Resource_dirs, a.resourceDirs.Strings()...) } // android_library builds and links sources into a `.jar` file for the device along with Android resources. @@ -1248,10 +1296,6 @@ func (a *AARImport) Name() string { return a.prebuilt.Name(a.ModuleBase.Name()) } -func (a *AARImport) JacocoReportClassesFile() android.Path { - return nil -} - func (a *AARImport) DepsMutator(ctx android.BottomUpMutatorContext) { if !ctx.Config().AlwaysUsePrebuiltSdks() { sdkDep := decodeSdkDep(ctx, android.SdkContext(a)) @@ -1267,6 +1311,7 @@ func (a *AARImport) DepsMutator(ctx android.BottomUpMutatorContext) { ctx.AddVariationDependencies(nil, staticLibTag, a.properties.Static_libs.GetOrDefault(ctx, nil)...) a.usesLibrary.deps(ctx, false) + a.EmbeddableSdkLibraryComponent.setComponentDependencyInfoProvider(ctx) } type JniPackageInfo struct { @@ -1585,6 +1630,11 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.SetOutputFiles([]android.Path{a.aarPath}, ".aar") buildComplianceMetadata(ctx) + + moduleInfoJSON := ctx.ModuleInfoJSON() + moduleInfoJSON.Class = []string{"JAVA_LIBRARIES"} + moduleInfoJSON.ClassesJar = []string{a.implementationAndResourcesJarFile.String()} + moduleInfoJSON.SystemSharedLibs = []string{"none"} } func (a *AARImport) HeaderJars() android.Paths { @@ -1656,5 +1706,12 @@ func AARImportFactory() android.Module { } func (a *AARImport) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { - dpInfo.Jars = append(dpInfo.Jars, a.implementationJarFile.String(), a.rJar.String()) + dpInfo.Jars = append(dpInfo.Jars, a.implementationJarFile.String(), a.rJar.String(), a.aarPath.String()) + dpInfo.Static_libs = append(dpInfo.Static_libs, a.properties.Static_libs.GetOrDefault(ctx, nil)...) +} + +type AARInfo struct { + Aar android.Path } + +var AARProvider = blueprint.NewProvider[AARInfo]() |
