11from os import uname
22
3+ class ComposableFunction (object ):
4+ def __init__ (self , function ):
5+ self .func = function
6+
7+ def __call__ (self , * args , ** kwargs ):
8+ return self .func (* args , ** kwargs )
9+
10+ def __and__ (self , f ):
11+ return ComposableFunction (lambda * args , ** kwargs : self (* args , ** kwargs ) and f (* args , ** kwargs ))
12+
13+ def __or__ (self , f ):
14+ return ComposableFunction (lambda * args , ** kwargs : self (* args , ** kwargs ) or f (* args , ** kwargs ))
15+
316
417def check_all (* callables ):
518 def check (** kwargs ):
619 return all (c (** kwargs ) for c in callables )
7- return check
20+ return ComposableFunction ( check )
821
922
1023def check_any (* callables ):
1124 def check (** kwargs ):
1225 return any (c (** kwargs ) for c in callables )
13- return check
26+ return ComposableFunction ( check )
1427
1528
1629def is_platform (platform ):
1730 def is_x (** kwargs ):
1831 return uname ()[0 ] == platform
19- return is_x
32+ return ComposableFunction ( is_x )
2033
2134is_linux = is_platform ('Linux' )
2235is_darwin = is_platform ('Darwin' )
@@ -25,43 +38,43 @@ def is_x(**kwargs):
2538def is_arch (xarch ):
2639 def is_x (arch , ** kwargs ):
2740 return arch .arch == xarch
28- return is_x
41+ return ComposableFunction ( is_x )
2942
3043
3144def is_api_gt (apiver ):
3245 def is_x (recipe , ** kwargs ):
3346 return recipe .ctx .android_api > apiver
34- return is_x
47+ return ComposableFunction ( is_x )
3548
3649
3750def is_api_gte (apiver ):
3851 def is_x (recipe , ** kwargs ):
3952 return recipe .ctx .android_api >= apiver
40- return is_x
53+ return ComposableFunction ( is_x )
4154
4255
4356def is_api_lt (apiver ):
4457 def is_x (recipe , ** kwargs ):
4558 return recipe .ctx .android_api < apiver
46- return is_x
59+ return ComposableFunction ( is_x )
4760
4861
4962def is_api_lte (apiver ):
5063 def is_x (recipe , ** kwargs ):
5164 return recipe .ctx .android_api <= apiver
52- return is_x
65+ return ComposableFunction ( is_x )
5366
5467
5568def is_api (apiver ):
5669 def is_x (recipe , ** kwargs ):
5770 return recipe .ctx .android_api == apiver
58- return is_x
71+ return ComposableFunction ( is_x )
5972
6073
6174def will_build (recipe_name ):
6275 def will (recipe , ** kwargs ):
6376 return recipe_name in recipe .ctx .recipe_build_order
64- return will
77+ return ComposableFunction ( will )
6578
6679
6780def is_ndk (ndk ):
0 commit comments