28
28
CompiledComponentsPythonRecipe ,
29
29
BootstrapNDKRecipe , NDKRecipe )
30
30
from pythonforandroid .archs import (ArchARM , ArchARMv7_a , Archx86 )
31
- from pythonforandroid .logger import (logger , info , warning , debug ,
31
+ from pythonforandroid .logger import (logger , info , warning , setup_color ,
32
32
Out_Style , Out_Fore , Err_Style , Err_Fore ,
33
- info_notify , info_main , shprint ,
34
- Null_Fore , Null_Style )
33
+ info_notify , info_main , shprint )
35
34
from pythonforandroid .util import current_directory , ensure_dir
36
35
from pythonforandroid .bootstrap import Bootstrap
37
36
from pythonforandroid .distribution import Distribution , pretty_log_dists
43
42
sys .path .insert (0 , join (toolchain_dir , "tools" , "external" ))
44
43
45
44
46
- info ('' .join (
47
- [Err_Style .BRIGHT , Err_Fore .RED ,
48
- 'This python-for-android revamp is an experimental alpha release!' ,
49
- Err_Style .RESET_ALL ]))
50
- info ('' .join (
51
- [Err_Fore .RED ,
52
- ('It should work (mostly), but you may experience '
53
- 'missing features or bugs.' ),
54
- Err_Style .RESET_ALL ]))
55
-
56
-
57
45
def add_boolean_option (parser , names , no_names = None ,
58
46
default = True , dest = None , description = None ):
59
47
group = parser .add_argument_group (description = description )
@@ -204,6 +192,9 @@ def __init__(self):
204
192
parser .add_argument (
205
193
'--debug' , dest = 'debug' , action = 'store_true' ,
206
194
help = 'Display debug output and all build info' )
195
+ parser .add_argument (
196
+ '--color' , dest = 'color' , choices = ['always' , 'never' , 'auto' ],
197
+ help = 'Enable or disable color output (default enabled on tty)' )
207
198
parser .add_argument (
208
199
'--sdk-dir' , '--sdk_dir' , dest = 'sdk_dir' , default = '' ,
209
200
help = 'The filepath where the Android SDK is installed' )
@@ -282,6 +273,18 @@ def __init__(self):
282
273
args , unknown = parser .parse_known_args (sys .argv [1 :])
283
274
self .dist_args = args
284
275
276
+ setup_color (args .color )
277
+
278
+ info ('' .join (
279
+ [Err_Style .BRIGHT , Err_Fore .RED ,
280
+ 'This python-for-android revamp is an experimental alpha release!' ,
281
+ Err_Style .RESET_ALL ]))
282
+ info ('' .join (
283
+ [Err_Fore .RED ,
284
+ ('It should work (mostly), but you may experience '
285
+ 'missing features or bugs.' ),
286
+ Err_Style .RESET_ALL ]))
287
+
285
288
# strip version from requirements, and put them in environ
286
289
requirements = []
287
290
for requirement in split_argument_list (args .requirements ):
@@ -357,19 +360,8 @@ def recipes(self, args):
357
360
"--compact" , action = "store_true" , default = False ,
358
361
help = "Produce a compact list suitable for scripting" )
359
362
360
- add_boolean_option (
361
- parser , ["color" ],
362
- default = True ,
363
- description = 'Whether the output should be colored:' )
364
-
365
363
args = parser .parse_args (args )
366
364
367
- Fore = Out_Fore
368
- Style = Out_Style
369
- if not args .color :
370
- Fore = Null_Fore
371
- Style = Null_Style
372
-
373
365
ctx = self .ctx
374
366
if args .compact :
375
367
print (" " .join (set (Recipe .list_recipes (ctx ))))
@@ -380,18 +372,18 @@ def recipes(self, args):
380
372
print ('{Fore.BLUE}{Style.BRIGHT}{recipe.name:<12} '
381
373
'{Style.RESET_ALL}{Fore.LIGHTBLUE_EX}'
382
374
'{version:<8}{Style.RESET_ALL}' .format (
383
- recipe = recipe , Fore = Fore , Style = Style ,
375
+ recipe = recipe , Fore = Out_Fore , Style = Out_Style ,
384
376
version = version ))
385
377
print (' {Fore.GREEN}depends: {recipe.depends}'
386
- '{Fore.RESET}' .format (recipe = recipe , Fore = Fore ))
378
+ '{Fore.RESET}' .format (recipe = recipe , Fore = Out_Fore ))
387
379
if recipe .conflicts :
388
380
print (' {Fore.RED}conflicts: {recipe.conflicts}'
389
381
'{Fore.RESET}'
390
- .format (recipe = recipe , Fore = Fore ))
382
+ .format (recipe = recipe , Fore = Out_Fore ))
391
383
if recipe .opt_depends :
392
384
print (' {Fore.YELLOW}optional depends: '
393
385
'{recipe.opt_depends}{Fore.RESET}'
394
- .format (recipe = recipe , Fore = Fore ))
386
+ .format (recipe = recipe , Fore = Out_Fore ))
395
387
396
388
def bootstraps (self , args ):
397
389
'''List all the bootstraps available to build with.'''
0 commit comments