12
12
from sys import stdout , stderr , platform
13
13
from os .path import (join , dirname , realpath , exists , isdir , basename ,
14
14
expanduser , splitext , split )
15
- from os import listdir , unlink , makedirs , environ , chdir , getcwd , walk , uname
15
+ from os import listdir , unlink , makedirs , environ , chdir , getcwd , uname
16
16
import os
17
17
import zipfile
18
18
import tarfile
@@ -56,7 +56,7 @@ def __init__(self):
56
56
57
57
def __getattr__ (self , key ):
58
58
return self ._dict [key ]
59
-
59
+
60
60
Null_Style = Null_Fore = colorama_shim ()
61
61
62
62
if stdout .isatty ():
@@ -148,14 +148,19 @@ def pretty_log_dists(dists, log_func=info):
148
148
for line in infos :
149
149
log_func ('\t ' + line )
150
150
151
+
151
152
def shorten_string (string , max_width ):
152
153
''' make limited length string in form:
153
154
"the string is very lo...(and 15 more)"
154
- '''
155
+ '''
155
156
string_len = len (string )
156
- if string_len <= max_width : return string
157
- visible = max_width - 16 - int (log10 (string_len )) #expected suffix len "...(and XXXXX more)"
158
- return '' .join ((string [:visible ], '...(and ' , str (string_len - visible ), ' more)' ))
157
+ if string_len <= max_width :
158
+ return string
159
+ visible = max_width - 16 - int (log10 (string_len ))
160
+ # expected suffix len "...(and XXXXX more)"
161
+ return '' .join ((string [:visible ], '...(and ' , str (string_len - visible ),
162
+ ' more)' ))
163
+
159
164
160
165
def shprint (command , * args , ** kwargs ):
161
166
'''Runs the command (which should be an sh.Command instance), while
@@ -351,17 +356,19 @@ def current_directory(new_dir):
351
356
Err_Fore .RESET )))
352
357
chdir (cur_dir )
353
358
359
+
354
360
@contextlib .contextmanager
355
361
def temp_directory ():
356
362
temp_dir = mkdtemp ()
357
363
try :
358
- logger .debug ('' .join ((Err_Fore .CYAN , ' + temp directory used ' , temp_dir ,
359
- Err_Fore .RESET )))
364
+ logger .debug ('' .join ((Err_Fore .CYAN , ' + temp directory used ' ,
365
+ temp_dir , Err_Fore .RESET )))
360
366
yield temp_dir
361
367
finally :
362
368
shutil .rmtree (temp_dir )
363
- logger .debug ('' .join ((Err_Fore .CYAN , ' - temp directory deleted ' , temp_dir ,
364
- Err_Fore .RESET )))
369
+ logger .debug ('' .join ((Err_Fore .CYAN , ' - temp directory deleted ' ,
370
+ temp_dir , Err_Fore .RESET )))
371
+
365
372
366
373
def cache_execution (f ):
367
374
def _cache_execution (self , * args , ** kwargs ):
@@ -532,21 +539,25 @@ def get_env(self):
532
539
533
540
return env
534
541
542
+
535
543
class ArchARM (Arch ):
536
544
arch = "armeabi"
537
545
toolchain_prefix = 'arm-linux-androideabi'
538
546
command_prefix = 'arm-linux-androideabi'
539
547
platform_dir = 'arch-arm'
540
548
549
+
541
550
class ArchARMv7_a (ArchARM ):
542
551
arch = 'armeabi-v7a'
543
552
544
553
def get_env (self ):
545
554
env = super (ArchARMv7_a , self ).get_env ()
546
- env ['CFLAGS' ] = env ['CFLAGS' ] + ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb'
555
+ env ['CFLAGS' ] = (env ['CFLAGS' ] +
556
+ ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb' )
547
557
env ['CXXFLAGS' ] = env ['CFLAGS' ]
548
558
return env
549
559
560
+
550
561
class Archx86 (Arch ):
551
562
arch = 'x86'
552
563
toolchain_prefix = 'x86'
@@ -555,10 +566,12 @@ class Archx86(Arch):
555
566
556
567
def get_env (self ):
557
568
env = super (Archx86 , self ).get_env ()
558
- env ['CFLAGS' ] = env ['CFLAGS' ] + ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32'
569
+ env ['CFLAGS' ] = (env ['CFLAGS' ] +
570
+ ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32' )
559
571
env ['CXXFLAGS' ] = env ['CFLAGS' ]
560
572
return env
561
573
574
+
562
575
class Archx86_64 (Arch ):
563
576
arch = 'x86_64'
564
577
toolchain_prefix = 'x86'
@@ -567,7 +580,8 @@ class Archx86_64(Arch):
567
580
568
581
def get_env (self ):
569
582
env = super (Archx86_64 , self ).get_env ()
570
- env ['CFLAGS' ] = env ['CFLAGS' ] + ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel'
583
+ env ['CFLAGS' ] = (env ['CFLAGS' ] +
584
+ ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel' )
571
585
env ['CXXFLAGS' ] = env ['CFLAGS' ]
572
586
return env
573
587
0 commit comments