Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional build script fixes #1604

Merged
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
26 changes: 16 additions & 10 deletions ci/rebuild_updated_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import sh
import os
from pythonforandroid.build import Context
from pythonforandroid import logger
from pythonforandroid.graph import get_recipe_order_and_bootstrap
from pythonforandroid.toolchain import current_directory
from pythonforandroid.util import BuildInterruptingException
from ci.constants import TargetPython, CORE_RECIPES, BROKEN_RECIPES


Expand Down Expand Up @@ -59,9 +61,10 @@ def build(target_python, requirements):
testapp = 'setup_testapp_python3.py'
requirements.add(target_python.name)
requirements = ','.join(requirements)
print('requirements:', requirements)
logger.info('requirements: {}'.format(requirements))
with current_directory('testapps/'):
try:
# 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',
Expand All @@ -74,21 +77,24 @@ def build(target_python, requirements):
def main():
target_python = TargetPython.python3
recipes = modified_recipes()
print('recipes modified:', recipes)
logger.info('recipes modified: {}'.format(recipes))
recipes -= CORE_RECIPES
print('recipes to build:', recipes)
logger.info('recipes to build: {}'.format(recipes))
context = Context()
build_order, python_modules, bs = get_recipe_order_and_bootstrap(
context, recipes, None)
# fallback to python2 if default target is not compatible
if target_python.name not in build_order:
print('incompatible with {}'.format(target_python.name))
# forces the default target
recipes_and_target = recipes | set([target_python.name])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try:
build_order, python_modules, bs = get_recipe_order_and_bootstrap(
context, recipes_and_target, None)
except BuildInterruptingException:
# fallback to python2 if default target is not compatible
logger.info('incompatible with {}'.format(target_python.name))
target_python = TargetPython.python2
print('falling back to {}'.format(target_python.name))
logger.info('falling back to {}'.format(target_python.name))
# removing the known broken recipe for the given target
broken_recipes = BROKEN_RECIPES[target_python]
recipes -= broken_recipes
print('recipes to build (no broken):', recipes)
logger.info('recipes to build (no broken): {}'.format(recipes))
build(target_python, recipes)


Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/libzbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LibZBarRecipe(Recipe):

def should_build(self, arch):
return not os.path.exists(
os.path.join(self.ctx.get_libs_dir(arch.arch), 'libzbar.so'))
os.path.join(self.ctx.get_libs_dir(arch.arch), 'libzbar.so'))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor E126 lint fix to demonstrate conditional recipe rebuild.
The libzbar recipe is currently python2 only so the conditional build script should first try with current default target python3 and then fallback to python2


def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(LibZBarRecipe, self).get_recipe_env(arch, with_flags_in_cc)
Expand Down