Merge "Store dex jar paths in bootclasspath_fragment's apex content info" am: bf4e6ec8a7
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1710510 Change-Id: I02ba146397786a66977c2412ddce2a5c98fd82d5
This commit is contained in:
commit
02d4f36f2c
3 changed files with 55 additions and 10 deletions
|
@ -2153,7 +2153,10 @@ func apexFileForBootclasspathFragmentContentModule(ctx android.ModuleContext, fr
|
|||
|
||||
// Get the dexBootJar from the bootclasspath_fragment as that is responsible for performing the
|
||||
// hidden API encpding.
|
||||
dexBootJar := bootclasspathFragmentInfo.DexBootJarPathForContentModule(javaModule)
|
||||
dexBootJar, err := bootclasspathFragmentInfo.DexBootJarPathForContentModule(javaModule)
|
||||
if err != nil {
|
||||
ctx.ModuleErrorf("%s", err)
|
||||
}
|
||||
|
||||
// Create an apexFile as for a normal java module but with the dex boot jar provided by the
|
||||
// bootclasspath_fragment.
|
||||
|
|
|
@ -512,7 +512,10 @@ func TestBootclasspathFragmentContentsNoName(t *testing.T) {
|
|||
|
||||
checkFragmentExportedDexJar := func(name string, expectedDexJar string) {
|
||||
module := result.Module(name, "android_common_apex10000")
|
||||
dexJar := info.DexBootJarPathForContentModule(module)
|
||||
dexJar, err := info.DexBootJarPathForContentModule(module)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
android.AssertPathRelativeToTopEquals(t, name+" dex", expectedDexJar, dexJar)
|
||||
|
||||
expectedCopyCommand := fmt.Sprintf("&& cp -f %s out/soong/.intermediates/myapex/android_common_myapex_image/image.apex/javalib/%s.jar", expectedDexJar, name)
|
||||
|
|
|
@ -273,6 +273,10 @@ type BootclasspathFragmentApexContentInfo struct {
|
|||
// Will be nil if the BootclasspathFragmentApexContentInfo has not been provided for a specific module. That can occur
|
||||
// when SkipDexpreoptBootJars(ctx) returns true.
|
||||
imageConfig *bootImageConfig
|
||||
|
||||
// Map from the name of the context module (as returned by Name()) to the hidden API encoded dex
|
||||
// jar path.
|
||||
contentModuleDexJarPaths map[string]android.Path
|
||||
}
|
||||
|
||||
func (i BootclasspathFragmentApexContentInfo) Modules() android.ConfiguredJarList {
|
||||
|
@ -299,10 +303,14 @@ func (i BootclasspathFragmentApexContentInfo) AndroidBootImageFilesByArchType()
|
|||
// DexBootJarPathForContentModule returns the path to the dex boot jar for specified module.
|
||||
//
|
||||
// The dex boot jar is one which has had hidden API encoding performed on it.
|
||||
func (i BootclasspathFragmentApexContentInfo) DexBootJarPathForContentModule(module android.Module) android.Path {
|
||||
j := module.(UsesLibraryDependency)
|
||||
dexJar := j.DexJarBuildPath()
|
||||
return dexJar
|
||||
func (i BootclasspathFragmentApexContentInfo) DexBootJarPathForContentModule(module android.Module) (android.Path, error) {
|
||||
name := module.Name()
|
||||
if dexJar, ok := i.contentModuleDexJarPaths[name]; ok {
|
||||
return dexJar, nil
|
||||
} else {
|
||||
return nil, fmt.Errorf("unknown bootclasspath_fragment content module %s, expected one of %s",
|
||||
name, strings.Join(android.SortedStringKeys(i.contentModuleDexJarPaths), ", "))
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BootclasspathFragmentModule) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
||||
|
@ -380,6 +388,28 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo
|
|||
// Perform hidden API processing.
|
||||
b.generateHiddenAPIBuildActions(ctx, contents)
|
||||
|
||||
// Verify that the image_name specified on a bootclasspath_fragment is valid even if this is a
|
||||
// prebuilt which will not use the image config.
|
||||
imageConfig := b.getImageConfig(ctx)
|
||||
|
||||
// A prebuilt fragment cannot contribute to the apex.
|
||||
if !android.IsModulePrebuilt(ctx.Module()) {
|
||||
// Provide the apex content info.
|
||||
b.provideApexContentInfo(ctx, imageConfig, contents)
|
||||
}
|
||||
}
|
||||
|
||||
// provideApexContentInfo creates, initializes and stores the apex content info for use by other
|
||||
// modules.
|
||||
func (b *BootclasspathFragmentModule) provideApexContentInfo(ctx android.ModuleContext, imageConfig *bootImageConfig, contents []android.Module) {
|
||||
// Construct the apex content info from the config.
|
||||
info := BootclasspathFragmentApexContentInfo{
|
||||
imageConfig: imageConfig,
|
||||
}
|
||||
|
||||
// Populate the apex content info with paths to the dex jars.
|
||||
b.populateApexContentInfoDexJars(ctx, &info, contents)
|
||||
|
||||
if !SkipDexpreoptBootJars(ctx) {
|
||||
// Force the GlobalSoongConfig to be created and cached for use by the dex_bootjars
|
||||
// GenerateSingletonBuildActions method as it cannot create it for itself.
|
||||
|
@ -387,11 +417,20 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo
|
|||
|
||||
// Only generate the boot image if the configuration does not skip it.
|
||||
b.generateBootImageBuildActions(ctx, contents)
|
||||
}
|
||||
|
||||
// Make the boot image info available for other modules
|
||||
ctx.SetProvider(BootclasspathFragmentApexContentInfoProvider, BootclasspathFragmentApexContentInfo{
|
||||
imageConfig: b.getImageConfig(ctx),
|
||||
})
|
||||
// Make the apex content info available for other modules.
|
||||
ctx.SetProvider(BootclasspathFragmentApexContentInfoProvider, info)
|
||||
}
|
||||
|
||||
// populateApexContentInfoDexJars adds paths to the dex jars provided by this fragment to the
|
||||
// apex content info.
|
||||
func (b *BootclasspathFragmentModule) populateApexContentInfoDexJars(ctx android.ModuleContext, info *BootclasspathFragmentApexContentInfo, contents []android.Module) {
|
||||
info.contentModuleDexJarPaths = map[string]android.Path{}
|
||||
for _, m := range contents {
|
||||
j := m.(UsesLibraryDependency)
|
||||
dexJar := j.DexJarBuildPath()
|
||||
info.contentModuleDexJarPaths[m.Name()] = dexJar
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue