Dynamically assemble the list of python launcher shared libs for precompiling
Still fall back to the hardcoded list for what to put in LOCAL_SHARED_LIBRARIES,
because I couldn't figure out a good way to get those modules at the moment.
Bug: 259718110
Test: Presubmits
Change-Id: Ia992ffea8819d8c67280b08bc45505f77af09de0
diff --git a/python/binary.go b/python/binary.go
index 75135f3..95c751a 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -125,6 +125,25 @@
launcherPath = provider.IntermPathForModuleOut()
}
})
+
+ // TODO: get the list of shared libraries directly from the launcher module somehow
+ var sharedLibs []string
+ sharedLibs = append(sharedLibs, "libsqlite")
+ if ctx.Target().Os.Bionic() {
+ sharedLibs = append(sharedLibs, "libc", "libdl", "libm")
+ }
+ if ctx.Target().Os == android.LinuxMusl && !ctx.Config().HostStaticBinaries() {
+ sharedLibs = append(sharedLibs, "libc_musl")
+ }
+ switch p.properties.Actual_version {
+ case pyVersion2:
+ sharedLibs = append(sharedLibs, "libc++")
+ case pyVersion3:
+ if ctx.Device() {
+ sharedLibs = append(sharedLibs, "liblog")
+ }
+ }
+ p.androidMkSharedLibs = sharedLibs
}
srcsZips := make(android.Paths, 0, len(depsSrcsZips)+1)
if embeddedLauncher {
@@ -136,14 +155,6 @@
p.installSource = registerBuildActionForParFile(ctx, embeddedLauncher, launcherPath,
p.getHostInterpreterName(ctx, p.properties.Actual_version),
main, p.getStem(ctx), srcsZips)
-
- var sharedLibs []string
- // if embedded launcher is enabled, we need to collect the shared library dependencies of the
- // launcher
- for _, dep := range ctx.GetDirectDepsWithTag(launcherSharedLibTag) {
- sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
- }
- p.androidMkSharedLibs = sharedLibs
}
func (p *PythonBinaryModule) AndroidMkEntries() []android.AndroidMkEntries {
@@ -176,7 +187,7 @@
p.PythonLibraryModule.DepsMutator(ctx)
if p.isEmbeddedLauncherEnabled() {
- p.AddDepsOnPythonLauncherAndStdlib(ctx, pythonLibTag, launcherTag, launcherSharedLibTag, p.autorun(), ctx.Target())
+ p.AddDepsOnPythonLauncherAndStdlib(ctx, pythonLibTag, launcherTag, p.autorun(), ctx.Target())
}
}