From 0563ef00ab5a64184f1290941ff2d8ee564cacbc Mon Sep 17 00:00:00 2001 From: opacam Date: Fri, 25 Jan 2019 21:50:17 +0100 Subject: [PATCH] Make bootstrap dynamic for rebuild_updated_recipes --- ci/rebuild_updated_recipes.py | 71 ++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/ci/rebuild_updated_recipes.py b/ci/rebuild_updated_recipes.py index 59db41bb1a..dc74d06888 100755 --- a/ci/rebuild_updated_recipes.py +++ b/ci/rebuild_updated_recipes.py @@ -48,7 +48,7 @@ def modified_recipes(branch='origin/master'): return recipes -def build(target_python, requirements): +def build(target_python, target_bootstrap, requirements): """ Builds an APK given a target Python and a set of requirements. """ @@ -65,34 +65,71 @@ def build(target_python, requirements): with current_directory('testapps/'): # iterates to stream the output for line in sh.python( - testapp, 'apk', '--sdk-dir', android_sdk_home, - '--ndk-dir', android_ndk_home, '--bootstrap', 'sdl2', '--requirements', - requirements, _err_to_out=True, _iter=True): + testapp, 'apk', + '--sdk-dir', android_sdk_home, + '--ndk-dir', android_ndk_home, + '--bootstrap', target_bootstrap, + '--requirements', requirements, + _err_to_out=True, _iter=True): print(line) -def main(): - target_python = TargetPython.python3 - recipes = modified_recipes() - logger.info('recipes modified: {}'.format(recipes)) - recipes -= CORE_RECIPES - logger.info('recipes to build: {}'.format(recipes)) +def get_bootstrap(recipes_and_target): + """ + Finds the right bootstrap given a set of requirements with a defined + target python recipe inside this set. + """ context = Context() - # forces the default target - recipes_and_target = recipes | set([target_python.name]) + bootstrap = None try: build_order, python_modules, bs = get_recipe_order_and_bootstrap( context, recipes_and_target, None) + bootstrap = bs.name except BuildInterruptingException: - # fallback to python2 if default target is not compatible - logger.info('incompatible with {}'.format(target_python.name)) - target_python = TargetPython.python2 - logger.info('falling back to {}'.format(target_python.name)) + pass + return bootstrap + + +def main(): + target_python_priorities = [ + TargetPython.python3, + TargetPython.python2, + TargetPython.python2legacy + ] + + recipes = modified_recipes() + logger.info('recipes modified: {}'.format(recipes)) + recipes -= CORE_RECIPES + logger.info('recipes to build: {}'.format(recipes)) + + bootstrap = None + target_python = None + for n, target_python in enumerate(target_python_priorities): + logger.info( + 'trying to get a bootstrap forcing target python: {}'.format( + target_python.name)) + bootstrap = get_bootstrap(recipes | {target_python.name}) + if bootstrap: + break + else: + # fallback to next TargetPython if current target is not compatible + logger.info('\t- incompatible with {}'.format(target_python.name)) + if len(target_python_priorities) < n + 1: + logger.info('\t- falling back to {}'.format( + target_python_priorities[n + 1].name)) + continue + if not bootstrap: + logger.warning('we didn\'t find any valid combination of bootstrap and' + ' target python...rebuild updated recipes cancelled.' + 'The recipes we couldn\'t rebuild are:' + '\n\t-{}'.format('\n\t-'.join(list(recipes)))) + exit(1) + # removing the known broken recipe for the given target broken_recipes = BROKEN_RECIPES[target_python] recipes -= broken_recipes logger.info('recipes to build (no broken): {}'.format(recipes)) - build(target_python, recipes) + build(target_python, bootstrap, recipes) if __name__ == '__main__':