summaryrefslogtreecommitdiff
path: root/java/app.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/app.go')
-rwxr-xr-xjava/app.go106
1 files changed, 54 insertions, 52 deletions
diff --git a/java/app.go b/java/app.go
index 2b52eab15..23a9816b4 100755
--- a/java/app.go
+++ b/java/app.go
@@ -63,13 +63,6 @@ type appProperties struct {
// list of resource labels to generate individual resource packages
Package_splits []string
- // Names of modules to be overridden. Listed modules can only be other binaries
- // (in Make or Soong).
- // This does not completely prevent installation of the overridden binaries, but if both
- // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
- // from PRODUCT_PACKAGES.
- Overrides []string
-
// list of native libraries that will be provided in or alongside the resulting jar
Jni_libs []string `android:"arch_variant"`
@@ -106,7 +99,6 @@ type appProperties struct {
// cc.Coverage related properties
PreventInstall bool `blueprint:"mutated"`
- HideFromMake bool `blueprint:"mutated"`
IsCoverageVariant bool `blueprint:"mutated"`
// Whether this app is considered mainline updatable or not. When set to true, this will enforce
@@ -133,6 +125,13 @@ type overridableAppProperties struct {
// Whether to rename the package in resources to the override name rather than the base name. Defaults to true.
Rename_resources_package *bool
+
+ // Names of modules to be overridden. Listed modules can only be other binaries
+ // (in Make or Soong).
+ // This does not completely prevent installation of the overridden binaries, but if both
+ // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
+ // from PRODUCT_PACKAGES.
+ Overrides []string
}
type AndroidApp struct {
@@ -299,10 +298,6 @@ func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
// If an updatable APK sets min_sdk_version, min_sdk_vesion of JNI libs should match with it.
// This check is enforced for "updatable" APKs (including APK-in-APEX).
-// b/155209650: until min_sdk_version is properly supported, use sdk_version instead.
-// because, sdk_version is overridden by min_sdk_version (if set as smaller)
-// and sdkLinkType is checked with dependencies so we can be sure that the whole dependency tree
-// will meet the requirements.
func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVersion android.ApiLevel) {
// It's enough to check direct JNI deps' sdk_version because all transitive deps from JNI deps are checked in cc.checkLinkType()
ctx.VisitDirectDeps(func(m android.Module) {
@@ -313,10 +308,10 @@ func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVer
// The domain of cc.sdk_version is "current" and <number>
// We can rely on android.SdkSpec to convert it to <number> so that "current" is
// handled properly regardless of sdk finalization.
- jniSdkVersion, err := android.SdkSpecFrom(ctx, dep.SdkVersion()).EffectiveVersion(ctx)
+ jniSdkVersion, err := android.SdkSpecFrom(ctx, dep.MinSdkVersion()).EffectiveVersion(ctx)
if err != nil || minSdkVersion.LessThan(jniSdkVersion) {
- ctx.OtherModuleErrorf(dep, "sdk_version(%v) is higher than min_sdk_version(%v) of the containing android_app(%v)",
- dep.SdkVersion(), minSdkVersion, ctx.ModuleName())
+ ctx.OtherModuleErrorf(dep, "min_sdk_version(%v) is higher than min_sdk_version(%v) of the containing android_app(%v)",
+ dep.MinSdkVersion(), minSdkVersion, ctx.ModuleName())
return
}
@@ -586,20 +581,18 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
}
a.onDeviceDir = android.InstallPathToOnDevicePath(ctx, a.installDir)
+ a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
+
+ var noticeAssetPath android.WritablePath
if Bool(a.appProperties.Embed_notices) || ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") {
- noticeFile := android.PathForModuleOut(ctx, "NOTICE.html.gz")
- android.BuildNoticeHtmlOutputFromLicenseMetadata(ctx, noticeFile)
- noticeAssetPath := android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
- builder := android.NewRuleBuilder(pctx, ctx)
- builder.Command().Text("cp").
- Input(noticeFile).
- Output(noticeAssetPath)
- builder.Build("notice_dir", "Building notice dir")
+ // The rule to create the notice file can't be generated yet, as the final output path
+ // for the apk isn't known yet. Add the path where the notice file will be generated to the
+ // aapt rules now before calling aaptBuildActions, the rule to create the notice file will
+ // be generated later.
+ noticeAssetPath = android.PathForModuleOut(ctx, "NOTICE", "NOTICE.html.gz")
a.aapt.noticeFile = android.OptionalPathForPath(noticeAssetPath)
}
- a.classLoaderContexts = a.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
-
// Process all building blocks, from AAPT to certificates.
a.aaptBuildActions(ctx)
@@ -671,6 +664,23 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
a.extraOutputFiles = append(a.extraOutputFiles, v4SignatureFile)
}
+ if a.aapt.noticeFile.Valid() {
+ // Generating the notice file rule has to be here after a.outputFile is known.
+ noticeFile := android.PathForModuleOut(ctx, "NOTICE.html.gz")
+ android.BuildNoticeHtmlOutputFromLicenseMetadata(
+ ctx, noticeFile, "", "",
+ []string{
+ a.installDir.String() + "/",
+ android.PathForModuleInstall(ctx).String() + "/",
+ a.outputFile.String(),
+ })
+ builder := android.NewRuleBuilder(pctx, ctx)
+ builder.Command().Text("cp").
+ Input(noticeFile).
+ Output(noticeAssetPath)
+ builder.Build("notice_dir", "Building notice dir")
+ }
+
for _, split := range a.aapt.splits {
// Sign the split APKs
packageFile := android.PathForModuleOut(ctx, a.installApkName+"_"+split.suffix+".apk")
@@ -730,7 +740,7 @@ func collectAppDeps(ctx android.ModuleContext, app appDepsInterface,
tag := ctx.OtherModuleDependencyTag(module)
if IsJniDepTag(tag) || cc.IsSharedDepTag(tag) {
- if dep, ok := module.(*cc.Module); ok {
+ if dep, ok := module.(cc.LinkableInterface); ok {
if dep.IsNdk(ctx.Config()) || dep.IsStubs() {
return false
}
@@ -842,6 +852,10 @@ func (a *AndroidApp) Updatable() bool {
return Bool(a.appProperties.Updatable)
}
+func (a *AndroidApp) SetUpdatable(val bool) {
+ a.appProperties.Updatable = &val
+}
+
func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string {
certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName())
if overridden {
@@ -880,10 +894,6 @@ func (a *AndroidApp) SetPreventInstall() {
a.appProperties.PreventInstall = true
}
-func (a *AndroidApp) HideFromMake() {
- a.appProperties.HideFromMake = true
-}
-
func (a *AndroidApp) MarkAsCoverageVariant(coverage bool) {
a.appProperties.IsCoverageVariant = coverage
}
@@ -900,6 +910,7 @@ func AndroidAppFactory() android.Module {
module.Module.dexProperties.Optimize.Shrink = proptools.BoolPtr(true)
module.Module.properties.Instrument = true
+ module.Module.properties.Supports_static_instrumentation = true
module.Module.properties.Installable = proptools.BoolPtr(true)
module.addHostAndDeviceProperties()
@@ -912,7 +923,7 @@ func AndroidAppFactory() android.Module {
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
- android.InitOverridableModule(module, &module.appProperties.Overrides)
+ android.InitOverridableModule(module, &module.overridableAppProperties.Overrides)
android.InitApexModule(module)
android.InitBazelModule(module)
@@ -1016,9 +1027,10 @@ func (a *AndroidTest) OverridablePropertiesDepsMutator(ctx android.BottomUpMutat
func AndroidTestFactory() android.Module {
module := &AndroidTest{}
- module.Module.dexProperties.Optimize.EnabledByDefault = true
+ module.Module.dexProperties.Optimize.EnabledByDefault = false
module.Module.properties.Instrument = true
+ module.Module.properties.Supports_static_instrumentation = true
module.Module.properties.Installable = proptools.BoolPtr(true)
module.appProperties.Use_embedded_native_libs = proptools.BoolPtr(true)
module.appProperties.AlwaysPackageNativeLibs = true
@@ -1035,7 +1047,7 @@ func AndroidTestFactory() android.Module {
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
- android.InitOverridableModule(module, &module.appProperties.Overrides)
+ android.InitOverridableModule(module, &module.overridableAppProperties.Overrides)
return module
}
@@ -1069,6 +1081,7 @@ func (a *AndroidTestHelperApp) InstallInTestcases() bool {
func AndroidTestHelperAppFactory() android.Module {
module := &AndroidTestHelperApp{}
+ // TODO(b/192032291): Disable by default after auditing downstream usage.
module.Module.dexProperties.Optimize.EnabledByDefault = true
module.Module.properties.Installable = proptools.BoolPtr(true)
@@ -1225,28 +1238,17 @@ func (u *usesLibrary) addLib(lib string, optional bool) {
func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, hasFrameworkLibs bool) {
if !ctx.Config().UnbundledBuild() || ctx.Config().UnbundledBuildImage() {
- reqTag := makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion, false, false)
- ctx.AddVariationDependencies(nil, reqTag, u.usesLibraryProperties.Uses_libs...)
-
- optTag := makeUsesLibraryDependencyTag(dexpreopt.AnySdkVersion, true, false)
- ctx.AddVariationDependencies(nil, optTag, u.presentOptionalUsesLibs(ctx)...)
-
+ ctx.AddVariationDependencies(nil, usesLibReqTag, u.usesLibraryProperties.Uses_libs...)
+ ctx.AddVariationDependencies(nil, usesLibOptTag, u.presentOptionalUsesLibs(ctx)...)
// Only add these extra dependencies if the module depends on framework libs. This avoids
// creating a cyclic dependency:
// e.g. framework-res -> org.apache.http.legacy -> ... -> framework-res.
if hasFrameworkLibs {
- // Add implicit <uses-library> dependencies on compatibility libraries. Some of them are
- // optional, and some required --- this depends on the most common usage of the library
- // and may be wrong for some apps (they need explicit `uses_libs`/`optional_uses_libs`).
-
- compat28OptTag := makeUsesLibraryDependencyTag(28, true, true)
- ctx.AddVariationDependencies(nil, compat28OptTag, dexpreopt.OptionalCompatUsesLibs28...)
-
- compat29ReqTag := makeUsesLibraryDependencyTag(29, false, true)
- ctx.AddVariationDependencies(nil, compat29ReqTag, dexpreopt.CompatUsesLibs29...)
-
- compat30OptTag := makeUsesLibraryDependencyTag(30, true, true)
- ctx.AddVariationDependencies(nil, compat30OptTag, dexpreopt.OptionalCompatUsesLibs30...)
+ // Dexpreopt needs paths to the dex jars of these libraries in order to construct
+ // class loader context for dex2oat. Add them as a dependency with a special tag.
+ ctx.AddVariationDependencies(nil, usesLibCompat29ReqTag, dexpreopt.CompatUsesLibs29...)
+ ctx.AddVariationDependencies(nil, usesLibCompat28OptTag, dexpreopt.OptionalCompatUsesLibs28...)
+ ctx.AddVariationDependencies(nil, usesLibCompat30OptTag, dexpreopt.OptionalCompatUsesLibs30...)
}
}
}
@@ -1305,7 +1307,7 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext
replaceInList(u.usesLibraryProperties.Uses_libs, dep, libName)
replaceInList(u.usesLibraryProperties.Optional_uses_libs, dep, libName)
}
- clcMap.AddContext(ctx, tag.sdkVersion, libName, tag.optional, tag.implicit,
+ clcMap.AddContext(ctx, tag.sdkVersion, libName, tag.optional,
lib.DexJarBuildPath().PathOrNil(), lib.DexJarInstallPath(),
lib.ClassLoaderContexts())
} else if ctx.Config().AllowMissingDependencies() {