From c27a8ef72f931e9c4e4c90be73bc6e9fb9fd4fdb Mon Sep 17 00:00:00 2001 From: surbhicis Date: Wed, 21 Sep 2022 11:09:17 +0530 Subject: [PATCH 1/3] update spec file with requirements param --- packages/android/buildozer.spec | 21 ++++++-- .../recipes/bitmsghash/__init__.py | 50 +++++++++++++++++++ 2 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 packages/android/python-for-android/recipes/bitmsghash/__init__.py diff --git a/packages/android/buildozer.spec b/packages/android/buildozer.spec index 5e4ad2b3..1e45799e 100644 --- a/packages/android/buildozer.spec +++ b/packages/android/buildozer.spec @@ -7,7 +7,7 @@ title = mockone package.name = mock # (str) Package domain (needed for android/ios packaging) -package.domain = org.mock +package.domain = org.test # (str) Source code where the main.py live source.dir = ../../src @@ -36,7 +36,17 @@ version = 0.1 # (list) Application requirements # comma separated e.g. requirements = sqlite3,kivy -requirements = python3,kivy +requirements = + openssl, + sqlite3, + python3, + kivy, + kivymd, + bitmsghash, + kivy-garden, + qrcode, + Pillow, + msgpack # (str) Custom source folders for requirements # Sets custom source for any requirements with recipes @@ -88,7 +98,7 @@ fullscreen = 0 #android.presplash_lottie = "path/to/lottie/file.json" # (list) Permissions -#android.permissions = INTERNET +android.permissions = INTERNET, CAMERA, WRITE_EXTERNAL_STORAGE # (int) Android API to use (targetSdkVersion AND compileSdkVersion) # note: when changing, Dockerfile also needs to be changed to install corresponding build tools @@ -225,7 +235,7 @@ android.ant_path = /opt/android/apache-ant #android.copy_libs = 1 # (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64 -android.archs = armeabi-v7a, arm64-v8a, x86, x86_64 +android.archs = armeabi-v7a # (int) overrides automatic versionCode computation (used in build.gradle) # this is not the same as app version and should only be edited if you know what you're doing @@ -257,7 +267,8 @@ android.allow_backup = True #p4a.source_dir = # (str) The directory in which python-for-android should look for your own build recipes (if any) -#p4a.local_recipes = +p4a.local_recipes = /home/surbhi/aug_peter/PyBitmessage/packages/android/python-for-android/recipes/ + # (str) Filename to the hook for p4a #p4a.hook = diff --git a/packages/android/python-for-android/recipes/bitmsghash/__init__.py b/packages/android/python-for-android/recipes/bitmsghash/__init__.py new file mode 100644 index 00000000..2438fe87 --- /dev/null +++ b/packages/android/python-for-android/recipes/bitmsghash/__init__.py @@ -0,0 +1,50 @@ +from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory +from os.path import exists, join +import os +import sys +from multiprocessing import cpu_count +import sh + + +class BitmsghashRecipe(Recipe): + # This could also inherit from PythonRecipe etc. if you want to + # use their pre-written build processes + + url = 'https://github.com/surbhicis/bitmsghash/archive/master.zip' + # {version} will be replaced with self.version when downloading + + depends = ['openssl'] + + conflicts = [] + + def get_recipe_env(self, arch=None): + env = super(BitmsghashRecipe, self).get_recipe_env(arch) + r = Recipe.get_recipe('openssl', self.ctx) + b = r.get_build_dir(arch.arch) + env['CCFLAGS'] = env['CFLAGS'] = \ + env['CFLAGS'] + ' -I{openssl_build_path}/include ' \ + '-I{openssl_build_path}/include/openssl'.format( + openssl_build_path=b) + env['LDFLAGS'] = \ + env['LDFLAGS'] + ' -L{openssl_build_path} ' \ + '-lcrypto{openssl_version} ' \ + '-lssl{openssl_version}'.format( + openssl_build_path=b, + openssl_version=r.version) + return env + + def should_build(self, arch=None): + super(BitmsghashRecipe, self).should_build(arch) + return not exists( + join(self.ctx.get_libs_dir(arch.arch), 'libbitmsghash.so')) + + def build_arch(self, arch=None): + super(BitmsghashRecipe, self).build_arch(arch) + env = self.get_recipe_env(arch) + with current_directory(join(self.get_build_dir(arch.arch))): + dst_dir = join(self.get_build_dir(arch.arch)) + shprint(sh.make, '-j', str(cpu_count()), _env=env) + self.install_libs(arch, '{}/libbitmsghash.so'.format(dst_dir), + 'libbitmsghash.so') + +recipe = BitmsghashRecipe() \ No newline at end of file -- 2.45.1 From 91c72bad6209b575c323072ea0ed7ad7db88be37 Mon Sep 17 00:00:00 2001 From: surbhicis Date: Wed, 21 Sep 2022 11:48:06 +0530 Subject: [PATCH 2/3] fix p4a.recipe path to dynamic --- packages/android/buildozer.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/android/buildozer.spec b/packages/android/buildozer.spec index 1e45799e..8db6162b 100644 --- a/packages/android/buildozer.spec +++ b/packages/android/buildozer.spec @@ -267,7 +267,7 @@ android.allow_backup = True #p4a.source_dir = # (str) The directory in which python-for-android should look for your own build recipes (if any) -p4a.local_recipes = /home/surbhi/aug_peter/PyBitmessage/packages/android/python-for-android/recipes/ +p4a.local_recipes = ../android/python-for-android/recipes/ # (str) Filename to the hook for p4a -- 2.45.1 From 7d105021b59bc7dd37e7a890dd1213386bdb9461 Mon Sep 17 00:00:00 2001 From: surbhicis Date: Wed, 21 Sep 2022 12:22:41 +0530 Subject: [PATCH 3/3] requirements parameter updated --- packages/android/buildozer.spec | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/android/buildozer.spec b/packages/android/buildozer.spec index 8db6162b..5c52e910 100644 --- a/packages/android/buildozer.spec +++ b/packages/android/buildozer.spec @@ -42,9 +42,6 @@ requirements = python3, kivy, kivymd, - bitmsghash, - kivy-garden, - qrcode, Pillow, msgpack -- 2.45.1