Merge "Add support for use_embedded_dex in Soong" am: 7805791106
am: cf3e29beef
am: e7557c90e4
Change-Id: Ie908d0ad56df4b48128540d3123cb9e399a9292d
This commit is contained in:
@@ -189,6 +189,7 @@ func init() {
|
|||||||
"LOCAL_PRIVILEGED_MODULE": "privileged",
|
"LOCAL_PRIVILEGED_MODULE": "privileged",
|
||||||
"LOCAL_AAPT_INCLUDE_ALL_RESOURCES": "aapt_include_all_resources",
|
"LOCAL_AAPT_INCLUDE_ALL_RESOURCES": "aapt_include_all_resources",
|
||||||
"LOCAL_USE_EMBEDDED_NATIVE_LIBS": "use_embedded_native_libs",
|
"LOCAL_USE_EMBEDDED_NATIVE_LIBS": "use_embedded_native_libs",
|
||||||
|
"LOCAL_USE_EMBEDDED_DEX": "use_embedded_dex",
|
||||||
|
|
||||||
"LOCAL_DEX_PREOPT": "dex_preopt.enabled",
|
"LOCAL_DEX_PREOPT": "dex_preopt.enabled",
|
||||||
"LOCAL_DEX_PREOPT_APP_IMAGE": "dex_preopt.app_image",
|
"LOCAL_DEX_PREOPT_APP_IMAGE": "dex_preopt.app_image",
|
||||||
|
@@ -76,6 +76,7 @@ type aapt struct {
|
|||||||
extraAaptPackagesFile android.Path
|
extraAaptPackagesFile android.Path
|
||||||
isLibrary bool
|
isLibrary bool
|
||||||
uncompressedJNI bool
|
uncompressedJNI bool
|
||||||
|
useEmbeddedDex bool
|
||||||
|
|
||||||
aaptProperties aaptProperties
|
aaptProperties aaptProperties
|
||||||
}
|
}
|
||||||
@@ -182,7 +183,8 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, ex
|
|||||||
manifestFile := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml")
|
manifestFile := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml")
|
||||||
manifestSrcPath := android.PathForModuleSrc(ctx, manifestFile)
|
manifestSrcPath := android.PathForModuleSrc(ctx, manifestFile)
|
||||||
|
|
||||||
manifestPath := manifestMerger(ctx, manifestSrcPath, sdkContext, staticLibManifests, a.isLibrary, a.uncompressedJNI)
|
manifestPath := manifestMerger(ctx, manifestSrcPath, sdkContext, staticLibManifests, a.isLibrary,
|
||||||
|
a.uncompressedJNI, a.useEmbeddedDex)
|
||||||
|
|
||||||
linkFlags, linkDeps, resDirs, overlayDirs, rroDirs := a.aapt2Flags(ctx, sdkContext, manifestPath)
|
linkFlags, linkDeps, resDirs, overlayDirs, rroDirs := a.aapt2Flags(ctx, sdkContext, manifestPath)
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@ var manifestMergerRule = pctx.AndroidStaticRule("manifestMerger",
|
|||||||
"libs")
|
"libs")
|
||||||
|
|
||||||
func manifestMerger(ctx android.ModuleContext, manifest android.Path, sdkContext sdkContext,
|
func manifestMerger(ctx android.ModuleContext, manifest android.Path, sdkContext sdkContext,
|
||||||
staticLibManifests android.Paths, isLibrary bool, uncompressedJNI bool) android.Path {
|
staticLibManifests android.Paths, isLibrary bool, uncompressedJNI, useEmbeddedDex bool) android.Path {
|
||||||
|
|
||||||
var args []string
|
var args []string
|
||||||
if isLibrary {
|
if isLibrary {
|
||||||
@@ -62,6 +62,10 @@ func manifestMerger(ctx android.ModuleContext, manifest android.Path, sdkContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if useEmbeddedDex {
|
||||||
|
args = append(args, "--use-embedded-dex=true")
|
||||||
|
}
|
||||||
|
|
||||||
// Inject minSdkVersion into the manifest
|
// Inject minSdkVersion into the manifest
|
||||||
fixedManifest := android.PathForModuleOut(ctx, "manifest_fixer", "AndroidManifest.xml")
|
fixedManifest := android.PathForModuleOut(ctx, "manifest_fixer", "AndroidManifest.xml")
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
@@ -73,6 +73,10 @@ type appProperties struct {
|
|||||||
// sdk_version or min_sdk_version is set to a version that doesn't support it (<23), defaults to false for other
|
// sdk_version or min_sdk_version is set to a version that doesn't support it (<23), defaults to false for other
|
||||||
// module types where the native libraries are generally preinstalled outside the APK.
|
// module types where the native libraries are generally preinstalled outside the APK.
|
||||||
Use_embedded_native_libs *bool
|
Use_embedded_native_libs *bool
|
||||||
|
|
||||||
|
// Store dex files uncompressed in the APK and set the android:useEmbeddedDex="true" manifest attribute so that
|
||||||
|
// they are used from inside the APK at runtime.
|
||||||
|
Use_embedded_dex *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type AndroidApp struct {
|
type AndroidApp struct {
|
||||||
@@ -141,6 +145,7 @@ func (a *AndroidApp) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
|
|
||||||
func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
a.aapt.uncompressedJNI = a.shouldUncompressJNI(ctx)
|
a.aapt.uncompressedJNI = a.shouldUncompressJNI(ctx)
|
||||||
|
a.aapt.useEmbeddedDex = Bool(a.appProperties.Use_embedded_dex)
|
||||||
a.generateAndroidBuildActions(ctx)
|
a.generateAndroidBuildActions(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +162,10 @@ func (a *AndroidApp) shouldUncompressJNI(ctx android.ModuleContext) bool {
|
|||||||
|
|
||||||
// Returns whether this module should have the dex file stored uncompressed in the APK.
|
// Returns whether this module should have the dex file stored uncompressed in the APK.
|
||||||
func (a *AndroidApp) shouldUncompressDex(ctx android.ModuleContext) bool {
|
func (a *AndroidApp) shouldUncompressDex(ctx android.ModuleContext) bool {
|
||||||
|
if Bool(a.appProperties.Use_embedded_dex) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
if ctx.Config().UnbundledBuild() {
|
if ctx.Config().UnbundledBuild() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user