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

Commit ad2aa3d2 authored by Spandan Das's avatar Spandan Das Committed by Gerrit Code Review
Browse files

Merge "Add all compile deps to module_bp_java_deps.json" into main

parents 00abdc02 8aac993b
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -550,6 +550,10 @@ type Module struct {
	// java_aconfig_library or java_library modules that are statically linked
	// to this module. Does not contain cache files from all transitive dependencies.
	aconfigCacheFiles android.Paths

	// List of soong module dependencies required to compile the current module.
	// This information is printed out to `Dependencies` field in module_bp_java_deps.json
	compileDepNames []string
}

var _ android.InstallableModule = (*Module)(nil)
@@ -2061,10 +2065,7 @@ func (j *Module) IDEInfo(dpInfo *android.IdeInfo) {
}

func (j *Module) CompilerDeps() []string {
	jdeps := []string{}
	jdeps = append(jdeps, j.properties.Libs...)
	jdeps = append(jdeps, j.properties.Static_libs...)
	return jdeps
	return j.compileDepNames
}

func (j *Module) hasCode(ctx android.ModuleContext) bool {
@@ -2408,6 +2409,11 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
			}
		}

		if android.InList(tag, compileDependencyTags) {
			// Add the dependency name to compileDepNames so that it can be recorded in module_bp_java_deps.json
			j.compileDepNames = append(j.compileDepNames, otherName)
		}

		addCLCFromDep(ctx, module, j.classLoaderContexts)
		addMissingOptionalUsesLibsFromDep(ctx, module, &j.usesLibrary)
	})
+24 −0
Original line number Diff line number Diff line
@@ -443,6 +443,30 @@ var (
	usesLibCompat30OptTag   = makeUsesLibraryDependencyTag(30, true)
)

// A list of tags for deps used for compiling a module.
// Any dependency tags that modifies the following properties of `deps` in `Module.collectDeps` should be
// added to this list:
// - bootClasspath
// - classpath
// - java9Classpath
// - systemModules
// - kotlin deps...
var (
	compileDependencyTags = []blueprint.DependencyTag{
		sdkLibTag,
		libTag,
		staticLibTag,
		bootClasspathTag,
		systemModulesTag,
		java9LibTag,
		kotlinStdlibTag,
		kotlinAnnotationsTag,
		kotlinPluginTag,
		syspropPublicStubDepTag,
		instrumentationForTag,
	}
)

func IsLibDepTag(depTag blueprint.DependencyTag) bool {
	return depTag == libTag || depTag == sdkLibTag
}
+28 −10
Original line number Diff line number Diff line
@@ -22,28 +22,46 @@ import (
)

func TestCollectJavaLibraryPropertiesAddLibsDeps(t *testing.T) {
	expected := []string{"Foo", "Bar"}
	module := LibraryFactory().(*Library)
	module.properties.Libs = append(module.properties.Libs, expected...)
	ctx, _ := testJava(t,
		`
		java_library {name: "Foo"}
		java_library {name: "Bar"}
		java_library {
			name: "javalib",
			libs: ["Foo", "Bar"],
		}
	`)
	module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
	dpInfo := &android.IdeInfo{}

	module.IDEInfo(dpInfo)

	if !reflect.DeepEqual(dpInfo.Deps, expected) {
		t.Errorf("Library.IDEInfo() Deps = %v, want %v", dpInfo.Deps, expected)
	for _, expected := range []string{"Foo", "Bar"} {
		if !android.InList(expected, dpInfo.Deps) {
			t.Errorf("Library.IDEInfo() Deps = %v, %v not found", dpInfo.Deps, expected)
		}
	}
}

func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) {
	expected := []string{"Foo", "Bar"}
	module := LibraryFactory().(*Library)
	module.properties.Static_libs = append(module.properties.Static_libs, expected...)
	ctx, _ := testJava(t,
		`
		java_library {name: "Foo"}
		java_library {name: "Bar"}
		java_library {
			name: "javalib",
			static_libs: ["Foo", "Bar"],
		}
	`)
	module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
	dpInfo := &android.IdeInfo{}

	module.IDEInfo(dpInfo)

	if !reflect.DeepEqual(dpInfo.Deps, expected) {
		t.Errorf("Library.IDEInfo() Deps = %v, want %v", dpInfo.Deps, expected)
	for _, expected := range []string{"Foo", "Bar"} {
		if !android.InList(expected, dpInfo.Deps) {
			t.Errorf("Library.IDEInfo() Deps = %v, %v not found", dpInfo.Deps, expected)
		}
	}
}