@@ -127,7 +127,8 @@ def shprint(command, *args, **kwargs):
127
127
need_closing_newline = False
128
128
for line in output :
129
129
if logger .level > logging .DEBUG :
130
- string = '\r ' + ' ' * 11 + 'working ... ' + line [:100 ].replace ('\n ' , '' ).rstrip () + ' ...'
130
+ string = '' .join ([Style .RESET_ALL , '\r ' , ' ' * 11 , 'working ... ' ,
131
+ line [:100 ].replace ('\n ' , '' ).rstrip (), ' ...' ])
131
132
if len (string ) < 20 :
132
133
continue
133
134
if len (string ) < 120 :
@@ -431,18 +432,18 @@ def remove_redundant_graphs(self):
431
432
for j in range (1 , len (graphs )):
432
433
comparison_graph = graphs [initial_num_graphs - 1 - j ]
433
434
if set (comparison_graph .keys ()) == set (graph .keys ()):
434
- graphs .pop ([ initial_num_graphs - 1 - i ] )
435
+ graphs .pop (initial_num_graphs - 1 - i )
435
436
break
436
437
437
438
def add (self , dependent , dependency ):
438
439
"""Add a dependency relationship to the graph"""
439
440
if isinstance (dependency , (tuple , list )):
440
- for graph in self .graphs :
441
- self ._add (graph , dependent , dependency [0 ])
441
+ for graph in self .graphs [:]:
442
442
for dep in dependency [1 :]:
443
443
new_graph = deepcopy (graph )
444
444
self ._add (new_graph , dependent , dep )
445
445
self .graphs .append (new_graph )
446
+ self ._add (graph , dependent , dependency [0 ])
446
447
else :
447
448
for graph in self .graphs :
448
449
self ._add (graph , dependent , dependency )
@@ -462,10 +463,24 @@ def conflicts(self, conflict):
462
463
for i in range (len (graphs )):
463
464
graph = graphs [len (graphs ) - 1 - i ]
464
465
if conflict in graph :
465
- print ('conflict in graph' , conflict , graph )
466
- graphs .pop ([len (graphs ) - 1 - i ])
466
+ graphs .pop (len (graphs ) - 1 - i )
467
467
return len (graphs ) == 0
468
468
469
+ def remove_remaining_conflicts (self , ctx ):
470
+ # It's unpleasant to have to pass ctx as an argument...
471
+ '''Checks all possible graphs for conflicts that have arisen during
472
+ the additon of alternative repice branches, as these are not checked
473
+ for conflicts at the time.'''
474
+ new_graphs = []
475
+ for i , graph in enumerate (self .graphs ):
476
+ for name in graph .keys ():
477
+ recipe = Recipe .get_recipe (name , ctx )
478
+ if any ([c in graph for c in recipe .conflicts ]):
479
+ break
480
+ else :
481
+ new_graphs .append (graph )
482
+ self .graphs = new_graphs
483
+
469
484
def add_optional (self , dependent , dependency ):
470
485
"""Add an optional (ordering only) dependency relationship to the graph
471
486
@@ -907,8 +922,6 @@ def get_libs_dir(self, arch):
907
922
'''The libs dir for a given arch.'''
908
923
ensure_dir (join (self .libs_dir , arch ))
909
924
# AND: See warning:
910
- warning ('Ensuring libs dir in get_libs_dir, should fix this '
911
- 'to ensure elsewhere' )
912
925
return join (self .libs_dir , arch )
913
926
914
927
@@ -1261,19 +1274,14 @@ class Recipe(object):
1261
1274
'''
1262
1275
1263
1276
conflicts = []
1264
- # AND: Not currently used, needs modifications to the dependency Graph
1265
1277
'''A list containing the names of any recipes that are known to be
1266
1278
incompatible with this one.'''
1267
1279
1268
- # patches = []
1269
- # '''Filepaths (relative to the recipe script) for any pathches that are
1270
- # to be applied. By default, these are applied in prebuild_arch, so
1271
- # if you override this but want to use patches then don't forget to
1272
- # call super().
1280
+ opt_depends = []
1281
+ '''A list of optional dependencies, that must be built before this
1282
+ recipe if they are built at all, but whose presence is not essential.'''
1273
1283
1274
- # name = None # name for the recipe dir
1275
-
1276
- archs = ['armeabi' ] # will android use this?
1284
+ archs = ['armeabi' ] # Not currently implemented properly
1277
1285
1278
1286
1279
1287
@property
@@ -1417,9 +1425,32 @@ def filtered_archs(self):
1417
1425
result .append (arch )
1418
1426
return result
1419
1427
1428
+ def check_recipe_choices (self ):
1429
+ '''Checks what recipes are being built to see which of the alternative
1430
+ and optional dependencies are being used, and returns a list of these.'''
1431
+ recipes = []
1432
+ built_recipes = self .ctx .recipe_build_order
1433
+ for recipe in self .depends :
1434
+ if isinstance (recipe , (tuple , list )):
1435
+ for alternative in recipe :
1436
+ if alternative in built_recipes :
1437
+ recipes .append (alternative )
1438
+ break
1439
+ for recipe in self .opt_depends :
1440
+ if recipe in built_recipes :
1441
+ recipes .append (recipe )
1442
+ return sorted (recipes )
1443
+
1420
1444
def get_build_container_dir (self , arch ):
1421
- '''Given the arch name, returns the directory where it will be built.'''
1422
- return join (self .ctx .build_dir , 'other_builds' , self .name , arch )
1445
+ '''Given the arch name, returns the directory where it will be
1446
+ built.
1447
+
1448
+ This returns a different directory depending on what
1449
+ alternative or optional dependencies are being built.
1450
+ '''
1451
+ choices = self .check_recipe_choices ()
1452
+ dir_name = '-' .join ([self .name ] + choices )
1453
+ return join (self .ctx .build_dir , 'other_builds' , dir_name , arch )
1423
1454
1424
1455
def get_build_dir (self , arch ):
1425
1456
'''Given the arch name, returns the directory where the
@@ -1616,7 +1647,7 @@ def prebuild_arch(self, arch):
1616
1647
if hasattr (self , prebuild ):
1617
1648
getattr (self , prebuild )()
1618
1649
else :
1619
- print ('{} has no {}, skipping' .format (self .name , prebuild ))
1650
+ info ('{} has no {}, skipping' .format (self .name , prebuild ))
1620
1651
1621
1652
def should_build (self ):
1622
1653
'''Should perform any necessary test and return True only if it needs
@@ -1928,7 +1959,7 @@ def build_recipes(names, ctx):
1928
1959
python_modules = []
1929
1960
while recipes_to_load :
1930
1961
name = recipes_to_load .pop (0 )
1931
- if name in recipe_loaded :
1962
+ if name in recipe_loaded or isinstance ( name , ( list , tuple )) :
1932
1963
continue
1933
1964
try :
1934
1965
recipe = Recipe .get_recipe (name , ctx )
@@ -1947,15 +1978,19 @@ def build_recipes(names, ctx):
1947
1978
if graph .conflicts (conflict ):
1948
1979
warning (
1949
1980
('{} conflicts with {}, but both have been '
1950
- 'included in the requirements.' .format (recipe .name , conflict )))
1981
+ 'included or pulled into the requirements.' .format (recipe .name , conflict )))
1951
1982
warning ('Due to this conflict the build cannot continue, exiting.' )
1952
1983
exit (1 )
1953
1984
recipe_loaded .append (name )
1985
+ graph .remove_remaining_conflicts (ctx )
1954
1986
if len (graph .graphs ) > 1 :
1955
1987
info ('Found multiple valid recipe sets:' )
1956
- for graph in graph .graphs :
1957
- info (' {}' .format (graph .keys ()))
1988
+ for g in graph .graphs :
1989
+ info (' {}' .format (g .keys ()))
1958
1990
info_notify ('Using the first of these: {}' .format (graph .graphs [0 ].keys ()))
1991
+ elif len (graph .graphs ) == 0 :
1992
+ warning ('Didn\' t find any valid dependency graphs, exiting.' )
1993
+ exit (1 )
1959
1994
else :
1960
1995
info ('Found a single valid recipe set (this is good)' )
1961
1996
build_order = list (graph .find_order (0 ))
@@ -2354,7 +2389,7 @@ def clean_all(self, args):
2354
2389
bootstrap builds and distributions.'''
2355
2390
parser = argparse .ArgumentParser (
2356
2391
description = "Clean the build cache, downloads and dists" )
2357
- args = parser .parse_args (args )
2392
+ parsed_args = parser .parse_args (args )
2358
2393
ctx = Context ()
2359
2394
self .clean_dists (args )
2360
2395
self .clean_builds (args )
@@ -2570,10 +2605,13 @@ def distributions(self, args):
2570
2605
ctx = Context ()
2571
2606
dists = Distribution .get_distributions (ctx )
2572
2607
2573
- info ('{Style.BRIGHT}Distributions currently installed are:'
2574
- '{Style.RESET_ALL}' .format (Style = Style , Fore = Fore ))
2575
-
2576
- pretty_log_dists (dists )
2608
+ if dists :
2609
+ info ('{Style.BRIGHT}Distributions currently installed are:'
2610
+ '{Style.RESET_ALL}' .format (Style = Style , Fore = Fore ))
2611
+ pretty_log_dists (dists )
2612
+ else :
2613
+ info ('{Style.BRIGHT}There are no dists currently built.'
2614
+ '{Style.RESET_ALL}' .format (Style = Style ))
2577
2615
2578
2616
def delete_dist (self , args ):
2579
2617
dist = self ._dist
0 commit comments