12
12
from xlsxwriter .workbook import Workbook
13
13
from xlsxwriter .worksheet import Worksheet
14
14
from xlsxwriter .worksheet import convert_cell_args
15
- from embarc_tools .download_manager import cd , getcwd , delete_dir_files
15
+ from embarc_tools .download_manager import cd , delete_dir_files
16
16
from embarc_tools .osp import osp
17
17
from embarc_tools .builder import build
18
18
import collections
31
31
32
32
MakefileNames = ['Makefile' , 'makefile' , 'GNUMakefile' ]
33
33
34
+
34
35
def excel_string_width (str ):
35
36
string_width = len (str )
36
37
if string_width == 0 :
@@ -69,7 +70,6 @@ def close(self):
69
70
return super (MyWorkbook , self ).close ()
70
71
71
72
72
-
73
73
def get_cache (osp_path ):
74
74
cache = ".cache/result"
75
75
cache_path = os .path .join (osp_path , cache )
@@ -78,7 +78,6 @@ def get_cache(osp_path):
78
78
return cache_path
79
79
80
80
81
-
82
81
def generate_json_file (data , path ):
83
82
with open (path , "w" ) as f :
84
83
json .dump (data , f , indent = 4 )
@@ -104,7 +103,6 @@ def result_json_artifacts(osp_path, result, file=None):
104
103
generate_json_file (result , file_path )
105
104
106
105
107
-
108
106
def takeApp (elem ):
109
107
return elem ["app_path" ]
110
108
@@ -118,22 +116,21 @@ def dict_to_excel(datas):
118
116
filename = toolchain_config + ".xlsx"
119
117
workbook = MyWorkbook (filename )
120
118
sheet_dict = dict ()
121
- merge_format = workbook .add_format ({'bold' : True , "align" : "center" ,"valign" : "vcenter" })
122
-
119
+ merge_format = workbook .add_format ({'bold' : True , "align" : "center" , "valign" : "vcenter" })
123
120
124
- for build in results :
125
- config = build .get ("config" , None )
121
+ for build_result in results :
122
+ config = build_result .get ("config" , None )
126
123
if config :
127
124
board_config = config ["BOARD" ] + "_" + config ["BD_VER" ]
128
125
if not results_board_config .get (board_config , None ):
129
- results_board_config [board_config ] = [build ]
126
+ results_board_config [board_config ] = [build_result ]
130
127
else :
131
- results_board_config [board_config ].append (build )
128
+ results_board_config [board_config ].append (build_result )
132
129
for board_config in results_board_config :
133
130
worksheet = workbook .add_worksheet (board_config )
134
131
sheet_dict [board_config ] = worksheet
135
- for board_config , build in results_board_config .items ():
136
- build .sort (key = takeApp )
132
+ for board_config , build_result in results_board_config .items ():
133
+ build_result .sort (key = takeApp )
137
134
worksheet = sheet_dict [board_config ]
138
135
worksheet .merge_range (0 , 0 , 1 , 0 , "APP" , merge_format )
139
136
worksheet .set_column (0 , 7 , 10 )
@@ -153,7 +150,7 @@ def dict_to_excel(datas):
153
150
same_app = dict ()
154
151
failed_count = dict ()
155
152
same_app = collections .OrderedDict ()
156
- for app_build in build :
153
+ for app_build in build_result :
157
154
app_name = app_build ["app_path" ]
158
155
if same_app .get (app_name , None ):
159
156
same_app [app_name ] = same_app [app_name ] + 1
@@ -162,7 +159,7 @@ def dict_to_excel(datas):
162
159
same_app [app_name ] = 1
163
160
failed_count [app_name ] = 0
164
161
165
- cell_format = workbook .add_format ({"align" : "center" ,"valign" : "vcenter" })
162
+ cell_format = workbook .add_format ({"align" : "center" , "valign" : "vcenter" })
166
163
failed = "No"
167
164
if not app_build ["code" ]:
168
165
failed = "Yes"
@@ -181,8 +178,8 @@ def dict_to_excel(datas):
181
178
row += 1
182
179
s = 2
183
180
for app , value in same_app .items ():
184
- merge_format_app = workbook .add_format ({"align" : "center" ,"valign" : "vcenter" })
185
- if value == failed_count [app ]:
181
+ merge_format_app = workbook .add_format ({"align" : "center" , "valign" : "vcenter" })
182
+ if value == failed_count [app ]:
186
183
if not failed_summarize .get (toolchain_config , None ):
187
184
failed_summarize [toolchain_config ] = dict ()
188
185
if not failed_summarize [toolchain_config ].get (board_config , None ):
@@ -196,28 +193,27 @@ def dict_to_excel(datas):
196
193
return failed_summarize
197
194
198
195
199
-
200
196
def result_excel_artifacts (osp_path ):
201
197
cache_path = get_cache (osp_path )
202
198
files = os .listdir (cache_path )
203
199
datas = dict ()
204
200
failed_summarize = None
205
201
for file in files :
206
202
filename , filesuffix = os .path .splitext (file )
207
- if not filesuffix == ".json" or filename == "results" :
203
+ if not filesuffix == ".json" or filename == "results" :
208
204
continue
209
205
file_path = os .path .join (cache_path , file )
210
206
with open (file_path , "r" ) as f :
211
207
results = json .load (f )
212
208
for app , build_status in results .items ():
213
- for build in build_status :
214
- config = build .get ("config" , None )
209
+ for build_result in build_status :
210
+ config = build_result .get ("config" , None )
215
211
if config :
216
212
toolchain_config = config ["TOOLCHAIN" ] + "_" + config ["TOOLCHAIN_VER" ]
217
213
if not datas .get (toolchain_config , None ):
218
- datas [toolchain_config ] = [build ]
214
+ datas [toolchain_config ] = [build_result ]
219
215
else :
220
- datas [toolchain_config ].append (build )
216
+ datas [toolchain_config ].append (build_result )
221
217
else :
222
218
continue
223
219
f .close ()
@@ -228,7 +224,6 @@ def result_excel_artifacts(osp_path):
228
224
result_json_artifacts (osp_path , failed_summarize , file = "failed_results" )
229
225
230
226
231
-
232
227
class TailRecurseException (Exception ):
233
228
def __init__ (self , args , kwargs ):
234
229
self .args = args
@@ -251,7 +246,6 @@ def func(*args, **kwargs):
251
246
return func
252
247
253
248
254
-
255
249
def parse_config (config ):
256
250
make_configs = config
257
251
core_key = "CUR_CORE"
@@ -270,7 +264,6 @@ def parse_config(config):
270
264
delete_dir_files (json_path , dir = True )
271
265
embarc_osp = osp .OSP ()
272
266
273
-
274
267
core_key = "CORE" if "CORE" in make_configs else "CUR_CORE"
275
268
if "PARALLEL" in make_configs and make_configs ["PARALLEL" ] is not None :
276
269
parallel = make_configs ["PARALLEL" ]
@@ -290,7 +283,6 @@ def parse_config(config):
290
283
board_input = make_configs ["BOARD" ]
291
284
support_boards = embarc_osp .supported_boards (osp_root )
292
285
293
-
294
286
boards = [board_input ] if board_input in support_boards else support_boards
295
287
if "BD_VER" in make_configs and make_configs ["BD_VER" ] is not None :
296
288
bd_ver_input = make_configs ["BD_VER" ]
@@ -310,13 +302,12 @@ def parse_config(config):
310
302
current_configs ["core_key" ] = core_key
311
303
current_configs ["parallel" ] = parallel
312
304
current_configs ["osp_root" ] = osp_root
313
- current_configs ["toolchain" ] = {"name" :toolchain , "version" : toolchain_ver }
305
+ current_configs ["toolchain" ] = {"name" : toolchain , "version" : toolchain_ver }
314
306
current_configs ["EXPECTED" ] = expected_file
315
307
current_configs ["COVERITY" ] = coverity
316
308
return current_configs
317
309
318
310
319
-
320
311
def is_embarc_makefile (makefile_path ):
321
312
with open (makefile_path ) as f :
322
313
embarc_root = False
@@ -332,7 +323,6 @@ def is_embarc_makefile(makefile_path):
332
323
return False
333
324
334
325
335
-
336
326
def get_config (config ):
337
327
make_configs = dict ()
338
328
if type (config ) == list :
@@ -347,7 +337,6 @@ def get_config(config):
347
337
return make_configs
348
338
349
339
350
-
351
340
def get_expected_result (expected_file , app_path , board , bd_ver ):
352
341
result = False
353
342
filesuffix = os .path .splitext (expected_file )[1 ]
@@ -372,21 +361,20 @@ def get_expected_result(expected_file, app_path, board, bd_ver):
372
361
return result
373
362
374
363
375
-
376
364
def send_pull_request_comment (columns , results ):
377
365
job = os .environ .get ("NAME" )
378
366
pr_number = os .environ .get ("TRAVIS_PULL_REQUEST" )
379
367
if all ([job , pr_number ]):
380
368
comment_job = "## " + job + "\n "
381
- if len (results )> 0 :
369
+ if len (results ) > 0 :
382
370
head = "|" .join (columns ) + "\n "
383
- table_format = "|" .join (["---" ]* len (columns )) + "\n "
384
- table_head = head + table_format
371
+ table_format = "|" .join (["---" ]* len (columns )) + "\n "
372
+ table_head = head + table_format
385
373
comments = ""
386
374
comment = ""
387
375
for result in results :
388
376
for k in result :
389
- comment += (k .replace (Fore .RED , "" )).replace ("\n " , "<br>" ) + " |"
377
+ comment += (k .replace (Fore .RED , "" )).replace ("\n " , "<br>" ) + " |"
390
378
comment = comment .rstrip ("|" ) + "\n "
391
379
comments += comment
392
380
comment_on_pull_request (comment_job + table_head + comments )
@@ -397,7 +385,7 @@ def send_pull_request_comment(columns, results):
397
385
398
386
399
387
def show_results (results , expected = None ):
400
- columns = [ 'TOOLCHAIN' ,"TOOLCHAIN_VER" , 'APP' , 'CONF' , 'PASS' ]
388
+ columns = ['TOOLCHAIN' , "TOOLCHAIN_VER" , 'APP' , 'CONF' , 'PASS' ]
401
389
failed_pt = PrettyTable (columns )
402
390
failed_results = []
403
391
success_results = []
@@ -476,7 +464,6 @@ def build_result_combine(results=None, formal_result=None):
476
464
return formal_result
477
465
478
466
479
-
480
467
def get_apps (path ):
481
468
result = []
482
469
for root , dirs , files in os .walk (path ):
@@ -506,7 +493,6 @@ def build_result_combine_tail(results):
506
493
return results_list
507
494
508
495
509
-
510
496
def get_applications (config ):
511
497
app_paths = None
512
498
if "EXAMPLES" in config and config ["EXAMPLES" ]:
@@ -519,7 +505,6 @@ def get_applications(config):
519
505
return app_paths
520
506
521
507
522
-
523
508
def startBuild (app , config , builder ):
524
509
525
510
for opt in build .BUILD_OPTION_NAMES :
@@ -533,15 +518,14 @@ def startBuild(app, config, builder):
533
518
534
519
# builder.build_target(app, target=str("clean"), parallel=config["PARALLEL"])
535
520
if os .environ .get ("COVERITY" , None ) == "true" :
536
- build_status = builder .build_target (app , target = str ("all" ), parallel = config ["PARALLEL" ], coverity = True , silent = True ) # builder.get_build_size(app, parallel=config["PARALLEL"], silent = True)
537
-
521
+ build_status = builder .build_target (app , target = str ("all" ), parallel = config ["PARALLEL" ], coverity = True , silent = True )
538
522
else :
539
- build_status = builder .get_build_size (app , parallel = config ["PARALLEL" ], silent = True )
523
+ build_status = builder .get_build_size (app , parallel = config ["PARALLEL" ], silent = True )
540
524
541
525
board = builder .buildopts .get ("BOARD" )
542
526
bd_ver = builder .buildopts .get ("BD_VER" )
543
527
core = builder .buildopts .get ("CUR_CORE" )
544
- build_conf = board + "_" + bd_ver + "_" + core
528
+ build_conf = board + "_" + bd_ver + "_" + core
545
529
546
530
build_status ["commit_sha" ] = os .environ .get ("CI_COMMIT_SHA" ) or os .environ .get ("TRAVIS_COMMIT" )
547
531
build_status ["JOB" ] = os .environ .get ("CI_JOB_NAME" ) or os .environ .get ("NAME" )
@@ -550,7 +534,6 @@ def startBuild(app, config, builder):
550
534
return build_status
551
535
552
536
553
-
554
537
def BuildApp (app , config ):
555
538
556
539
BuildOptions = config ["make_options" ]
@@ -581,7 +564,7 @@ def BuildApp(app, config):
581
564
CurrentBuildConfig [core_key ] = cur_core
582
565
CurrentBuildConfig ["TOOLCHAIN" ] = toolchain ["name" ]
583
566
CurrentBuildConfig ["TOOLCHAIN_VER" ] = toolchain ["version" ]
584
- CurrentBuildConfig ["PARALLEL" ] = None if parallel == "" else parallel
567
+ CurrentBuildConfig ["PARALLEL" ] = None if parallel == "" else parallel
585
568
586
569
build_status = startBuild (app , CurrentBuildConfig , builder )
587
570
if not app_build_status .get (app , None ):
@@ -616,12 +599,10 @@ def BuildApp(app, config):
616
599
return app_build_results , expected_different , app_build_status
617
600
618
601
619
-
620
-
621
602
def comment_on_pull_request (comment ):
622
603
623
604
pr_number = os .environ .get ("TRAVIS_PULL_REQUEST" )
624
- slug = os .environ .get ("TRAVIS_REPO_SLUG" )
605
+ slug = os .environ .get ("TRAVIS_REPO_SLUG" )
625
606
token = os .environ .get ("GH_TOKEN" )
626
607
request_config = [pr_number , slug , token , comment ]
627
608
for i in range (len (request_config )):
@@ -636,15 +617,14 @@ def comment_on_pull_request(comment):
636
617
return response .json ()
637
618
638
619
639
-
640
620
def get_options_parser ():
641
621
configs = dict ()
642
622
toolchainlist = ["gnu" , "mw" ]
643
623
boardlist = ["emsk" , "nsim" , "axs" , "hsdk" ]
644
624
parser = argparse .ArgumentParser ()
645
625
parser .add_argument ("--osp_root" , dest = "osp_root" , default = "." , help = ("the path of embarc_osp" ), metavar = "OSP_ROOT" )
646
- parser .add_argument ("--toolchain" , dest = "toolchain" , default = None , help = ("build using the given TOOLCHAIN (%s)" % ', ' .join (toolchainlist )), metavar = "TOOLCHAIN" )
647
- parser .add_argument ("--board" , dest = "board" , default = None , help = ("build using the given BOARD (%s)" % ', ' .join (boardlist )), metavar = "BOARD" )
626
+ parser .add_argument ("--toolchain" , dest = "toolchain" , default = None , help = ("build using the given TOOLCHAIN (%s)" % ', ' .join (toolchainlist )), metavar = "TOOLCHAIN" )
627
+ parser .add_argument ("--board" , dest = "board" , default = None , help = ("build using the given BOARD (%s)" % ', ' .join (boardlist )), metavar = "BOARD" )
648
628
parser .add_argument ("--bd_ver" , dest = "bd_ver" , default = None , help = ("build using the given BOARD VERSION" ), metavar = "BOARD VERSION" )
649
629
parser .add_argument ("--core" , dest = "cur_core" , default = None , help = ("build using the given core" ), metavar = "CUR_CORE" )
650
630
parser .add_argument ("--toolchain_ver" , dest = "toolchain_ver" , default = None , help = ("build using the given toolchian verion" ), metavar = "TOOLCHAIN_VER" )
@@ -716,11 +696,12 @@ def main(config):
716
696
comment_on_pull_request (comment )
717
697
sys .exit (1 )
718
698
699
+
719
700
if __name__ == '__main__' :
720
701
721
702
cwd_path = os .getcwd ()
722
703
osp_path = os .path .dirname (cwd_path )
723
704
make_config = get_config (sys .argv [1 :])
724
705
with cd (osp_path ):
725
706
main (make_config )
726
- print ("The end" )
707
+ print ("The end" )
0 commit comments