]> begriffs open source - cmsis/blob - CMSIS/CoreValidation/Examples/DS-MDK/build.py
CoreValidation: Fixed DS-MDK projects and added build script.
[cmsis] / CMSIS / CoreValidation / Examples / DS-MDK / build.py
1 #! python
2
3 import sys
4 from argparse import ArgumentParser
5 from datetime import datetime
6
7 sys.path.append('../../../Utilities/buildutils') 
8
9 from fvpcmd import FvpCmd 
10 from testresult import TestResult
11
12 DEVICE_A5  = 'Cortex-A5'
13 DEVICE_A7  = 'Cortex-A7'
14 DEVICE_A9  = 'Cortex-A9'
15
16 CC_AC6 = 'AC6'
17 CC_AC5 = 'AC5'
18 CC_GCC = 'GCC'
19
20 TARGET_FVP = 'FVP'
21
22 DEVICES = [ DEVICE_A5, DEVICE_A7, DEVICE_A9 ]
23 COMPILERS = [ CC_AC5, CC_AC6, CC_GCC ]
24 TARGETS = [ TARGET_FVP ]
25
26 SKIP = [ 
27   ]
28
29 DEVICE_ABREV = {
30   DEVICE_A5 : 'CA5',
31   DEVICE_A7 : 'CA7',
32   DEVICE_A9 : 'CA9'
33 }
34   
35 APP_FORMAT = {
36   CC_AC6: "axf",
37   CC_AC5: "axf",
38   CC_GCC: "elf"
39 }
40   
41 FVP_MODELS = { 
42     DEVICE_A5   : { 'cmd': "fvp_ve_cortex-a5x1.exe",  'args': { 'limit': "5000000" } },
43     DEVICE_A7   : { 'cmd': "fvp_ve_cortex-a7x1.exe",  'args': { 'limit': "5000000" } },
44     DEVICE_A9   : { 'cmd': "fvp_ve_cortex-a9x1.exe",  'args': { 'limit': "5000000" } }
45   }
46
47 def isSkipped(dev, cc, target):
48   for skip in SKIP:
49     skipDev = (skip[0] == None or skip[0] == dev)
50     skipCc = (skip[1] == None or skip[1] == cc)
51     skipTarget = (skip[2] == None or skip[2] == target)
52     if skipDev and skipCc and skipTarget:
53       return True
54   return False
55
56 def prepare(steps, args):
57   for dev in args.devices:
58     for cc in args.compilers:
59       for target in args.targets:
60         if not isSkipped(dev, cc, target):
61           config = "{dev} ({cc}, {target})".format(dev = dev, cc = cc, target = target)
62           prefix = "{dev}_{cc}_{target}".format(dev = dev, cc = cc, target = target)
63           build = None
64           binary = "{dev}/{cc}/Debug/CMSIS_CV_{abrev}_{cc}.{format}".format(dev = dev, abrev = DEVICE_ABREV[dev], cc = cc, format = APP_FORMAT[cc])
65           test = FvpCmd(FVP_MODELS[dev]['cmd'], binary, **FVP_MODELS[dev]['args'])
66           steps += [ { 'name': config, 'prefix': prefix, 'build': build, 'test': test } ]
67
68 def execute(steps):
69   for step in steps:
70     print step['name']
71     if step['build']:
72       step['build'].run()
73     else:
74       print "Skipping build"
75       
76     if (not step['build']) or step['build'].isSuccess():
77       step['test'].run()
78       step['result'] = TestResult(step['test'].getOutput())
79       step['result'].saveXml("result_{0}_{1}.xml".format(step['prefix'], datetime.now().strftime("%Y%m%d%H%M%S")))
80     else:
81       print "Skipping test"
82       
83 def printSummary(steps):
84   print ""
85   print "Test Summary"
86   print "============"
87   print
88   print "Test run                       Total Exec  Pass  Fail  "
89   print "-------------------------------------------------------"
90   for step in steps:
91     try:
92       print "{0:30} {1:>4}  {2:>4}  {3:>4}  {4:>4}".format(step['name'], *step['result'].getSummary())
93     except:
94       print "{0:30} ------ NO RESULTS ------".format(step['name'])
95
96 def main(argv):
97   parser = ArgumentParser()
98   parser.add_argument('-d', '--devices', nargs='*', choices=DEVICES, default=DEVICES, help = 'Devices to be considered.')
99   parser.add_argument('-c', '--compilers', nargs='*', choices=COMPILERS, default=COMPILERS, help = 'Compilers to be considered.')
100   parser.add_argument('-t', '--targets', nargs='*', choices=TARGETS, default=TARGETS, help = 'Targets to be considered.')
101   args = parser.parse_args()
102     
103   steps = []
104
105   prepare(steps, args)
106   
107   execute(steps)
108   
109   printSummary(steps)
110   
111 if __name__ == "__main__":
112   main(sys.argv[1:])