From 8c7c65ee0ad573eac46b6a1549abb2abbcb554f5 Mon Sep 17 00:00:00 2001 From: Brett Brotherton Date: Wed, 12 Mar 2025 20:56:07 -0700 Subject: 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 --- python/binary.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'python/binary.go') 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) -- cgit v1.2.3-59-g8ed1b