Merge "Add all compile deps to module_bp_java_deps.json" into main
This commit is contained in:
14
java/base.go
14
java/base.go
@@ -550,6 +550,10 @@ type Module struct {
|
|||||||
// java_aconfig_library or java_library modules that are statically linked
|
// java_aconfig_library or java_library modules that are statically linked
|
||||||
// to this module. Does not contain cache files from all transitive dependencies.
|
// to this module. Does not contain cache files from all transitive dependencies.
|
||||||
aconfigCacheFiles android.Paths
|
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)
|
var _ android.InstallableModule = (*Module)(nil)
|
||||||
@@ -2061,10 +2065,7 @@ func (j *Module) IDEInfo(dpInfo *android.IdeInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) CompilerDeps() []string {
|
func (j *Module) CompilerDeps() []string {
|
||||||
jdeps := []string{}
|
return j.compileDepNames
|
||||||
jdeps = append(jdeps, j.properties.Libs...)
|
|
||||||
jdeps = append(jdeps, j.properties.Static_libs...)
|
|
||||||
return jdeps
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) hasCode(ctx android.ModuleContext) bool {
|
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)
|
addCLCFromDep(ctx, module, j.classLoaderContexts)
|
||||||
addMissingOptionalUsesLibsFromDep(ctx, module, &j.usesLibrary)
|
addMissingOptionalUsesLibsFromDep(ctx, module, &j.usesLibrary)
|
||||||
})
|
})
|
||||||
|
24
java/java.go
24
java/java.go
@@ -443,6 +443,30 @@ var (
|
|||||||
usesLibCompat30OptTag = makeUsesLibraryDependencyTag(30, true)
|
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 {
|
func IsLibDepTag(depTag blueprint.DependencyTag) bool {
|
||||||
return depTag == libTag || depTag == sdkLibTag
|
return depTag == libTag || depTag == sdkLibTag
|
||||||
}
|
}
|
||||||
|
@@ -22,28 +22,46 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCollectJavaLibraryPropertiesAddLibsDeps(t *testing.T) {
|
func TestCollectJavaLibraryPropertiesAddLibsDeps(t *testing.T) {
|
||||||
expected := []string{"Foo", "Bar"}
|
ctx, _ := testJava(t,
|
||||||
module := LibraryFactory().(*Library)
|
`
|
||||||
module.properties.Libs = append(module.properties.Libs, expected...)
|
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{}
|
dpInfo := &android.IdeInfo{}
|
||||||
|
|
||||||
module.IDEInfo(dpInfo)
|
module.IDEInfo(dpInfo)
|
||||||
|
|
||||||
if !reflect.DeepEqual(dpInfo.Deps, expected) {
|
for _, expected := range []string{"Foo", "Bar"} {
|
||||||
t.Errorf("Library.IDEInfo() Deps = %v, want %v", dpInfo.Deps, expected)
|
if !android.InList(expected, dpInfo.Deps) {
|
||||||
|
t.Errorf("Library.IDEInfo() Deps = %v, %v not found", dpInfo.Deps, expected)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) {
|
func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) {
|
||||||
expected := []string{"Foo", "Bar"}
|
ctx, _ := testJava(t,
|
||||||
module := LibraryFactory().(*Library)
|
`
|
||||||
module.properties.Static_libs = append(module.properties.Static_libs, expected...)
|
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{}
|
dpInfo := &android.IdeInfo{}
|
||||||
|
|
||||||
module.IDEInfo(dpInfo)
|
module.IDEInfo(dpInfo)
|
||||||
|
|
||||||
if !reflect.DeepEqual(dpInfo.Deps, expected) {
|
for _, expected := range []string{"Foo", "Bar"} {
|
||||||
t.Errorf("Library.IDEInfo() Deps = %v, want %v", dpInfo.Deps, expected)
|
if !android.InList(expected, dpInfo.Deps) {
|
||||||
|
t.Errorf("Library.IDEInfo() Deps = %v, %v not found", dpInfo.Deps, expected)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user