Move validation from FindDeapexerProviderForModule to rdeps

FindDeapexerProviderForModule raises an exception if multiple apexes in
the tree has an export dep on the java module. In prepartation to
support multiple prebuilts, move this error check out of
FindDeapexerProviderForModule and into rdeps. i.e. raise an exception
only if an rdep calls DexJarBuildPath

- This should be a no-op for now.
- In the short-term future, a java import module will be allowed to have
  multiple deapexers. An error will be raised if anyone actually tries
  to depend on the dexjar
- In the long-term future, this function will be removed. All processing
  will be done at the prebuilt apex level and not at the prebuilt java
  library level

Since this check now happens in the moduleCtx of rdeps, add some
additional props to unit tests to ensure that it does not exit early on
unrelated validation checks (e.g. hidden_api prop is not set)

Test: go test ./apex ./java
Bug: 308790457

Change-Id: I3323d993c1ea8f43305834cae8e65b6fe41dfefd
This commit is contained in:
Spandan Das
2023-12-12 23:23:53 +00:00
parent 2069c3f74d
commit fae468ef14
6 changed files with 59 additions and 18 deletions

View File

@@ -2378,7 +2378,8 @@ type SdkLibraryImport struct {
xmlPermissionsFileModule *sdkLibraryXml
// Build path to the dex implementation jar obtained from the prebuilt_apex, if any.
dexJarFile OptionalDexJarPath
dexJarFile OptionalDexJarPath
dexJarFileErr error
// Expected install file path of the source module(sdk_library)
// or dex implementation jar obtained from the prebuilt_apex, if any.
@@ -2687,9 +2688,12 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
ai, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if ai.ForPrebuiltApex {
// Get the path of the dex implementation jar from the `deapexer` module.
di := android.FindDeapexerProviderForModule(ctx)
if di == nil {
return // An error has been reported by FindDeapexerProviderForModule.
di, err := android.FindDeapexerProviderForModule(ctx)
if err != nil {
// An error was found, possibly due to multiple apexes in the tree that export this library
// Defer the error till a client tries to call DexJarBuildPath
module.dexJarFileErr = err
return
}
dexJarFileApexRootRelative := apexRootRelativePathToJavaLib(module.BaseModuleName())
if dexOutputPath := di.PrebuiltExportPath(dexJarFileApexRootRelative); dexOutputPath != nil {
@@ -2751,6 +2755,9 @@ func (module *SdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleCont
func (module *SdkLibraryImport) DexJarBuildPath() OptionalDexJarPath {
// The dex implementation jar extracted from the .apex file should be used in preference to the
// source.
if module.dexJarFileErr != nil {
panic(module.dexJarFileErr.Error())
}
if module.dexJarFile.IsSet() {
return module.dexJarFile
}