Merge changes I67589bcc,Ibcfae390 am: 7cbdf81e95
am: 33f495f305
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1683868 Change-Id: I1b3d7fae197d3e072ac205cfe8e09a1c6bf0ddc3
This commit is contained in:
@@ -1924,7 +1924,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
// Rlib is statically linked, but it might have shared lib
|
// Rlib is statically linked, but it might have shared lib
|
||||||
// dependencies. Track them.
|
// dependencies. Track them.
|
||||||
return true
|
return true
|
||||||
} else if java.IsbootImageContentDepTag(depTag) {
|
} else if java.IsBootclasspathFragmentContentDepTag(depTag) {
|
||||||
// Add the contents of the bootclasspath fragment to the apex.
|
// Add the contents of the bootclasspath fragment to the apex.
|
||||||
switch child.(type) {
|
switch child.(type) {
|
||||||
case *java.Library, *java.SdkLibrary:
|
case *java.Library, *java.SdkLibrary:
|
||||||
|
@@ -216,6 +216,22 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java_import {
|
||||||
|
name: "foo",
|
||||||
|
jars: ["foo.jar"],
|
||||||
|
apex_available: [
|
||||||
|
"com.android.art",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
java_import {
|
||||||
|
name: "bar",
|
||||||
|
jars: ["bar.jar"],
|
||||||
|
apex_available: [
|
||||||
|
"com.android.art",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure that a preferred prebuilt doesn't affect the apex.
|
// Make sure that a preferred prebuilt doesn't affect the apex.
|
||||||
prebuilt_boot_image {
|
prebuilt_boot_image {
|
||||||
name: "mybootclasspathfragment",
|
name: "mybootclasspathfragment",
|
||||||
|
@@ -53,7 +53,7 @@ func RegisterBootImageBuildComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.RegisterModuleType("prebuilt_bootclasspath_fragment", prebuiltBootImageFactory)
|
ctx.RegisterModuleType("prebuilt_bootclasspath_fragment", prebuiltBootImageFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
type bootImageContentDependencyTag struct {
|
type bootclasspathFragmentContentDependencyTag struct {
|
||||||
blueprint.BaseDependencyTag
|
blueprint.BaseDependencyTag
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,16 +62,22 @@ type bootImageContentDependencyTag struct {
|
|||||||
// This is a temporary workaround to make it easier to migrate to boot image modules with proper
|
// This is a temporary workaround to make it easier to migrate to boot image modules with proper
|
||||||
// dependencies.
|
// dependencies.
|
||||||
// TODO(b/177892522): Remove this and add needed visibility.
|
// TODO(b/177892522): Remove this and add needed visibility.
|
||||||
func (b bootImageContentDependencyTag) ExcludeFromVisibilityEnforcement() {
|
func (b bootclasspathFragmentContentDependencyTag) ExcludeFromVisibilityEnforcement() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// The bootclasspath_fragment contents must never depend on prebuilts.
|
||||||
|
func (b bootclasspathFragmentContentDependencyTag) ReplaceSourceWithPrebuilt() bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// The tag used for the dependency between the boot image module and its contents.
|
// The tag used for the dependency between the boot image module and its contents.
|
||||||
var bootImageContentDepTag = bootImageContentDependencyTag{}
|
var bootclasspathFragmentContentDepTag = bootclasspathFragmentContentDependencyTag{}
|
||||||
|
|
||||||
var _ android.ExcludeFromVisibilityEnforcementTag = bootImageContentDepTag
|
var _ android.ExcludeFromVisibilityEnforcementTag = bootclasspathFragmentContentDepTag
|
||||||
|
var _ android.ReplaceSourceWithPrebuilt = bootclasspathFragmentContentDepTag
|
||||||
|
|
||||||
func IsbootImageContentDepTag(tag blueprint.DependencyTag) bool {
|
func IsBootclasspathFragmentContentDepTag(tag blueprint.DependencyTag) bool {
|
||||||
return tag == bootImageContentDepTag
|
return tag == bootclasspathFragmentContentDepTag
|
||||||
}
|
}
|
||||||
|
|
||||||
type bootImageProperties struct {
|
type bootImageProperties struct {
|
||||||
@@ -187,7 +193,7 @@ func (i BootImageInfo) AndroidBootImageFilesByArchType() map[android.ArchType]an
|
|||||||
|
|
||||||
func (b *BootImageModule) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
func (b *BootImageModule) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
|
||||||
tag := ctx.OtherModuleDependencyTag(dep)
|
tag := ctx.OtherModuleDependencyTag(dep)
|
||||||
if tag == bootImageContentDepTag {
|
if IsBootclasspathFragmentContentDepTag(tag) {
|
||||||
// Boot image contents are automatically added to apex.
|
// Boot image contents are automatically added to apex.
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -202,8 +208,26 @@ func (b *BootImageModule) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ComponentDepsMutator adds dependencies onto modules before any prebuilt modules without a
|
||||||
|
// corresponding source module are renamed. This means that adding a dependency using a name without
|
||||||
|
// a prebuilt_ prefix will always resolve to a source module and when using a name with that prefix
|
||||||
|
// it will always resolve to a prebuilt module.
|
||||||
|
func (b *BootImageModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
|
module := ctx.Module()
|
||||||
|
_, isSourceModule := module.(*BootImageModule)
|
||||||
|
|
||||||
|
for _, name := range b.properties.Contents {
|
||||||
|
// A bootclasspath_fragment must depend only on other source modules, while the
|
||||||
|
// prebuilt_bootclasspath_fragment must only depend on other prebuilt modules.
|
||||||
|
if !isSourceModule {
|
||||||
|
name = android.PrebuiltNameFromSource(name)
|
||||||
|
}
|
||||||
|
ctx.AddDependency(module, bootclasspathFragmentContentDepTag, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (b *BootImageModule) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (b *BootImageModule) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
ctx.AddDependency(ctx.Module(), bootImageContentDepTag, b.properties.Contents...)
|
|
||||||
|
|
||||||
if SkipDexpreoptBootJars(ctx) {
|
if SkipDexpreoptBootJars(ctx) {
|
||||||
return
|
return
|
||||||
|
@@ -20,7 +20,7 @@ bootstrap_go_package {
|
|||||||
"update.go",
|
"update.go",
|
||||||
],
|
],
|
||||||
testSrcs: [
|
testSrcs: [
|
||||||
"boot_image_sdk_test.go",
|
"bootclasspath_fragment_sdk_test.go",
|
||||||
"bp_test.go",
|
"bp_test.go",
|
||||||
"cc_sdk_test.go",
|
"cc_sdk_test.go",
|
||||||
"compat_config_sdk_test.go",
|
"compat_config_sdk_test.go",
|
||||||
|
@@ -20,17 +20,17 @@ import (
|
|||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSnapshotWithBootImage(t *testing.T) {
|
func TestSnapshotWithBootclasspathFragment(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
prepareForSdkTestWithJava,
|
prepareForSdkTestWithJava,
|
||||||
android.FixtureWithRootAndroidBp(`
|
android.FixtureWithRootAndroidBp(`
|
||||||
sdk {
|
sdk {
|
||||||
name: "mysdk",
|
name: "mysdk",
|
||||||
boot_images: ["mybootimage"],
|
bootclasspath_fragments: ["mybootclasspathfragment"],
|
||||||
}
|
}
|
||||||
|
|
||||||
boot_image {
|
bootclasspath_fragment {
|
||||||
name: "mybootimage",
|
name: "mybootclasspathfragment",
|
||||||
image_name: "art",
|
image_name: "art",
|
||||||
}
|
}
|
||||||
`),
|
`),
|
||||||
@@ -40,8 +40,8 @@ func TestSnapshotWithBootImage(t *testing.T) {
|
|||||||
checkUnversionedAndroidBpContents(`
|
checkUnversionedAndroidBpContents(`
|
||||||
// This is auto-generated. DO NOT EDIT.
|
// This is auto-generated. DO NOT EDIT.
|
||||||
|
|
||||||
prebuilt_boot_image {
|
prebuilt_bootclasspath_fragment {
|
||||||
name: "mybootimage",
|
name: "mybootclasspathfragment",
|
||||||
prefer: false,
|
prefer: false,
|
||||||
visibility: ["//visibility:public"],
|
visibility: ["//visibility:public"],
|
||||||
apex_available: ["//apex_available:platform"],
|
apex_available: ["//apex_available:platform"],
|
||||||
@@ -51,9 +51,9 @@ prebuilt_boot_image {
|
|||||||
checkVersionedAndroidBpContents(`
|
checkVersionedAndroidBpContents(`
|
||||||
// This is auto-generated. DO NOT EDIT.
|
// This is auto-generated. DO NOT EDIT.
|
||||||
|
|
||||||
prebuilt_boot_image {
|
prebuilt_bootclasspath_fragment {
|
||||||
name: "mysdk_mybootimage@current",
|
name: "mysdk_mybootclasspathfragment@current",
|
||||||
sdk_member_name: "mybootimage",
|
sdk_member_name: "mybootclasspathfragment",
|
||||||
visibility: ["//visibility:public"],
|
visibility: ["//visibility:public"],
|
||||||
apex_available: ["//apex_available:platform"],
|
apex_available: ["//apex_available:platform"],
|
||||||
image_name: "art",
|
image_name: "art",
|
||||||
@@ -62,37 +62,37 @@ prebuilt_boot_image {
|
|||||||
sdk_snapshot {
|
sdk_snapshot {
|
||||||
name: "mysdk@current",
|
name: "mysdk@current",
|
||||||
visibility: ["//visibility:public"],
|
visibility: ["//visibility:public"],
|
||||||
boot_images: ["mysdk_mybootimage@current"],
|
bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"],
|
||||||
}
|
}
|
||||||
`),
|
`),
|
||||||
checkAllCopyRules(""))
|
checkAllCopyRules(""))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that boot_image works with sdk.
|
// Test that bootclasspath_fragment works with sdk.
|
||||||
func TestBasicSdkWithBootImage(t *testing.T) {
|
func TestBasicSdkWithBootclasspathFragment(t *testing.T) {
|
||||||
android.GroupFixturePreparers(
|
android.GroupFixturePreparers(
|
||||||
prepareForSdkTestWithApex,
|
prepareForSdkTestWithApex,
|
||||||
prepareForSdkTestWithJava,
|
prepareForSdkTestWithJava,
|
||||||
android.FixtureWithRootAndroidBp(`
|
android.FixtureWithRootAndroidBp(`
|
||||||
sdk {
|
sdk {
|
||||||
name: "mysdk",
|
name: "mysdk",
|
||||||
boot_images: ["mybootimage"],
|
bootclasspath_fragments: ["mybootclasspathfragment"],
|
||||||
}
|
}
|
||||||
|
|
||||||
boot_image {
|
bootclasspath_fragment {
|
||||||
name: "mybootimage",
|
name: "mybootclasspathfragment",
|
||||||
image_name: "art",
|
image_name: "art",
|
||||||
apex_available: ["myapex"],
|
apex_available: ["myapex"],
|
||||||
}
|
}
|
||||||
|
|
||||||
sdk_snapshot {
|
sdk_snapshot {
|
||||||
name: "mysdk@1",
|
name: "mysdk@1",
|
||||||
boot_images: ["mybootimage_mysdk_1"],
|
bootclasspath_fragments: ["mybootclasspathfragment_mysdk_1"],
|
||||||
}
|
}
|
||||||
|
|
||||||
prebuilt_boot_image {
|
prebuilt_bootclasspath_fragment {
|
||||||
name: "mybootimage_mysdk_1",
|
name: "mybootclasspathfragment_mysdk_1",
|
||||||
sdk_member_name: "mybootimage",
|
sdk_member_name: "mybootclasspathfragment",
|
||||||
prefer: false,
|
prefer: false,
|
||||||
visibility: ["//visibility:public"],
|
visibility: ["//visibility:public"],
|
||||||
apex_available: [
|
apex_available: [
|
Reference in New Issue
Block a user