From 6c42aefab7d432411c46c1a207cfa7981ffd7a7d Mon Sep 17 00:00:00 2001 From: Philipp Auersperg Date: Wed, 18 Mar 2020 15:28:45 +0100 Subject: [PATCH 1/6] android-library --- buildozer/targets/android.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index d16098ba9..d15c3f616 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -1057,12 +1057,13 @@ def build_package(self): build_cmd += [("--feature", feature)] # android.entrypoint - entrypoint = config.getdefault('app', 'android.entrypoint', 'org.kivy.android.PythonActivity') - build_cmd += [('--android-entrypoint', entrypoint)] + if config.getdefault('app', 'p4a.bootstrap', 'sdl2') != 'library': + entrypoint = config.getdefault('app', 'android.entrypoint', 'org.kivy.android.PythonActivity') + build_cmd += [('--android-entrypoint', entrypoint)] - # android.apptheme - apptheme = config.getdefault('app', 'android.apptheme', '@android:style/Theme.NoTitleBar') - build_cmd += [('--android-apptheme', apptheme)] + # android.apptheme + apptheme = config.getdefault('app', 'android.apptheme', '@android:style/Theme.NoTitleBar') + build_cmd += [('--android-apptheme', apptheme)] # android.compile_options compile_options = config.getlist('app', 'android.add_compile_options', []) From 1647f8bebff524f641e3b61d7c143f2ca078846a Mon Sep 17 00:00:00 2001 From: Philipp Auersperg-Castell Date: Sat, 21 Mar 2020 00:39:09 +0100 Subject: [PATCH 2/6] aar output --- buildozer/targets/android.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index d15c3f616..f25168d33 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -1233,7 +1233,18 @@ def build_package(self): arch=self._arch) # copy to our place - copyfile(join(apk_dir, apk), join(self.buildozer.bin_dir, apk_dest)) + bootstrap = self._p4a_bootstrap + if bootstrap == 'library': + # XXX: this has to be moved to a seperate command 'aar' + aar_dir = join(dist_dir, "build", "outputs", "aar") + aar = u'{packagename}-{mode}.aar'.format( + packagename=packagename_src, mode=mode) + aar_dest = u'{packagename}-{version}-{arch}-{mode}.aar'.format( + packagename=packagename, mode=mode, version=version, + arch=self._arch) + copyfile(join(aar_dir, aar), join(self.buildozer.bin_dir, aar_dest)) + else: + copyfile(join(apk_dir, apk), join(self.buildozer.bin_dir, apk_dest)) self.buildozer.info('Android packaging done!') self.buildozer.info( From 30c170f00d637bd4e7517ffe45435f3c273fbde9 Mon Sep 17 00:00:00 2001 From: Philipp Auersperg-Castell Date: Fri, 27 Mar 2020 20:49:56 +0100 Subject: [PATCH 3/6] option for p4a.command ('apk', 'aar') --- buildozer/default.spec | 3 +++ buildozer/targets/android.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/buildozer/default.spec b/buildozer/default.spec index 988fbe829..2ef2f0bd4 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -254,6 +254,9 @@ android.allow_backup = True # (str) Filename to the hook for p4a #p4a.hook = +# (str) p4a command: apk (default) or aar (can be used as library from e.g. an android native project) +# p4a.command = apk + # (str) Bootstrap to use for android builds # p4a.bootstrap = sdl2 diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index f25168d33..a07d9927f 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -60,7 +60,7 @@ class TargetAndroid(Target): p4a_directory_name = "python-for-android" p4a_fork = 'kivy' p4a_branch = 'master' - p4a_apk_cmd = "apk --debug --bootstrap=" + p4a_build_cmd = "%s --debug --bootstrap=" p4a_recommended_ndk_version = None extra_p4a_args = '' @@ -74,7 +74,7 @@ def __init__(self, *args, **kwargs): self._p4a_cmd = '{} -m pythonforandroid.toolchain '.format(executable) self._p4a_bootstrap = self.buildozer.config.getdefault( 'app', 'p4a.bootstrap', 'sdl2') - self.p4a_apk_cmd += self._p4a_bootstrap + self.p4a_build_cmd += self._p4a_bootstrap color = 'always' if USE_COLOR else 'never' self.extra_p4a_args = ' --color={} --storage-dir="{}"'.format( color, self._build_dir) @@ -830,7 +830,8 @@ def execute_build_package(self, build_cmd): # wrapper from previous old_toolchain to new toolchain dist_name = self.buildozer.config.get('app', 'package.name') local_recipes = self.get_local_recipes_dir() - cmd = [self.p4a_apk_cmd, "--dist_name", dist_name] + self.p4a_build_cmd = self.p4a_build_cmd % self.buildozer.config.getdefault('app', 'p4a.command', 'apk') + cmd = [self.p4a_build_cmd, "--dist_name", dist_name] for args in build_cmd: option, values = args[0], args[1:] if option == "debug": From c434a2a4b30d91f857dada3f84a120af1b7ae57b Mon Sep 17 00:00:00 2001 From: Philipp Auersperg-Castell Date: Sat, 28 Mar 2020 21:28:13 +0100 Subject: [PATCH 4/6] cleanup --- buildozer/default.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildozer/default.spec b/buildozer/default.spec index 2ef2f0bd4..3a09b33df 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -255,7 +255,7 @@ android.allow_backup = True #p4a.hook = # (str) p4a command: apk (default) or aar (can be used as library from e.g. an android native project) -# p4a.command = apk +#p4a.command = apk # (str) Bootstrap to use for android builds # p4a.bootstrap = sdl2 From be27717d5ed9c1ff2f7d480f5cd0e8016381a19b Mon Sep 17 00:00:00 2001 From: Philipp Auersperg-Castell Date: Sat, 28 Mar 2020 23:50:42 +0100 Subject: [PATCH 5/6] renamed library to service_library --- buildozer/targets/android.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py index a07d9927f..6458a8d61 100644 --- a/buildozer/targets/android.py +++ b/buildozer/targets/android.py @@ -1235,7 +1235,7 @@ def build_package(self): # copy to our place bootstrap = self._p4a_bootstrap - if bootstrap == 'library': + if bootstrap == 'service_library': # XXX: this has to be moved to a seperate command 'aar' aar_dir = join(dist_dir, "build", "outputs", "aar") aar = u'{packagename}-{mode}.aar'.format( From 9e649744725ac60a2f3f3bc1bdb249e7f2257850 Mon Sep 17 00:00:00 2001 From: Philipp Auersperg-Castell Date: Mon, 19 Oct 2020 19:37:09 +0200 Subject: [PATCH 6/6] fixed tests reflecting that command is a variable --- tests/targets/test_android.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/targets/test_android.py b/tests/targets/test_android.py index 170840ef3..4844226be 100644 --- a/tests/targets/test_android.py +++ b/tests/targets/test_android.py @@ -109,7 +109,7 @@ def test_init(self): ) assert target_android._p4a_bootstrap == "sdl2" assert target_android._p4a_cmd.endswith( - "python -m pythonforandroid.toolchain " + "-m pythonforandroid.toolchain " ) assert target_android.build_mode == "debug" assert ( @@ -119,7 +119,7 @@ def test_init(self): buildozer_dir=buildozer.buildozer_dir) ) ) - assert target_android.p4a_apk_cmd == "apk --debug --bootstrap=sdl2" + assert target_android.p4a_build_cmd == "%s --debug --bootstrap=sdl2" assert target_android.platform_update is False def test_init_positional_buildozer(self):