Merge changes I8e8e8b01,Ifb1f54d5,I9986e64f

* changes:
  Add systemserverclasspath_fragments property to apex.
  Add "contents" property to systemserverclasspath_fragment.
  Move classpaths.proto related info into a separate provider.
This commit is contained in:
satayev
2021-05-17 22:40:08 +00:00
committed by Gerrit Code Review
7 changed files with 206 additions and 42 deletions

View File

@@ -268,22 +268,6 @@ var BootclasspathFragmentApexContentInfoProvider = blueprint.NewProvider(Bootcla
// BootclasspathFragmentApexContentInfo contains the bootclasspath_fragments contributions to the
// apex contents.
type BootclasspathFragmentApexContentInfo struct {
// ClasspathFragmentProtoOutput is an output path for the generated classpaths.proto config of this module.
//
// The file should be copied to a relevant place on device, see ClasspathFragmentProtoInstallDir
// for more details.
ClasspathFragmentProtoOutput android.OutputPath
// ClasspathFragmentProtoInstallDir contains information about on device location for the generated classpaths.proto file.
//
// The path encodes expected sub-location within partitions, i.e. etc/classpaths/<proto-file>,
// for ClasspathFragmentProtoOutput. To get sub-location, instead of the full output / make path
// use android.InstallPath#Rel().
//
// This is only relevant for APEX modules as they perform their own installation; while regular
// system files are installed via ClasspathFragmentBase#androidMkEntries().
ClasspathFragmentProtoInstallDir android.InstallPath
// The image config, internal to this module (and the dex_bootjars singleton).
//
// Will be nil if the BootclasspathFragmentApexContentInfo has not been provided for a specific module. That can occur
@@ -396,25 +380,19 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo
// Perform hidden API processing.
b.generateHiddenAPIBuildActions(ctx, contents)
// Construct the boot image info from the config.
info := BootclasspathFragmentApexContentInfo{
ClasspathFragmentProtoInstallDir: b.classpathFragmentBase().installDirPath,
ClasspathFragmentProtoOutput: b.classpathFragmentBase().outputFilepath,
imageConfig: nil,
}
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.
dexpreopt.GetGlobalSoongConfig(ctx)
info.imageConfig = b.getImageConfig(ctx)
// Only generate the boot image if the configuration does not skip it.
b.generateBootImageBuildActions(ctx, contents)
}
// Make it available for other modules.
ctx.SetProvider(BootclasspathFragmentApexContentInfoProvider, info)
// Make the boot image info available for other modules
ctx.SetProvider(BootclasspathFragmentApexContentInfoProvider, BootclasspathFragmentApexContentInfo{
imageConfig: b.getImageConfig(ctx),
})
}
}
// generateClasspathProtoBuildActions generates all required build actions for classpath.proto config

View File

@@ -18,6 +18,7 @@ package java
import (
"fmt"
"github.com/google/blueprint"
"strings"
"android/soong/android"
@@ -120,6 +121,12 @@ func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.M
FlagWithOutput("--output=", c.outputFilepath)
rule.Build("classpath_fragment", "Compiling "+c.outputFilepath.String())
classpathProtoInfo := ClasspathFragmentProtoContentInfo{
ClasspathFragmentProtoInstallDir: c.installDirPath,
ClasspathFragmentProtoOutput: c.outputFilepath,
}
ctx.SetProvider(ClasspathFragmentProtoContentInfoProvider, classpathProtoInfo)
}
func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) {
@@ -157,3 +164,23 @@ func (c *ClasspathFragmentBase) androidMkEntries() []android.AndroidMkEntries {
},
}}
}
var ClasspathFragmentProtoContentInfoProvider = blueprint.NewProvider(ClasspathFragmentProtoContentInfo{})
type ClasspathFragmentProtoContentInfo struct {
// ClasspathFragmentProtoOutput is an output path for the generated classpaths.proto config of this module.
//
// The file should be copied to a relevant place on device, see ClasspathFragmentProtoInstallDir
// for more details.
ClasspathFragmentProtoOutput android.OutputPath
// ClasspathFragmentProtoInstallDir contains information about on device location for the generated classpaths.proto file.
//
// The path encodes expected sub-location within partitions, i.e. etc/classpaths/<proto-file>,
// for ClasspathFragmentProtoOutput. To get sub-location, instead of the full output / make path
// use android.InstallPath#Rel().
//
// This is only relevant for APEX modules as they perform their own installation; while regular
// system files are installed via ClasspathFragmentBase#androidMkEntries().
ClasspathFragmentProtoInstallDir android.InstallPath
}

View File

@@ -17,6 +17,7 @@ package java
import (
"android/soong/android"
"android/soong/dexpreopt"
"github.com/google/blueprint"
)
func init() {
@@ -66,24 +67,63 @@ func (p *platformSystemServerClasspathModule) ClasspathFragmentToConfiguredJarLi
}).(android.ConfiguredJarList)
}
type systemServerClasspathModule struct {
type SystemServerClasspathModule struct {
android.ModuleBase
android.ApexModuleBase
ClasspathFragmentBase
properties systemServerClasspathFragmentProperties
}
func (s *SystemServerClasspathModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
return nil
}
type systemServerClasspathFragmentProperties struct {
// The contents of this systemserverclasspath_fragment, could be either java_library, or java_sdk_library.
//
// The order of this list matters as it is the order that is used in the SYSTEMSERVERCLASSPATH.
Contents []string
}
func systemServerClasspathFactory() android.Module {
m := &systemServerClasspathModule{}
m := &SystemServerClasspathModule{}
m.AddProperties(&m.properties)
android.InitApexModule(m)
initClasspathFragment(m, SYSTEMSERVERCLASSPATH)
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
return m
}
func (s *systemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if len(s.properties.Contents) == 0 {
ctx.PropertyErrorf("contents", "empty contents are not allowed")
}
s.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJarListToClasspathJars(ctx, s.ClasspathFragmentToConfiguredJarList(ctx)))
}
func (s *systemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
func (s *SystemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
// TODO(satayev): populate with actual content
return android.EmptyConfiguredJarList()
}
type systemServerClasspathFragmentContentDependencyTag struct {
blueprint.BaseDependencyTag
}
// The tag used for the dependency between the systemserverclasspath_fragment module and its contents.
var systemServerClasspathFragmentContentDepTag = systemServerClasspathFragmentContentDependencyTag{}
func IsSystemServerClasspathFragmentContentDepTag(tag blueprint.DependencyTag) bool {
return tag == systemServerClasspathFragmentContentDepTag
}
func (s *SystemServerClasspathModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
module := ctx.Module()
for _, name := range s.properties.Contents {
ctx.AddDependency(module, systemServerClasspathFragmentContentDepTag, name)
}
}

View File

@@ -20,13 +20,13 @@ import (
"android/soong/android"
)
var prepareForTestWithSystemserverClasspath = android.GroupFixturePreparers(
var prepareForTestWithSystemServerClasspath = android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
)
func TestSystemserverClasspathVariant(t *testing.T) {
func TestPlatformSystemserverClasspathVariant(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithSystemserverClasspath,
prepareForTestWithSystemServerClasspath,
android.FixtureWithRootAndroidBp(`
platform_systemserverclasspath {
name: "platform-systemserverclasspath",
@@ -38,9 +38,9 @@ func TestSystemserverClasspathVariant(t *testing.T) {
android.AssertIntEquals(t, "expect 1 variant", 1, len(variants))
}
func TestSystemserverClasspath_ClasspathFragmentPaths(t *testing.T) {
func TestPlatformSystemserverClasspath_ClasspathFragmentPaths(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithSystemserverClasspath,
prepareForTestWithSystemServerClasspath,
android.FixtureWithRootAndroidBp(`
platform_systemserverclasspath {
name: "platform-systemserverclasspath",
@@ -53,9 +53,9 @@ func TestSystemserverClasspath_ClasspathFragmentPaths(t *testing.T) {
android.AssertPathRelativeToTopEquals(t, "install filepath", "out/soong/target/product/test_device/system/etc/classpaths", p.ClasspathFragmentBase.installDirPath)
}
func TestSystemserverClasspathModule_AndroidMkEntries(t *testing.T) {
func TestPlatformSystemserverClasspathModule_AndroidMkEntries(t *testing.T) {
preparer := android.GroupFixturePreparers(
prepareForTestWithSystemserverClasspath,
prepareForTestWithSystemServerClasspath,
android.FixtureWithRootAndroidBp(`
platform_systemserverclasspath {
name: "platform-systemserverclasspath",
@@ -95,3 +95,14 @@ func TestSystemserverClasspathModule_AndroidMkEntries(t *testing.T) {
}
})
}
func TestSystemserverclasspathFragmentWithoutContents(t *testing.T) {
prepareForTestWithSystemServerClasspath.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
`\Qempty contents are not allowed\E`)).
RunTestWithBp(t, `
systemserverclasspath_fragment {
name: "systemserverclasspath-fragment",
}
`)
}