forked from joelsherrill/rtems-cron-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtems-cron-runner.py
executable file
·927 lines (779 loc) · 26.6 KB
/
rtems-cron-runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
#! /usr/bin/python
"""
Example Usage:
- python rtems-cron-runner.py -v -f -w
- build it verbosely, force build with default version (6 in this case)
- python rtems-cron-runner.py -v -f -g -V 5
- build it verbosely, force build, do git update, use version 5
"""
from __future__ import print_function
import datetime
import logging
import os
import subprocess
import sys
import time
from shutil import rmtree
from optparse import OptionParser
starting_directory = os.getcwd()
sys.path.insert(1, starting_directory + '/rtemstoolkit')
from rtemstoolkit import git
script_start = datetime.datetime.now()
description = '''Runs all of the build tests'''
# if build bsp fails, there will be a b.log that needs to be mailed
parser = OptionParser(
usage='usage: %prog [OPTIONS]',
description=description,
add_help_option=False
)
parser.add_option(
'-v',
'--verbose',
dest='verbose',
action='store_true',
default=False,
help='verbose (default=no)'
)
parser.add_option(
'-f',
'--force-build',
dest='force_build',
action='store_true',
default=False,
help='force build (default=no)'
)
parser.add_option(
'-g',
'--git-update',
dest='git',
action='store_true',
default=False,
help='do git update (default=no)'
)
parser.add_option(
'-D',
dest='top',
default=os.environ['HOME']+'/rtems-cron',
help='Top directory (default=${HOME}/rtems-cron'
)
parser.add_option(
'-V',
dest='version',
default='6',
help='RTEMS Version (default=6)'
)
parser.add_option(
'-w',
'--waf-build',
dest='waf_build',
default=False,
action='store_true',
help='Build using the WAF build system (default=no)'
)
parser.add_option(
'-m',
'--send-email',
dest='send_email',
action='store_true',
default=False,
help='send email (default=no)'
)
parser.add_option(
'-F',
dest='from_addr',
default='[email protected]',
help='From address ([email protected])'
)
parser.add_option(
'-T',
dest='to_addr',
default='[email protected]',
help='To address ([email protected])'
)
parser.add_option(
'-S',
dest='build_in_steps',
default=False,
action='store_true',
help='Build in steps (default=no)'
)
parser.add_option(
'-s',
dest='start_step',
default=1,
help='Step to start executing at (default=1)'
)
parser.add_option(
'-e',
dest='end_step',
default=1,
help='Step to stop executing at (default=1)'
)
parser.add_option(
'-l',
dest='log_path',
default=os.environ['HOME'] + '/rtems-cron',
help='Path to log file (default=$HOME/rtems-cron)'
)
parser.add_option(
'-h',
'--help',
dest='help',
default=False,
action='store_true'
)
parser.add_option(
'-z',
dest='testing',
default=False,
action='store_true',
)
(options, args) = parser.parse_args(sys.argv)
# if the user wants to see the help menu
if options.help:
print('Usage: rtems-cron-runner [OPTIONS]\n')
print('Options:')
print(' -h, --help Show this help message and exit')
print(' -v, --verbose Verbose (default=no)')
print(' -f, --force-build Force build (default=no)')
print(' -g, --git-update Do git update (default=no)')
print(' -D TOP Top directory (default=${HOME}/rtems-cron)')
print(' -V VERSION RTEMS Version (default=6)')
print(' -w, --waf-build Build using the WAF build system (default=no)')
print(' -m, --send-email Send email (default=no)')
print(' -T TO_ADDR To address ([email protected])')
print(' -F FROM_ADDR From address ([email protected])')
print(' -l LOG_PATH Path to log file (default-${HOME}/rtems-cron)')
print(' -S BUILD_IN_STEPS Build in steps (default=no)')
print(' -s START_STEP Step to start executing at (default=1)')
print(' -e END_STEP Step to stop executing at (default=1)\n\n')
print('Steps:')
print(' 1. Build basic cross compilation tools')
print(' 2. Build device tree compiler')
print(' 3. Build Spike RISC-V simulator')
print(' 4. Build Qemu4 Simulator')
print(' 5. Bootstrap')
print(' 6. Test the BSPs')
print(' 7. Build the bsets')
print(' 8. Build the BSPs')
print('\nNOTE: Some steps may be skipped if the \'-f\' option is not used.')
sys.exit(0)
testing = options.testing # don't run the code, just print out what would run
# Helps us do the build process in steps
step = int(options.start_step)
steps = {
'build_tools' : [1, 'building tools'],
'build_dtc' : [2, 'building device tree compiler'],
'build_spike' : [3, 'building RISC-V Simulator'],
'build_qemu' : [4, 'building Qemu4 Simulator'],
'bootstrap' : [5, 'bootstrapping'],
'test_bsps' : [6, 'testing the BSPs'],
'build_bsets' : [7, 'buildings the bsets'],
'build_bsps' : [8, 'building the BSPs']
}
# create log file
logging.basicConfig(
filename=options.log_path,
level=logging.DEBUG,
format='%(levelname)s:%(asctime)s:%(message)s'
)
def info(string):
logging.info(string)
def log(status, msg):
if status == 0:
logging.info('PASSED ' + msg)
else:
logging.error('FAILED(' + str(status) + ') ' + msg)
def vprint(string):
if options.verbose:
print(string)
else:
return
def step_done(key):
try:
vprint('Done with step {} ({})'.format(steps[key][0], steps[key][1]))
except KeyError:
output = '{} is not a key in the steps dictionary'.format(key)
print(output, file=sys.stderr)
info(output)
def cmd_exists(cmd):
return any(
os.access(os.path.join(path, cmd), os.X_OK)
for path in os.environ["PATH"].split(os.pathsep)
)
def exedir():
os.chdir(starting_directory)
return os.getcwd()
def yes_or_no(val):
if val:
return 'yes'
else:
return 'no'
master_version = '6'
# verify that Top directory exists
if not os.path.isdir(options.top):
print('The top directory, ' + options.top + \
', does not exist.', file=sys.stderr
)
print('Run rtems-cron-prepdir.py before this script!', file=sys.stderr)
sys.exit(1)
os.chdir(options.top)
# verify that arguments make sense
# make sure that end step is not less than start steps
if options.build_in_steps and options.start_step >= options.end_step:
print(
'When building in steps, ensure that start step is less than end step!',
file=sys.stderr
)
sys.exit(1)
# RTEMS5 did not have the WAF build system
if options.version == '5' and options.waf_build:
print('WAF was not the build system used with RTEMS 5.', file=sys.stderr)
sys.exit(1)
rsb_updated = False
rtems_updated = False
# this only works if it was created by rtems-cron-prepdir.py
if os.path.isdir(options.top + '/rtems') and \
os.path.isdir(options.top + '/rtems-source-builder'):
# if the directories were gotten from git, they may be updated
if options.git:
# ensure that git was used to get these directories
if '.git' in os.listdir(options.top + '/rtems') and \
os.listdir(options.top + '/rtems-source-builder'):
os.chdir('./rtems-source-builder')
rsb_repo = git.repo(os.getcwd())
# determine what branch we're on and determine if we need to checkout a
# different one
if (rsb_repo.branch() != options.version) and \
(options.version != master_version):
try:
rsb_repo.checkout(options.version)
except:
print('An error occured when trying to checkout branch ' + \
options.version + '...'
)
sys.exit(1)
rsb_repo.fetch()
if options.version == master_version:
result = rsb_repo._run(['rev-list', 'HEAD...master', '--count'])
else:
result = rsb_repo._run([
'rev-list', 'HEAD...' + options.version, '--count'])
result = int(result[1]) # the number of revisions behind
info('RSB had {} revision(s) to update'.format(result))
if result != 0:
vprint('Pulling rtems_source_builder...')
rsb_repo.pull()
rsb_updated = True
vprint('Done...')
os.chdir('../rtems')
rtems_repo = git.repo(os.getcwd())
# determine what branch we're on and determine if we need to checkout a
# different one
if (rtems_repo.branch() != options.version) and \
(options.version != master_version):
try:
rtems_repo.checkout(options.version)
except:
print('An error occured when trying to checkout branch ' + \
options.version + '...'
)
sys.exit(1)
rtems_repo.fetch()
if options.version == master_version:
result = rtems_repo._run(['rev-list', 'HEAD...master', '--count'])
else:
result = rtems_repo._run([
'rev-list', 'HEAD...' + options.version, '--count'])
result = int(result[1]) # the number of revisions behind
info('rtems had {} revision(s) to update'.format(result))
if result != 0:
vprint('Pulling rtems...')
rtems_repo.pull()
rtems_updated = True
vprint('Done...')
os.chdir('..')
else:
print(
'All \'.git\' directories not present. Clean up and rerun prepdir!',
file=sys.stderr
)
sys.exit(1)
# if the user wants to force an update
if options.force_build:
rsb_updated = True
rtems_updated = True
if options.verbose:
print('Forcing builds whether or not there are updates')
vprint('Git Update: ' + yes_or_no(options.git))
vprint('Forced Update: ' + yes_or_no(options.force_build))
vprint('RSB Updated: ' + yes_or_no(rsb_updated))
vprint('RTEMS Updated: ' + yes_or_no(rtems_updated))
# nothing to be done if everything is up to date
if not options.force_build and \
not rsb_updated and \
not rtems_updated:
print('No updates and forced build not requested -- NOACTION!')
sys.exit(0)
# build the tools
def do_rsb_build_tools(version):
# Basic Cross-compilation Tools
os.chdir(options.top + '/rtems-source-builder/rtems')
# clean the install point
if os.path.isdir(options.top + '/tools'):
vprint('Removing tools...')
rmtree(options.top + '/tools')
if not os.path.isfile('./config/' + str(version) + '/rtems-all.bset'):
print(options.top + '/rtems-source-builder/rtems/config/' + \
str(version) + '/rtems-all.bset', end='', file=sys.stderr)
print(' does not exist.', file=sys.stderr)
sys.exit(1)
# remove the trailing '\n'
with open('./config/' + str(version) + '/rtems-all.bset') as f:
rset = [line.rstrip() for line in f]
# rset = [str(options.version) + '/rtems-sparc']
start_time = time.time()
result = 0
for r in rset:
call_beg_time = time.time()
rcpu = r.split('-')[1]
if testing:
print(
'\ntime ../source-builder/sb-set-builder ' +\
'--mail --mail-to=' + options.to_addr + \
' --mail-from=' + options.from_addr + \
' --keep-going ' +\
'--log=l-' + rcpu + '-' + version + '.txt ' +\
'--prefix=' + options.top + '/tools/' + version + ' ' +\
r + ' >o-' + rcpu + '-' + version + '.txt 2>&1\n' \
)
else:
# if step is in range, or the build isn't being ran in steps
if step <= steps['build_tools'] or not options.build_in_steps:
vprint('Building the tools for ' + rcpu + '...')
file_name = 'o-' + rcpu + '-' + str(version) + '.txt'
outfile = open(file_name, 'w')
if options.send_email:
ARGS = [
'../source-builder/sb-set-builder',
'--mail',
'--mail-to=' + options.to_addr,
'--mail-from=' + options.from_addr,
'--keep-going',
'--log=l-' + rcpu + '-' + version,
'--prefix=' + options.top + '/tools/' + version,
r
]
else:
ARGS = [
'../source-builder/sb-set-builder',
'--keep-going',
'--log=l-' + rcpu + '-' + version,
'--prefix=' + options.top + '/tools/' + version,
r
]
result = subprocess.call(ARGS,stdout=outfile, stderr=outfile)
outfile.close()
log(result, 'RSB build of ' + r)
call_end_time = time.time()
vprint('Done...')
vprint('Building the tools for ' + rcpu + ' took ' + \
str(call_end_time - call_beg_time) + ' seconds...'
)
end_time = time.time()
# figure out how to display this in minutes or something
vprint('\n\nBuilding all of the tools took ' + \
str(end_time - start_time) + ' seconds.'
)
# if the basic cross-compilation of the tools failed
if result != 0:
print('RSB build of RTEMS ' + version + ' Tools failed. ', file=sys.stderr)
sys.exit(1)
# if we are at the end step, end it, if not increase step
if options.build_in_steps:
step_done('build_tools')
if step == options.end_step:
sys.exit(0)
else:
step += 1
# Device Tree Compiler
start_time = time.time()
os.chdir(options.top + '/rtems-source-builder/bare')
if testing:
print(
'\n../source-builder/sb-set-builder ' + \
'--mail --mail-to=' + options.to_addr + \
'--mail-from=' + options.from_addr + \
' --log=l-dtc-' + options.version +'.txt' +\
'--prefix=' + options.top + '/tools/' + version +\
' devel/dtc >l-dtc-' + options.version + '.txt 2>&1\n'
)
else:
if step <= steps['build_dtc'] or not options.build_in_steps:
vprint('Running the device tree compiler...')
file_name = 'l-dtc' + version + '.txt'
outfile = open(file_name, 'w')
# if the user wants an email to be sent
if options.send_email:
ARGS = [
'../source-builder/sb-set-builder',
'--mail',
'--mail-to=' + options.to_addr,
'--mail-from=' + options.from_addr,
'--log=l-dtc-' + version + '.txt',
'--prefix=' + options.top + '/tools/' + version,
'devel/dtc'
]
else:
ARGS = [
'../source-builder/sb-set-builder',
'--log=l-dtc-' + version + '.txt',
'--prefix=' + options.top + '/tools/' + version,
'devel/dtc'
]
result = subprocess.call(ARGS ,stdout=outfile, stderr=outfile)
outfile.close()
log(result, 'RSB build of devel/dtc')
end_time = time.time()
vprint(
'Running the device tree compiler took ' + \
str(end_time - start_time) + ' seconds.'
)
# if building the device tree compiler failed
if result != 0:
print('Running the device tree compiler failed. ', file=sys.stderr)
sys.exit(1)
# if building in steps, check if the script needs to end or if step needs
# incrementing
if options.build_in_steps:
step_done('build_dtc')
if step == options.end_step:
sys.exit(0)
else:
step += 1
# Spike RISC-V Simulator
start_time = time.time()
os.chdir(options.top + '/rtems-source-builder/bare')
if testing:
print(
'\n../source-builder/sb-set-builder ' + \
'--mail --mail-to=' + options.to_addr + \
'--mail-from=' + options.from_addr + \
'--log=l-spike-' + version + '.txt' + \
'--prefix=' + options.top + '/tools/' + version + \
'devel/spike >l-spike-' + version + '.txt 2>&1\n'
)
else:
if step <= steps['build_spike'] or not options.build_in_steps:
vprint('Running the Spike RISC-V Simulator...')
file_name = 'l-spike' + version + '.txt'
outfile = open(file_name, 'w')
if options.send_email:
ARGS = [
'../source-builder/sb-set-builder',
'--mail',
'--mail-to=' + options.to_addr,
'--mail-from=' + options.from_addr,
'--log=l-dtc-' + version + '.txt',
'--prefix=' + options.top + '/tools/' + version,
'devel/dtc'
]
else:
ARGS = [
'../source-builder/sb-set-builder',
'--log=l-spike-' + version + '.txt',
'--prefix=' + options.top + '/tools/' + version,
'devel/spike'
]
result = subprocess.call(ARGS, stdout=outfile, stderr=outfile)
outfile.close()
log(result, 'RSB build of devel/spike')
end_time = time.time()
vprint(
'Running the Spike RISC-V Simulator took ' + \
str(end_time - start_time) + ' seconds.'
)
# if building the Spike RISC-V Simulator failed
if result != 0:
print('Running the Spike RISC-V Simulator failed. ', file=sys.stderr)
sys.exit(1)
if options.build_in_steps:
step_done('build_spike')
if step == options.end_step:
sys.exit(0)
else:
step += 1
# Qemu Simulator
start_time = time.time()
os.chdir(options.top + '/rtems-source-builder/bare')
if testing:
print(
'\n../source-builder/sb-set-builder ' + \
'--mail --mail-to=' + options.to_addr + \
'--mail-from=' + options.from_addr + \
' --log=l-qemu-' + version + '.txt' + \
'--prefix=' + options.top + '/tools/' + version + \
'devel/qemu4 >l-qemu4-' + version + '.txt 2>&1\n'
)
else:
if step <= steps['build_qemu'] or not options.build_in_steps:
vprint('Running the Qemu Simulator...')
file_name = 'l-qemu4-' + version + '.txt'
outfile = open(file_name, 'w')
if options.send_email:
ARGS = [
'../source-builder/sb-set-builder',
'--mail',
'--mail-to=' + options.to_addr,
'--mail-from=' + options.from_addr,
'--log=l-qemu-' + version + '.txt',
'--prefix=' + options.top + '/tools/' + version,
'devel/qemu4'
]
else:
ARGS = [
'../source-builder/sb-set-builder',
'--log=l-qemu-' + version + '.txt',
'--prefix=' + options.top + '/tools/' + version,
'devel/qemu4'
]
result = subprocess.call(ARGS, stdout=outfile, stderr=outfile)
outfile.close()
log(result, 'RSB build of devel/qemu4')
end_time = time.time()
vprint(
'Running Qemu Simulator took ' + \
str(end_time - start_time) + ' seconds.'
)
# if building the Qemu 4 simulator failed
if result != 0:
print('Running the Qemu 4 simulator failed. ', file=sys.stderr)
sys.exit(1)
if options.build_in_steps:
step_done('build_qemu')
if step == options.end_step:
sys.exit(0)
else:
step += 1
def do_bsp_builder():
start_time = time.time()
if testing:
print(
'\n' + options.top + '/rtems-tools/tester/rtems-bsp-builder ' + \
'--rtems=' + options.top + '/rtems ' + \
'--build-path=' + options.top + '/build ' + \
'--prefix=' + options.top + '/tools/' + options.version + '/bsps ' + \
'--log=build.log ' + \
'--warnings-report=warnings.log ' + \
'--mail --mail-to=' + options.to_addr + \
'--mail-from=' + options.from_addr + \
' --profiles=everything'
)
else:
vprint('Running BSP builder...')
result = subprocess.call([
options.top + '/rtems-tools/tester/rtems-bsp-builder',
'--rtems=' + options.top + '/rtems',
'--build-path=' + options.top + '/build',
'--prefix=' + options.top + '/tools/' + options.version + '/bsps',
'--log=build.log',
'--warnings-report=warnings.log',
'--mail',
'--mail-to=' + options.to_addr,
'--mail-from=' + options.from_addr,
'--profiles=everything',
])
end_time = time.time()
vprint('BSP builder took ' + str(end_time - start_time) + ' seconds.')
log(result, 'rtems-bsp-builder build of everything')
if result != 0:
print('BSP builder failed. ', file=sys.stderr)
sys.exit(1)
# double check this
addition = options.top + '/tools/' + str(options.version) + '/bin:'
os.environ['PATH'] = addition + os.environ['PATH']
# Build RTEMS ${version}.x tools if needed
if rsb_updated:
do_rsb_build_tools(str(options.version)) # I don't think I need this, double-check
if rtems_updated:
os.chdir(options.top + '/rtems')
if testing:
print('./bootstrap -c')
else:
if step <= steps['bootstrap'] or not options.build_in_steps:
result = subprocess.call(['./bootstrap', '-c'])
if result != 0:
print('The bootstrapping of RTEMS failed.')
log(result, 'The bootstrapping of RTEMS failed')
sys.exit(1)
# Ensure this is after the RSB has built tools and PATH is updated
# Check that rtems-bootstrap exists, is readable, and executable
if not os.path.isfile('./rtems-bootstrap') or \
not os.access('./rtems-bootstrap', os.R_OK) or \
not os.access('./rtems-bootstrap', os.X_OK):
print('This is not an RTEMS version this script supports.')
sys.exit(0)
else:
if testing:
print('./rtems-bootstrap')
else:
result = subprocess.call(['./rtems-bootstrap'])
log(result, 'rtems-bootstrap')
if result != 0:
print('rtems-bootstrap failed. ', file=sys.stderr)
sys.exit(1)
if options.build_in_steps:
step_done('bootstrap')
if step == options.end_step:
sys.exit(0)
else:
step += 1
def generate_arguments(build_system, cpu_and_bsp, SMP_ARG):
BB_ARGS = [build_system, '-T', options.top, '-v', '-r']
# add the mailing flag
if options.send_email:
BB_ARGS.append('-m')
BB_ARGS.append('-t')
ARGS1 = [exedir() + '/build_bsp', '-V', options.version] + BB_ARGS
SMP = "NOSMP"
# if SMP arg is given, add it
if SMP_ARG != '':
ARGS1 += SMP_ARG
SMP = 'SMP'
ARGS2 = ARGS1.copy()
ARGS1 += cpu_and_bsp
ARGS2.append('-D')
ARGS2 += cpu_and_bsp
ARGS = [ARGS1, ARGS2]
return ARGS
def test_single_bsp(cpu, bsp, SMP_ARG=''):
if SMP_ARG != ''
if cmd_exists(cpu + '-rtems' + options.version + '-gcc') or testing:
arch_and_bsp = [cpu, bsp]
# (NO DEBUG) if this RTEMS version has a autoconf build, then build it that way
if 'configure.ac' in os.listdir(options.top + '/rtems'):
AC_ARGS = generate_arguments('-a', arch_and_bsp, SMP_ARG)
if testing:
for arg in AC_ARGS[0]:
print(arg, end=' ')
print()
else:
result = subprocess.call(AC_ARGS[0])
log(result, 'autoconf build of {} {} ({}/NODEBUG)'.format(cpu, bsp, SMP))
# (NO DEBUG) if this RTEMS version has a waf build, then build it that way
if 'waf' in os.listdir(options.top + '/rtems'):
WAF_ARGS = generate_arguments('-w', arch_and_bsp, SMP_ARG)
if testing:
for arg in WAF_ARGS[0]:
print(arg, end=' ')
print()
else:
result = subprocess.call(WAF_ARGS[0])
log(result, 'waf build of {} {} ({}/NODEBUG)'.format(cpu, bsp, SMP))
# (DEBUG) if this RTEMS version has a autoconf build, then build it that way
if 'configure.ac' in os.listdir(options.top + '/rtems'):
if testing:
for arg in AC_ARGS[1]:
print(arg, end=' ')
print()
else:
result = subprocess.call(AC_ARGS[1])
log(result, 'autoconf build of {} {} ({}/DEBUG)'.format(cpu, bsp, SMP))
# (DEBUG) if this RTEMS version has a waf build, then build it that way
if 'waf' in os.listdir(options.top + '/rtems'):
if testing:
for arg in WAF_ARGS[1]:
print(arg, end=' ')
print()
else:
result = subprocess.call(WAF_ARGS[1])
log(result, 'waf build of {} {} ({}/DEBUG)'.format(cpu, bsp, SMP))
if result == 0:
prev_dir = os.getcwd()
os.chdir(options.top + '/rtems')
subprocess.call(['./waf', 'distclean'])
os.chdir(prev_dir)
else:
print('WARNING - no gcc for ' + cpu + ' ' + bsp)
if rsb_updated or rtems_updated:
start_time = time.time()
os.chdir(options.top)
if step <= steps['test_bsps'] or not options.build_in_steps:
test_single_bsp('sparc', 'erc32-sis')
test_single_bsp('sparc', 'leon2-sis')
test_single_bsp('sparc', 'leon3-sis')
test_single_bsp('powerpc', 'psim')
test_single_bsp('mips', 'jmr3904')
test_single_bsp('riscv', 'griscv-sis')
test_single_bsp('sparc', 'leon3-sis', '-S')
# Make sure Spike is available for these BSPs
if cmd_exists('spike'):
bsps = ['rv32iac_spike', 'rv32imac_spike', 'rv32imafc_spike',
'rv32imafdc_spike', 'rv32imafd_spike', 'rv32im_spike', 'rv32i_spike',
'rv64imac_medany_spike', 'rv64imac_spike', 'rv64imafdc_medany_spike',
'rv64imafdc_spike', 'rv64imafd_medany', 'rv64imafd_medany_spike',
'rv64imafd_spike'
]
for bsp in bsps:
test_single_bsp('riscv', bsp)
if options.build_in_steps:
step_done('test_bsps')
if step == options.end_step:
sys.exit(0)
else:
step += 1
# Now build all supported BSP bset stacks
os.chdir(options.top + '/rtems-source-builder/rtems')
bsets = ['atsamv', 'beagleboneblack', 'erc32', 'gr712rc', 'gr740', 'imx7',
'pc', 'qoriq_e500', 'qoriq_e6500_32', 'qoriq_e6500_64', 'raspberrypi2',
'xilinx_zynq_zc702', 'xilinx_zynq_zc706', 'xilinx_zynq_zedboard'
]
for bset in bsets:
bset_start_time = time.time()
if testing:
print( \
'../source-builder/sb-set-builder ' + \
'--mail --mail-to=' + options.to_addr + \
'--mail-from=' + options.from_addr + \
' --log=l-' + bset + '-' + options.version + '.txt ' + \
'--prefix=' + options.top + '/tools/' + options.version + ' ' + \
options.version + '/bsps/' + bset + ' ' + \
'>o-' + bset + '-' + options.version + '.txt' + ' 2>&1'
)
else:
if step <= steps['build_bsets'] or not options.build_in_steps:
file_name = 'o-' + bset + '-' + options.version + '.txt'
outfile = open(file_name, 'w')
result = subprocess.call([
'../source-builder/sb-set-builder',
'--mail',
'--mail-to=' + options.to_addr,
'--mail-from=' + options.from_addr,
'--log=l-' + bset + '-' + options.version + '.txt',
'--prefix=' + options.top + '/tools/' + options.version,
options.version + '/bsps/' + bset],
stdout=outfile,
stderr=outfile
)
log(result, 'RSB build of bsps/' + bset)
if options.build_in_steps:
step_done('build_bsets')
if step == options.end_step:
sys.exit(0)
else:
step += 1
bset_end_time = time.time()
print(
'Building all supported BSP bset stacks took' + \
str(bset_end_time - bset_start_time) + ' seconds.'
)
if step <= steps['build_bsps'] or not options.build_in_steps:
do_bsp_builder()
if options.build_in_steps:
step_done('build_bsps')
script_end = datetime.datetime.now()
log('START: {}'.format(script_start))
log('END: {}'.format(script_end))
print('START: ', script_start)
print('END: ', script_end)
sys.exit(0)