aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorLogan Chien <loganchien@google.com>2018-11-06 17:30:35 +0800
committerLogan Chien <loganchien@google.com>2019-01-29 22:26:57 +0800
commit02880e41963fdc799c6b202da41d15be224a5602 (patch)
treed56c4159e4f6b7dfdd313e6e200b98ab0a9db55c /python
parent62f6fcbbb9528b58fd98e5fd5c71e484844be12f (diff)
downloadbuild_soong-02880e41963fdc799c6b202da41d15be224a5602.tar.gz
build_soong-02880e41963fdc799c6b202da41d15be224a5602.tar.bz2
build_soong-02880e41963fdc799c6b202da41d15be224a5602.zip
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
Diffstat (limited to 'python')
-rw-r--r--python/androidmk.go1
-rw-r--r--python/installer.go6
-rw-r--r--python/python.go54
3 files changed, 47 insertions, 14 deletions
diff --git a/python/androidmk.go b/python/androidmk.go
index c1eaa5eb..1e51e7b8 100644
--- a/python/androidmk.go
+++ b/python/androidmk.go
@@ -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, " "))
})
}
diff --git a/python/installer.go b/python/installer.go
index ab3d9b4a..62f36f4b 100644
--- a/python/installer.go
+++ b/python/installer.go
@@ -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
+}
diff --git a/python/python.go b/python/python.go
index e8b47131..ddc3f1f9 100644
--- a/python/python.go
+++ b/python/python.go
@@ -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())
+ }
}
}