summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/bootclasspath_fragment.go184
-rw-r--r--java/bootclasspath_fragment_test.go35
-rw-r--r--java/classpath_fragment.go2
-rw-r--r--java/droidstubs.go3
-rw-r--r--java/platform_bootclasspath_test.go4
-rw-r--r--java/systemserver_classpath_fragment.go16
-rw-r--r--java/systemserver_classpath_fragment_test.go14
7 files changed, 122 insertions, 136 deletions
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index db49df8df..188d36225 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -168,61 +168,70 @@ func bootclasspathFragmentFactory() android.Module {
// necessary.
func bootclasspathFragmentInitContentsFromImage(ctx android.EarlyModuleContext, m *BootclasspathFragmentModule) {
contents := m.properties.Contents
- if m.properties.Image_name == nil && len(contents) == 0 {
- ctx.ModuleErrorf(`neither of the "image_name" and "contents" properties have been supplied, please supply exactly one`)
+ if len(contents) == 0 {
+ ctx.PropertyErrorf("contents", "required property is missing")
+ return
+ }
+
+ if m.properties.Image_name == nil {
+ // Nothing to do.
+ return
}
imageName := proptools.String(m.properties.Image_name)
- if imageName == "art" {
- // TODO(b/177892522): Prebuilts (versioned or not) should not use the image_name property.
- if android.IsModuleInVersionedSdk(m) {
- // The module is a versioned prebuilt so ignore it. This is done for a couple of reasons:
- // 1. There is no way to use this at the moment so ignoring it is safe.
- // 2. Attempting to initialize the contents property from the configuration will end up having
- // the versioned prebuilt depending on the unversioned prebuilt. That will cause problems
- // as the unversioned prebuilt could end up with an APEX variant created for the source
- // APEX which will prevent it from having an APEX variant for the prebuilt APEX which in
- // turn will prevent it from accessing the dex implementation jar from that which will
- // break hidden API processing, amongst others.
- return
- }
+ if imageName != "art" {
+ ctx.PropertyErrorf("image_name", `unknown image name %q, expected "art"`, imageName)
+ return
+ }
- // Get the configuration for the art apex jars. Do not use getImageConfig(ctx) here as this is
- // too early in the Soong processing for that to work.
- global := dexpreopt.GetGlobalConfig(ctx)
- modules := global.ArtApexJars
-
- // Make sure that the apex specified in the configuration is consistent and is one for which
- // this boot image is available.
- commonApex := ""
- for i := 0; i < modules.Len(); i++ {
- apex := modules.Apex(i)
- jar := modules.Jar(i)
- if apex == "platform" {
- ctx.ModuleErrorf("ArtApexJars is invalid as it requests a platform variant of %q", jar)
- continue
- }
- if !m.AvailableFor(apex) {
- ctx.ModuleErrorf("ArtApexJars configuration incompatible with this module, ArtApexJars expects this to be in apex %q but this is only in apexes %q",
- apex, m.ApexAvailable())
- continue
- }
- if commonApex == "" {
- commonApex = apex
- } else if commonApex != apex {
- ctx.ModuleErrorf("ArtApexJars configuration is inconsistent, expected all jars to be in the same apex but it specifies apex %q and %q",
- commonApex, apex)
- }
- }
+ // TODO(b/177892522): Prebuilts (versioned or not) should not use the image_name property.
+ if android.IsModuleInVersionedSdk(m) {
+ // The module is a versioned prebuilt so ignore it. This is done for a couple of reasons:
+ // 1. There is no way to use this at the moment so ignoring it is safe.
+ // 2. Attempting to initialize the contents property from the configuration will end up having
+ // the versioned prebuilt depending on the unversioned prebuilt. That will cause problems
+ // as the unversioned prebuilt could end up with an APEX variant created for the source
+ // APEX which will prevent it from having an APEX variant for the prebuilt APEX which in
+ // turn will prevent it from accessing the dex implementation jar from that which will
+ // break hidden API processing, amongst others.
+ return
+ }
- if len(contents) != 0 {
- // Nothing to do.
- return
+ // Get the configuration for the art apex jars. Do not use getImageConfig(ctx) here as this is
+ // too early in the Soong processing for that to work.
+ global := dexpreopt.GetGlobalConfig(ctx)
+ modules := global.ArtApexJars
+
+ // Make sure that the apex specified in the configuration is consistent and is one for which
+ // this boot image is available.
+ commonApex := ""
+ for i := 0; i < modules.Len(); i++ {
+ apex := modules.Apex(i)
+ jar := modules.Jar(i)
+ if apex == "platform" {
+ ctx.ModuleErrorf("ArtApexJars is invalid as it requests a platform variant of %q", jar)
+ continue
+ }
+ if !m.AvailableFor(apex) {
+ ctx.ModuleErrorf("ArtApexJars configuration incompatible with this module, ArtApexJars expects this to be in apex %q but this is only in apexes %q",
+ apex, m.ApexAvailable())
+ continue
+ }
+ if commonApex == "" {
+ commonApex = apex
+ } else if commonApex != apex {
+ ctx.ModuleErrorf("ArtApexJars configuration is inconsistent, expected all jars to be in the same apex but it specifies apex %q and %q",
+ commonApex, apex)
}
+ }
- // Store the jars in the Contents property so that they can be used to add dependencies.
- m.properties.Contents = modules.CopyOfJars()
+ if len(contents) != 0 {
+ // Nothing to do.
+ return
}
+
+ // Store the jars in the Contents property so that they can be used to add dependencies.
+ m.properties.Contents = modules.CopyOfJars()
}
// bootclasspathImageNameContentsConsistencyCheck checks that the configuration that applies to this
@@ -270,11 +279,12 @@ var BootclasspathFragmentApexContentInfoProvider = blueprint.NewProvider(Bootcla
// BootclasspathFragmentApexContentInfo contains the bootclasspath_fragments contributions to the
// apex contents.
type BootclasspathFragmentApexContentInfo struct {
- // 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
- // when SkipDexpreoptBootJars(ctx) returns true.
- imageConfig *bootImageConfig
+ // The configured modules, will be empty if this is from a bootclasspath_fragment that does not
+ // set image_name: "art".
+ modules android.ConfiguredJarList
+
+ // Map from arch type to the boot image files.
+ bootImageFilesByArch map[android.ArchType]android.OutputPaths
// Map from the name of the context module (as returned by Name()) to the hidden API encoded dex
// jar path.
@@ -282,24 +292,14 @@ type BootclasspathFragmentApexContentInfo struct {
}
func (i BootclasspathFragmentApexContentInfo) Modules() android.ConfiguredJarList {
- return i.imageConfig.modules
+ return i.modules
}
// Get a map from ArchType to the associated boot image's contents for Android.
//
// Extension boot images only return their own files, not the files of the boot images they extend.
func (i BootclasspathFragmentApexContentInfo) AndroidBootImageFilesByArchType() map[android.ArchType]android.OutputPaths {
- files := map[android.ArchType]android.OutputPaths{}
- if i.imageConfig != nil {
- for _, variant := range i.imageConfig.variants {
- // We also generate boot images for host (for testing), but we don't need those in the apex.
- // TODO(b/177892522) - consider changing this to check Os.OsClass = android.Device
- if variant.target.Os == android.Android {
- files[variant.target.Arch.ArchType] = variant.imagesDeps
- }
- }
- }
- return files
+ return i.bootImageFilesByArch
}
// DexBootJarPathForContentModule returns the path to the dex boot jar for specified module.
@@ -412,20 +412,33 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo
// modules.
func (b *BootclasspathFragmentModule) provideApexContentInfo(ctx android.ModuleContext, imageConfig *bootImageConfig, contents []android.Module, hiddenAPIFlagOutput *HiddenAPIFlagOutput) {
// Construct the apex content info from the config.
- info := BootclasspathFragmentApexContentInfo{
- imageConfig: imageConfig,
- }
+ info := BootclasspathFragmentApexContentInfo{}
// Populate the apex content info with paths to the dex jars.
b.populateApexContentInfoDexJars(ctx, &info, contents, hiddenAPIFlagOutput)
- 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)
-
- // Only generate the boot image if the configuration does not skip it.
- b.generateBootImageBuildActions(ctx, contents)
+ if imageConfig != nil {
+ info.modules = imageConfig.modules
+
+ 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)
+
+ // Only generate the boot image if the configuration does not skip it.
+ if b.generateBootImageBuildActions(ctx, contents, imageConfig) {
+ // Allow the apex to access the boot image files.
+ files := map[android.ArchType]android.OutputPaths{}
+ for _, variant := range imageConfig.variants {
+ // We also generate boot images for host (for testing), but we don't need those in the apex.
+ // TODO(b/177892522) - consider changing this to check Os.OsClass = android.Device
+ if variant.target.Os == android.Android {
+ files[variant.target.Arch.ArchType] = variant.imagesDeps
+ }
+ }
+ info.bootImageFilesByArch = files
+ }
+ }
}
// Make the apex content info available for other modules.
@@ -589,32 +602,23 @@ func (b *BootclasspathFragmentModule) produceHiddenAPIAllFlagsFile(ctx android.M
// generateBootImageBuildActions generates ninja rules to create the boot image if required for this
// module.
-func (b *BootclasspathFragmentModule) generateBootImageBuildActions(ctx android.ModuleContext, contents []android.Module) {
+//
+// Returns true if the boot image is created, false otherwise.
+func (b *BootclasspathFragmentModule) generateBootImageBuildActions(ctx android.ModuleContext, contents []android.Module, imageConfig *bootImageConfig) bool {
global := dexpreopt.GetGlobalConfig(ctx)
if !shouldBuildBootImages(ctx.Config(), global) {
- return
- }
-
- // Bootclasspath fragment modules that are not preferred do not produce a boot image.
- if !isActiveModule(ctx.Module()) {
- return
- }
-
- // Bootclasspath fragment modules that have no image_name property do not produce a boot image.
- imageConfig := b.getImageConfig(ctx)
- if imageConfig == nil {
- return
+ return false
}
// Bootclasspath fragment modules that are for the platform do not produce a boot image.
apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
if apexInfo.IsForPlatform() {
- return
+ return false
}
// Bootclasspath fragment modules that are versioned do not produce a boot image.
if android.IsModuleInVersionedSdk(ctx.Module()) {
- return
+ return false
}
// Copy the dex jars of this fragment's content modules to their predefined locations.
@@ -623,6 +627,8 @@ func (b *BootclasspathFragmentModule) generateBootImageBuildActions(ctx android.
// Build a profile for the image config and then use that to build the boot image.
profile := bootImageProfileRule(ctx, imageConfig)
buildBootImage(ctx, imageConfig, profile)
+
+ return true
}
type bootclasspathFragmentMemberType struct {
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go
index 581625d8c..fba7d1a71 100644
--- a/java/bootclasspath_fragment_test.go
+++ b/java/bootclasspath_fragment_test.go
@@ -29,38 +29,28 @@ var prepareForTestWithBootclasspathFragment = android.GroupFixturePreparers(
dexpreopt.PrepareForTestByEnablingDexpreopt,
)
-func TestUnknownBootclasspathFragment(t *testing.T) {
+func TestBootclasspathFragment_UnknownImageName(t *testing.T) {
prepareForTestWithBootclasspathFragment.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
- `\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)).
+ `\Qimage_name: unknown image name "unknown", expected "art"\E`)).
RunTestWithBp(t, `
bootclasspath_fragment {
name: "unknown-bootclasspath-fragment",
image_name: "unknown",
+ contents: ["foo"],
}
`)
}
-func TestUnknownBootclasspathFragmentImageName(t *testing.T) {
+func TestPrebuiltBootclasspathFragment_UnknownImageName(t *testing.T) {
prepareForTestWithBootclasspathFragment.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
- `\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)).
- RunTestWithBp(t, `
- bootclasspath_fragment {
- name: "unknown-bootclasspath-fragment",
- image_name: "unknown",
- }
- `)
-}
-
-func TestUnknownPrebuiltBootclasspathFragment(t *testing.T) {
- prepareForTestWithBootclasspathFragment.
- ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
- `\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)).
+ `\Qimage_name: unknown image name "unknown", expected "art"\E`)).
RunTestWithBp(t, `
prebuilt_bootclasspath_fragment {
name: "unknown-bootclasspath-fragment",
image_name: "unknown",
+ contents: ["foo"],
}
`)
}
@@ -76,6 +66,7 @@ func TestBootclasspathFragmentInconsistentArtConfiguration_Platform(t *testing.T
bootclasspath_fragment {
name: "bootclasspath-fragment",
image_name: "art",
+ contents: ["foo", "bar"],
apex_available: [
"apex",
],
@@ -94,6 +85,7 @@ func TestBootclasspathFragmentInconsistentArtConfiguration_ApexMixture(t *testin
bootclasspath_fragment {
name: "bootclasspath-fragment",
image_name: "art",
+ contents: ["foo", "bar"],
apex_available: [
"apex1",
"apex2",
@@ -102,17 +94,6 @@ func TestBootclasspathFragmentInconsistentArtConfiguration_ApexMixture(t *testin
`)
}
-func TestBootclasspathFragmentWithoutImageNameOrContents(t *testing.T) {
- prepareForTestWithBootclasspathFragment.
- ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
- `\Qneither of the "image_name" and "contents" properties\E`)).
- RunTestWithBp(t, `
- bootclasspath_fragment {
- name: "bootclasspath-fragment",
- }
- `)
-}
-
func TestBootclasspathFragment_Coverage(t *testing.T) {
prepareForTestWithFrameworkCoverage := android.FixtureMergeEnv(map[string]string{
"EMMA_INSTRUMENT": "true",
diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go
index bc0416a47..0e14d24f2 100644
--- a/java/classpath_fragment.go
+++ b/java/classpath_fragment.go
@@ -105,7 +105,7 @@ func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars
}
func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.ModuleContext, jars []classpathJar) {
- outputFilename := ctx.ModuleName() + ".pb"
+ outputFilename := strings.ToLower(c.classpathType.String()) + ".pb"
c.outputFilepath = android.PathForModuleOut(ctx, outputFilename).OutputPath
c.installDirPath = android.PathForModuleInstall(ctx, "etc", "classpaths")
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 566f7e30d..953105603 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -546,7 +546,8 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
`\n` +
`If it is not possible to do so, there are workarounds:\n` +
`\n` +
- `1. You can suppress the errors with @SuppressLint("<id>")\n`
+ `1. You can suppress the errors with @SuppressLint("<id>")\n` +
+ ` where the <id> is given in brackets in the error message above.\n`
if baselineFile.Valid() {
cmd.FlagWithInput("--baseline:api-lint ", baselineFile.Path())
diff --git a/java/platform_bootclasspath_test.go b/java/platform_bootclasspath_test.go
index d332f63df..ed5549d35 100644
--- a/java/platform_bootclasspath_test.go
+++ b/java/platform_bootclasspath_test.go
@@ -287,7 +287,7 @@ func TestPlatformBootclasspath_ClasspathFragmentPaths(t *testing.T) {
).RunTest(t)
p := result.Module("platform-bootclasspath", "android_common").(*platformBootclasspathModule)
- android.AssertStringEquals(t, "output filepath", p.Name()+".pb", p.ClasspathFragmentBase.outputFilepath.Base())
+ android.AssertStringEquals(t, "output filepath", "bootclasspath.pb", p.ClasspathFragmentBase.outputFilepath.Base())
android.AssertPathRelativeToTopEquals(t, "install filepath", "out/soong/target/product/test_device/system/etc/classpaths", p.ClasspathFragmentBase.installDirPath)
}
@@ -327,7 +327,7 @@ func TestPlatformBootclasspathModule_AndroidMkEntries(t *testing.T) {
want := map[string][]string{
"LOCAL_MODULE": {"platform-bootclasspath"},
"LOCAL_MODULE_CLASS": {"ETC"},
- "LOCAL_INSTALLED_MODULE_STEM": {"platform-bootclasspath.pb"},
+ "LOCAL_INSTALLED_MODULE_STEM": {"bootclasspath.pb"},
// Output and Install paths are tested separately in TestPlatformBootclasspath_ClasspathFragmentPaths
}
diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go
index a72b3f60c..9111c309f 100644
--- a/java/systemserver_classpath_fragment.go
+++ b/java/systemserver_classpath_fragment.go
@@ -53,13 +53,7 @@ func (p *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx an
func (p *platformSystemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
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
+ return global.SystemServerJars
}
type SystemServerClasspathModule struct {
@@ -101,8 +95,12 @@ func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.Mo
}
func (s *SystemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList {
- // TODO(satayev): populate with actual content
- return android.EmptyConfiguredJarList()
+ global := dexpreopt.GetGlobalConfig(ctx)
+
+ // Only create configs for updatable boot jars. Non-updatable system server jars must be part of the
+ // platform_systemserverclasspath's classpath proto config to guarantee that they come before any
+ // updatable jars at runtime.
+ return global.UpdatableSystemServerJars.Filter(s.properties.Contents)
}
type systemServerClasspathFragmentContentDependencyTag struct {
diff --git a/java/systemserver_classpath_fragment_test.go b/java/systemserver_classpath_fragment_test.go
index 5272f271d..9ad50dd4a 100644
--- a/java/systemserver_classpath_fragment_test.go
+++ b/java/systemserver_classpath_fragment_test.go
@@ -24,7 +24,7 @@ var prepareForTestWithSystemServerClasspath = android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
)
-func TestPlatformSystemserverClasspathVariant(t *testing.T) {
+func TestPlatformSystemServerClasspathVariant(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithSystemServerClasspath,
android.FixtureWithRootAndroidBp(`
@@ -38,7 +38,7 @@ func TestPlatformSystemserverClasspathVariant(t *testing.T) {
android.AssertIntEquals(t, "expect 1 variant", 1, len(variants))
}
-func TestPlatformSystemserverClasspath_ClasspathFragmentPaths(t *testing.T) {
+func TestPlatformSystemServerClasspath_ClasspathFragmentPaths(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithSystemServerClasspath,
android.FixtureWithRootAndroidBp(`
@@ -49,11 +49,11 @@ func TestPlatformSystemserverClasspath_ClasspathFragmentPaths(t *testing.T) {
).RunTest(t)
p := result.Module("platform-systemserverclasspath", "android_common").(*platformSystemServerClasspathModule)
- android.AssertStringEquals(t, "output filepath", p.Name()+".pb", p.ClasspathFragmentBase.outputFilepath.Base())
+ android.AssertStringEquals(t, "output filepath", "systemserverclasspath.pb", p.ClasspathFragmentBase.outputFilepath.Base())
android.AssertPathRelativeToTopEquals(t, "install filepath", "out/soong/target/product/test_device/system/etc/classpaths", p.ClasspathFragmentBase.installDirPath)
}
-func TestPlatformSystemserverClasspathModule_AndroidMkEntries(t *testing.T) {
+func TestPlatformSystemServerClasspathModule_AndroidMkEntries(t *testing.T) {
preparer := android.GroupFixturePreparers(
prepareForTestWithSystemServerClasspath,
android.FixtureWithRootAndroidBp(`
@@ -78,8 +78,8 @@ func TestPlatformSystemserverClasspathModule_AndroidMkEntries(t *testing.T) {
want := map[string][]string{
"LOCAL_MODULE": {"platform-systemserverclasspath"},
"LOCAL_MODULE_CLASS": {"ETC"},
- "LOCAL_INSTALLED_MODULE_STEM": {"platform-systemserverclasspath.pb"},
- // Output and Install paths are tested separately in TestSystemserverClasspath_ClasspathFragmentPaths
+ "LOCAL_INSTALLED_MODULE_STEM": {"systemserverclasspath.pb"},
+ // Output and Install paths are tested separately in TestPlatformSystemServerClasspath_ClasspathFragmentPaths
}
p := result.Module("platform-systemserverclasspath", "android_common").(*platformSystemServerClasspathModule)
@@ -96,7 +96,7 @@ func TestPlatformSystemserverClasspathModule_AndroidMkEntries(t *testing.T) {
})
}
-func TestSystemserverclasspathFragmentWithoutContents(t *testing.T) {
+func TestSystemServerClasspathFragmentWithoutContents(t *testing.T) {
prepareForTestWithSystemServerClasspath.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
`\Qempty contents are not allowed\E`)).