Skip to content

Commit 48485b3

Browse files
committed
add NDKRecipe, rename old to BootstrapNDKRecipe
1 parent eba92ab commit 48485b3

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
@@ -549,15 +549,13 @@ def prepare_build_dir(self, arch):
549549
self.get_build_dir(arch))
550550

551551

552-
class NDKRecipe(Recipe):
552+
class BootstrapNDKRecipe(Recipe):
553553
'''A recipe class for recipes built in an Android project jni dir with
554554
an Android.mk. These are not cached separatly, but built in the
555555
bootstrap's own building directory.
556556
557-
In the future they should probably also copy their contents from a
558-
standalone set of ndk recipes, but for now the bootstraps include
559-
all their recipe code.
560-
557+
To build an NDK project which is not part of the bootstrap, see
558+
:class:`~pythonforandroid.recipe.NDKRecipe`.
561559
'''
562560

563561
dir_name = None # The name of the recipe build folder in the jni dir
@@ -575,6 +573,34 @@ def get_jni_dir(self):
575573
return join(self.ctx.bootstrap.build_dir, 'jni')
576574

577575

576+
class NDKRecipe(Recipe):
577+
'''A recipe class for any NDK project not included in the bootstrap.'''
578+
579+
generated_libraries = []
580+
581+
def should_build(self, arch):
582+
lib_dir = self.get_lib_dir(arch)
583+
584+
for lib in self.generated_libraries:
585+
if not exists(join(lib_dir, lib)):
586+
return True
587+
588+
return False
589+
590+
def get_lib_dir(self, arch):
591+
return join(self.get_build_dir(arch.arch), 'obj', 'local', arch.arch)
592+
593+
def get_jni_dir(self, arch):
594+
return join(self.get_build_dir(arch.arch), 'jni')
595+
596+
def build_arch(self, arch, *extra_args):
597+
super(NDKRecipe, self).build_arch(arch)
598+
599+
env = self.get_recipe_env(arch)
600+
with current_directory(self.get_build_dir(arch.arch)):
601+
shprint(sh.ndk_build, 'V=1', 'APP_ABI=' + arch.arch, *extra_args, _env=env)
602+
603+
578604
class PythonRecipe(Recipe):
579605
site_packages_name = None
580606
'''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)