Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/fontconfig/__init__.py
Original file line number Diff line number Diff line change
@@ -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']
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/sdl/__init__.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/sdl2/__init__.py
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/sdl2_image/__init__.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/sdl2_mixer/__init__.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/sdl2_ttf/__init__.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/sdl2python3/__init__.py
Original file line number Diff line number Diff line change
@@ -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']
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down