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

Commit d831af42 authored by Jihoon Kang's avatar Jihoon Kang
Browse files

Remove compilation actions from java sdk library

This change modifies the build actions of java_sdk_library module type
so that it does not perform any compilation actions (i.e. does not
create the top level java_sdk_library jar file). Instead, it delegates
the build actions the top level jar file was performing to the
dynamically created ".impl"-suffixed java library module. The build
actions that are delegated to the impl library module include hiddenapi
processing, dexing, and dexpreopt.

Test: m nothing --no-skip-soong-tests
Bug: 332785297
Change-Id: I7534f9eaacf6d9f72fbf8d540b1e26af84106c20
parent 2ddb22ce
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1122,7 +1122,7 @@ func AndroidMkEntriesForTest(t *testing.T, ctx *TestContext, mod blueprint.Modul

	entriesList := p.AndroidMkEntries()
	aconfigUpdateAndroidMkEntries(ctx, mod.(Module), &entriesList)
	for i, _ := range entriesList {
	for i := range entriesList {
		entriesList[i].fillInEntries(ctx, mod)
	}
	return entriesList
+7 −1
Original line number Diff line number Diff line
@@ -1672,7 +1672,13 @@ func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaMod
	af.jacocoReportClassesFile = module.JacocoReportClassesFile()
	af.lintDepSets = module.LintDepSets()
	af.customStem = module.Stem() + ".jar"
	if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
	// TODO: b/338641779 - Remove special casing of sdkLibrary once bcpf and sscpf depends
	// on the implementation library
	if sdkLib, ok := module.(*java.SdkLibrary); ok {
		for _, install := range sdkLib.BuiltInstalledForApex() {
			af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
		}
	} else if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
		for _, install := range dexpreopter.DexpreoptBuiltInstalledForApex() {
			af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
		}
+2 −2
Original line number Diff line number Diff line
@@ -7167,7 +7167,7 @@ func TestJavaSDKLibrary_WithinApex(t *testing.T) {

	// The bar library should depend on the implementation jar.
	barLibrary := ctx.ModuleForTests("bar", "android_common_myapex").Rule("javac")
	if expected, actual := `^-classpath [^:]*/turbine-combined/foo\.impl\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
	if expected, actual := `^-classpath [^:]*/turbine-combined/foo\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
		t.Errorf("expected %q, found %#q", expected, actual)
	}
}
@@ -7308,7 +7308,7 @@ func TestJavaSDKLibrary_ImportPreferred(t *testing.T) {

	// The bar library should depend on the implementation jar.
	barLibrary := ctx.ModuleForTests("bar", "android_common_myapex").Rule("javac")
	if expected, actual := `^-classpath [^:]*/turbine-combined/foo\.impl\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
	if expected, actual := `^-classpath [^:]*/turbine-combined/foo\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
		t.Errorf("expected %q, found %#q", expected, actual)
	}
}
+2 −2
Original line number Diff line number Diff line
@@ -161,8 +161,8 @@ func TestJavaSdkLibrary_RequireXmlPermissionFile(t *testing.T) {
		moduleName string
		expected   []string
	}{
		{"foo-shared_library", []string{"foo-shared_library.xml"}},
		{"foo-no_shared_library", nil},
		{"foo-shared_library", []string{"foo-shared_library.impl", "foo-shared_library.xml"}},
		{"foo-no_shared_library", []string{"foo-no_shared_library.impl"}},
	}
	for _, tc := range testCases {
		mod := result.ModuleForTests(tc.moduleName, "android_common").Module()
+5 −1
Original line number Diff line number Diff line
@@ -1682,7 +1682,11 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
			j.dexJarFile = makeDexJarPathFromPath(dexOutputFile)

			// Dexpreopting
			j.dexpreopt(ctx, android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName()), dexOutputFile)
			libName := android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName())
			if j.SdkLibraryName() != nil && strings.HasSuffix(ctx.ModuleName(), ".impl") {
				libName = strings.TrimSuffix(libName, ".impl")
			}
			j.dexpreopt(ctx, libName, dexOutputFile)

			outputFile = dexOutputFile
		} else {
Loading