From a911996070d1990a2487ca948239a8fcad393fd4 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 24 Nov 2025 01:46:51 +0100 Subject: [PATCH] Build native LXST filterlib.so and inject into APK --- recipes/lxst/__init__.py | 33 +++++++++++++++++++++++++++++++++ sbapp/Makefile | 10 ++++++++-- sbapp/buildozer.spec | 4 ++-- 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 recipes/lxst/__init__.py diff --git a/recipes/lxst/__init__.py b/recipes/lxst/__init__.py new file mode 100644 index 0000000..ec6639c --- /dev/null +++ b/recipes/lxst/__init__.py @@ -0,0 +1,33 @@ +""" +Android Bluetooth Low Energy +""" +from pythonforandroid.recipe import PythonRecipe +from pythonforandroid.toolchain import current_directory, info, shprint +import sh +from os.path import join + + +class LXSTRecipe(PythonRecipe): + name = 'lxst_recipe' + depends = ['python3', 'setuptools', 'android', "cffi"] + call_hostpython_via_targetpython = False + install_in_hostpython = True + + def prepare_build_dir(self, arch): + build_dir = self.get_build_dir(arch) + assert build_dir.endswith(self.name) + shprint(sh.rm, '-rf', build_dir) + shprint(sh.mkdir, build_dir) + + srcs = ('/home/markqvist/Information/Source/LXST/LXST', '/home/markqvist/Information/Source/LXST/setup.py', '/home/markqvist/Information/Source/LXST/README.md') + + for filename in srcs: + print(f"Copy {join(self.get_recipe_dir(), filename)} to {build_dir}") + shprint(sh.cp, '-a', join(self.get_recipe_dir(), filename), + build_dir) + + def postbuild_arch(self, arch): + super(LXSTRecipe, self).postbuild_arch(arch) + info("LXST native build completed") + +recipe = LXSTRecipe() diff --git a/sbapp/Makefile b/sbapp/Makefile index 8eacb30..cb54e64 100644 --- a/sbapp/Makefile +++ b/sbapp/Makefile @@ -47,6 +47,11 @@ injectxml: cp patches/AndroidManifest.tmpl.xml .buildozer/android/platform/build-arm64-v8a/dists/sideband/templates/ cp patches/p4a_build.py .buildozer/android/platform/build-arm64-v8a/dists/sideband/build.py +injectlibs: + @(echo Injecting native libs...) + cp .buildozer/android/platform/build-arm64-v8a/dists/sideband/_python_bundle__arm64-v8a/_python_bundle/site-packages/LXST/filterlib.so LXST/ + @(sleep 1) + debug: buildozer android debug @@ -83,10 +88,11 @@ release: postbuild: $(MAKE) cleanrns + -(rm ../LXST/filterlib.so) -apk: prepare prebake pacthfiles fetchshare release postbuild +apk: prepare prebake pacthfiles fetchshare injectlibs release postbuild -devapk: prepare prebake pacthfiles fetchshare debug postbuild +devapk: prepare prebake pacthfiles fetchshare injectlibs debug postbuild version: @(echo $$(python ./gv.py)) diff --git a/sbapp/buildozer.spec b/sbapp/buildozer.spec index c5bbffe..af3020e 100644 --- a/sbapp/buildozer.spec +++ b/sbapp/buildozer.spec @@ -4,7 +4,7 @@ package.name = sideband package.domain = io.unsigned source.dir = . -source.include_exts = py,png,jpg,jpeg,webp,ttf,kv,pyi,typed,so,0,1,2,3,atlas,frag,html,css,js,whl,zip,gz,woff2,pdf,epub,pgm,opus +source.include_exts = py,png,jpg,jpeg,webp,ttf,kv,pyi,typed,so,0,1,2,3,atlas,frag,html,css,js,whl,zip,gz,woff2,pdf,epub,pgm,opus,h,c source.include_patterns = assets/*,assets/fonts/*,assets/audio/notifications/*,share/* source.exclude_patterns = app_storage/*,venv/*,Makefile,./Makefil*,requirements,precompiled/*,parked/*,./setup.py,Makef*,./Makefile,Makefile,bin/*,build/*,dist/*,__pycache__/* @@ -12,7 +12,7 @@ version.regex = __version__ = ['"](.*)['"] version.filename = %(source.dir)s/main.py android.numeric_version = 20251122 -requirements = kivy==2.3.0,libbz2,sqlite3,pillow==10.2.0,qrcode==7.3.1,usb4a,usbserial4a,able_recipe,libwebp,libogg,libopus,opusfile,numpy,cryptography,ffpyplayer,codec2,pycodec2,sh,pynacl,typing-extensions,mistune>=3.0.2,beautifulsoup4 +requirements = kivy==2.3.0,libbz2,sqlite3,pillow==10.2.0,qrcode==7.3.1,usb4a,usbserial4a,able_recipe,libwebp,libogg,libopus,opusfile,numpy,cryptography,ffpyplayer,codec2,pycodec2,sh,pynacl,typing-extensions,mistune>=3.0.2,beautifulsoup4,lxst android.gradle_dependencies = com.android.support:support-compat:28.0.0 #android.enable_androidx = True