summaryrefslogtreecommitdiff
path: root/sdk
diff options
context:
space:
mode:
Diffstat (limited to 'sdk')
-rw-r--r--sdk/Android.bp2
-rw-r--r--sdk/bootclasspath_fragment_sdk_test.go244
-rw-r--r--sdk/bp.go10
-rw-r--r--sdk/cc_sdk_test.go217
-rw-r--r--sdk/compat_config_sdk_test.go5
-rw-r--r--sdk/exports_test.go5
-rw-r--r--sdk/genrule.go44
-rw-r--r--sdk/genrule_test.go52
-rw-r--r--sdk/java_sdk_test.go331
-rw-r--r--sdk/license_sdk_test.go5
-rw-r--r--sdk/member_trait_test.go16
-rw-r--r--sdk/sdk.go4
-rw-r--r--sdk/sdk_test.go167
-rw-r--r--sdk/systemserverclasspath_fragment_sdk_test.go145
-rw-r--r--sdk/update.go348
15 files changed, 1279 insertions, 316 deletions
diff --git a/sdk/Android.bp b/sdk/Android.bp
index f42b4787d..f436320df 100644
--- a/sdk/Android.bp
+++ b/sdk/Android.bp
@@ -18,6 +18,7 @@ bootstrap_go_package {
"bp.go",
"build_release.go",
"exports.go",
+ "genrule.go",
"member_trait.go",
"member_type.go",
"sdk.go",
@@ -30,6 +31,7 @@ bootstrap_go_package {
"cc_sdk_test.go",
"compat_config_sdk_test.go",
"exports_test.go",
+ "genrule_test.go",
"java_sdk_test.go",
"license_sdk_test.go",
"member_trait_test.go",
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index bef82d601..7048a15b7 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -86,27 +86,27 @@ func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
// Add a platform_bootclasspath that depends on the fragment.
fixtureAddPlatformBootclasspathForBootclasspathFragmentWithExtra(
- "com.android.art", "mybootclasspathfragment", java.ApexBootJarFragmentsForPlatformBootclasspath),
+ "com.android.art", "art-bootclasspath-fragment", java.ApexBootJarFragmentsForPlatformBootclasspath),
java.PrepareForBootImageConfigTest,
java.PrepareApexBootJarConfigsAndModules,
android.FixtureWithRootAndroidBp(`
sdk {
name: "mysdk",
- bootclasspath_fragments: ["mybootclasspathfragment"],
+ bootclasspath_fragments: ["art-bootclasspath-fragment"],
}
apex {
name: "com.android.art",
key: "com.android.art.key",
bootclasspath_fragments: [
- "mybootclasspathfragment",
+ "art-bootclasspath-fragment",
],
updatable: false,
}
bootclasspath_fragment {
- name: "mybootclasspathfragment",
+ name: "art-bootclasspath-fragment",
image_name: "art",
contents: ["core1", "core2"],
apex_available: ["com.android.art"],
@@ -142,18 +142,23 @@ func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
).RunTest(t)
// A preparer to update the test fixture used when processing an unpackage snapshot.
- preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "mybootclasspathfragment")
+ preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "art-bootclasspath-fragment")
// Check that source on its own configures the bootImageConfig correctly.
- java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic")
- java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
+ java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic")
+ java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic")
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: [],
+}
+
prebuilt_bootclasspath_fragment {
- name: "mybootclasspathfragment",
+ name: "art-bootclasspath-fragment",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["com.android.art"],
@@ -187,14 +192,15 @@ java_import {
apex_available: ["com.android.art"],
jars: ["java_boot_libs/snapshot/jars/are/invalid/core2.jar"],
}
+
`),
checkAllCopyRules(`
-.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
-.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
-.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
-.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
-.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
-.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
+.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
+.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
+.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
+.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
+.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
+.intermediates/art-bootclasspath-fragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core1.jar
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core2.jar
`),
@@ -206,31 +212,31 @@ java_import {
checkBootJarsPackageCheckRule(t, result,
append(
[]string{
- "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core1.jar",
- "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core2.jar",
+ "out/soong/.intermediates/prebuilts/apex/prebuilt_com.android.art.deapexer/android_common/deapexer/javalib/core1.jar",
+ "out/soong/.intermediates/prebuilts/apex/prebuilt_com.android.art.deapexer/android_common/deapexer/javalib/core2.jar",
"out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar",
},
java.ApexBootJarDexJarPaths...,
)...,
)
- java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/mybootclasspathfragment/android_common_com.android.art/meta_lic")
- java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
+ java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic")
+ java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic")
}),
snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
// Check the behavior of the snapshot when the source is preferred.
snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) {
- java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic")
- java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
+ java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic")
+ java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic")
}),
snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
// Check the behavior of the snapshot when it is preferred.
snapshotTestChecker(checkSnapshotPreferredWithSource, func(t *testing.T, result *android.TestResult) {
- java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/prebuilt_mybootclasspathfragment/android_common_com.android.art/meta_lic")
- java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
+ java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic")
+ java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/default/java/dex_bootjars/android_common/meta_lic")
}),
)
@@ -270,6 +276,25 @@ func testSnapshotWithBootClasspathFragment_Contents(t *testing.T, sdk string, co
// Add a platform_bootclasspath that depends on the fragment.
fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
+ }
+ }),
+ // Make sure that we have atleast one platform library so that we can check the monolithic hiddenapi
+ // file creation.
+ java.FixtureConfigureBootJars("platform:foo"),
+ android.FixtureModifyMockFS(func(fs android.MockFS) {
+ fs["platform/Android.bp"] = []byte(`
+ java_library {
+ name: "foo",
+ srcs: ["Test.java"],
+ compile_dex: true,
+ }
+ `)
+ fs["platform/Test.java"] = nil
+ }),
+
android.FixtureWithRootAndroidBp(sdk+`
apex {
name: "myapex",
@@ -347,6 +372,15 @@ func testSnapshotWithBootClasspathFragment_Contents(t *testing.T, sdk string, co
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: [
+ "prebuilt_myothersdklibrary",
+ "prebuilt_mysdklibrary",
+ "prebuilt_mycoreplatform",
+ ],
+}
+
prebuilt_bootclasspath_fragment {
name: "mybootclasspathfragment",
prefer: false,
@@ -489,15 +523,15 @@ func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) {
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
-.intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
-.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
-.intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
+.intermediates/myothersdklibrary.stubs.exportable/android_common/combined/myothersdklibrary.stubs.exportable.jar -> sdk_library/public/myothersdklibrary-stubs.jar
+.intermediates/myothersdklibrary.stubs.source/android_common/exportable/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
+.intermediates/myothersdklibrary.stubs.source/android_common/exportable/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.exportable/android_common/combined/mysdklibrary.stubs.exportable.jar -> sdk_library/public/mysdklibrary-stubs.jar
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mycoreplatform.stubs.exportable/android_common/combined/mycoreplatform.stubs.exportable.jar -> sdk_library/public/mycoreplatform-stubs.jar
+.intermediates/mycoreplatform.stubs.source/android_common/exportable/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
+.intermediates/mycoreplatform.stubs.source/android_common/exportable/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
`)
})
@@ -509,15 +543,15 @@ func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) {
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
-.intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
-.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
-.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
-.intermediates/mycoreplatform.stubs/android_common/javac/mycoreplatform.stubs.jar -> sdk_library/public/mycoreplatform-stubs.jar
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
-.intermediates/mycoreplatform.stubs.source/android_common/metalava/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
+.intermediates/myothersdklibrary.stubs.exportable/android_common/combined/myothersdklibrary.stubs.exportable.jar -> sdk_library/public/myothersdklibrary-stubs.jar
+.intermediates/myothersdklibrary.stubs.source/android_common/exportable/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
+.intermediates/myothersdklibrary.stubs.source/android_common/exportable/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.exportable/android_common/combined/mysdklibrary.stubs.exportable.jar -> sdk_library/public/mysdklibrary-stubs.jar
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mycoreplatform.stubs.exportable/android_common/combined/mycoreplatform.stubs.exportable.jar -> sdk_library/public/mycoreplatform-stubs.jar
+.intermediates/mycoreplatform.stubs.source/android_common/exportable/mycoreplatform.stubs.source_api.txt -> sdk_library/public/mycoreplatform.txt
+.intermediates/mycoreplatform.stubs.source/android_common/exportable/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
`
t.Run("added-via-apex", func(t *testing.T) {
testSnapshotWithBootClasspathFragment_Contents(t, `
@@ -636,6 +670,11 @@ func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mysdklibrary"],
+}
+
prebuilt_bootclasspath_fragment {
name: "mybootclasspathfragment",
prefer: false,
@@ -760,6 +799,12 @@ func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
// Add a platform_bootclasspath that depends on the fragment.
fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
+ }
+ }),
+
android.MockFS{
"my-blocked.txt": nil,
"my-max-target-o-low-priority.txt": nil,
@@ -869,6 +914,14 @@ func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: [
+ "prebuilt_mynewlibrary",
+ "prebuilt_mysdklibrary",
+ ],
+}
+
prebuilt_bootclasspath_fragment {
name: "mybootclasspathfragment",
prefer: false,
@@ -963,12 +1016,12 @@ my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
-.intermediates/mynewlibrary.stubs/android_common/javac/mynewlibrary.stubs.jar -> sdk_library/public/mynewlibrary-stubs.jar
-.intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt
-.intermediates/mynewlibrary.stubs.source/android_common/metalava/mynewlibrary.stubs.source_removed.txt -> sdk_library/public/mynewlibrary-removed.txt
-.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mynewlibrary.stubs.exportable/android_common/combined/mynewlibrary.stubs.exportable.jar -> sdk_library/public/mynewlibrary-stubs.jar
+.intermediates/mynewlibrary.stubs.source/android_common/exportable/mynewlibrary.stubs.source_api.txt -> sdk_library/public/mynewlibrary.txt
+.intermediates/mynewlibrary.stubs.source/android_common/exportable/mynewlibrary.stubs.source_removed.txt -> sdk_library/public/mynewlibrary-removed.txt
+.intermediates/mysdklibrary.stubs.exportable/android_common/combined/mysdklibrary.stubs.exportable.jar -> sdk_library/public/mysdklibrary-stubs.jar
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
`),
snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
@@ -996,6 +1049,15 @@ func testSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T, targetBui
android.FixtureMergeEnv(map[string]string{
"SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": targetBuildRelease,
}),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_version_active_codenames = []string{"VanillaIceCream"}
+ }),
+
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
+ }
+ }),
android.FixtureWithRootAndroidBp(`
sdk {
@@ -1046,7 +1108,7 @@ func testSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T, targetBui
bcpf := result.ModuleForTests("mybootclasspathfragment", "android_common")
rule := bcpf.Output("out/soong/.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi" + suffix + "/stub-flags.csv")
- android.AssertPathsRelativeToTopEquals(t, "stub flags inputs", expectedStubFlagsInputs, rule.Implicits)
+ android.AssertPathsRelativeToTopEquals(t, "stub flags inputs", android.SortedUniqueStrings(expectedStubFlagsInputs), android.SortedUniquePaths(rule.Implicits))
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(expectedSdkSnapshot),
@@ -1095,16 +1157,16 @@ java_sdk_library_import {
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/index.csv -> hiddenapi/index.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/stub-flags.csv -> hiddenapi/stub-flags.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi-for-sdk-snapshot/all-flags.csv -> hiddenapi/all-flags.csv
-.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.exportable/android_common/combined/mysdklibrary.stubs.exportable.jar -> sdk_library/public/mysdklibrary-stubs.jar
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
`
// On S the stub flags should only be generated from mysdklibrary as mynewsdklibrary is not part
// of the snapshot.
expectedStubFlagsInputs := []string{
- "out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar",
- "out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar",
+ "out/soong/.intermediates/mysdklibrary.stubs.exportable/android_common/dex/mysdklibrary.stubs.exportable.jar",
+ "out/soong/.intermediates/mysdklibrary.impl/android_common/aligned/mysdklibrary.jar",
}
testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "S",
@@ -1173,24 +1235,82 @@ java_sdk_library_import {
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
.intermediates/mybootclasspathfragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
-.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
-.intermediates/mynewsdklibrary.stubs/android_common/javac/mynewsdklibrary.stubs.jar -> sdk_library/public/mynewsdklibrary-stubs.jar
-.intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt
-.intermediates/mynewsdklibrary.stubs.source/android_common/metalava/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.exportable/android_common/combined/mysdklibrary.stubs.exportable.jar -> sdk_library/public/mysdklibrary-stubs.jar
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mynewsdklibrary.stubs.exportable/android_common/combined/mynewsdklibrary.stubs.exportable.jar -> sdk_library/public/mynewsdklibrary-stubs.jar
+.intermediates/mynewsdklibrary.stubs.source/android_common/exportable/mynewsdklibrary.stubs.source_api.txt -> sdk_library/public/mynewsdklibrary.txt
+.intermediates/mynewsdklibrary.stubs.source/android_common/exportable/mynewsdklibrary.stubs.source_removed.txt -> sdk_library/public/mynewsdklibrary-removed.txt
`
// On tiramisu the stub flags should be generated from both mynewsdklibrary and mysdklibrary as
// they are both part of the snapshot.
expectedStubFlagsInputs := []string{
- "out/soong/.intermediates/mynewsdklibrary.stubs/android_common/dex/mynewsdklibrary.stubs.jar",
- "out/soong/.intermediates/mynewsdklibrary/android_common/aligned/mynewsdklibrary.jar",
- "out/soong/.intermediates/mysdklibrary.stubs/android_common/dex/mysdklibrary.stubs.jar",
- "out/soong/.intermediates/mysdklibrary/android_common/aligned/mysdklibrary.jar",
+ "out/soong/.intermediates/mynewsdklibrary.stubs.exportable/android_common/dex/mynewsdklibrary.stubs.exportable.jar",
+ "out/soong/.intermediates/mynewsdklibrary.impl/android_common/aligned/mynewsdklibrary.jar",
+ "out/soong/.intermediates/mysdklibrary.stubs.exportable/android_common/dex/mysdklibrary.stubs.exportable.jar",
+ "out/soong/.intermediates/mysdklibrary.impl/android_common/aligned/mysdklibrary.jar",
}
testSnapshotWithBootClasspathFragment_MinSdkVersion(t, "Tiramisu",
expectedSnapshot, expectedCopyRules, expectedStubFlagsInputs, "")
})
}
+
+func TestSnapshotWithEmptyBootClasspathFragment(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForSdkTestWithJava,
+ java.PrepareForTestWithJavaDefaultModules,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureWithLastReleaseApis("mysdklibrary", "mynewsdklibrary"),
+ java.FixtureConfigureApexBootJars("myapex:mysdklibrary", "myapex:mynewsdklibrary"),
+ prepareForSdkTestWithApex,
+ // Add a platform_bootclasspath that depends on the fragment.
+ fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
+ android.FixtureMergeEnv(map[string]string{
+ "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S",
+ }),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_version_active_codenames = []string{"VanillaIceCream"}
+ }),
+ android.FixtureWithRootAndroidBp(`
+ sdk {
+ name: "mysdk",
+ apexes: ["myapex"],
+ }
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "S",
+ bootclasspath_fragments: ["mybootclasspathfragment"],
+ }
+ bootclasspath_fragment {
+ name: "mybootclasspathfragment",
+ apex_available: ["myapex"],
+ contents: ["mysdklibrary", "mynewsdklibrary"],
+ hidden_api: {
+ split_packages: [],
+ },
+ }
+ java_sdk_library {
+ name: "mysdklibrary",
+ apex_available: ["myapex"],
+ srcs: ["Test.java"],
+ shared_library: false,
+ public: {enabled: true},
+ min_sdk_version: "Tiramisu",
+ }
+ java_sdk_library {
+ name: "mynewsdklibrary",
+ apex_available: ["myapex"],
+ srcs: ["Test.java"],
+ compile_dex: true,
+ public: {enabled: true},
+ min_sdk_version: "Tiramisu",
+ permitted_packages: ["mynewsdklibrary"],
+ }
+ `),
+ ).RunTest(t)
+
+ CheckSnapshot(t, result, "mysdk", "", checkAndroidBpContents(`// This is auto-generated. DO NOT EDIT.`))
+}
diff --git a/sdk/bp.go b/sdk/bp.go
index 7ff85a121..57eb2ca38 100644
--- a/sdk/bp.go
+++ b/sdk/bp.go
@@ -311,13 +311,15 @@ func (t identityTransformation) transformProperty(_ string, value interface{}, t
}
func (m *bpModule) deepCopy() *bpModule {
- return m.transform(deepCopyTransformer)
+ return transformModule(m, deepCopyTransformer)
}
-func (m *bpModule) transform(transformer bpTransformer) *bpModule {
+func transformModule(m *bpModule, transformer bpTransformer) *bpModule {
transformedModule := transformer.transformModule(m)
- // Copy the contents of the returned property set into the module and then transform that.
- transformedModule.bpPropertySet, _ = transformPropertySet(transformer, "", transformedModule.bpPropertySet, nil)
+ if transformedModule != nil {
+ // Copy the contents of the returned property set into the module and then transform that.
+ transformedModule.bpPropertySet, _ = transformPropertySet(transformer, "", transformedModule.bpPropertySet, nil)
+ }
return transformedModule
}
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 265579aa1..5d76930b4 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -123,6 +123,11 @@ func TestSdkCompileMultilibOverride(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_sdkmember"],
+}
+
cc_prebuilt_library_shared {
name: "sdkmember",
prefer: false,
@@ -143,6 +148,9 @@ cc_prebuilt_library_shared {
srcs: ["linux_glibc/x86_64/lib/sdkmember.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -226,6 +234,11 @@ func TestSnapshotWithObject(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_crtobj"],
+}
+
cc_prebuilt_object {
name: "crtobj",
prefer: false,
@@ -333,6 +346,11 @@ func TestSnapshotWithCcExportGeneratedHeaders(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
@@ -353,6 +371,9 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/mynativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -406,6 +427,11 @@ func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
@@ -435,6 +461,9 @@ cc_prebuilt_library_shared {
},
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -465,6 +494,11 @@ func TestSnapshotWithCcBinary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mymodule_exports.contributions",
+ contents: ["prebuilt_mynativebinary"],
+}
+
cc_prebuilt_binary {
name: "mynativebinary",
prefer: false,
@@ -523,6 +557,11 @@ func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_mynativebinary"],
+}
+
cc_prebuilt_binary {
name: "mynativebinary",
prefer: false,
@@ -621,6 +660,14 @@ func TestSnapshotWithSingleHostOsType(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: [
+ "prebuilt_mynativebinary",
+ "prebuilt_mynativelib",
+ ],
+}
+
cc_prebuilt_binary {
name: "mynativebinary",
prefer: false,
@@ -659,6 +706,9 @@ cc_prebuilt_library_shared {
srcs: ["x86_64/lib/mynativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -696,6 +746,11 @@ func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mymodule_exports.contributions",
+ contents: ["prebuilt_linker"],
+}
+
cc_prebuilt_binary {
name: "linker",
prefer: false,
@@ -755,6 +810,11 @@ func TestSnapshotWithCcSharedLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
@@ -776,6 +836,9 @@ cc_prebuilt_library_shared {
export_include_dirs: ["arm/include_gen/mynativelib/android_arm_armv7-a-neon_shared/gen/aidl"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -856,6 +919,15 @@ func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: [
+ "prebuilt_mynativelib",
+ "prebuilt_myothernativelib",
+ "prebuilt_mysystemnativelib",
+ ],
+}
+
cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
@@ -875,6 +947,9 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/mynativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
cc_prebuilt_library_shared {
@@ -893,6 +968,9 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/myothernativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
cc_prebuilt_library_shared {
@@ -910,6 +988,9 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/mysystemnativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -953,6 +1034,11 @@ func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
@@ -979,6 +1065,9 @@ cc_prebuilt_library_shared {
export_include_dirs: ["x86/include_gen/mynativelib/linux_glibc_x86_shared/gen/aidl"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -1029,6 +1118,11 @@ func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
@@ -1060,6 +1154,9 @@ cc_prebuilt_library_shared {
srcs: ["windows/x86_64/lib/mynativelib.dll"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -1095,6 +1192,11 @@ func TestSnapshotWithCcStaticLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library_static {
name: "mynativelib",
prefer: false,
@@ -1158,6 +1260,11 @@ func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library_static {
name: "mynativelib",
prefer: false,
@@ -1222,6 +1329,11 @@ func TestSnapshotWithCcLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library {
name: "mynativelib",
prefer: false,
@@ -1298,6 +1410,11 @@ func TestSnapshotSameLibraryWithNativeLibsAndNativeSharedLib(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library {
name: "mynativelib",
prefer: false,
@@ -1394,6 +1511,11 @@ func TestSnapshotSameLibraryWithAndroidNativeLibsAndHostNativeSharedLib(t *testi
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library {
name: "mynativelib",
prefer: false,
@@ -1520,6 +1642,11 @@ func TestHostSnapshotWithMultiLib64(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library_static {
name: "mynativelib",
prefer: false,
@@ -1572,6 +1699,11 @@ func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mynativeheaders"],
+}
+
cc_prebuilt_library_headers {
name: "mynativeheaders",
prefer: false,
@@ -1594,6 +1726,9 @@ func TestSnapshotWithCcHeadersLibraryAndNativeBridgeSupport(t *testing.T) {
PrepareForTestWithSdkBuildComponents,
ccTestFs.AddToFixture(),
prepareForTestWithNativeBridgeTarget,
+ android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
+ android.RegisterApexContributionsBuildComponents(ctx)
+ }),
).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1616,6 +1751,11 @@ func TestSnapshotWithCcHeadersLibraryAndNativeBridgeSupport(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mynativeheaders"],
+}
+
cc_prebuilt_library_headers {
name: "mynativeheaders",
prefer: false,
@@ -1679,6 +1819,9 @@ func TestSnapshotWithCcHeadersLibraryAndImageVariants(t *testing.T) {
cc.PrepareForTestWithCcDefaultModules,
PrepareForTestWithSdkBuildComponents,
ccTestFs.AddToFixture(),
+ android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
+ android.RegisterApexContributionsBuildComponents(ctx)
+ }),
).RunTestWithBp(t, fmt.Sprintf(`
sdk {
name: "mysdk",
@@ -1701,6 +1844,11 @@ func TestSnapshotWithCcHeadersLibraryAndImageVariants(t *testing.T) {
checkAndroidBpContents(fmt.Sprintf(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mynativeheaders"],
+}
+
cc_prebuilt_library_headers {
name: "mynativeheaders",
prefer: false,
@@ -1750,6 +1898,11 @@ func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mynativeheaders"],
+}
+
cc_prebuilt_library_headers {
name: "mynativeheaders",
prefer: false,
@@ -1807,6 +1960,11 @@ func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mynativeheaders"],
+}
+
cc_prebuilt_library_headers {
name: "mynativeheaders",
prefer: false,
@@ -1870,6 +2028,15 @@ func TestSystemSharedLibPropagation(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: [
+ "prebuilt_sslnil",
+ "prebuilt_sslempty",
+ "prebuilt_sslnonempty",
+ ],
+}
+
cc_prebuilt_library_shared {
name: "sslnil",
prefer: false,
@@ -1884,6 +2051,9 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/sslnil.so"],
},
},
+ strip: {
+ none: true,
+ },
}
cc_prebuilt_library_shared {
@@ -1901,6 +2071,9 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/sslempty.so"],
},
},
+ strip: {
+ none: true,
+ },
}
cc_prebuilt_library_shared {
@@ -1918,6 +2091,9 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/sslnonempty.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`))
@@ -1943,6 +2119,11 @@ cc_prebuilt_library_shared {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_sslvariants"],
+}
+
cc_prebuilt_library_shared {
name: "sslvariants",
prefer: false,
@@ -1972,6 +2153,9 @@ cc_prebuilt_library_shared {
srcs: ["linux_glibc/x86/lib/sslvariants.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
)
@@ -2002,11 +2186,17 @@ func TestStubsLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_stubslib"],
+}
+
cc_prebuilt_library_shared {
name: "stubslib",
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
+ stl: "none",
compile_multilib: "both",
stubs: {
versions: [
@@ -2024,6 +2214,9 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/stubslib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`))
}
@@ -2056,6 +2249,11 @@ func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_stubslib"],
+}
+
cc_prebuilt_library_shared {
name: "stubslib",
prefer: false,
@@ -2090,6 +2288,9 @@ cc_prebuilt_library_shared {
srcs: ["linux_glibc/x86/lib/stubslib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
)
@@ -2114,6 +2315,11 @@ func TestUniqueHostSoname(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mylib"],
+}
+
cc_prebuilt_library_shared {
name: "mylib",
prefer: false,
@@ -2141,6 +2347,9 @@ cc_prebuilt_library_shared {
srcs: ["linux_glibc/x86/lib/mylib-host.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
@@ -2178,6 +2387,11 @@ func TestNoSanitizerMembers(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mynativelib"],
+}
+
cc_prebuilt_library_shared {
name: "mynativelib",
prefer: false,
@@ -2193,6 +2407,9 @@ cc_prebuilt_library_shared {
srcs: ["arm/lib/mynativelib.so"],
},
},
+ strip: {
+ none: true,
+ },
}
`),
checkAllCopyRules(`
diff --git a/sdk/compat_config_sdk_test.go b/sdk/compat_config_sdk_test.go
index 45e8e0ed6..75b5229bf 100644
--- a/sdk/compat_config_sdk_test.go
+++ b/sdk/compat_config_sdk_test.go
@@ -36,6 +36,11 @@ func testSnapshotWithCompatConfig(t *testing.T, sdk string) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myconfig"],
+}
+
prebuilt_platform_compat_config {
name: "myconfig",
prefer: false,
diff --git a/sdk/exports_test.go b/sdk/exports_test.go
index 2605fd141..9d0a24210 100644
--- a/sdk/exports_test.go
+++ b/sdk/exports_test.go
@@ -46,6 +46,11 @@ func TestModuleExportsSnapshot(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_import {
name: "myjavalib",
prefer: false,
diff --git a/sdk/genrule.go b/sdk/genrule.go
new file mode 100644
index 000000000..347ab0556
--- /dev/null
+++ b/sdk/genrule.go
@@ -0,0 +1,44 @@
+// Copyright 2023 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package sdk
+
+import (
+ "android/soong/android"
+ "android/soong/genrule"
+)
+
+func init() {
+ registerGenRuleBuildComponents(android.InitRegistrationContext)
+}
+
+func registerGenRuleBuildComponents(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("sdk_genrule", SdkGenruleFactory)
+}
+
+// sdk_genrule_host is a genrule that can depend on sdk and sdk_snapshot module types
+//
+// What this means is that it's a genrule with only the "common_os" variant.
+// sdk modules have 3 variants: host, android, and common_os. The common_os one depends
+// on the host/device ones and packages their result into a final snapshot zip.
+// Genrules probably want access to this snapshot zip when they depend on an sdk module,
+// which means they want to depend on the common_os variant and not the host/android
+// variants.
+func SdkGenruleFactory() android.Module {
+ module := genrule.NewGenRule()
+
+ android.InitCommonOSAndroidMultiTargetsArchModule(module, android.NeitherHostNorDeviceSupported, android.MultilibCommon)
+ android.InitDefaultableModule(module)
+
+ return module
+}
diff --git a/sdk/genrule_test.go b/sdk/genrule_test.go
new file mode 100644
index 000000000..6e52a3db0
--- /dev/null
+++ b/sdk/genrule_test.go
@@ -0,0 +1,52 @@
+// Copyright 2018 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package sdk
+
+import (
+ "testing"
+
+ "android/soong/android"
+ "android/soong/genrule"
+ "android/soong/java"
+)
+
+func TestSdkGenrule(t *testing.T) {
+ // Test that an sdk_genrule can depend on an sdk, and that a genrule can depend on an sdk_genrule
+ bp := `
+ sdk {
+ name: "my_sdk",
+ }
+ sdk_genrule {
+ name: "my_sdk_genrule",
+ tool_files: ["tool"],
+ cmd: "$(location tool) $(in) $(out)",
+ srcs: [":my_sdk"],
+ out: ["out"],
+ }
+ genrule {
+ name: "my_regular_genrule",
+ srcs: [":my_sdk_genrule"],
+ out: ["out"],
+ cmd: "cp $(in) $(out)",
+ }
+ `
+ android.GroupFixturePreparers(
+ // if java components aren't registered, the sdk module doesn't create a snapshot for some reason.
+ java.PrepareForTestWithJavaBuildComponents,
+ genrule.PrepareForTestWithGenRuleBuildComponents,
+ PrepareForTestWithSdkBuildComponents,
+ android.FixtureRegisterWithContext(registerGenRuleBuildComponents),
+ ).RunTestWithBp(t, bp)
+}
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index 6159ea9c2..0a5483b07 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -45,6 +45,11 @@ var prepareForSdkTestWithJavaSdkLibrary = android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("myjavalib"),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
+ }
+ }),
)
// Contains tests for SDK members provided by the java package.
@@ -103,6 +108,11 @@ func TestSnapshotWithJavaHeaderLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_import {
name: "myjavalib",
prefer: false,
@@ -149,6 +159,11 @@ func TestHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_import {
name: "myjavalib",
prefer: false,
@@ -160,7 +175,7 @@ java_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/myjavalib.jar
+.intermediates/myjavalib/linux_glibc_common/javac-header/myjavalib.jar -> java/myjavalib.jar
aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
`),
)
@@ -188,6 +203,11 @@ func TestDeviceAndHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_import {
name: "myjavalib",
prefer: false,
@@ -206,7 +226,7 @@ java_import {
`),
checkAllCopyRules(`
.intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/android/myjavalib.jar
-.intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/linux_glibc/myjavalib.jar
+.intermediates/myjavalib/linux_glibc_common/javac-header/myjavalib.jar -> java/linux_glibc/myjavalib.jar
`),
)
}
@@ -240,6 +260,11 @@ func TestSnapshotWithJavaImplLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_import {
name: "myjavalib",
prefer: false,
@@ -286,6 +311,11 @@ func TestSnapshotWithJavaBootLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: [],
+}
+
java_import {
name: "myjavalib",
prefer: false,
@@ -308,6 +338,9 @@ func TestSnapshotWithJavaBootLibrary_UpdatableMedia(t *testing.T) {
android.FixtureMergeEnv(map[string]string{
"SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": targetBuildRelease,
}),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_version_active_codenames = []string{"VanillaIceCream"}
+ }),
).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -390,6 +423,11 @@ func TestSnapshotWithJavaLibrary_MinSdkVersion(t *testing.T) {
checkAndroidBpContents(fmt.Sprintf(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mylib"],
+}
+
java_import {
name: "mylib",
prefer: false,
@@ -454,6 +492,11 @@ func TestSnapshotWithJavaSystemserverLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: [],
+}
+
java_import {
name: "myjavalib",
prefer: false,
@@ -499,6 +542,11 @@ func TestHostSnapshotWithJavaImplLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_import {
name: "myjavalib",
prefer: false,
@@ -537,6 +585,11 @@ func TestSnapshotWithJavaTest(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_myjavatests"],
+}
+
java_test_import {
name: "myjavatests",
prefer: false,
@@ -577,6 +630,11 @@ func TestHostSnapshotWithJavaTest(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: ["prebuilt_myjavatests"],
+}
+
java_test_import {
name: "myjavatests",
prefer: false,
@@ -608,6 +666,11 @@ func TestSnapshotWithJavaSystemModules(t *testing.T) {
"1": {"myjavalib"},
"2": {"myjavalib"},
}),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
+ }
+ }),
).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -625,6 +688,12 @@ func TestSnapshotWithJavaSystemModules(t *testing.T) {
public: {
enabled: true,
},
+ system: {
+ enabled: true,
+ },
+ module_lib: {
+ enabled: true,
+ },
}
java_system_modules {
@@ -651,6 +720,15 @@ func TestSnapshotWithJavaSystemModules(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: [
+ "prebuilt_exported-system-module",
+ "prebuilt_myjavalib",
+ "prebuilt_my-system-modules",
+ ],
+}
+
java_import {
name: "exported-system-module",
prefer: false,
@@ -680,6 +758,20 @@ java_sdk_library_import {
removed_api: "sdk_library/public/myjavalib-removed.txt",
sdk_version: "current",
},
+ system: {
+ jars: ["sdk_library/system/myjavalib-stubs.jar"],
+ stub_srcs: ["sdk_library/system/myjavalib_stub_sources"],
+ current_api: "sdk_library/system/myjavalib.txt",
+ removed_api: "sdk_library/system/myjavalib-removed.txt",
+ sdk_version: "system_current",
+ },
+ module_lib: {
+ jars: ["sdk_library/module-lib/myjavalib-stubs.jar"],
+ stub_srcs: ["sdk_library/module-lib/myjavalib_stub_sources"],
+ current_api: "sdk_library/module-lib/myjavalib.txt",
+ removed_api: "sdk_library/module-lib/myjavalib-removed.txt",
+ sdk_version: "module_current",
+ },
}
java_system_modules_import {
@@ -696,9 +788,15 @@ java_system_modules_import {
checkAllCopyRules(`
.intermediates/exported-system-module/android_common/turbine-combined/exported-system-module.jar -> java/exported-system-module.jar
.intermediates/system-module/android_common/turbine-combined/system-module.jar -> java/system-module.jar
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable.system/android_common/combined/myjavalib.stubs.exportable.system.jar -> sdk_library/system/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable.module_lib/android_common/combined/myjavalib.stubs.exportable.module_lib.jar -> sdk_library/module-lib/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source.module_lib/android_common/exportable/myjavalib.stubs.source.module_lib_api.txt -> sdk_library/module-lib/myjavalib.txt
+.intermediates/myjavalib.stubs.source.module_lib/android_common/exportable/myjavalib.stubs.source.module_lib_removed.txt -> sdk_library/module-lib/myjavalib-removed.txt
`),
checkInfoContents(result.Config, `
[
@@ -733,11 +831,23 @@ java_system_modules_import {
"@name": "myjavalib",
"dist_stem": "myjavalib",
"scopes": {
+ "module-lib": {
+ "current_api": "sdk_library/module-lib/myjavalib.txt",
+ "latest_api": "out/soong/.intermediates/prebuilts/sdk/myjavalib.api.module-lib.latest/gen/myjavalib.api.module-lib.latest",
+ "latest_removed_api": "out/soong/.intermediates/prebuilts/sdk/myjavalib-removed.api.module-lib.latest/gen/myjavalib-removed.api.module-lib.latest",
+ "removed_api": "sdk_library/module-lib/myjavalib-removed.txt"
+ },
"public": {
"current_api": "sdk_library/public/myjavalib.txt",
"latest_api": "out/soong/.intermediates/prebuilts/sdk/myjavalib.api.public.latest/gen/myjavalib.api.public.latest",
"latest_removed_api": "out/soong/.intermediates/prebuilts/sdk/myjavalib-removed.api.public.latest/gen/myjavalib-removed.api.public.latest",
"removed_api": "sdk_library/public/myjavalib-removed.txt"
+ },
+ "system": {
+ "current_api": "sdk_library/system/myjavalib.txt",
+ "latest_api": "out/soong/.intermediates/prebuilts/sdk/myjavalib.api.system.latest/gen/myjavalib.api.system.latest",
+ "latest_removed_api": "out/soong/.intermediates/prebuilts/sdk/myjavalib-removed.api.system.latest/gen/myjavalib-removed.api.system.latest",
+ "removed_api": "sdk_library/system/myjavalib-removed.txt"
}
}
},
@@ -780,6 +890,11 @@ func TestHostSnapshotWithJavaSystemModules(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_my-system-modules"],
+}
+
java_import {
name: "mysdk_system-module",
prefer: false,
@@ -799,7 +914,7 @@ java_system_modules_import {
libs: ["mysdk_system-module"],
}
`),
- checkAllCopyRules(".intermediates/system-module/linux_glibc_common/javac/system-module.jar -> java/system-module.jar"),
+ checkAllCopyRules(".intermediates/system-module/linux_glibc_common/javac-header/system-module.jar -> java/system-module.jar"),
)
}
@@ -844,6 +959,15 @@ func TestDeviceAndHostSnapshotWithOsSpecificMembers(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "myexports.contributions",
+ contents: [
+ "prebuilt_hostjavalib",
+ "prebuilt_androidjavalib",
+ "prebuilt_myjavalib",
+ ],
+}
+
java_import {
name: "hostjavalib",
prefer: false,
@@ -879,7 +1003,7 @@ java_import {
}
`),
checkAllCopyRules(`
-.intermediates/hostjavalib/linux_glibc_common/javac/hostjavalib.jar -> java/hostjavalib.jar
+.intermediates/hostjavalib/linux_glibc_common/javac-header/hostjavalib.jar -> java/hostjavalib.jar
.intermediates/androidjavalib/android_common/turbine-combined/androidjavalib.jar -> java/androidjavalib.jar
.intermediates/myjavalib/android_common/javac/myjavalib.jar -> java/android/myjavalib.jar
.intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/linux_glibc/myjavalib.jar
@@ -910,6 +1034,11 @@ func TestSnapshotWithJavaSdkLibrary(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -941,15 +1070,15 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
-.intermediates/myjavalib.stubs.system/android_common/javac/myjavalib.stubs.system.jar -> sdk_library/system/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
-.intermediates/myjavalib.stubs.test/android_common/javac/myjavalib.stubs.test.jar -> sdk_library/test/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.test/android_common/metalava/myjavalib.stubs.source.test_api.txt -> sdk_library/test/myjavalib.txt
-.intermediates/myjavalib.stubs.source.test/android_common/metalava/myjavalib.stubs.source.test_removed.txt -> sdk_library/test/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable.system/android_common/combined/myjavalib.stubs.exportable.system.jar -> sdk_library/system/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable.test/android_common/combined/myjavalib.stubs.exportable.test.jar -> sdk_library/test/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source.test/android_common/exportable/myjavalib.stubs.source.test_api.txt -> sdk_library/test/myjavalib.txt
+.intermediates/myjavalib.stubs.source.test/android_common/exportable/myjavalib.stubs.source.test_removed.txt -> sdk_library/test/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -983,6 +1112,11 @@ func TestSnapshotWithJavaSdkLibrary_DistStem(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib-foo"],
+}
+
java_sdk_library_import {
name: "myjavalib-foo",
prefer: false,
@@ -999,9 +1133,9 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib-foo.stubs/android_common/javac/myjavalib-foo.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib-foo.stubs.source/android_common/metalava/myjavalib-foo.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib-foo.stubs.source/android_common/metalava/myjavalib-foo.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib-foo.stubs.exportable/android_common/combined/myjavalib-foo.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib-foo.stubs.source/android_common/exportable/myjavalib-foo.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib-foo.stubs.source/android_common/exportable/myjavalib-foo.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1036,6 +1170,11 @@ func TestSnapshotWithJavaSdkLibrary_UseSrcJar(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -1052,10 +1191,10 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source-stubs.srcjar -> sdk_library/public/myjavalib.srcjar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source-stubs.srcjar -> sdk_library/public/myjavalib.srcjar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
)
}
@@ -1083,6 +1222,11 @@ func TestSnapshotWithJavaSdkLibrary_AnnotationsZip(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -1100,10 +1244,10 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_annotations.zip -> sdk_library/public/myjavalib_annotations.zip
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_annotations.zip -> sdk_library/public/myjavalib_annotations.zip
`),
checkMergeZips(".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip"),
)
@@ -1137,6 +1281,11 @@ func TestSnapshotWithJavaSdkLibrary_AnnotationsZip_PreT(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -1153,16 +1302,23 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip"),
)
}
func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) {
- result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
+ result := android.GroupFixturePreparers(
+ prepareForSdkTestWithJavaSdkLibrary,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
+ }
+ }),
+ ).RunTestWithBp(t, `
sdk {
name: "mysdk",
java_sdk_libs: ["myjavalib"],
@@ -1187,6 +1343,11 @@ func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -1214,21 +1375,22 @@ java_sdk_library_import {
ctx := android.ModuleInstallPathContextForTesting(result.Config)
dexJarBuildPath := func(name string, kind android.SdkKind) string {
dep := result.Module(name, "android_common").(java.SdkLibraryDependency)
- path := dep.SdkApiStubDexJar(ctx, kind).Path()
+ path := dep.SdkApiExportableStubDexJar(ctx, kind).Path()
return path.RelativeToTop().String()
}
dexJarPath := dexJarBuildPath("myjavalib", android.SdkPublic)
- android.AssertStringEquals(t, "source dex public stubs jar build path", "out/soong/.intermediates/myjavalib.stubs/android_common/dex/myjavalib.stubs.jar", dexJarPath)
+ android.AssertStringEquals(t, "source dex public stubs jar build path", "out/soong/.intermediates/myjavalib.stubs.exportable/android_common/dex/myjavalib.stubs.exportable.jar", dexJarPath)
dexJarPath = dexJarBuildPath("myjavalib", android.SdkSystem)
- systemDexJar := "out/soong/.intermediates/myjavalib.stubs.system/android_common/dex/myjavalib.stubs.system.jar"
+ systemDexJar := "out/soong/.intermediates/myjavalib.stubs.exportable.system/android_common/dex/myjavalib.stubs.exportable.system.jar"
android.AssertStringEquals(t, "source dex system stubs jar build path", systemDexJar, dexJarPath)
// This should fall back to system as module is not available.
dexJarPath = dexJarBuildPath("myjavalib", android.SdkModule)
android.AssertStringEquals(t, "source dex module stubs jar build path", systemDexJar, dexJarPath)
+ // Prebuilt dex jar does not come from the exportable stubs.
dexJarPath = dexJarBuildPath(android.PrebuiltNameFromSource("myjavalib"), android.SdkPublic)
android.AssertStringEquals(t, "prebuilt dex public stubs jar build path", "out/soong/.intermediates/snapshot/prebuilt_myjavalib.stubs/android_common/dex/myjavalib.stubs.jar", dexJarPath)
}),
@@ -1254,6 +1416,11 @@ func TestSnapshotWithJavaSdkLibrary_SdkVersion_None(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -1270,9 +1437,9 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1302,6 +1469,11 @@ func TestSnapshotWithJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -1318,9 +1490,9 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1353,6 +1525,11 @@ func TestSnapshotWithJavaSdkLibrary_ApiScopes(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -1376,12 +1553,12 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
-.intermediates/myjavalib.stubs.system/android_common/javac/myjavalib.stubs.system.jar -> sdk_library/system/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable.system/android_common/combined/myjavalib.stubs.exportable.system.jar -> sdk_library/system/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1418,6 +1595,11 @@ func TestSnapshotWithJavaSdkLibrary_ModuleLib(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -1448,15 +1630,15 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
-.intermediates/myjavalib.stubs.system/android_common/javac/myjavalib.stubs.system.jar -> sdk_library/system/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
-.intermediates/myjavalib.stubs.module_lib/android_common/javac/myjavalib.stubs.module_lib.jar -> sdk_library/module-lib/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.module_lib/android_common/metalava/myjavalib.stubs.source.module_lib_api.txt -> sdk_library/module-lib/myjavalib.txt
-.intermediates/myjavalib.stubs.source.module_lib/android_common/metalava/myjavalib.stubs.source.module_lib_removed.txt -> sdk_library/module-lib/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable.system/android_common/combined/myjavalib.stubs.exportable.system.jar -> sdk_library/system/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable.module_lib/android_common/combined/myjavalib.stubs.exportable.module_lib.jar -> sdk_library/module-lib/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source.module_lib/android_common/exportable/myjavalib.stubs.source.module_lib_api.txt -> sdk_library/module-lib/myjavalib.txt
+.intermediates/myjavalib.stubs.source.module_lib/android_common/exportable/myjavalib.stubs.source.module_lib_removed.txt -> sdk_library/module-lib/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/module-lib/myjavalib_stub_sources.zip",
@@ -1491,6 +1673,11 @@ func TestSnapshotWithJavaSdkLibrary_SystemServer(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -1514,12 +1701,12 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
-.intermediates/myjavalib.stubs.system_server/android_common/javac/myjavalib.stubs.system_server.jar -> sdk_library/system-server/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source.system_server/android_common/metalava/myjavalib.stubs.source.system_server_api.txt -> sdk_library/system-server/myjavalib.txt
-.intermediates/myjavalib.stubs.source.system_server/android_common/metalava/myjavalib.stubs.source.system_server_removed.txt -> sdk_library/system-server/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable.system_server/android_common/combined/myjavalib.stubs.exportable.system_server.jar -> sdk_library/system-server/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source.system_server/android_common/exportable/myjavalib.stubs.source.system_server_api.txt -> sdk_library/system-server/myjavalib.txt
+.intermediates/myjavalib.stubs.source.system_server/android_common/exportable/myjavalib.stubs.source.system_server_removed.txt -> sdk_library/system-server/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1551,6 +1738,11 @@ func TestSnapshotWithJavaSdkLibrary_NamingScheme(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -1568,9 +1760,9 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
`),
checkMergeZips(
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
@@ -1608,6 +1800,11 @@ func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_sdk_library_import {
name: "myjavalib",
prefer: false,
@@ -1625,9 +1822,9 @@ java_sdk_library_import {
}
`),
checkAllCopyRules(`
-.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
-.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
+.intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
+.intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
docs/known_doctags -> doctags/docs/known_doctags
`),
)
diff --git a/sdk/license_sdk_test.go b/sdk/license_sdk_test.go
index 829edf117..754f01961 100644
--- a/sdk/license_sdk_test.go
+++ b/sdk/license_sdk_test.go
@@ -69,6 +69,11 @@ package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_import {
name: "myjavalib",
prefer: false,
diff --git a/sdk/member_trait_test.go b/sdk/member_trait_test.go
index 99caf13e3..673d6fb6e 100644
--- a/sdk/member_trait_test.go
+++ b/sdk/member_trait_test.go
@@ -137,6 +137,11 @@ func TestBasicTrait_WithoutTrait(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_import {
name: "myjavalib",
prefer: false,
@@ -202,6 +207,17 @@ func TestBasicTrait_MultipleTraits(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: [
+ "prebuilt_myjavalib",
+ "prebuilt_myjavalib_extra",
+ "prebuilt_myjavalib_special",
+ "prebuilt_anotherjavalib",
+ "prebuilt_anotherjavalib_special",
+ ],
+}
+
java_test_import {
name: "myjavalib",
prefer: false,
diff --git a/sdk/sdk.go b/sdk/sdk.go
index 4d4a2a2c4..5b644fd85 100644
--- a/sdk/sdk.go
+++ b/sdk/sdk.go
@@ -193,6 +193,10 @@ func (s *sdk) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Generate the snapshot from the member info.
s.buildSnapshot(ctx, sdkVariants)
}
+
+ if s.snapshotFile.Valid() {
+ ctx.SetOutputFiles([]android.Path{s.snapshotFile.Path()}, "")
+ }
}
func (s *sdk) AndroidMkEntries() []android.AndroidMkEntries {
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index 108a664ea..4894210d4 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -118,6 +118,16 @@ func TestSnapshotVisibility(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: [
+ "prebuilt_myjavalib",
+ "prebuilt_mypublicjavalib",
+ "prebuilt_mydefaultedjavalib",
+ "prebuilt_myprivatejavalib",
+ ],
+}
+
java_import {
name: "myjavalib",
prefer: false,
@@ -398,6 +408,11 @@ func TestSnapshot_EnvConfiguration(t *testing.T) {
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_myjavalib"],
+}
+
java_import {
name: "myjavalib",
prefer: false,
@@ -442,12 +457,22 @@ java_import {
android.FixtureMergeEnv(map[string]string{
"SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S",
}),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
+ }
+ }),
).RunTest(t)
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mysdklibrary"],
+}
+
prebuilt_bootclasspath_fragment {
name: "mybootclasspathfragment",
prefer: false,
@@ -487,9 +512,145 @@ java_sdk_library_import {
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv
-.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
-.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+.intermediates/mysdklibrary.stubs.exportable/android_common/combined/mysdklibrary.stubs.exportable.jar -> sdk_library/public/mysdklibrary-stubs.jar
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
+.intermediates/mysdklibrary.stubs.source/android_common/exportable/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
+`),
+ )
+ })
+
+ t.Run("test replacing exportable module", func(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForSdkTestWithJava,
+ java.PrepareForTestWithJavaDefaultModules,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureWithLastReleaseApis("mysdklibrary", "anothersdklibrary"),
+ android.FixtureWithRootAndroidBp(`
+ sdk {
+ name: "mysdk",
+ bootclasspath_fragments: ["mybootclasspathfragment"],
+ }
+
+ bootclasspath_fragment {
+ name: "mybootclasspathfragment",
+ apex_available: ["myapex"],
+ contents: ["mysdklibrary"],
+ hidden_api: {
+ split_packages: ["*"],
+ },
+ core_platform_api: {
+ stub_libs: [
+ "anothersdklibrary.stubs.exportable",
+ ],
+ },
+ api: {
+ stub_libs: [
+ "anothersdklibrary",
+ ],
+ },
+ }
+
+ java_sdk_library {
+ name: "mysdklibrary",
+ srcs: ["Test.java"],
+ compile_dex: true,
+ min_sdk_version: "S",
+ public: {enabled: true},
+ permitted_packages: ["mysdklibrary"],
+ }
+
+ java_sdk_library {
+ name: "anothersdklibrary",
+ srcs: ["Test.java"],
+ compile_dex: true,
+ min_sdk_version: "S",
+ public: {enabled: true},
+ system: {enabled: true},
+ module_lib: {enabled: true},
+ }
+ `),
+ android.FixtureMergeEnv(map[string]string{
+ "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S",
+ }),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.BuildFlags = map[string]string{
+ "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
+ }
+ variables.Platform_version_active_codenames = []string{"UpsideDownCake", "Tiramisu", "S-V2"}
+ }),
+ ).RunTest(t)
+
+ CheckSnapshot(t, result, "mysdk", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+prebuilt_bootclasspath_fragment {
+ name: "mybootclasspathfragment",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["myapex"],
+ contents: ["mysdklibrary"],
+ api: {
+ stub_libs: ["anothersdklibrary"],
+ },
+ core_platform_api: {
+ stub_libs: ["anothersdklibrary.stubs"],
+ },
+ hidden_api: {
+ annotation_flags: "hiddenapi/annotation-flags.csv",
+ metadata: "hiddenapi/metadata.csv",
+ index: "hiddenapi/index.csv",
+ stub_flags: "hiddenapi/stub-flags.csv",
+ all_flags: "hiddenapi/all-flags.csv",
+ },
+}
+
+java_sdk_library_import {
+ name: "mysdklibrary",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ shared_library: true,
+ compile_dex: true,
+ permitted_packages: ["mysdklibrary"],
+ public: {
+ jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
+ current_api: "sdk_library/public/mysdklibrary.txt",
+ removed_api: "sdk_library/public/mysdklibrary-removed.txt",
+ sdk_version: "current",
+ },
+}
+
+java_sdk_library_import {
+ name: "anothersdklibrary",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ shared_library: true,
+ compile_dex: true,
+ public: {
+ jars: ["sdk_library/public/anothersdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/public/anothersdklibrary_stub_sources"],
+ current_api: "sdk_library/public/anothersdklibrary.txt",
+ removed_api: "sdk_library/public/anothersdklibrary-removed.txt",
+ sdk_version: "current",
+ },
+ system: {
+ jars: ["sdk_library/system/anothersdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/system/anothersdklibrary_stub_sources"],
+ current_api: "sdk_library/system/anothersdklibrary.txt",
+ removed_api: "sdk_library/system/anothersdklibrary-removed.txt",
+ sdk_version: "system_current",
+ },
+ module_lib: {
+ jars: ["sdk_library/module-lib/anothersdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/module-lib/anothersdklibrary_stub_sources"],
+ current_api: "sdk_library/module-lib/anothersdklibrary.txt",
+ removed_api: "sdk_library/module-lib/anothersdklibrary-removed.txt",
+ sdk_version: "module_current",
+ },
+}
`),
)
})
diff --git a/sdk/systemserverclasspath_fragment_sdk_test.go b/sdk/systemserverclasspath_fragment_sdk_test.go
index 66c44c843..c1c4ed699 100644
--- a/sdk/systemserverclasspath_fragment_sdk_test.go
+++ b/sdk/systemserverclasspath_fragment_sdk_test.go
@@ -34,6 +34,9 @@ func testSnapshotWithSystemServerClasspathFragment(t *testing.T, sdk string, tar
env["SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE"] = targetBuildRelease
}
}),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_version_active_codenames = []string{"VanillaIceCream"}
+ }),
prepareForSdkTestWithApex,
android.FixtureWithRootAndroidBp(sdk+`
@@ -86,6 +89,143 @@ func testSnapshotWithSystemServerClasspathFragment(t *testing.T, sdk string, tar
)
}
+func TestSnapshotWithPartialSystemServerClasspathFragment(t *testing.T) {
+ commonSdk := `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "Tiramisu",
+ systemserverclasspath_fragments: ["mysystemserverclasspathfragment"],
+ }
+ systemserverclasspath_fragment {
+ name: "mysystemserverclasspathfragment",
+ apex_available: ["myapex"],
+ contents: [
+ "mysdklibrary",
+ "mysdklibrary-future",
+ ],
+ }
+ java_sdk_library {
+ name: "mysdklibrary",
+ apex_available: ["myapex"],
+ srcs: ["Test.java"],
+ min_sdk_version: "33", // Tiramisu
+ }
+ java_sdk_library {
+ name: "mysdklibrary-future",
+ apex_available: ["myapex"],
+ srcs: ["Test.java"],
+ min_sdk_version: "34", // UpsideDownCake
+ }
+ sdk {
+ name: "mysdk",
+ apexes: ["myapex"],
+ }
+ `
+
+ result := android.GroupFixturePreparers(
+ prepareForSdkTestWithJava,
+ java.PrepareForTestWithJavaDefaultModules,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureWithLastReleaseApis("mysdklibrary", "mysdklibrary-future"),
+ dexpreopt.FixtureSetApexSystemServerJars("myapex:mysdklibrary", "myapex:mysdklibrary-future"),
+ android.FixtureModifyEnv(func(env map[string]string) {
+ // targeting Tiramisu here means that we won't export mysdklibrary-future
+ env["SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE"] = "Tiramisu"
+ }),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_version_active_codenames = []string{"UpsideDownCake"}
+ }),
+ prepareForSdkTestWithApex,
+ android.FixtureWithRootAndroidBp(commonSdk),
+ ).RunTest(t)
+
+ CheckSnapshot(t, result, "mysdk", "", checkAndroidBpContents(
+ `// This is auto-generated. DO NOT EDIT.
+
+java_sdk_library_import {
+ name: "mysdklibrary",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["myapex"],
+ shared_library: true,
+ public: {
+ jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
+ current_api: "sdk_library/public/mysdklibrary.txt",
+ removed_api: "sdk_library/public/mysdklibrary-removed.txt",
+ sdk_version: "current",
+ },
+ system: {
+ jars: ["sdk_library/system/mysdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/system/mysdklibrary_stub_sources"],
+ current_api: "sdk_library/system/mysdklibrary.txt",
+ removed_api: "sdk_library/system/mysdklibrary-removed.txt",
+ sdk_version: "system_current",
+ },
+ test: {
+ jars: ["sdk_library/test/mysdklibrary-stubs.jar"],
+ stub_srcs: ["sdk_library/test/mysdklibrary_stub_sources"],
+ current_api: "sdk_library/test/mysdklibrary.txt",
+ removed_api: "sdk_library/test/mysdklibrary-removed.txt",
+ sdk_version: "test_current",
+ },
+}
+
+prebuilt_systemserverclasspath_fragment {
+ name: "mysystemserverclasspathfragment",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["myapex"],
+ contents: ["mysdklibrary"],
+} `))
+}
+
+func TestSnapshotWithEmptySystemServerClasspathFragment(t *testing.T) {
+ commonSdk := `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "Tiramisu",
+ systemserverclasspath_fragments: ["mysystemserverclasspathfragment"],
+ }
+ systemserverclasspath_fragment {
+ name: "mysystemserverclasspathfragment",
+ apex_available: ["myapex"],
+ contents: ["mysdklibrary"],
+ }
+ java_sdk_library {
+ name: "mysdklibrary",
+ apex_available: ["myapex"],
+ srcs: ["Test.java"],
+ min_sdk_version: "34", // UpsideDownCake
+ }
+ sdk {
+ name: "mysdk",
+ apexes: ["myapex"],
+ }
+ `
+
+ result := android.GroupFixturePreparers(
+ prepareForSdkTestWithJava,
+ java.PrepareForTestWithJavaDefaultModules,
+ java.PrepareForTestWithJavaSdkLibraryFiles,
+ java.FixtureWithLastReleaseApis("mysdklibrary"),
+ dexpreopt.FixtureSetApexSystemServerJars("myapex:mysdklibrary"),
+ android.FixtureModifyEnv(func(env map[string]string) {
+ // targeting Tiramisu here means that we won't export mysdklibrary
+ env["SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE"] = "Tiramisu"
+ }),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_version_active_codenames = []string{"UpsideDownCake"}
+ }),
+ prepareForSdkTestWithApex,
+ android.FixtureWithRootAndroidBp(commonSdk),
+ ).RunTest(t)
+
+ CheckSnapshot(t, result, "mysdk", "", checkAndroidBpContents(`// This is auto-generated. DO NOT EDIT.`))
+}
+
func TestSnapshotWithSystemServerClasspathFragment(t *testing.T) {
commonSdk := `
@@ -105,6 +245,11 @@ sdk {
expectedLatestSnapshot := `
// This is auto-generated. DO NOT EDIT.
+apex_contributions_defaults {
+ name: "mysdk.contributions",
+ contents: ["prebuilt_mysdklibrary"],
+}
+
java_sdk_library_import {
name: "mysdklibrary",
prefer: false,
diff --git a/sdk/update.go b/sdk/update.go
index d98ab683d..198c8d4a8 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -24,6 +24,7 @@ import (
"android/soong/apex"
"android/soong/cc"
+ "android/soong/java"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -89,19 +90,6 @@ type generatedContents struct {
indentLevel int
}
-// generatedFile abstracts operations for writing contents into a file and emit a build rule
-// for the file.
-type generatedFile struct {
- generatedContents
- path android.OutputPath
-}
-
-func newGeneratedFile(ctx android.ModuleContext, path ...string) *generatedFile {
- return &generatedFile{
- path: android.PathForModuleOut(ctx, path...).OutputPath,
- }
-}
-
func (gc *generatedContents) Indent() {
gc.indentLevel++
}
@@ -122,26 +110,6 @@ func (gc *generatedContents) UnindentedPrintf(format string, args ...interface{}
_, _ = fmt.Fprintf(&(gc.content), format, args...)
}
-func (gf *generatedFile) build(pctx android.PackageContext, ctx android.BuilderContext, implicits android.Paths) {
- rb := android.NewRuleBuilder(pctx, ctx)
-
- content := gf.content.String()
-
- // ninja consumes newline characters in rspfile_content. Prevent it by
- // escaping the backslash in the newline character. The extra backslash
- // is removed when the rspfile is written to the actual script file
- content = strings.ReplaceAll(content, "\n", "\\n")
-
- rb.Command().
- Implicits(implicits).
- Text("echo -n").Text(proptools.ShellEscape(content)).
- // convert \\n to \n
- Text("| sed 's/\\\\n/\\n/g' >").Output(gf.path)
- rb.Command().
- Text("chmod a+x").Output(gf.path)
- rb.Build(gf.path.Base(), "Build "+gf.path.Base())
-}
-
// Collect all the members.
//
// Updates the sdk module with a list of sdkMemberVariantDep instances and details as to which
@@ -166,14 +134,11 @@ func (s *sdk) collectMembers(ctx android.ModuleContext) {
// Keep track of which multilib variants are used by the sdk.
s.multilibUsages = s.multilibUsages.addArchType(child.Target().Arch.ArchType)
- var exportedComponentsInfo android.ExportedComponentsInfo
- if ctx.OtherModuleHasProvider(child, android.ExportedComponentsInfoProvider) {
- exportedComponentsInfo = ctx.OtherModuleProvider(child, android.ExportedComponentsInfoProvider).(android.ExportedComponentsInfo)
- }
+ exportedComponentsInfo, _ := android.OtherModuleProvider(ctx, child, android.ExportedComponentsInfoProvider)
var container android.Module
if parent != ctx.Module() {
- container = parent.(android.Module)
+ container = parent
}
minApiLevel := android.MinApiLevelForSdkSnapshot(ctx, child)
@@ -182,7 +147,7 @@ func (s *sdk) collectMembers(ctx android.ModuleContext) {
s.memberVariantDeps = append(s.memberVariantDeps, sdkMemberVariantDep{
sdkVariant: s,
memberType: memberType,
- variant: child.(android.Module),
+ variant: child,
minApiLevel: minApiLevel,
container: container,
export: export,
@@ -198,6 +163,20 @@ func (s *sdk) collectMembers(ctx android.ModuleContext) {
})
}
+// A denylist of modules whose host variants will be removed from the generated snapshots above the ApiLevel
+// even if they are listed in the corresponding `sdk`.
+// The key is the module name
+// The value is the _last_ dessert where the host variant of the module will be present
+// This is a workaround to ensure that these modules are generated in <=$ApiLevel, but not in in >=$ApiLevel
+var ignoreHostModuleVariantsAboveDessert = map[string]android.ApiLevel{
+ // ignore host variant of libdexfile and its transitive dependencies.
+ // The platform test that depends on them (`libunwindstack_unit_test` at the time of writing)
+ // no longer requires a prebuilt variant of libdexfile.
+ "libdexfile": android.ApiLevelUpsideDownCake,
+ "libartpalette": android.ApiLevelUpsideDownCake,
+ "libartbase": android.ApiLevelUpsideDownCake,
+}
+
// groupMemberVariantsByMemberThenType groups the member variant dependencies so that all the
// variants of each member are grouped together within an sdkMember instance.
//
@@ -216,6 +195,14 @@ func (s *sdk) groupMemberVariantsByMemberThenType(ctx android.ModuleContext, tar
variant := memberVariantDep.variant
name := ctx.OtherModuleName(variant)
+ targetApiLevel, err := android.ApiLevelFromUser(ctx, targetBuildRelease.name)
+ if err != nil {
+ targetApiLevel = android.FutureApiLevel
+ }
+ if lastApiLevel, exists := ignoreHostModuleVariantsAboveDessert[name]; exists && targetApiLevel.GreaterThan(lastApiLevel) && memberVariantDep.Host() {
+ // ignore host variant of this module if the targetApiLevel is V and above.
+ continue
+ }
member := byName[name]
if member == nil {
member = &sdkMember{memberType: memberType, name: name}
@@ -378,7 +365,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) {
snapshotDir := android.PathForModuleOut(ctx, "snapshot")
- bp := newGeneratedFile(ctx, "snapshot", "Android.bp")
+ bp := android.PathForModuleOut(ctx, "snapshot", "Android.bp")
bpFile := &bpFile{
modules: make(map[string]*bpModule),
@@ -392,7 +379,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) {
sdk: s,
snapshotDir: snapshotDir.OutputPath,
copies: make(map[string]string),
- filesToZip: []android.Path{bp.path},
+ filesToZip: []android.Path{bp},
bpFile: bpFile,
prebuiltModules: make(map[string]*bpModule),
allMembersByName: allMembersByName,
@@ -424,6 +411,7 @@ be unnecessary as every module in the sdk already has its own licenses property.
// Create the prebuilt modules for each of the member modules.
traits := s.gatherTraits()
+ memberNames := []string{} // soong module names of the members. contains the prebuilt_ prefix.
for _, member := range members {
memberType := member.memberType
if !memberType.ArePrebuiltsRequired() {
@@ -445,6 +433,46 @@ be unnecessary as every module in the sdk already has its own licenses property.
prebuiltModule := memberType.AddPrebuiltModule(memberCtx, member)
s.createMemberSnapshot(memberCtx, member, prebuiltModule.(*bpModule))
+
+ // Set stripper to none to skip stripping for generated snapshots.
+ // Mainline prebuilts (cc_prebuilt_library_shared) are not strippable in older platforms.
+ // Thus, stripping should be skipped when being used as prebuilts.
+ if memberType.DisablesStrip() {
+ stripPropertySet := prebuiltModule.(*bpModule).AddPropertySet("strip")
+ stripPropertySet.AddProperty("none", true)
+ }
+
+ if member.memberType != android.LicenseModuleSdkMemberType && !builder.isInternalMember(member.name) {
+ // More exceptions
+ // 1. Skip BCP and SCCP fragments
+ // 2. Skip non-sdk contents of BCP and SCCP fragments
+ //
+ // The non-sdk contents of BCP/SSCP fragments should only be used for dexpreopt and hiddenapi,
+ // and are not available to the rest of the build.
+ if android.InList(member.memberType,
+ []android.SdkMemberType{
+ // bcp
+ java.BootclasspathFragmentSdkMemberType,
+ java.JavaBootLibsSdkMemberType,
+ // sscp
+ java.SystemServerClasspathFragmentSdkMemberType,
+ java.JavaSystemserverLibsSdkMemberType,
+ },
+ ) {
+ continue
+ }
+
+ memberNames = append(memberNames, android.PrebuiltNameFromSource(member.name))
+ }
+ }
+
+ // create an apex_contributions_defaults for this module's sdk.
+ // this module type is supported in V and above.
+ if targetApiLevel.GreaterThan(android.ApiLevelUpsideDownCake) {
+ ac := newModule("apex_contributions_defaults")
+ ac.AddProperty("name", s.Name()+".contributions")
+ ac.AddProperty("contents", memberNames)
+ bpFile.AddModule(ac)
}
// Create a transformer that will transform a module by replacing any references
@@ -455,25 +483,31 @@ be unnecessary as every module in the sdk already has its own licenses property.
for _, module := range builder.prebuiltOrder {
// Prune any empty property sets.
- module = module.transform(pruneEmptySetTransformer{})
+ module = transformModule(module, pruneEmptySetTransformer{})
// Transform the module module to make it suitable for use in the snapshot.
- module.transform(snapshotTransformer)
- bpFile.AddModule(module)
+ module = transformModule(module, snapshotTransformer)
+ module = transformModule(module, emptyClasspathContentsTransformation{})
+
+ targetApiLevel, err := android.ApiLevelFromUserWithConfig(ctx.Config(), s.targetBuildRelease(ctx).name)
+ if err == nil && targetApiLevel.LessThan(android.ApiLevelVanillaIceCream) {
+ module = transformModule(module, replaceExportablePropertiesTransformer{})
+ }
+
+ if module != nil {
+ bpFile.AddModule(module)
+ }
}
// generate Android.bp
- bp = newGeneratedFile(ctx, "snapshot", "Android.bp")
- generateBpContents(&bp.generatedContents, bpFile)
-
- contents := bp.content.String()
+ contents := generateBpContents(bpFile)
// If the snapshot is being generated for the current build release then check the syntax to make
// sure that it is compatible.
if targetBuildRelease == buildReleaseCurrent {
syntaxCheckSnapshotBpFile(ctx, contents)
}
- bp.build(pctx, ctx, nil)
+ android.WriteFileRuleVerbatim(ctx, bp, contents)
// Copy the build number file into the snapshot.
builder.CopyToSnapshot(ctx.Config().BuildNumberFile(ctx), BUILD_NUMBER_FILE)
@@ -522,16 +556,14 @@ be unnecessary as every module in the sdk already has its own licenses property.
modules := s.generateInfoData(ctx, memberVariantDeps)
// Output the modules information as pretty printed JSON.
- info := newGeneratedFile(ctx, fmt.Sprintf("%s%s.info", ctx.ModuleName(), snapshotFileSuffix))
+ info := android.PathForModuleOut(ctx, fmt.Sprintf("%s%s.info", ctx.ModuleName(), snapshotFileSuffix))
output, err := json.MarshalIndent(modules, "", " ")
if err != nil {
ctx.ModuleErrorf("error generating %q: %s", info, err)
}
builder.infoContents = string(output)
- info.generatedContents.UnindentedPrintf("%s", output)
- info.build(pctx, ctx, nil)
- infoPath := info.path
- installedInfo := ctx.InstallFile(android.PathForMainlineSdksInstall(ctx), infoPath.Base(), infoPath)
+ android.WriteFileRuleVerbatim(ctx, info, builder.infoContents)
+ installedInfo := ctx.InstallFile(android.PathForMainlineSdksInstall(ctx), info.Base(), info)
s.infoFile = android.OptionalPathForPath(installedInfo)
// Install the zip, making sure that the info file has been installed as well.
@@ -604,7 +636,7 @@ func (s *sdk) generateInfoData(ctx android.ModuleContext, memberVariantDeps []sd
name: name,
}
- additionalSdkInfo := ctx.OtherModuleProvider(module, android.AdditionalSdkInfoProvider).(android.AdditionalSdkInfo)
+ additionalSdkInfo, _ := android.OtherModuleProvider(ctx, module, android.AdditionalSdkInfoProvider)
info.memberSpecific = additionalSdkInfo.Properties
name2Info[name] = info
@@ -718,105 +750,6 @@ func extractCommonProperties(ctx android.ModuleContext, extractor *commonValueEx
}
}
-// snapshotModuleStaticProperties contains snapshot static (i.e. not dynamically generated) properties.
-type snapshotModuleStaticProperties struct {
- Compile_multilib string `android:"arch_variant"`
-}
-
-// combinedSnapshotModuleProperties are the properties that are associated with the snapshot module.
-type combinedSnapshotModuleProperties struct {
- // The sdk variant from which this information was collected.
- sdkVariant *sdk
-
- // Static snapshot module properties.
- staticProperties *snapshotModuleStaticProperties
-
- // The dynamically generated member list properties.
- dynamicProperties interface{}
-}
-
-// collateSnapshotModuleInfo collates all the snapshot module info from supplied sdk variants.
-func (s *sdk) collateSnapshotModuleInfo(ctx android.BaseModuleContext, sdkVariants []*sdk, memberVariantDeps []sdkMemberVariantDep) []*combinedSnapshotModuleProperties {
- sdkVariantToCombinedProperties := map[*sdk]*combinedSnapshotModuleProperties{}
- var list []*combinedSnapshotModuleProperties
- for _, sdkVariant := range sdkVariants {
- staticProperties := &snapshotModuleStaticProperties{
- Compile_multilib: sdkVariant.multilibUsages.String(),
- }
- dynamicProperties := s.dynamicSdkMemberTypes.createMemberTypeListProperties()
-
- combinedProperties := &combinedSnapshotModuleProperties{
- sdkVariant: sdkVariant,
- staticProperties: staticProperties,
- dynamicProperties: dynamicProperties,
- }
- sdkVariantToCombinedProperties[sdkVariant] = combinedProperties
-
- list = append(list, combinedProperties)
- }
-
- for _, memberVariantDep := range memberVariantDeps {
- // If the member dependency is internal then do not add the dependency to the snapshot member
- // list properties.
- if !memberVariantDep.export {
- continue
- }
-
- combined := sdkVariantToCombinedProperties[memberVariantDep.sdkVariant]
- memberListProperty := s.memberTypeListProperty(memberVariantDep.memberType)
- memberName := ctx.OtherModuleName(memberVariantDep.variant)
-
- if memberListProperty.getter == nil {
- continue
- }
-
- // Append the member to the appropriate list, if it is not already present in the list.
- memberList := memberListProperty.getter(combined.dynamicProperties)
- if !android.InList(memberName, memberList) {
- memberList = append(memberList, memberName)
- }
- memberListProperty.setter(combined.dynamicProperties, memberList)
- }
-
- return list
-}
-
-func (s *sdk) optimizeSnapshotModuleProperties(ctx android.ModuleContext, list []*combinedSnapshotModuleProperties) *combinedSnapshotModuleProperties {
-
- // Extract the dynamic properties and add them to a list of propertiesContainer.
- propertyContainers := []propertiesContainer{}
- for _, i := range list {
- propertyContainers = append(propertyContainers, sdkVariantPropertiesContainer{
- sdkVariant: i.sdkVariant,
- properties: i.dynamicProperties,
- })
- }
-
- // Extract the common members, removing them from the original properties.
- commonDynamicProperties := s.dynamicSdkMemberTypes.createMemberTypeListProperties()
- extractor := newCommonValueExtractor(commonDynamicProperties)
- extractCommonProperties(ctx, extractor, commonDynamicProperties, propertyContainers)
-
- // Extract the static properties and add them to a list of propertiesContainer.
- propertyContainers = []propertiesContainer{}
- for _, i := range list {
- propertyContainers = append(propertyContainers, sdkVariantPropertiesContainer{
- sdkVariant: i.sdkVariant,
- properties: i.staticProperties,
- })
- }
-
- commonStaticProperties := &snapshotModuleStaticProperties{}
- extractor = newCommonValueExtractor(commonStaticProperties)
- extractCommonProperties(ctx, extractor, &commonStaticProperties, propertyContainers)
-
- return &combinedSnapshotModuleProperties{
- sdkVariant: nil,
- staticProperties: commonStaticProperties,
- dynamicProperties: commonDynamicProperties,
- }
-}
-
type propertyTag struct {
name string
}
@@ -835,9 +768,11 @@ type snapshotTransformation struct {
}
func (t snapshotTransformation) transformModule(module *bpModule) *bpModule {
- // If the module is an internal member then use a unique name for it.
- name := module.Name()
- module.setProperty("name", t.builder.snapshotSdkMemberName(name, true))
+ if module != nil {
+ // If the module is an internal member then use a unique name for it.
+ name := module.Name()
+ module.setProperty("name", t.builder.snapshotSdkMemberName(name, true))
+ }
return module
}
@@ -850,6 +785,25 @@ func (t snapshotTransformation) transformProperty(_ string, value interface{}, t
}
}
+type emptyClasspathContentsTransformation struct {
+ identityTransformation
+}
+
+func (t emptyClasspathContentsTransformation) transformModule(module *bpModule) *bpModule {
+ classpathModuleTypes := []string{
+ "prebuilt_bootclasspath_fragment",
+ "prebuilt_systemserverclasspath_fragment",
+ }
+ if module != nil && android.InList(module.moduleType, classpathModuleTypes) {
+ if contents, ok := module.bpPropertySet.properties["contents"].([]string); ok {
+ if len(contents) == 0 {
+ return nil
+ }
+ }
+ }
+ return module
+}
+
type pruneEmptySetTransformer struct {
identityTransformation
}
@@ -864,7 +818,52 @@ func (t pruneEmptySetTransformer) transformPropertySetAfterContents(_ string, pr
}
}
-func generateBpContents(contents *generatedContents, bpFile *bpFile) {
+type replaceExportablePropertiesTransformer struct {
+ identityTransformation
+}
+
+var _ bpTransformer = (*replaceExportablePropertiesTransformer)(nil)
+
+func handleExportableProperties[T any](value T) any {
+ switch v := any(value).(type) {
+ case string:
+ return java.AllApiScopes.ConvertStubsLibraryExportableToEverything(v)
+ case *bpPropertySet:
+ v.properties = handleExportableProperties(v.properties).(map[string]interface{})
+ return v
+ case []string:
+ result := make([]string, len(v))
+ for i, elem := range v {
+ result[i] = handleExportableProperties(elem).(string)
+ }
+ return result
+ case []any:
+ result := make([]any, len(v))
+ for i, elem := range v {
+ result[i] = handleExportableProperties(elem)
+ }
+ return result
+ case map[string]any:
+ result := make(map[string]any)
+ for k, val := range v {
+ result[k] = handleExportableProperties(val)
+ }
+ return result
+ default:
+ return value
+ }
+}
+
+func (t replaceExportablePropertiesTransformer) transformPropertySetAfterContents(name string, propertySet *bpPropertySet, tag android.BpPropertyTag) (*bpPropertySet, android.BpPropertyTag) {
+ if name == "name" {
+ return propertySet, tag
+ }
+ propertySet.properties = handleExportableProperties(propertySet.properties).(map[string]interface{})
+ return propertySet, tag
+}
+
+func generateBpContents(bpFile *bpFile) string {
+ contents := &generatedContents{}
contents.IndentedPrintf("// This is auto-generated. DO NOT EDIT.\n")
for _, bpModule := range bpFile.order {
contents.IndentedPrintf("\n")
@@ -872,6 +871,7 @@ func generateBpContents(contents *generatedContents, bpFile *bpFile) {
outputPropertySet(contents, bpModule.bpPropertySet)
contents.IndentedPrintf("}\n")
}
+ return contents.content.String()
}
func outputPropertySet(contents *generatedContents, set *bpPropertySet) {
@@ -986,7 +986,7 @@ func outputUnnamedValue(contents *generatedContents, value reflect.Value) {
contents.IndentedPrintf("}")
default:
- panic(fmt.Errorf("Unknown type: %T of value %#v", value, value))
+ panic(fmt.Errorf("unknown type: %T of value %#v", value, value))
}
}
@@ -997,9 +997,7 @@ func multiLineValue(value reflect.Value) bool {
}
func (s *sdk) GetAndroidBpContentsForTests() string {
- contents := &generatedContents{}
- generateBpContents(contents, s.builderForTests.bpFile)
- return contents.content.String()
+ return generateBpContents(s.builderForTests.bpFile)
}
func (s *sdk) GetInfoContentsForTests() string {
@@ -1147,7 +1145,7 @@ func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType
// The licenses are the same for all variants.
mctx := s.ctx
- licenseInfo := mctx.OtherModuleProvider(variant, android.LicenseInfoProvider).(android.LicenseInfo)
+ licenseInfo, _ := android.OtherModuleProvider(mctx, variant, android.LicenseInfoProvider)
if len(licenseInfo.Licenses) > 0 {
m.AddPropertyWithTag("licenses", licenseInfo.Licenses, s.OptionalSdkMemberReferencePropertyTag())
}
@@ -1313,7 +1311,7 @@ func (m multilibUsage) addArchType(archType android.ArchType) multilibUsage {
case "lib64":
return m | multilib64
default:
- panic(fmt.Errorf("Unknown Multilib field in ArchType, expected 'lib32' or 'lib64', found %q", multilib))
+ panic(fmt.Errorf("unknown Multilib field in ArchType, expected 'lib32' or 'lib64', found %q", multilib))
}
}
@@ -1328,7 +1326,7 @@ func (m multilibUsage) String() string {
case multilibBoth:
return "both"
default:
- panic(fmt.Errorf("Unknown multilib value, found %b, expected one of %b, %b, %b or %b",
+ panic(fmt.Errorf("unknown multilib value, found %b, expected one of %b, %b, %b or %b",
m, multilibNone, multilib32, multilib64, multilibBoth))
}
}
@@ -1393,7 +1391,7 @@ func selectApexVariantsWhereAvailable(ctx *memberContext, variants []android.Mod
variantsByApex := make(map[string]android.Module)
conflictDetected := false
for _, variant := range list {
- apexInfo := moduleCtx.OtherModuleProvider(variant, android.ApexInfoProvider).(android.ApexInfo)
+ apexInfo, _ := android.OtherModuleProvider(moduleCtx, variant, android.ApexInfoProvider)
apexVariationName := apexInfo.ApexVariationName
// If there are two variants for a specific APEX variation then there is conflict.
if _, ok := variantsByApex[apexVariationName]; ok {
@@ -1963,6 +1961,10 @@ type memberContext struct {
requiredTraits android.SdkMemberTraitSet
}
+func (m *memberContext) ModuleErrorf(fmt string, args ...interface{}) {
+ m.sdkMemberContext.ModuleErrorf(fmt, args...)
+}
+
func (m *memberContext) SdkModuleContext() android.ModuleContext {
return m.sdkMemberContext
}
@@ -2277,20 +2279,6 @@ type propertiesContainer interface {
optimizableProperties() interface{}
}
-// A wrapper for sdk variant related properties to allow them to be optimized.
-type sdkVariantPropertiesContainer struct {
- sdkVariant *sdk
- properties interface{}
-}
-
-func (c sdkVariantPropertiesContainer) optimizableProperties() interface{} {
- return c.properties
-}
-
-func (c sdkVariantPropertiesContainer) String() string {
- return c.sdkVariant.String()
-}
-
// Extract common properties from a slice of property structures of the same type.
//
// All the property structures must be of the same type.