Merge changes I9e94662d,I4b4e0dc8 am: 254aee4843
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1574746 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I996cffec92935fdfca054231d87777696a4420b6
This commit is contained in:
@@ -177,12 +177,6 @@ type SnapshotBuilder interface {
|
|||||||
// to the zip
|
// to the zip
|
||||||
CopyToSnapshot(src Path, dest string)
|
CopyToSnapshot(src Path, dest string)
|
||||||
|
|
||||||
// Return the path to an empty file.
|
|
||||||
//
|
|
||||||
// This can be used by sdk member types that need to create an empty file in the snapshot, simply
|
|
||||||
// pass the value returned from this to the CopyToSnapshot() method.
|
|
||||||
EmptyFile() Path
|
|
||||||
|
|
||||||
// Unzip the supplied zip into the snapshot relative directory destDir.
|
// Unzip the supplied zip into the snapshot relative directory destDir.
|
||||||
UnzipToSnapshot(zipPath Path, destDir string)
|
UnzipToSnapshot(zipPath Path, destDir string)
|
||||||
|
|
||||||
|
@@ -435,6 +435,11 @@ func (d *dexpreoptBootJars) GenerateSingletonBuildActions(ctx android.SingletonC
|
|||||||
// Inspect this module to see if it contains a bootclasspath dex jar.
|
// Inspect this module to see if it contains a bootclasspath dex jar.
|
||||||
// Note that the same jar may occur in multiple modules.
|
// Note that the same jar may occur in multiple modules.
|
||||||
// This logic is tested in the apex package to avoid import cycle apex <-> java.
|
// This logic is tested in the apex package to avoid import cycle apex <-> java.
|
||||||
|
//
|
||||||
|
// This is similar to logic in isModuleInConfiguredList() so any changes needed here are likely to
|
||||||
|
// be needed there too.
|
||||||
|
//
|
||||||
|
// TODO(b/177892522): Avoid having to perform this type of check or if necessary dedup it.
|
||||||
func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, module android.Module) (int, android.Path) {
|
func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, module android.Module) (int, android.Path) {
|
||||||
name := ctx.ModuleName(module)
|
name := ctx.ModuleName(module)
|
||||||
|
|
||||||
|
@@ -213,6 +213,10 @@ func stubFlagsRule(ctx android.SingletonContext) {
|
|||||||
|
|
||||||
var bootDexJars android.Paths
|
var bootDexJars android.Paths
|
||||||
|
|
||||||
|
// Get the configured non-updatable and updatable boot jars.
|
||||||
|
nonUpdatableBootJars := ctx.Config().NonUpdatableBootJars()
|
||||||
|
updatableBootJars := ctx.Config().UpdatableBootJars()
|
||||||
|
|
||||||
ctx.VisitAllModules(func(module android.Module) {
|
ctx.VisitAllModules(func(module android.Module) {
|
||||||
// Collect dex jar paths for the modules listed above.
|
// Collect dex jar paths for the modules listed above.
|
||||||
if j, ok := module.(Dependency); ok {
|
if j, ok := module.(Dependency); ok {
|
||||||
@@ -227,11 +231,8 @@ func stubFlagsRule(ctx android.SingletonContext) {
|
|||||||
// Collect dex jar paths for modules that had hiddenapi encode called on them.
|
// Collect dex jar paths for modules that had hiddenapi encode called on them.
|
||||||
if h, ok := module.(hiddenAPIIntf); ok {
|
if h, ok := module.(hiddenAPIIntf); ok {
|
||||||
if jar := h.bootDexJar(); jar != nil {
|
if jar := h.bootDexJar(); jar != nil {
|
||||||
// For a java lib included in an APEX, only take the one built for
|
if !isModuleInConfiguredList(ctx, module, nonUpdatableBootJars) &&
|
||||||
// the platform variant, and skip the variants for APEXes.
|
!isModuleInConfiguredList(ctx, module, updatableBootJars) {
|
||||||
// Otherwise, the hiddenapi tool will complain about duplicated classes
|
|
||||||
apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
|
|
||||||
if !apexInfo.IsForPlatform() {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,6 +281,47 @@ func stubFlagsRule(ctx android.SingletonContext) {
|
|||||||
rule.Build("hiddenAPIStubFlagsFile", "hiddenapi stub flags")
|
rule.Build("hiddenAPIStubFlagsFile", "hiddenapi stub flags")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks to see whether the supplied module variant is in the list of boot jars.
|
||||||
|
//
|
||||||
|
// This is similar to logic in getBootImageJar() so any changes needed here are likely to be needed
|
||||||
|
// there too.
|
||||||
|
//
|
||||||
|
// TODO(b/179354495): Avoid having to perform this type of check or if necessary dedup it.
|
||||||
|
func isModuleInConfiguredList(ctx android.SingletonContext, module android.Module, configuredBootJars android.ConfiguredJarList) bool {
|
||||||
|
name := ctx.ModuleName(module)
|
||||||
|
|
||||||
|
// Strip a prebuilt_ prefix so that this can match a prebuilt module that has not been renamed.
|
||||||
|
name = android.RemoveOptionalPrebuiltPrefix(name)
|
||||||
|
|
||||||
|
// Ignore any module that is not listed in the boot image configuration.
|
||||||
|
index := configuredBootJars.IndexOfJar(name)
|
||||||
|
if index == -1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is an error if the module is not an ApexModule.
|
||||||
|
if _, ok := module.(android.ApexModule); !ok {
|
||||||
|
ctx.Errorf("module %q configured in boot jars does not support being added to an apex", module)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
|
||||||
|
|
||||||
|
// Now match the apex part of the boot image configuration.
|
||||||
|
requiredApex := configuredBootJars.Apex(index)
|
||||||
|
if requiredApex == "platform" {
|
||||||
|
if len(apexInfo.InApexes) != 0 {
|
||||||
|
// A platform variant is required but this is for an apex so ignore it.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
} else if !apexInfo.InApexByBaseName(requiredApex) {
|
||||||
|
// An apex variant for a specific apex is required but this is the wrong apex.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func prebuiltFlagsRule(ctx android.SingletonContext) android.Path {
|
func prebuiltFlagsRule(ctx android.SingletonContext) android.Path {
|
||||||
outputPath := hiddenAPISingletonPaths(ctx).flags
|
outputPath := hiddenAPISingletonPaths(ctx).flags
|
||||||
inputPath := android.PathForSource(ctx, ctx.Config().PrebuiltHiddenApiDir(ctx), "hiddenapi-flags.csv")
|
inputPath := android.PathForSource(ctx, ctx.Config().PrebuiltHiddenApiDir(ctx), "hiddenapi-flags.csv")
|
||||||
|
35
java/java.go
35
java/java.go
@@ -40,18 +40,21 @@ func init() {
|
|||||||
// Register sdk member types.
|
// Register sdk member types.
|
||||||
android.RegisterSdkMemberType(javaHeaderLibsSdkMemberType)
|
android.RegisterSdkMemberType(javaHeaderLibsSdkMemberType)
|
||||||
|
|
||||||
|
// Export implementation classes jar as part of the sdk.
|
||||||
|
exportImplementationClassesJar := func(_ android.SdkMemberContext, j *Library) android.Path {
|
||||||
|
implementationJars := j.ImplementationAndResourcesJars()
|
||||||
|
if len(implementationJars) != 1 {
|
||||||
|
panic(fmt.Errorf("there must be only one implementation jar from %q", j.Name()))
|
||||||
|
}
|
||||||
|
return implementationJars[0]
|
||||||
|
}
|
||||||
|
|
||||||
// Register java implementation libraries for use only in module_exports (not sdk).
|
// Register java implementation libraries for use only in module_exports (not sdk).
|
||||||
android.RegisterSdkMemberType(&librarySdkMemberType{
|
android.RegisterSdkMemberType(&librarySdkMemberType{
|
||||||
android.SdkMemberTypeBase{
|
android.SdkMemberTypeBase{
|
||||||
PropertyName: "java_libs",
|
PropertyName: "java_libs",
|
||||||
},
|
},
|
||||||
func(_ android.SdkMemberContext, j *Library) android.Path {
|
exportImplementationClassesJar,
|
||||||
implementationJars := j.ImplementationAndResourcesJars()
|
|
||||||
if len(implementationJars) != 1 {
|
|
||||||
panic(fmt.Errorf("there must be only one implementation jar from %q", j.Name()))
|
|
||||||
}
|
|
||||||
return implementationJars[0]
|
|
||||||
},
|
|
||||||
sdkSnapshotFilePathForJar,
|
sdkSnapshotFilePathForJar,
|
||||||
copyEverythingToSnapshot,
|
copyEverythingToSnapshot,
|
||||||
})
|
})
|
||||||
@@ -72,19 +75,11 @@ func init() {
|
|||||||
PropertyName: "java_boot_libs",
|
PropertyName: "java_boot_libs",
|
||||||
SupportsSdk: true,
|
SupportsSdk: true,
|
||||||
},
|
},
|
||||||
func(ctx android.SdkMemberContext, j *Library) android.Path {
|
// Temporarily export implementation classes jar for java_boot_libs as it is required for the
|
||||||
// Java boot libs are only provided in the SDK to provide access to their dex implementation
|
// hiddenapi processing.
|
||||||
// jar for use by dexpreopting and boot jars package check. They do not need to provide an
|
// TODO(b/179354495): Revert once hiddenapi processing has been modularized.
|
||||||
// actual implementation jar but the java_import will need a file that exists so just copy an
|
exportImplementationClassesJar,
|
||||||
// empty file. Any attempt to use that file as a jar will cause a build error.
|
sdkSnapshotFilePathForJar,
|
||||||
return ctx.SnapshotBuilder().EmptyFile()
|
|
||||||
},
|
|
||||||
func(osPrefix, name string) string {
|
|
||||||
// Create a special name for the implementation jar to try and provide some useful information
|
|
||||||
// to a developer that attempts to compile against this.
|
|
||||||
// TODO(b/175714559): Provide a proper error message in Soong not ninja.
|
|
||||||
return filepath.Join(osPrefix, "java_boot_libs", "snapshot", "jars", "are", "invalid", name+jarFileSuffix)
|
|
||||||
},
|
|
||||||
onlyCopyJarToSnapshot,
|
onlyCopyJarToSnapshot,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -503,7 +503,7 @@ java_import {
|
|||||||
sdk_member_name: "myjavalib",
|
sdk_member_name: "myjavalib",
|
||||||
visibility: ["//visibility:public"],
|
visibility: ["//visibility:public"],
|
||||||
apex_available: ["//apex_available:platform"],
|
apex_available: ["//apex_available:platform"],
|
||||||
jars: ["java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar"],
|
jars: ["java/myjavalib.jar"],
|
||||||
}
|
}
|
||||||
|
|
||||||
java_import {
|
java_import {
|
||||||
@@ -511,7 +511,7 @@ java_import {
|
|||||||
prefer: false,
|
prefer: false,
|
||||||
visibility: ["//visibility:public"],
|
visibility: ["//visibility:public"],
|
||||||
apex_available: ["//apex_available:platform"],
|
apex_available: ["//apex_available:platform"],
|
||||||
jars: ["java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar"],
|
jars: ["java/myjavalib.jar"],
|
||||||
}
|
}
|
||||||
|
|
||||||
module_exports_snapshot {
|
module_exports_snapshot {
|
||||||
@@ -519,10 +519,9 @@ module_exports_snapshot {
|
|||||||
visibility: ["//visibility:public"],
|
visibility: ["//visibility:public"],
|
||||||
java_boot_libs: ["myexports_myjavalib@current"],
|
java_boot_libs: ["myexports_myjavalib@current"],
|
||||||
}
|
}
|
||||||
|
|
||||||
`),
|
`),
|
||||||
checkAllCopyRules(`
|
checkAllCopyRules(`
|
||||||
.intermediates/myexports/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar
|
.intermediates/myjavalib/android_common/withres/myjavalib.jar -> java/myjavalib.jar
|
||||||
`),
|
`),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -653,9 +653,6 @@ type snapshotBuilder struct {
|
|||||||
filesToZip android.Paths
|
filesToZip android.Paths
|
||||||
zipsToMerge android.Paths
|
zipsToMerge android.Paths
|
||||||
|
|
||||||
// The path to an empty file.
|
|
||||||
emptyFile android.WritablePath
|
|
||||||
|
|
||||||
prebuiltModules map[string]*bpModule
|
prebuiltModules map[string]*bpModule
|
||||||
prebuiltOrder []*bpModule
|
prebuiltOrder []*bpModule
|
||||||
|
|
||||||
@@ -706,19 +703,6 @@ func (s *snapshotBuilder) UnzipToSnapshot(zipPath android.Path, destDir string)
|
|||||||
s.zipsToMerge = append(s.zipsToMerge, tmpZipPath)
|
s.zipsToMerge = append(s.zipsToMerge, tmpZipPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *snapshotBuilder) EmptyFile() android.Path {
|
|
||||||
if s.emptyFile == nil {
|
|
||||||
ctx := s.ctx
|
|
||||||
s.emptyFile = android.PathForModuleOut(ctx, "empty")
|
|
||||||
s.ctx.Build(pctx, android.BuildParams{
|
|
||||||
Rule: android.Touch,
|
|
||||||
Output: s.emptyFile,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.emptyFile
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType string) android.BpModule {
|
func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType string) android.BpModule {
|
||||||
name := member.Name()
|
name := member.Name()
|
||||||
if s.prebuiltModules[name] != nil {
|
if s.prebuiltModules[name] != nil {
|
||||||
|
Reference in New Issue
Block a user