@@ -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+
578604class PythonRecipe (Recipe ):
579605 site_packages_name = None
580606 '''The name of the module's folder when installed in the Python
0 commit comments