Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 968b2e1c authored by Jihoon Kang's avatar Jihoon Kang Committed by Automerger Merge Worker
Browse files

Fix bootclasspath_fragment build failure during from-text stub build am: 7e9e20e3 am: 4fa9e5f4

parents dcfeb53b 4fa9e5f4
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -432,3 +432,39 @@ func TestBootclasspathFragment_Test(t *testing.T) {
	fragment = result.Module("a_test_fragment", "android_common").(*BootclasspathFragmentModule)
	android.AssertBoolEquals(t, "is a test fragment by type", true, fragment.isTestFragment())
}

func TestBootclassFragment_LinkTextStub(t *testing.T) {
	result := android.GroupFixturePreparers(
		prepareForJavaTest,
		prepareForTestWithBootclasspathFragment,
		PrepareForTestWithJavaSdkLibraryFiles,
		FixtureWithLastReleaseApis("mysdklibrary"),
		android.FixtureModifyConfig(func(config android.Config) {
			config.SetBuildFromTextStub(true)
		}),
	).RunTestWithBp(t, `
        bootclasspath_fragment {
            name: "myfragment",
            contents: ["mysdklibrary"],
            hidden_api: {split_packages: ["*"]},
            additional_stubs: [
                "android-non-updatable",
            ],
        }
        java_sdk_library {
            name: "mysdklibrary",
            srcs: ["a.java"],
            shared_library: false,
            public: {enabled: true},
            system: {enabled: true},
        }
    `)

	fragment := result.ModuleForTests("myfragment", "android_common")
	ruleCommand := fragment.Rule("modularHiddenAPIStubFlagsFile").RuleParams.Command
	android.AssertStringDoesContain(t, "Command expected to contain library as dependency stub dex",
		ruleCommand, "--dependency-stub-dex=out/soong/.intermediates/default/java/android-non-updatable.stubs.module_lib.from-text/android_common/dex/android-non-updatable.stubs.module_lib.from-text.jar")
	android.AssertStringDoesNotContain(t,
		"Command not expected to contain multiple api_library as dependency stub dex", ruleCommand,
		"--dependency-stub-dex=out/soong/.intermediates/default/java/android-non-updatable.stubs.from-text/android_common/dex/android-non-updatable.stubs.from-text.jar")
}
+1 −1
Original line number Diff line number Diff line
@@ -647,7 +647,7 @@ func (s StubDexJarsByModule) addStubDexJar(ctx android.ModuleContext, module and
	// public version is provided by the art.module.public.api module. In those cases it is necessary
	// to treat all those modules as they were the same name, otherwise it will result in multiple
	// definitions of a single class being passed to hidden API processing which will cause an error.
	if name == scope.nonUpdatablePrebuiltModule || name == scope.nonUpdatableSourceModule {
	if name == scope.nonUpdatablePrebuiltModule || name == android.JavaApiLibraryName(ctx.Config(), scope.nonUpdatableSourceModule) {
		// Treat all *android-non-updatable* modules as if they were part of an android-non-updatable
		// java_sdk_library.
		// TODO(b/192067200): Remove once android-non-updatable is a java_sdk_library or equivalent.