Merge "Declare ConfiguredJarList in specific fragment implementations."
This commit is contained in:
@@ -51,6 +51,10 @@ type classpathFragment interface {
|
|||||||
android.Module
|
android.Module
|
||||||
|
|
||||||
classpathFragmentBase() *ClasspathFragmentBase
|
classpathFragmentBase() *ClasspathFragmentBase
|
||||||
|
|
||||||
|
// ClasspathFragmentToConfiguredJarList returns android.ConfiguredJarList representation of all
|
||||||
|
// the jars in this classpath fragment.
|
||||||
|
ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClasspathFragmentBase is meant to be embedded in any module types that implement classpathFragment;
|
// ClasspathFragmentBase is meant to be embedded in any module types that implement classpathFragment;
|
||||||
@@ -84,24 +88,26 @@ type classpathJar struct {
|
|||||||
maxSdkVersion int32
|
maxSdkVersion int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.ModuleContext) {
|
// Converts android.ConfiguredJarList into a list of classpathJars for each given classpathType.
|
||||||
|
func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars android.ConfiguredJarList, classpaths ...classpathType) []classpathJar {
|
||||||
|
paths := configuredJars.DevicePaths(ctx.Config(), android.Android)
|
||||||
|
jars := make([]classpathJar, 0, len(paths)*len(classpaths))
|
||||||
|
for i := 0; i < len(paths); i++ {
|
||||||
|
for _, classpathType := range classpaths {
|
||||||
|
jars = append(jars, classpathJar{
|
||||||
|
classpath: classpathType,
|
||||||
|
path: paths[i],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jars
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.ModuleContext, jars []classpathJar) {
|
||||||
outputFilename := ctx.ModuleName() + ".pb"
|
outputFilename := ctx.ModuleName() + ".pb"
|
||||||
c.outputFilepath = android.PathForModuleOut(ctx, outputFilename).OutputPath
|
c.outputFilepath = android.PathForModuleOut(ctx, outputFilename).OutputPath
|
||||||
c.installDirPath = android.PathForModuleInstall(ctx, "etc", "classpaths")
|
c.installDirPath = android.PathForModuleInstall(ctx, "etc", "classpaths")
|
||||||
|
|
||||||
var jars []classpathJar
|
|
||||||
switch c.classpathType {
|
|
||||||
case BOOTCLASSPATH:
|
|
||||||
jars = appendClasspathJar(jars, BOOTCLASSPATH, defaultBootclasspath(ctx)...)
|
|
||||||
jars = appendClasspathJar(jars, DEX2OATBOOTCLASSPATH, defaultBootImageConfig(ctx).getAnyAndroidVariant().dexLocationsDeps...)
|
|
||||||
case SYSTEMSERVERCLASSPATH:
|
|
||||||
jars = appendClasspathJar(jars, SYSTEMSERVERCLASSPATH, systemServerClasspath(ctx)...)
|
|
||||||
default:
|
|
||||||
// Only supported classpath fragments are BOOTCLASSPATH and SYSTEMSERVERCLASSPATH.
|
|
||||||
// DEX2OATBOOTCLASSPATH is a special case of BOOTCLASSPATH and is auto-generated.
|
|
||||||
panic(fmt.Errorf("found %v, expected either BOOTCLASSPATH or SYSTEMSERVERCLASSPATH", c.classpathType))
|
|
||||||
}
|
|
||||||
|
|
||||||
generatedJson := android.PathForModuleOut(ctx, outputFilename+".json")
|
generatedJson := android.PathForModuleOut(ctx, outputFilename+".json")
|
||||||
writeClasspathsJson(ctx, generatedJson, jars)
|
writeClasspathsJson(ctx, generatedJson, jars)
|
||||||
|
|
||||||
@@ -137,19 +143,8 @@ func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath,
|
|||||||
android.WriteFileRule(ctx, output, content.String())
|
android.WriteFileRule(ctx, output, content.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendClasspathJar(slice []classpathJar, classpathType classpathType, paths ...string) (result []classpathJar) {
|
|
||||||
result = append(result, slice...)
|
|
||||||
for _, path := range paths {
|
|
||||||
result = append(result, classpathJar{
|
|
||||||
path: path,
|
|
||||||
classpath: classpathType,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *ClasspathFragmentBase) androidMkEntries() []android.AndroidMkEntries {
|
func (c *ClasspathFragmentBase) androidMkEntries() []android.AndroidMkEntries {
|
||||||
return []android.AndroidMkEntries{android.AndroidMkEntries{
|
return []android.AndroidMkEntries{{
|
||||||
Class: "ETC",
|
Class: "ETC",
|
||||||
OutputFile: android.OptionalPathForPath(c.outputFilepath),
|
OutputFile: android.OptionalPathForPath(c.outputFilepath),
|
||||||
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||||
|
@@ -163,18 +163,6 @@ func defaultBootImageConfig(ctx android.PathContext) *bootImageConfig {
|
|||||||
return genBootImageConfigs(ctx)[frameworkBootImageName]
|
return genBootImageConfigs(ctx)[frameworkBootImageName]
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultBootclasspath(ctx android.PathContext) []string {
|
|
||||||
return ctx.Config().OnceStringSlice(defaultBootclasspathKey, func() []string {
|
|
||||||
global := dexpreopt.GetGlobalConfig(ctx)
|
|
||||||
image := defaultBootImageConfig(ctx)
|
|
||||||
|
|
||||||
updatableBootclasspath := global.UpdatableBootJars.DevicePaths(ctx.Config(), android.Android)
|
|
||||||
|
|
||||||
bootclasspath := append(copyOf(image.getAnyAndroidVariant().dexLocationsDeps), updatableBootclasspath...)
|
|
||||||
return bootclasspath
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updatable boot config allows to access build/install paths of updatable boot jars without going
|
// Updatable boot config allows to access build/install paths of updatable boot jars without going
|
||||||
// through the usual trouble of registering dependencies on those modules and extracting build paths
|
// through the usual trouble of registering dependencies on those modules and extracting build paths
|
||||||
// from those dependencies.
|
// from those dependencies.
|
||||||
|
@@ -167,8 +167,6 @@ func (d *platformBootclasspathModule) MakeVars(ctx android.MakeVarsContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx)
|
|
||||||
|
|
||||||
// Gather all the dependencies from the art, updatable and non-updatable boot jars.
|
// Gather all the dependencies from the art, updatable and non-updatable boot jars.
|
||||||
artModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathArtBootJarDepTag)
|
artModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathArtBootJarDepTag)
|
||||||
nonUpdatableModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathNonUpdatableBootJarDepTag)
|
nonUpdatableModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathNonUpdatableBootJarDepTag)
|
||||||
@@ -189,6 +187,8 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo
|
|||||||
b.checkNonUpdatableModules(ctx, nonUpdatableModules)
|
b.checkNonUpdatableModules(ctx, nonUpdatableModules)
|
||||||
b.checkUpdatableModules(ctx, updatableModules)
|
b.checkUpdatableModules(ctx, updatableModules)
|
||||||
|
|
||||||
|
b.generateClasspathProtoBuildActions(ctx)
|
||||||
|
|
||||||
b.generateHiddenAPIBuildActions(ctx, b.configuredModules, b.fragments)
|
b.generateHiddenAPIBuildActions(ctx, b.configuredModules, b.fragments)
|
||||||
|
|
||||||
// Nothing to do if skipping the dexpreopt of boot image jars.
|
// Nothing to do if skipping the dexpreopt of boot image jars.
|
||||||
@@ -199,6 +199,23 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo
|
|||||||
b.generateBootImageBuildActions(ctx, updatableModules)
|
b.generateBootImageBuildActions(ctx, updatableModules)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate classpaths.proto config
|
||||||
|
func (b *platformBootclasspathModule) generateClasspathProtoBuildActions(ctx android.ModuleContext) {
|
||||||
|
// ART and platform boot jars must have a corresponding entry in DEX2OATBOOTCLASSPATH
|
||||||
|
classpathJars := configuredJarListToClasspathJars(ctx, b.ClasspathFragmentToConfiguredJarList(ctx), BOOTCLASSPATH, DEX2OATBOOTCLASSPATH)
|
||||||
|
// TODO(satayev): remove updatable boot jars once each apex has its own fragment
|
||||||
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
|
classpathJars = append(classpathJars, configuredJarListToClasspathJars(ctx, global.UpdatableBootJars, BOOTCLASSPATH)...)
|
||||||
|
|
||||||
|
b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, classpathJars)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *platformBootclasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
|
||||||
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
|
// TODO(satayev): split ART apex jars into their own classpathFragment
|
||||||
|
return global.BootJars
|
||||||
|
}
|
||||||
|
|
||||||
// checkNonUpdatableModules ensures that the non-updatable modules supplied are not part of an
|
// checkNonUpdatableModules ensures that the non-updatable modules supplied are not part of an
|
||||||
// updatable module.
|
// updatable module.
|
||||||
func (b *platformBootclasspathModule) checkNonUpdatableModules(ctx android.ModuleContext, modules []android.Module) {
|
func (b *platformBootclasspathModule) checkNonUpdatableModules(ctx android.ModuleContext, modules []android.Module) {
|
||||||
|
@@ -16,6 +16,7 @@ package java
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"android/soong/dexpreopt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -45,6 +46,22 @@ func (b *platformSystemServerClasspathModule) AndroidMkEntries() (entries []andr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (b *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
// TODO(satayev): split apex jars into separate configs.
|
configuredJars := configuredJarListToClasspathJars(ctx, b.ClasspathFragmentToConfiguredJarList(ctx), b.classpathType)
|
||||||
b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx)
|
b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars)
|
||||||
|
}
|
||||||
|
|
||||||
|
var platformSystemServerClasspathKey = android.NewOnceKey("platform_systemserverclasspath")
|
||||||
|
|
||||||
|
func (b *platformSystemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
|
||||||
|
return ctx.Config().Once(platformSystemServerClasspathKey, func() interface{} {
|
||||||
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
|
|
||||||
|
jars := global.SystemServerJars
|
||||||
|
|
||||||
|
// TODO(satayev): split apex jars into separate configs.
|
||||||
|
for i := 0; i < global.UpdatableSystemServerJars.Len(); i++ {
|
||||||
|
jars = jars.Append(global.UpdatableSystemServerJars.Apex(i), global.UpdatableSystemServerJars.Jar(i))
|
||||||
|
}
|
||||||
|
return jars
|
||||||
|
}).(android.ConfiguredJarList)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user