summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2025-02-05 23:02:39 +0000
committer Colin Cross <ccross@android.com> 2025-02-07 16:00:28 -0800
commit22558312b9c07ddda22fcd00d6a84aa0f73f4d10 (patch)
treef9f2362a5b9c874cd99dbdf47b82315229846477
parent10f6c32353292f22844dfd9945abc435969435e0 (diff)
Reland: Move MutateApexTransition shortcut later
Returning from MutateApexTransition too early is allowing invalid apex_available values to be ignored for modules that have no apex variations. Move the exit later so that apex_available checks happen and platform variants are hidden consistently. This relands I324de8090a9f1a874b5b22f20b8d62bf22c7d79c along with fixes to make more tests visible to the platform. Bug: 394664568 Test: builds Change-Id: I161dcefb8c7465eb2bf1bd924fb9c6e4ff5dea85
-rw-r--r--android/apex.go19
-rw-r--r--cc/testing.go4
-rw-r--r--sdk/bootclasspath_fragment_sdk_test.go9
-rw-r--r--sdk/cc_sdk_test.go25
-rw-r--r--sdk/systemserverclasspath_fragment_sdk_test.go12
5 files changed, 52 insertions, 17 deletions
diff --git a/android/apex.go b/android/apex.go
index c2f73a9c1..a5ccd520e 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -616,25 +616,26 @@ func MutateApexTransition(ctx BaseModuleContext, variation string) {
apexInfos = allApexInfos.ApexInfos
}
- // Shortcut
- if len(apexInfos) == 0 {
- return
+ if platformVariation && !ctx.Host() && !module.AvailableFor(AvailableToPlatform) && module.NotAvailableForPlatform() {
+ // Do not install the module for platform, but still allow it to output
+ // uninstallable AndroidMk entries in certain cases when they have side
+ // effects. TODO(jiyong): move this routine to somewhere else
+ module.MakeUninstallable()
}
// Do some validity checks.
// TODO(jiyong): is this the right place?
base.checkApexAvailableProperty(ctx)
+ // Shortcut
+ if len(apexInfos) == 0 {
+ return
+ }
+
if !module.UniqueApexVariations() && !base.ApexProperties.UniqueApexVariationsForDeps {
apexInfos, _ = mergeApexVariations(apexInfos)
}
- if platformVariation && !ctx.Host() && !module.AvailableFor(AvailableToPlatform) && module.NotAvailableForPlatform() {
- // Do not install the module for platform, but still allow it to output
- // uninstallable AndroidMk entries in certain cases when they have side
- // effects. TODO(jiyong): move this routine to somewhere else
- module.MakeUninstallable()
- }
if !platformVariation {
var thisApexInfo ApexInfo
diff --git a/cc/testing.go b/cc/testing.go
index 14a6b7a6a..c9d362da2 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -193,7 +193,7 @@ func commonDefaultModules() string {
},
apex_available: [
"//apex_available:platform",
- "myapex"
+ "//apex_available:anyapex",
],
llndk: {
symbol_file: "libm.map.txt",
@@ -253,7 +253,7 @@ func commonDefaultModules() string {
},
apex_available: [
"//apex_available:platform",
- "myapex"
+ "//apex_available:anyapex",
],
llndk: {
symbol_file: "libdl.map.txt",
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index 36f001065..ad315bfd0 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -759,6 +759,13 @@ func TestBasicSdkWithBootclasspathFragment(t *testing.T) {
bootclasspath_fragments: ["mybootclasspathfragment"],
}
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "1",
+ bootclasspath_fragments: ["mybootclasspathfragment"],
+ }
+
bootclasspath_fragment {
name: "mybootclasspathfragment",
image_name: "art",
@@ -801,7 +808,7 @@ func TestBasicSdkWithBootclasspathFragment(t *testing.T) {
java_import {
name: "mybootlib",
visibility: ["//visibility:public"],
- apex_available: ["com.android.art"],
+ apex_available: ["myapex"],
jars: ["java/mybootlib.jar"],
}
`),
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 939477f61..5bac67da6 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -805,13 +805,19 @@ func TestSnapshotWithCcSharedLibrary(t *testing.T) {
native_shared_libs: ["mynativelib"],
}
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "1",
+ }
+
cc_library_shared {
name: "mynativelib",
srcs: [
"Test.cpp",
"aidl/foo/bar/Test.aidl",
],
- apex_available: ["apex1", "apex2"],
+ apex_available: ["myapex"],
export_include_dirs: ["myinclude"],
aidl: {
export_aidl_headers: true,
@@ -821,6 +827,18 @@ func TestSnapshotWithCcSharedLibrary(t *testing.T) {
`)
CheckSnapshot(t, result, "mysdk", "",
+ snapshotTestPreparer(checkSnapshotWithoutSource,
+ android.FixtureMergeMockFs(android.MockFS{
+ "myapex/Android.bp": []byte(`
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "1",
+ }
+ `),
+ "myapex/apex_manifest.json": nil,
+ }),
+ ),
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
@@ -833,10 +851,7 @@ cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
- apex_available: [
- "apex1",
- "apex2",
- ],
+ apex_available: ["myapex"],
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/myinclude"],
diff --git a/sdk/systemserverclasspath_fragment_sdk_test.go b/sdk/systemserverclasspath_fragment_sdk_test.go
index 60e5b9521..7ebdcd4c3 100644
--- a/sdk/systemserverclasspath_fragment_sdk_test.go
+++ b/sdk/systemserverclasspath_fragment_sdk_test.go
@@ -87,6 +87,18 @@ func testSnapshotWithSystemServerClasspathFragment(t *testing.T, sdk string, tar
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(expectedSdkSnapshot),
+ snapshotTestPreparer(checkSnapshotWithoutSource,
+ android.FixtureMergeMockFs(android.MockFS{
+ "myapex/Android.bp": []byte(`
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "1",
+ }
+ `),
+ "myapex/apex_manifest.json": nil,
+ }),
+ ),
)
}