From 48485b32a9b0443f79494de8f95d8d81bf96c1c2 Mon Sep 17 00:00:00 2001 From: Ryan Pessa Date: Mon, 14 Dec 2015 12:38:36 -0600 Subject: [PATCH] add NDKRecipe, rename old to BootstrapNDKRecipe --- pythonforandroid/recipe.py | 36 ++++++++++++++++--- .../recipes/fontconfig/__init__.py | 4 +-- .../pygame_bootstrap_components/__init__.py | 4 +-- pythonforandroid/recipes/sdl/__init__.py | 4 +-- pythonforandroid/recipes/sdl2/__init__.py | 4 +-- .../recipes/sdl2_image/__init__.py | 4 +-- .../recipes/sdl2_mixer/__init__.py | 4 +-- pythonforandroid/recipes/sdl2_ttf/__init__.py | 4 +-- .../recipes/sdl2python3/__init__.py | 4 +-- pythonforandroid/toolchain.py | 2 +- 10 files changed, 48 insertions(+), 22 deletions(-) diff --git a/pythonforandroid/recipe.py b/pythonforandroid/recipe.py index 3a8f0c7968..366c73a010 100644 --- a/pythonforandroid/recipe.py +++ b/pythonforandroid/recipe.py @@ -549,15 +549,13 @@ def prepare_build_dir(self, arch): self.get_build_dir(arch)) -class NDKRecipe(Recipe): +class BootstrapNDKRecipe(Recipe): '''A recipe class for recipes built in an Android project jni dir with an Android.mk. These are not cached separatly, but built in the bootstrap's own building directory. - In the future they should probably also copy their contents from a - standalone set of ndk recipes, but for now the bootstraps include - all their recipe code. - + To build an NDK project which is not part of the bootstrap, see + :class:`~pythonforandroid.recipe.NDKRecipe`. ''' dir_name = None # The name of the recipe build folder in the jni dir @@ -575,6 +573,34 @@ def get_jni_dir(self): return join(self.ctx.bootstrap.build_dir, 'jni') +class NDKRecipe(Recipe): + '''A recipe class for any NDK project not included in the bootstrap.''' + + generated_libraries = [] + + def should_build(self, arch): + lib_dir = self.get_lib_dir(arch) + + for lib in self.generated_libraries: + if not exists(join(lib_dir, lib)): + return True + + return False + + def get_lib_dir(self, arch): + return join(self.get_build_dir(arch.arch), 'obj', 'local', arch.arch) + + def get_jni_dir(self, arch): + return join(self.get_build_dir(arch.arch), 'jni') + + def build_arch(self, arch, *extra_args): + super(NDKRecipe, self).build_arch(arch) + + env = self.get_recipe_env(arch) + with current_directory(self.get_build_dir(arch.arch)): + shprint(sh.ndk_build, 'V=1', 'APP_ABI=' + arch.arch, *extra_args, _env=env) + + class PythonRecipe(Recipe): site_packages_name = None '''The name of the module's folder when installed in the Python diff --git a/pythonforandroid/recipes/fontconfig/__init__.py b/pythonforandroid/recipes/fontconfig/__init__.py index 1a3e52f7c9..f91232e771 100644 --- a/pythonforandroid/recipes/fontconfig/__init__.py +++ b/pythonforandroid/recipes/fontconfig/__init__.py @@ -1,12 +1,12 @@ -from pythonforandroid.toolchain import NDKRecipe, shprint, current_directory, info_main +from pythonforandroid.toolchain import BootstrapNDKRecipe, shprint, current_directory, info_main from os.path import exists, join import sh -class FontconfigRecipe(NDKRecipe): +class FontconfigRecipe(BootstrapNDKRecipe): version = "really_old" url = 'https://github.com/vault/fontconfig/archive/androidbuild.zip' depends = ['sdl2'] diff --git a/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py b/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py index 0c6ba08f40..af7ec6b11b 100644 --- a/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py +++ b/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py @@ -1,9 +1,9 @@ -from pythonforandroid.toolchain import NDKRecipe, current_directory, shprint, info +from pythonforandroid.toolchain import BootstrapNDKRecipe, current_directory, shprint, info from os.path import exists, join import sh import glob -class PygameJNIComponentsRecipe(NDKRecipe): +class PygameJNIComponentsRecipe(BootstrapNDKRecipe): version = 'master' url = 'https://github.com/kivy/p4a-pygame-bootstrap-components/archive/{version}.zip' dir_name = 'bootstrap_components' diff --git a/pythonforandroid/recipes/sdl/__init__.py b/pythonforandroid/recipes/sdl/__init__.py index a8044f65e2..a7de674911 100644 --- a/pythonforandroid/recipes/sdl/__init__.py +++ b/pythonforandroid/recipes/sdl/__init__.py @@ -1,8 +1,8 @@ -from pythonforandroid.toolchain import NDKRecipe, shprint, ArchARM, current_directory, info +from pythonforandroid.toolchain import BootstrapNDKRecipe, shprint, ArchARM, current_directory, info from os.path import exists, join import sh -class LibSDLRecipe(NDKRecipe): +class LibSDLRecipe(BootstrapNDKRecipe): version = "1.2.14" url = None name = 'sdl' diff --git a/pythonforandroid/recipes/sdl2/__init__.py b/pythonforandroid/recipes/sdl2/__init__.py index f10e36d9b4..7ca4c4a368 100644 --- a/pythonforandroid/recipes/sdl2/__init__.py +++ b/pythonforandroid/recipes/sdl2/__init__.py @@ -1,9 +1,9 @@ -from pythonforandroid.toolchain import NDKRecipe, shprint, current_directory, info +from pythonforandroid.toolchain import BootstrapNDKRecipe, shprint, current_directory, info from os.path import exists, join import sh -class LibSDL2Recipe(NDKRecipe): +class LibSDL2Recipe(BootstrapNDKRecipe): version = "2.0.3" url = "https://www.libsdl.org/release/SDL2-{version}.tar.gz" diff --git a/pythonforandroid/recipes/sdl2_image/__init__.py b/pythonforandroid/recipes/sdl2_image/__init__.py index 9c7afe15e4..75cd76d672 100644 --- a/pythonforandroid/recipes/sdl2_image/__init__.py +++ b/pythonforandroid/recipes/sdl2_image/__init__.py @@ -1,8 +1,8 @@ -from pythonforandroid.toolchain import NDKRecipe +from pythonforandroid.toolchain import BootstrapNDKRecipe from pythonforandroid.patching import is_arch -class LibSDL2Image(NDKRecipe): +class LibSDL2Image(BootstrapNDKRecipe): version = '2.0.0' url = 'https://www.libsdl.org/projects/SDL_image/release/SDL2_image-{version}.tar.gz' dir_name = 'SDL2_image' diff --git a/pythonforandroid/recipes/sdl2_mixer/__init__.py b/pythonforandroid/recipes/sdl2_mixer/__init__.py index d963ab0550..d8f1f266e6 100644 --- a/pythonforandroid/recipes/sdl2_mixer/__init__.py +++ b/pythonforandroid/recipes/sdl2_mixer/__init__.py @@ -1,7 +1,7 @@ -from pythonforandroid.toolchain import NDKRecipe +from pythonforandroid.toolchain import BootstrapNDKRecipe -class LibSDL2Mixer(NDKRecipe): +class LibSDL2Mixer(BootstrapNDKRecipe): version = '2.0.0' url = 'https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-{version}.tar.gz' dir_name = 'SDL2_mixer' diff --git a/pythonforandroid/recipes/sdl2_ttf/__init__.py b/pythonforandroid/recipes/sdl2_ttf/__init__.py index 764943d2e4..e5b214eb6f 100644 --- a/pythonforandroid/recipes/sdl2_ttf/__init__.py +++ b/pythonforandroid/recipes/sdl2_ttf/__init__.py @@ -1,7 +1,7 @@ -from pythonforandroid.toolchain import NDKRecipe +from pythonforandroid.toolchain import BootstrapNDKRecipe from os.path import exists -class LibSDL2TTF(NDKRecipe): +class LibSDL2TTF(BootstrapNDKRecipe): version = '2.0.12' url = 'https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-{version}.tar.gz' dir_name = 'SDL2_ttf' diff --git a/pythonforandroid/recipes/sdl2python3/__init__.py b/pythonforandroid/recipes/sdl2python3/__init__.py index 865937a072..c7c863bb2e 100644 --- a/pythonforandroid/recipes/sdl2python3/__init__.py +++ b/pythonforandroid/recipes/sdl2python3/__init__.py @@ -1,8 +1,8 @@ -from pythonforandroid.toolchain import NDKRecipe, shprint, current_directory +from pythonforandroid.toolchain import BootstrapNDKRecipe, shprint, current_directory import sh -class LibSDL2Recipe(NDKRecipe): +class LibSDL2Recipe(BootstrapNDKRecipe): version = "2.0.3" url = "https://www.libsdl.org/release/SDL2-{version}.tar.gz" depends = ['python3', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf'] diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 261fe5c9b5..f03dbfc0f3 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -26,7 +26,7 @@ from pythonforandroid.recipe import (Recipe, PythonRecipe, CythonRecipe, CompiledComponentsPythonRecipe, - NDKRecipe) + BootstrapNDKRecipe, NDKRecipe) from pythonforandroid.archs import (ArchARM, ArchARMv7_a, Archx86) from pythonforandroid.logger import (logger, info, warning, debug, Out_Style, Out_Fore, Err_Style, Err_Fore,