summaryrefslogtreecommitdiff
path: root/python/binary.go
diff options
context:
space:
mode:
author Brett Brotherton <bbrotherton@google.com> 2025-03-12 20:56:07 -0700
committer Brett Brotherton <bbrotherton@google.com> 2025-03-12 20:56:07 -0700
commit8c7c65ee0ad573eac46b6a1549abb2abbcb554f5 (patch)
tree75755f5832f71805d040852f5f8db70d6d6ac75e /python/binary.go
parentd98a99722186fbd0500c0dae8e7fe49364987fc6 (diff)
Add Shared libraries support for Android python libraries
- New shared_libs property to Python code for specify shared libs that should be packed into the library for modules with compiled code. - Expand shared_lib dependencies when building the python library. - Change python main entrypoint to extract the zip if there are any shared libraries in the executable to workaround linker limitations Bug: 395678202 Change-Id: Id94caebf36f7eb1cfa492b2fa78f8c56623e9a43 Test: m py-grpcio
Diffstat (limited to 'python/binary.go')
-rw-r--r--python/binary.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/python/binary.go b/python/binary.go
index feac72a26..156de6f75 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -125,6 +125,7 @@ func (p *PythonBinaryModule) GenerateAndroidBuildActions(ctx android.ModuleConte
func (p *PythonBinaryModule) buildBinary(ctx android.ModuleContext) {
embeddedLauncher := p.isEmbeddedLauncherEnabled()
depsSrcsZips := p.collectPathsFromTransitiveDeps(ctx, embeddedLauncher)
+ bundleSharedLibs := p.collectSharedLibDeps(ctx)
main := ""
if p.autorun() {
main = p.getPyMainFile(ctx, p.srcsPathMappings)
@@ -149,6 +150,11 @@ func (p *PythonBinaryModule) buildBinary(ctx android.ModuleContext) {
srcsZips = append(srcsZips, p.srcsZip)
}
srcsZips = append(srcsZips, depsSrcsZips...)
+ if ctx.Host() && len(bundleSharedLibs) > 0 {
+ // only bundle shared libs for host binaries
+ sharedLibZip := p.zipSharedLibs(ctx, bundleSharedLibs)
+ srcsZips = append(srcsZips, sharedLibZip)
+ }
p.installSource = registerBuildActionForParFile(ctx, embeddedLauncher, launcherPath,
"python3", main, p.getStem(ctx), srcsZips)