Add missing dependencies for python_test

This commit adds missing shared lib dependencies for `python_test`
modules with embedded launcher.

Bug: 119086738
Test: CHECK_ELF_FIELS=true make check-elf-files
Change-Id: I26f8e1eb9086930093f60c7daa54469850fab32d
This commit is contained in:
Logan Chien 2018-11-06 17:30:35 +08:00
parent 62f6fcbbb9
commit 02880e4196
3 changed files with 47 additions and 14 deletions

View File

@ -96,5 +96,6 @@ func (installer *pythonInstaller) AndroidMk(base *Module, ret *android.AndroidMk
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(installer.androidMkSharedLibs, " "))
})
}

View File

@ -34,6 +34,8 @@ type pythonInstaller struct {
relative string
path android.OutputPath
androidMkSharedLibs []string
}
func NewPythonInstaller(dir, dir64 string) *pythonInstaller {
@ -59,3 +61,7 @@ func (installer *pythonInstaller) installDir(ctx android.ModuleContext) android.
func (installer *pythonInstaller) install(ctx android.ModuleContext, file android.Path) {
installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
}
func (installer *pythonInstaller) setAndroidMkSharedLibs(sharedLibs []string) {
installer.androidMkSharedLibs = sharedLibs
}

View File

@ -160,6 +160,7 @@ type bootstrapper interface {
type installer interface {
install(ctx android.ModuleContext, path android.Path)
setAndroidMkSharedLibs(sharedLibs []string)
}
type PythonDependency interface {
@ -203,18 +204,19 @@ type dependencyTag struct {
}
var (
pythonLibTag = dependencyTag{name: "pythonLib"}
launcherTag = dependencyTag{name: "launcher"}
pyIdentifierRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
pyExt = ".py"
protoExt = ".proto"
pyVersion2 = "PY2"
pyVersion3 = "PY3"
initFileName = "__init__.py"
mainFileName = "__main__.py"
entryPointFile = "entry_point.txt"
parFileExt = ".zip"
internal = "internal"
pythonLibTag = dependencyTag{name: "pythonLib"}
launcherTag = dependencyTag{name: "launcher"}
launcherSharedLibTag = dependencyTag{name: "launcherSharedLib"}
pyIdentifierRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
pyExt = ".py"
protoExt = ".proto"
pyVersion2 = "PY2"
pyVersion3 = "PY3"
initFileName = "__init__.py"
mainFileName = "__main__.py"
entryPointFile = "entry_point.txt"
parFileExt = ".zip"
internal = "internal"
)
// create version variants for modules.
@ -308,6 +310,20 @@ func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddFarVariationDependencies([]blueprint.Variation{
{Mutator: "arch", Variation: ctx.Target().String()},
}, launcherTag, "py2-launcher")
// Add py2-launcher shared lib dependencies. Ideally, these should be
// derived from the `shared_libs` property of "py2-launcher". However, we
// cannot read the property at this stage and it will be too late to add
// dependencies later.
ctx.AddFarVariationDependencies([]blueprint.Variation{
{Mutator: "arch", Variation: ctx.Target().String()},
}, launcherSharedLibTag, "libsqlite")
if ctx.Target().Os.Bionic() {
ctx.AddFarVariationDependencies([]blueprint.Variation{
{Mutator: "arch", Variation: ctx.Target().String()},
}, launcherSharedLibTag, "libc", "libdl", "libm")
}
}
case pyVersion3:
@ -374,8 +390,18 @@ func (p *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
embeddedLauncher, p.srcsPathMappings, p.srcsZip, p.depsSrcsZips)
}
if p.installer != nil && p.installSource.Valid() {
p.installer.install(ctx, p.installSource.Path())
if p.installer != nil {
var sharedLibs []string
ctx.VisitDirectDeps(func(dep android.Module) {
if ctx.OtherModuleDependencyTag(dep) == launcherSharedLibTag {
sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
}
})
p.installer.setAndroidMkSharedLibs(sharedLibs)
if p.installSource.Valid() {
p.installer.install(ctx, p.installSource.Path())
}
}
}