Merge changes I957f3df8,I68986dcc
* changes: Consolidate the code to resolve a deapexer module dependency. Propagate the dex jar path as an OptionalPath which is either valid or invalid with a message.
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
|
||||
@@ -915,10 +915,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
|
||||
@@ -1044,7 +1044,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
|
||||
@@ -1941,7 +1941,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.
|
||||
@@ -2169,8 +2169,6 @@ func (module *SdkLibraryImport) OutputFiles(tag string) (android.Paths, error) {
|
||||
func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
module.generateCommonBuildActions(ctx)
|
||||
|
||||
var deapexerModule android.Module
|
||||
|
||||
// Assume that source module(sdk_library) is installed in /<sdk_library partition>/framework
|
||||
module.installFile = android.PathForModuleInstall(ctx, "framework", module.Stem()+".jar")
|
||||
|
||||
@@ -2199,11 +2197,6 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
|
||||
ctx.ModuleErrorf("xml permissions file module must be of type *sdkLibraryXml but was %T", to)
|
||||
}
|
||||
}
|
||||
|
||||
// Save away the `deapexer` module on which this depends, if any.
|
||||
if tag == android.DeapexerTag {
|
||||
deapexerModule = to
|
||||
}
|
||||
})
|
||||
|
||||
// Populate the scope paths with information from the properties.
|
||||
@@ -2223,21 +2216,18 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
|
||||
// obtained from the associated deapexer module.
|
||||
ai := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
|
||||
if ai.ForPrebuiltApex {
|
||||
if deapexerModule == nil {
|
||||
// This should never happen as a variant for a prebuilt_apex is only created if the
|
||||
// deapxer module has been configured to export the dex implementation jar for this module.
|
||||
ctx.ModuleErrorf("internal error: module %q does not depend on a `deapexer` module for prebuilt_apex %q",
|
||||
module.Name(), ai.ApexVariationName)
|
||||
}
|
||||
|
||||
// Get the path of the dex implementation jar from the `deapexer` module.
|
||||
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
|
||||
di := android.FindDeapexerProviderForModule(ctx)
|
||||
if di == nil {
|
||||
return // An error has been reported by FindDeapexerProviderForModule.
|
||||
}
|
||||
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)
|
||||
@@ -2247,7 +2237,7 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
|
||||
} else {
|
||||
// This should never happen as a variant for a prebuilt_apex is only created if the
|
||||
// prebuilt_apex has been configured to export the java library dex file.
|
||||
ctx.ModuleErrorf("internal error: no dex implementation jar available from prebuilt_apex %q", deapexerModule.Name())
|
||||
ctx.ModuleErrorf("internal error: no dex implementation jar available from prebuilt APEX %s", di.ApexModuleName())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2282,14 +2272,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