Add ctx argument to IDEInfo()
The IDEInfo() methods read properties. To make those properties configurable, we need a context to evaluate them with. Bug: 362579941 Test: m nothing --no-skip-soong-tests Change-Id: I26d4b7084439b3006e50b02277298f74a929e1aa
This commit is contained in:
@@ -1959,7 +1959,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
||||
|
||||
if x, ok := m.module.(IDEInfo); ok {
|
||||
var result IdeInfo
|
||||
x.IDEInfo(&result)
|
||||
x.IDEInfo(ctx, &result)
|
||||
result.BaseModuleName = x.BaseModuleName()
|
||||
SetProvider(ctx, IdeInfoProviderKey, result)
|
||||
}
|
||||
@@ -2748,7 +2748,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||
|
||||
// Collect information for opening IDE project files in java/jdeps.go.
|
||||
type IDEInfo interface {
|
||||
IDEInfo(ideInfo *IdeInfo)
|
||||
IDEInfo(ctx BaseModuleContext, ideInfo *IdeInfo)
|
||||
BaseModuleName() string
|
||||
}
|
||||
|
||||
|
@@ -2865,7 +2865,7 @@ func isStaticExecutableAllowed(apex string, exec string) bool {
|
||||
}
|
||||
|
||||
// Collect information for opening IDE project files in java/jdeps.go.
|
||||
func (a *apexBundle) IDEInfo(dpInfo *android.IdeInfo) {
|
||||
func (a *apexBundle) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
|
||||
dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...)
|
||||
dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments...)
|
||||
dpInfo.Deps = append(dpInfo.Deps, a.properties.ResolvedSystemserverclasspathFragments...)
|
||||
|
@@ -625,7 +625,7 @@ func (g *Module) setOutputFiles(ctx android.ModuleContext) {
|
||||
}
|
||||
|
||||
// Collect information for opening IDE project files in java/jdeps.go.
|
||||
func (g *Module) IDEInfo(dpInfo *android.IdeInfo) {
|
||||
func (g *Module) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
|
||||
dpInfo.Srcs = append(dpInfo.Srcs, g.Srcs().Strings()...)
|
||||
for _, src := range g.properties.ResolvedSrcs {
|
||||
if strings.HasPrefix(src, ":") {
|
||||
|
10
java/aar.go
10
java/aar.go
@@ -914,12 +914,12 @@ func (a *AndroidLibrary) setOutputFiles(ctx android.ModuleContext) {
|
||||
setOutputFiles(ctx, a.Library.Module)
|
||||
}
|
||||
|
||||
func (a *AndroidLibrary) IDEInfo(dpInfo *android.IdeInfo) {
|
||||
a.Library.IDEInfo(dpInfo)
|
||||
a.aapt.IDEInfo(dpInfo)
|
||||
func (a *AndroidLibrary) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
|
||||
a.Library.IDEInfo(ctx, dpInfo)
|
||||
a.aapt.IDEInfo(ctx, dpInfo)
|
||||
}
|
||||
|
||||
func (a *aapt) IDEInfo(dpInfo *android.IdeInfo) {
|
||||
func (a *aapt) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
|
||||
if a.rJar != nil {
|
||||
dpInfo.Jars = append(dpInfo.Jars, a.rJar.String())
|
||||
}
|
||||
@@ -1451,6 +1451,6 @@ func AARImportFactory() android.Module {
|
||||
return module
|
||||
}
|
||||
|
||||
func (a *AARImport) IDEInfo(dpInfo *android.IdeInfo) {
|
||||
func (a *AARImport) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
|
||||
dpInfo.Jars = append(dpInfo.Jars, a.headerJarFile.String(), a.rJar.String())
|
||||
}
|
||||
|
@@ -1243,9 +1243,9 @@ func (a *AndroidApp) EnableCoverageIfNeeded() {}
|
||||
|
||||
var _ cc.Coverage = (*AndroidApp)(nil)
|
||||
|
||||
func (a *AndroidApp) IDEInfo(dpInfo *android.IdeInfo) {
|
||||
a.Library.IDEInfo(dpInfo)
|
||||
a.aapt.IDEInfo(dpInfo)
|
||||
func (a *AndroidApp) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
|
||||
a.Library.IDEInfo(ctx, dpInfo)
|
||||
a.aapt.IDEInfo(ctx, dpInfo)
|
||||
}
|
||||
|
||||
func (a *AndroidApp) productCharacteristicsRROPackageName() string {
|
||||
|
@@ -2049,7 +2049,7 @@ func (j *Module) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
|
||||
}
|
||||
|
||||
// Collect information for opening IDE project files in java/jdeps.go.
|
||||
func (j *Module) IDEInfo(dpInfo *android.IdeInfo) {
|
||||
func (j *Module) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
|
||||
// jarjar rules will repackage the sources. To prevent misleading results, IdeInfo should contain the
|
||||
// repackaged jar instead of the input sources.
|
||||
if j.expandJarjarRules != nil {
|
||||
|
@@ -836,7 +836,7 @@ func (b *BootclasspathFragmentModule) getProfilePath() android.Path {
|
||||
}
|
||||
|
||||
// Collect information for opening IDE project files in java/jdeps.go.
|
||||
func (b *BootclasspathFragmentModule) IDEInfo(dpInfo *android.IdeInfo) {
|
||||
func (b *BootclasspathFragmentModule) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
|
||||
dpInfo.Deps = append(dpInfo.Deps, b.properties.Contents...)
|
||||
}
|
||||
|
||||
|
@@ -192,7 +192,7 @@ func (d *DeviceHostConverter) AndroidMk() android.AndroidMkData {
|
||||
// implement the following interface for IDE completion.
|
||||
var _ android.IDEInfo = (*DeviceHostConverter)(nil)
|
||||
|
||||
func (d *DeviceHostConverter) IDEInfo(ideInfo *android.IdeInfo) {
|
||||
func (d *DeviceHostConverter) IDEInfo(ctx android.BaseModuleContext, ideInfo *android.IdeInfo) {
|
||||
ideInfo.Deps = append(ideInfo.Deps, d.properties.Libs...)
|
||||
ideInfo.Libs = append(ideInfo.Libs, d.properties.Libs...)
|
||||
}
|
||||
|
@@ -2404,15 +2404,15 @@ func (al *ApiLibrary) TargetSdkVersion(ctx android.EarlyModuleContext) android.A
|
||||
return al.SdkVersion(ctx).ApiLevel
|
||||
}
|
||||
|
||||
func (al *ApiLibrary) IDEInfo(i *android.IdeInfo) {
|
||||
i.Deps = append(i.Deps, al.ideDeps()...)
|
||||
func (al *ApiLibrary) IDEInfo(ctx android.BaseModuleContext, i *android.IdeInfo) {
|
||||
i.Deps = append(i.Deps, al.ideDeps(ctx)...)
|
||||
i.Libs = append(i.Libs, al.properties.Libs...)
|
||||
i.Static_libs = append(i.Static_libs, al.properties.Static_libs...)
|
||||
i.SrcJars = append(i.SrcJars, al.stubsSrcJar.String())
|
||||
}
|
||||
|
||||
// deps of java_api_library for module_bp_java_deps.json
|
||||
func (al *ApiLibrary) ideDeps() []string {
|
||||
func (al *ApiLibrary) ideDeps(ctx android.BaseModuleContext) []string {
|
||||
ret := []string{}
|
||||
ret = append(ret, al.properties.Libs...)
|
||||
ret = append(ret, al.properties.Static_libs...)
|
||||
@@ -2933,7 +2933,7 @@ var _ android.IDECustomizedModuleName = (*Import)(nil)
|
||||
|
||||
// Collect information for opening IDE project files in java/jdeps.go.
|
||||
|
||||
func (j *Import) IDEInfo(dpInfo *android.IdeInfo) {
|
||||
func (j *Import) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
|
||||
dpInfo.Jars = append(dpInfo.Jars, j.combinedHeaderFile.String())
|
||||
}
|
||||
|
||||
|
@@ -32,9 +32,7 @@ func TestCollectJavaLibraryPropertiesAddLibsDeps(t *testing.T) {
|
||||
}
|
||||
`)
|
||||
module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
|
||||
dpInfo := &android.IdeInfo{}
|
||||
|
||||
module.IDEInfo(dpInfo)
|
||||
dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
|
||||
|
||||
for _, expected := range []string{"Foo", "Bar"} {
|
||||
if !android.InList(expected, dpInfo.Deps) {
|
||||
@@ -54,9 +52,7 @@ func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) {
|
||||
}
|
||||
`)
|
||||
module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
|
||||
dpInfo := &android.IdeInfo{}
|
||||
|
||||
module.IDEInfo(dpInfo)
|
||||
dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
|
||||
|
||||
for _, expected := range []string{"Foo", "Bar"} {
|
||||
if !android.InList(expected, dpInfo.Deps) {
|
||||
@@ -66,26 +62,36 @@ func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCollectJavaLibraryPropertiesAddScrs(t *testing.T) {
|
||||
expected := []string{"Foo", "Bar"}
|
||||
module := LibraryFactory().(*Library)
|
||||
module.expandIDEInfoCompiledSrcs = append(module.expandIDEInfoCompiledSrcs, expected...)
|
||||
dpInfo := &android.IdeInfo{}
|
||||
|
||||
module.IDEInfo(dpInfo)
|
||||
ctx, _ := testJava(t,
|
||||
`
|
||||
java_library {
|
||||
name: "javalib",
|
||||
srcs: ["Foo.java", "Bar.java"],
|
||||
}
|
||||
`)
|
||||
module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
|
||||
dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
|
||||
|
||||
expected := []string{"Foo.java", "Bar.java"}
|
||||
if !reflect.DeepEqual(dpInfo.Srcs, expected) {
|
||||
t.Errorf("Library.IDEInfo() Srcs = %v, want %v", dpInfo.Srcs, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollectJavaLibraryPropertiesAddAidlIncludeDirs(t *testing.T) {
|
||||
ctx, _ := testJava(t,
|
||||
`
|
||||
java_library {
|
||||
name: "javalib",
|
||||
aidl: {
|
||||
include_dirs: ["Foo", "Bar"],
|
||||
},
|
||||
}
|
||||
`)
|
||||
module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
|
||||
dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
|
||||
|
||||
expected := []string{"Foo", "Bar"}
|
||||
module := LibraryFactory().(*Library)
|
||||
module.deviceProperties.Aidl.Include_dirs = append(module.deviceProperties.Aidl.Include_dirs, expected...)
|
||||
dpInfo := &android.IdeInfo{}
|
||||
|
||||
module.IDEInfo(dpInfo)
|
||||
|
||||
if !reflect.DeepEqual(dpInfo.Aidl_include_dirs, expected) {
|
||||
t.Errorf("Library.IDEInfo() Aidl_include_dirs = %v, want %v", dpInfo.Aidl_include_dirs, expected)
|
||||
}
|
||||
@@ -101,9 +107,8 @@ func TestCollectJavaLibraryWithJarJarRules(t *testing.T) {
|
||||
}
|
||||
`)
|
||||
module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
|
||||
dpInfo := &android.IdeInfo{}
|
||||
dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
|
||||
|
||||
module.IDEInfo(dpInfo)
|
||||
android.AssertBoolEquals(t, "IdeInfo.Srcs of repackaged library should be empty", true, len(dpInfo.Srcs) == 0)
|
||||
android.AssertStringEquals(t, "IdeInfo.Jar_rules of repackaged library should not be empty", "jarjar_rules.txt", dpInfo.Jarjar_rules[0])
|
||||
if !android.SubstringInList(dpInfo.Jars, "soong/.intermediates/javalib/android_common/jarjar/turbine/javalib.jar") {
|
||||
@@ -125,8 +130,7 @@ func TestCollectJavaLibraryLinkingAgainstVersionedSdk(t *testing.T) {
|
||||
}
|
||||
`)
|
||||
module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
|
||||
dpInfo := &android.IdeInfo{}
|
||||
dpInfo, _ := android.OtherModuleProvider(ctx, module, android.IdeInfoProviderKey)
|
||||
|
||||
module.IDEInfo(dpInfo)
|
||||
android.AssertStringListContains(t, "IdeInfo.Deps should contain versioned sdk module", dpInfo.Deps, "sdk_public_29_android")
|
||||
}
|
||||
|
@@ -3599,8 +3599,8 @@ func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCo
|
||||
}
|
||||
|
||||
// TODO(b/358613520): This can be removed when modules are no longer allowed to depend on the top-level library.
|
||||
func (s *SdkLibrary) IDEInfo(dpInfo *android.IdeInfo) {
|
||||
s.Library.IDEInfo(dpInfo)
|
||||
func (s *SdkLibrary) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
|
||||
s.Library.IDEInfo(ctx, dpInfo)
|
||||
if s.implLibraryModule != nil {
|
||||
dpInfo.Deps = append(dpInfo.Deps, s.implLibraryModule.Name())
|
||||
} else {
|
||||
|
@@ -307,7 +307,7 @@ func (p *systemModulesInfoProperties) AddToPropertySet(ctx android.SdkMemberCont
|
||||
// implement the following interface for IDE completion.
|
||||
var _ android.IDEInfo = (*SystemModules)(nil)
|
||||
|
||||
func (s *SystemModules) IDEInfo(ideInfo *android.IdeInfo) {
|
||||
func (s *SystemModules) IDEInfo(ctx android.BaseModuleContext, ideInfo *android.IdeInfo) {
|
||||
ideInfo.Deps = append(ideInfo.Deps, s.properties.Libs...)
|
||||
ideInfo.Libs = append(ideInfo.Libs, s.properties.Libs...)
|
||||
}
|
||||
|
@@ -239,7 +239,7 @@ func (s *SystemServerClasspathModule) ComponentDepsMutator(ctx android.BottomUpM
|
||||
}
|
||||
|
||||
// Collect information for opening IDE project files in java/jdeps.go.
|
||||
func (s *SystemServerClasspathModule) IDEInfo(dpInfo *android.IdeInfo) {
|
||||
func (s *SystemServerClasspathModule) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) {
|
||||
dpInfo.Deps = append(dpInfo.Deps, s.properties.Contents...)
|
||||
dpInfo.Deps = append(dpInfo.Deps, s.properties.Standalone_contents...)
|
||||
}
|
||||
|
Reference in New Issue
Block a user