Skip to content

Commit e01767d

Browse files
committed
Merge pull request kivy#531 from kived/ndkrecipe
add NDKRecipe, rename old to BootstrapNDKRecipe
2 parents a072ab5 + 48485b3 commit e01767d

File tree

10 files changed

+48
-22
lines changed

10 files changed

+48
-22
lines changed

pythonforandroid/recipe.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,15 +556,13 @@ def prepare_build_dir(self, arch):
556556
self.get_build_dir(arch))
557557

558558

559-
class NDKRecipe(Recipe):
559+
class BootstrapNDKRecipe(Recipe):
560560
'''A recipe class for recipes built in an Android project jni dir with
561561
an Android.mk. These are not cached separatly, but built in the
562562
bootstrap's own building directory.
563563
564-
In the future they should probably also copy their contents from a
565-
standalone set of ndk recipes, but for now the bootstraps include
566-
all their recipe code.
567-
564+
To build an NDK project which is not part of the bootstrap, see
565+
:class:`~pythonforandroid.recipe.NDKRecipe`.
568566
'''
569567

570568
dir_name = None # The name of the recipe build folder in the jni dir
@@ -582,6 +580,34 @@ def get_jni_dir(self):
582580
return join(self.ctx.bootstrap.build_dir, 'jni')
583581

584582

583+
class NDKRecipe(Recipe):
584+
'''A recipe class for any NDK project not included in the bootstrap.'''
585+
586+
generated_libraries = []
587+
588+
def should_build(self, arch):
589+
lib_dir = self.get_lib_dir(arch)
590+
591+
for lib in self.generated_libraries:
592+
if not exists(join(lib_dir, lib)):
593+
return True
594+
595+
return False
596+
597+
def get_lib_dir(self, arch):
598+
return join(self.get_build_dir(arch.arch), 'obj', 'local', arch.arch)
599+
600+
def get_jni_dir(self, arch):
601+
return join(self.get_build_dir(arch.arch), 'jni')
602+
603+
def build_arch(self, arch, *extra_args):
604+
super(NDKRecipe, self).build_arch(arch)
605+
606+
env = self.get_recipe_env(arch)
607+
with current_directory(self.get_build_dir(arch.arch)):
608+
shprint(sh.ndk_build, 'V=1', 'APP_ABI=' + arch.arch, *extra_args, _env=env)
609+
610+
585611
class PythonRecipe(Recipe):
586612
site_packages_name = None
587613
'''The name of the module's folder when installed in the Python

pythonforandroid/recipes/fontconfig/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

2-
from pythonforandroid.toolchain import NDKRecipe, shprint, current_directory, info_main
2+
from pythonforandroid.toolchain import BootstrapNDKRecipe, shprint, current_directory, info_main
33
from os.path import exists, join
44
import sh
55

66

77

88

9-
class FontconfigRecipe(NDKRecipe):
9+
class FontconfigRecipe(BootstrapNDKRecipe):
1010
version = "really_old"
1111
url = 'https://github.com/vault/fontconfig/archive/androidbuild.zip'
1212
depends = ['sdl2']

pythonforandroid/recipes/pygame_bootstrap_components/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from pythonforandroid.toolchain import NDKRecipe, current_directory, shprint, info
1+
from pythonforandroid.toolchain import BootstrapNDKRecipe, current_directory, shprint, info
22
from os.path import exists, join
33
import sh
44
import glob
55

6-
class PygameJNIComponentsRecipe(NDKRecipe):
6+
class PygameJNIComponentsRecipe(BootstrapNDKRecipe):
77
version = 'master'
88
url = 'https://github.com/kivy/p4a-pygame-bootstrap-components/archive/{version}.zip'
99
dir_name = 'bootstrap_components'

pythonforandroid/recipes/sdl/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pythonforandroid.toolchain import NDKRecipe, shprint, ArchARM, current_directory, info
1+
from pythonforandroid.toolchain import BootstrapNDKRecipe, shprint, ArchARM, current_directory, info
22
from os.path import exists, join
33
import sh
44

5-
class LibSDLRecipe(NDKRecipe):
5+
class LibSDLRecipe(BootstrapNDKRecipe):
66
version = "1.2.14"
77
url = None
88
name = 'sdl'

pythonforandroid/recipes/sdl2/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from pythonforandroid.toolchain import NDKRecipe, shprint, current_directory, info
1+
from pythonforandroid.toolchain import BootstrapNDKRecipe, shprint, current_directory, info
22
from os.path import exists, join
33
import sh
44

55

6-
class LibSDL2Recipe(NDKRecipe):
6+
class LibSDL2Recipe(BootstrapNDKRecipe):
77
version = "2.0.3"
88
url = "https://www.libsdl.org/release/SDL2-{version}.tar.gz"
99

pythonforandroid/recipes/sdl2_image/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pythonforandroid.toolchain import NDKRecipe
1+
from pythonforandroid.toolchain import BootstrapNDKRecipe
22
from pythonforandroid.patching import is_arch
33

44

5-
class LibSDL2Image(NDKRecipe):
5+
class LibSDL2Image(BootstrapNDKRecipe):
66
version = '2.0.0'
77
url = 'https://www.libsdl.org/projects/SDL_image/release/SDL2_image-{version}.tar.gz'
88
dir_name = 'SDL2_image'

pythonforandroid/recipes/sdl2_mixer/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from pythonforandroid.toolchain import NDKRecipe
1+
from pythonforandroid.toolchain import BootstrapNDKRecipe
22

33

4-
class LibSDL2Mixer(NDKRecipe):
4+
class LibSDL2Mixer(BootstrapNDKRecipe):
55
version = '2.0.0'
66
url = 'https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-{version}.tar.gz'
77
dir_name = 'SDL2_mixer'

pythonforandroid/recipes/sdl2_ttf/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from pythonforandroid.toolchain import NDKRecipe
1+
from pythonforandroid.toolchain import BootstrapNDKRecipe
22
from os.path import exists
33

4-
class LibSDL2TTF(NDKRecipe):
4+
class LibSDL2TTF(BootstrapNDKRecipe):
55
version = '2.0.12'
66
url = 'https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-{version}.tar.gz'
77
dir_name = 'SDL2_ttf'

pythonforandroid/recipes/sdl2python3/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from pythonforandroid.toolchain import NDKRecipe, shprint, current_directory
1+
from pythonforandroid.toolchain import BootstrapNDKRecipe, shprint, current_directory
22
import sh
33

44

5-
class LibSDL2Recipe(NDKRecipe):
5+
class LibSDL2Recipe(BootstrapNDKRecipe):
66
version = "2.0.3"
77
url = "https://www.libsdl.org/release/SDL2-{version}.tar.gz"
88
depends = ['python3', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf']

pythonforandroid/toolchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
from pythonforandroid.recipe import (Recipe, PythonRecipe, CythonRecipe,
2828
CompiledComponentsPythonRecipe,
29-
NDKRecipe)
29+
BootstrapNDKRecipe, NDKRecipe)
3030
from pythonforandroid.archs import (ArchARM, ArchARMv7_a, Archx86)
3131
from pythonforandroid.logger import (logger, info, warning, debug,
3232
Out_Style, Out_Fore, Err_Style, Err_Fore,

0 commit comments

Comments
 (0)