Propagate the dex jar path as an OptionalPath which is either valid or
invalid with a message. This will allow propagating any error from the deapexer module for prebuilt APEXes to the location where the dex jars get used. It's only at those points that we can raise errors about not being able to extract files from the deapexer modules if they are invalid, and this way we avoid encoding knowledge there about why they may be invalid. To keep the refactoring limited it intentionally does not change any of the existing logic for when dexJarFiles are set or not (non-nil vs nil prior to this change), although there may be opportunity to use this for more conditions when dex jars aren't available. The refactoring is also not extended to dexpreopt.ClassLoaderContextMap. Test: m nothing Bug: 192006406 Change-Id: I68986dccd9a9b3fee4d24caa1947ea17a36caedc
This commit is contained in:
@@ -540,7 +540,7 @@ type scopePaths struct {
|
||||
// The dex jar for the stubs.
|
||||
//
|
||||
// This is not the implementation jar, it still only contains stubs.
|
||||
stubsDexJarPath android.Path
|
||||
stubsDexJarPath OptionalDexJarPath
|
||||
|
||||
// The API specification file, e.g. system_current.txt.
|
||||
currentApiFilePath android.OptionalPath
|
||||
@@ -906,10 +906,10 @@ func sdkKindToApiScope(kind android.SdkKind) *apiScope {
|
||||
}
|
||||
|
||||
// to satisfy SdkLibraryDependency interface
|
||||
func (c *commonToSdkLibraryAndImport) SdkApiStubDexJar(ctx android.BaseModuleContext, kind android.SdkKind) android.Path {
|
||||
func (c *commonToSdkLibraryAndImport) SdkApiStubDexJar(ctx android.BaseModuleContext, kind android.SdkKind) OptionalDexJarPath {
|
||||
paths := c.selectScopePaths(ctx, kind)
|
||||
if paths == nil {
|
||||
return nil
|
||||
return makeUnsetDexJarPath()
|
||||
}
|
||||
|
||||
return paths.stubsDexJarPath
|
||||
@@ -1035,7 +1035,7 @@ type SdkLibraryDependency interface {
|
||||
|
||||
// SdkApiStubDexJar returns the dex jar for the stubs. It is needed by the hiddenapi processing
|
||||
// tool which processes dex files.
|
||||
SdkApiStubDexJar(ctx android.BaseModuleContext, kind android.SdkKind) android.Path
|
||||
SdkApiStubDexJar(ctx android.BaseModuleContext, kind android.SdkKind) OptionalDexJarPath
|
||||
|
||||
// SdkRemovedTxtFile returns the optional path to the removed.txt file for the specified sdk kind.
|
||||
SdkRemovedTxtFile(ctx android.BaseModuleContext, kind android.SdkKind) android.OptionalPath
|
||||
@@ -1929,7 +1929,7 @@ type SdkLibraryImport struct {
|
||||
xmlPermissionsFileModule *sdkLibraryXml
|
||||
|
||||
// Build path to the dex implementation jar obtained from the prebuilt_apex, if any.
|
||||
dexJarFile android.Path
|
||||
dexJarFile OptionalDexJarPath
|
||||
|
||||
// Expected install file path of the source module(sdk_library)
|
||||
// or dex implementation jar obtained from the prebuilt_apex, if any.
|
||||
@@ -2220,11 +2220,12 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
|
||||
// Get the path of the dex implementation jar from the `deapexer` module.
|
||||
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
|
||||
if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(module.BaseModuleName())); dexOutputPath != nil {
|
||||
module.dexJarFile = dexOutputPath
|
||||
dexJarFile := makeDexJarPathFromPath(dexOutputPath)
|
||||
module.dexJarFile = dexJarFile
|
||||
installPath := android.PathForModuleInPartitionInstall(
|
||||
ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(module.BaseModuleName()))
|
||||
module.installFile = installPath
|
||||
module.initHiddenAPI(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0], nil)
|
||||
module.initHiddenAPI(ctx, dexJarFile, module.findScopePaths(apiScopePublic).stubsImplPath[0], nil)
|
||||
|
||||
// Dexpreopting.
|
||||
module.dexpreopter.installPath = module.dexpreopter.getInstallPath(ctx, installPath)
|
||||
@@ -2269,14 +2270,14 @@ func (module *SdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleCont
|
||||
}
|
||||
|
||||
// to satisfy UsesLibraryDependency interface
|
||||
func (module *SdkLibraryImport) DexJarBuildPath() android.Path {
|
||||
func (module *SdkLibraryImport) DexJarBuildPath() OptionalDexJarPath {
|
||||
// The dex implementation jar extracted from the .apex file should be used in preference to the
|
||||
// source.
|
||||
if module.dexJarFile != nil {
|
||||
if module.dexJarFile.IsSet() {
|
||||
return module.dexJarFile
|
||||
}
|
||||
if module.implLibraryModule == nil {
|
||||
return nil
|
||||
return makeUnsetDexJarPath()
|
||||
} else {
|
||||
return module.implLibraryModule.DexJarBuildPath()
|
||||
}
|
||||
|
Reference in New Issue
Block a user