Skip to content

Commit 2b6f980

Browse files
committed
Added recipe conflict handling (and build failure)
1 parent 7064fa9 commit 2b6f980

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

pythonforandroid/toolchain.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ class ArchAndroid(Arch):
413413

414414

415415
class Graph(object):
416-
# Taken from python-for-android/depsort
416+
# Taken from the old python-for-android/depsort
417417
def __init__(self):
418418
# `graph`: dict that maps each package to a set of its dependencies.
419419
self.graph = {}
@@ -1875,16 +1875,16 @@ def get_recipe_env(self, arch):
18751875
def build_recipes(names, ctx):
18761876
# Put recipes in correct build order
18771877
graph = Graph()
1878-
recipe_to_load = set(names)
1878+
recipes_to_load = set(names)
18791879
bs = ctx.bootstrap
1880-
if bs.recipe_depends:
1880+
if bs is not None and bs.recipe_depends:
18811881
info('Bootstrap requires recipes {}'.format(bs.recipe_depends))
1882-
recipe_to_load = recipe_to_load.union(set(bs.recipe_depends))
1883-
recipe_to_load = list(recipe_to_load)
1882+
recipes_to_load = recipes_to_load.union(set(bs.recipe_depends))
1883+
recipes_to_load = list(recipes_to_load)
18841884
recipe_loaded = []
18851885
python_modules = []
1886-
while recipe_to_load:
1887-
name = recipe_to_load.pop(0)
1886+
while recipes_to_load:
1887+
name = recipes_to_load.pop(0)
18881888
if name in recipe_loaded:
18891889
continue
18901890
try:
@@ -1894,10 +1894,17 @@ def build_recipes(names, ctx):
18941894
python_modules.append(name)
18951895
continue
18961896
graph.add(name, name)
1897-
info('Loaded recipe {} (depends on {})'.format(name, recipe.depends))
1897+
info('Loaded recipe {} (depends on {}, conflicts {})'.format(name, recipe.depends, recipe.conflicts))
18981898
for depend in recipe.depends:
18991899
graph.add(name, depend)
1900-
recipe_to_load += recipe.depends
1900+
recipes_to_load += recipe.depends
1901+
for conflict in recipe.conflicts:
1902+
if conflict in graph.graph:
1903+
warning(
1904+
('{} conflicts with {}, but both have been '
1905+
'included in the requirements.'.format(recipe.name, conflict)))
1906+
warning('Due to this conflict the build cannot continue, exiting.')
1907+
exit(1)
19011908
recipe_loaded.append(name)
19021909
build_order = list(graph.find_order())
19031910
info("Recipe build order is {}".format(build_order))
@@ -2102,6 +2109,7 @@ def build_dist_from_args(ctx, dist, args_list):
21022109
args, unknown = parser.parse_known_args(args_list)
21032110

21042111
bs = Bootstrap.get_bootstrap(args.bootstrap, ctx)
2112+
info('The selected bootstrap is {}'.format(bs.name))
21052113
info_main('# Creating dist with {} bootstrap'.format(bs.name))
21062114
bs.distribution = dist
21072115
info_notify('Dist will have name {} and recipes ({})'.format(
@@ -2522,7 +2530,9 @@ def delete_dist(self, args):
25222530

25232531
def adb(self, args):
25242532
'''Runs the adb binary from the detected SDK directory, passing all
2525-
arguments straight to it.'''
2533+
arguments straight to it. This is intended as a convenience
2534+
function if adb is not in your $PATH.
2535+
'''
25262536
ctx = self.ctx
25272537
ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir,
25282538
user_ndk_dir=self.ndk_dir,
@@ -2535,7 +2545,8 @@ def adb(self, args):
25352545
info_notify('Starting adb...')
25362546
output = adb(args, _iter=True, _out_bufsize=1, _err_to_out=True)
25372547
for line in output:
2538-
print(line)
2548+
sys.stdout.write(line)
2549+
sys.stdout.flush()
25392550

25402551
def logcat(self, args):
25412552
'''Runs ``adb logcat`` using the adb binary from the detected SDK

0 commit comments

Comments
 (0)