]> begriffs open source - cmsis/blob - CMSIS/CoreValidation/Tests/builder.py
Pack: Bump version numbers and histories for release 5.5.1.
[cmsis] / CMSIS / CoreValidation / Tests / builder.py
1 #! python
2
3 import os
4 import shutil
5 import sys
6
7 from datetime import datetime
8 from buildutils.builder import Device, Compiler, Axis, Step, BuildStep, RunModelStep, Builder, Filter
9
10 OPTIMIZATION = [ 'O1', 'O2', 'Ofast', 'Os', 'Oz' ]
11
12 CC_OPT = {
13   Compiler.AC5: {
14     'O1': 'O0', 
15     'O2': 'O1', 
16     'Ofast': 'Otime', 
17     'Os': 'O2', 
18     'Oz': 'O3'
19   },
20   Compiler.AC6: {
21     'O1': 'O1', 
22     'O2': 'O2', 
23     'Ofast': 'Ofast', 
24     'Os': 'Os', 
25     'Oz': 'Oz'
26   },
27   Compiler.AC6LTM: {
28     'O1': 'O1', 
29     'O2': 'O2', 
30     'Ofast': 'Ofast', 
31     'Os': 'Os', 
32     'Oz': 'Oz'
33   },
34   Compiler.AC6STBL: {
35     'O1': 'O1', 
36     'O2': 'O2', 
37     'Ofast': 'Ofast', 
38     'Os': 'Os', 
39     'Oz': 'Oz'
40   },
41   Compiler.GCC: {
42     'O1': 'O1', 
43     'O2': 'O2', 
44     'Ofast': 'Ofast', 
45     'Os': 'Os', 
46     'Oz': 'O3'
47   },
48 }
49
50 CORTEX_M = [
51   Device.CM0,
52   Device.CM0PLUS,
53   Device.CM3,
54   Device.CM4,
55   Device.CM4FP,
56   Device.CM7,
57   Device.CM7SP,
58   Device.CM7DP,
59   Device.CM23,
60   Device.CM33,
61   Device.CM23NS,
62   Device.CM33NS,
63   Device.CM23S,
64   Device.CM33S,
65   Device.CM35P,
66   Device.CM35PS,
67   Device.CM35PNS
68 ]
69
70 BOOTLOADER = [
71   Device.CM23NS,
72   Device.CM33NS,
73   Device.CM35PNS
74 ]
75
76 FVP_MODELS = {
77   Device.CM0         : { 'cmd': "FVP_MPS2_Cortex-M0",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM0_config.txt"     } },
78   Device.CM0PLUS     : { 'cmd': "FVP_MPS2_Cortex-M0plus",  'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM0plus_config.txt" } },
79   Device.CM3         : { 'cmd': "FVP_MPS2_Cortex-M3",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM3_config.txt"     } },
80   Device.CM4         : { 'cmd': "FVP_MPS2_Cortex-M4",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM4_config.txt"     } },
81   Device.CM4FP       : { 'cmd': "FVP_MPS2_Cortex-M4",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM4FP_config.txt"   } },
82   Device.CM7         : { 'cmd': "FVP_MPS2_Cortex-M7",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM7_config.txt"     } },
83   Device.CM7SP       : { 'cmd': "FVP_MPS2_Cortex-M7",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM7SP_config.txt"   } },
84   Device.CM7DP       : { 'cmd': "FVP_MPS2_Cortex-M7",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM7DP_config.txt"   } },
85   Device.CM23        : { 'cmd': "FVP_MPS2_Cortex-M23",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM23_config.txt",            'target': "cpu0" } },
86   Device.CM33        : { 'cmd': "FVP_MPS2_Cortex-M33",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM33_config.txt",            'target': "cpu0" } },
87   Device.CM23NS      : { 'cmd': "FVP_MPS2_Cortex-M23",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM23_TZ_config.txt",         'target': "cpu0" } },
88   Device.CM33NS      : { 'cmd': "FVP_MPS2_Cortex-M33",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM33_DSP_FP_TZ_config.txt",  'target': "cpu0" } },
89   Device.CM23S       : { 'cmd': "FVP_MPS2_Cortex-M23",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM23_TZ_config.txt",         'target': "cpu0" } },
90   Device.CM33S       : { 'cmd': "FVP_MPS2_Cortex-M33",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM33_DSP_FP_TZ_config.txt",  'target': "cpu0" } },
91   Device.CM35P       : { 'cmd': "FVP_MPS2_Cortex-M35P",    'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM35P_config.txt",           'target': "cpu0" } },
92   Device.CM35PS      : { 'cmd': "FVP_MPS2_Cortex-M35P",    'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM35P_DSP_FP_TZ_config.txt", 'target': "cpu0" } },
93   Device.CM35PNS     : { 'cmd': "FVP_MPS2_Cortex-M35P",    'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM35P_DSP_FP_TZ_config.txt", 'target': "cpu0" } },
94   Device.CA5         : { 'cmd': "FVP_VE_Cortex-A5x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA5_config.txt" } },
95   Device.CA7         : { 'cmd': "FVP_VE_Cortex-A7x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA7_config.txt" } },
96   Device.CA9         : { 'cmd': "FVP_VE_Cortex-A9x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA9_config.txt" } },
97   Device.CA5NEON     : { 'cmd': "FVP_VE_Cortex-A5x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA5neon_config.txt" } },
98   Device.CA7NEON     : { 'cmd': "FVP_VE_Cortex-A7x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA7neon_config.txt" } },
99   Device.CA9NEON     : { 'cmd': "FVP_VE_Cortex-A9x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA9neon_config.txt" } }
100 }
101
102 def projects(step, config):
103   result = [ str(config['compiler']).lower()+".rtebuild" ]
104   if config['device'] in BOOTLOADER:
105     result += [ "bootloader/"+str(config['compiler']).lower()+".rtebuild" ]
106   return result
107
108 def images(step, config):
109   result = [ "build/arm{dev}/arm{dev}.elf".format(dev=config['device'].value[1].lower()) ]
110   if config['device'] in BOOTLOADER:
111     result += [ "bootloader/build/arm{dev}/arm{dev}.elf".format(dev=config['device'].value[1].lower()) ]
112   return result
113
114 def storeResult(step, config, cmd):
115   result = "result_{cc}_{dev}_{opt}_{now}.junit".format(dev=config['device'], cc=config['compiler'], opt=config['optimize'],now=datetime.now().strftime("%Y%m%d%H%M%S"))
116   resultfile = step.storeJunitResult(cmd, result, "{cc}.{dev}.{opt}".format(dev=config['device'], cc=config['compiler'], opt=config['optimize']))
117   if not resultfile:
118     cmd.appendOutput("Storing results failed!");
119     cmd.forceResult(1)
120
121 def add_options(step, config, cmd):
122   cmd._options['optimize']  = CC_OPT[config['compiler']][config['optimize']]
123
124 def create():
125   deviceAxis = Axis("device", abbrev="d", values=Device, desc="Device(s) to be considered.")
126   compilerAxis = Axis("compiler", abbrev="c", values=Compiler, desc="Compiler(s) to be considered.")
127   optimizeAxis = Axis("optimize", abbrev="o", values=OPTIMIZATION , desc="Optimization level(s) to be considered.")
128
129   buildStep = BuildStep("build", abbrev="b", desc="Build the selected configurations.")
130   buildStep.projects = projects
131   buildStep.target = lambda step, config: "arm"+config['device'].value[1].lower()
132   buildStep.pre = add_options
133
134   runStep = RunModelStep("run", abbrev="r", desc="Run the selected configurations.")
135   runStep.images = images
136   runStep.model = lambda step, config: FVP_MODELS[config['device']]
137   runStep.post = storeResult
138
139   debugStep = RunModelStep("debug", abbrev="d", desc="Debug the selected configurations.")
140   debugStep.images = images
141   debugStep.args = lambda step, config: { 'cadi' : True, 'timeout': None }
142   debugStep.model = lambda step, config: FVP_MODELS[config['device']]
143   
144   filterAC5 = Filter().addAxis(compilerAxis, Compiler.AC5).addAxis(deviceAxis, "CM[23]3*")
145   filterAC6LTM = Filter().addAxis(compilerAxis, Compiler.AC6LTM).addAxis(deviceAxis, "CM[23]3*")
146
147   builder = Builder()
148   builder.addAxis([ compilerAxis, deviceAxis, optimizeAxis ])
149   builder.addStep([ buildStep, runStep, debugStep ])
150   builder.addFilter([ filterAC5, filterAC6LTM ])
151
152   return builder
153
154 def complete(builder, success):
155   builder.saveJunitResult("build_{now}.junit".format(now = datetime.now().strftime("%Y%m%d%H%M%S")))