]> begriffs open source - cmsis/blob - CMSIS/CoreValidation/Tests/builder.py
CoreValidation: Fixed AC6 assembler and linker flags for Cortex-M targets.
[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 ]
66
67 BOOTLOADER = [
68   Device.CM23NS,
69   Device.CM33NS
70 ]
71
72 FVP_MODELS = {
73   Device.CM0      : { 'cmd': "FVP_MPS2_Cortex-M0",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM0_config.txt"     } },
74   Device.CM0PLUS  : { 'cmd': "FVP_MPS2_Cortex-M0plus",  'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM0plus_config.txt" } },
75   Device.CM3      : { 'cmd': "FVP_MPS2_Cortex-M3",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM3_config.txt"     } },
76   Device.CM4      : { 'cmd': "FVP_MPS2_Cortex-M4",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM4_config.txt"     } },
77   Device.CM4FP    : { 'cmd': "FVP_MPS2_Cortex-M4",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM4FP_config.txt"   } },
78   Device.CM7      : { 'cmd': "FVP_MPS2_Cortex-M7",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM7_config.txt"     } },
79   Device.CM7SP    : { 'cmd': "FVP_MPS2_Cortex-M7",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM7SP_config.txt"   } },
80   Device.CM7DP    : { 'cmd': "FVP_MPS2_Cortex-M7",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM7DP_config.txt"   } },
81   Device.CM23     : { 'cmd': "FVP_MPS2_Cortex-M23",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM23_config.txt",           'target': "cpu0" } },
82   Device.CM33     : { 'cmd': "FVP_MPS2_Cortex-M33",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM33_config.txt",           'target': "cpu0" } },
83   Device.CM23NS   : { 'cmd': "FVP_MPS2_Cortex-M23",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM23_TZ_config.txt",        'target': "cpu0" } },
84   Device.CM33NS   : { 'cmd': "FVP_MPS2_Cortex-M33",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM33_DSP_FP_TZ_config.txt", 'target': "cpu0" } },
85   Device.CM23S    : { 'cmd': "FVP_MPS2_Cortex-M23",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM23_TZ_config.txt",        'target': "cpu0" } },
86   Device.CM33S    : { 'cmd': "FVP_MPS2_Cortex-M33",     'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM33_DSP_FP_TZ_config.txt", 'target': "cpu0" } },
87   Device.CA5      : { 'cmd': "FVP_VE_Cortex-A5x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA5_config.txt" } },
88   Device.CA7      : { 'cmd': "FVP_VE_Cortex-A7x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA7_config.txt" } },
89   Device.CA9      : { 'cmd': "FVP_VE_Cortex-A9x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA9_config.txt" } },
90   Device.CA5NEON  : { 'cmd': "FVP_VE_Cortex-A5x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA5neon_config.txt" } },
91   Device.CA7NEON  : { 'cmd': "FVP_VE_Cortex-A7x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA7neon_config.txt" } },
92   Device.CA9NEON  : { 'cmd': "FVP_VE_Cortex-A9x1",      'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA9neon_config.txt" } }
93 }
94
95 def projects(step, config):
96   result = [ str(config['compiler']).lower()+".rtebuild" ]
97   if config['device'] in BOOTLOADER:
98     result += [ "bootloader/"+str(config['compiler']).lower()+".rtebuild" ]
99   return result
100
101 def images(step, config):
102   result = [ "build/arm{dev}/arm{dev}.elf".format(dev=config['device'].value[1].lower()) ]
103   if config['device'] in BOOTLOADER:
104     result += [ "bootloader/build/arm{dev}/arm{dev}.elf".format(dev=config['device'].value[1].lower()) ]
105   return result
106
107 def storeResult(step, config, cmd):
108   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"))
109   resultfile = step.storeJunitResult(cmd, result, "{cc}.{dev}.{opt}".format(dev=config['device'], cc=config['compiler'], opt=config['optimize']))
110   if not resultfile:
111     cmd.appendOutput("Storing results failed!");
112     cmd.forceResult(1)
113
114 def add_options(step, config, cmd):
115   cmd._options['optimize']  = CC_OPT[config['compiler']][config['optimize']]
116
117 def create():
118   deviceAxis = Axis("device", abbrev="d", values=Device, desc="Device(s) to be considered.")
119   compilerAxis = Axis("compiler", abbrev="c", values=Compiler, desc="Compiler(s) to be considered.")
120   optimizeAxis = Axis("optimize", abbrev="o", values=OPTIMIZATION , desc="Optimization level(s) to be considered.")
121
122   buildStep = BuildStep("build", abbrev="b", desc="Build the selected configurations.")
123   buildStep.projects = projects
124   buildStep.target = lambda step, config: "arm"+config['device'].value[1].lower()
125   buildStep.pre = add_options
126
127   runStep = RunModelStep("run", abbrev="r", desc="Run the selected configurations.")
128   runStep.images = images
129   runStep.model = lambda step, config: FVP_MODELS[config['device']]
130   runStep.post = storeResult
131
132   debugStep = RunModelStep("debug", abbrev="d", desc="Debug the selected configurations.")
133   debugStep.images = images
134   debugStep.args = lambda step, config: { 'cadi' : True, 'timeout': None }
135   debugStep.model = lambda step, config: FVP_MODELS[config['device']]
136   
137   filterAC5 = Filter().addAxis(compilerAxis, Compiler.AC5).addAxis(deviceAxis, "CM[23]3*")
138   filterAC6LTM = Filter().addAxis(compilerAxis, Compiler.AC6LTM).addAxis(deviceAxis, "CM[23]3*")
139
140   builder = Builder()
141   builder.addAxis([ compilerAxis, deviceAxis, optimizeAxis ])
142   builder.addStep([ buildStep, runStep, debugStep ])
143   builder.addFilter([ filterAC5, filterAC6LTM ])
144
145   return builder
146
147 def complete(builder, success):
148   builder.saveJunitResult("build_{now}.junit".format(now = datetime.now().strftime("%Y%m%d%H%M%S")))