7 from datetime import datetime
8 from buildutils.builder import Device, Compiler, Axis, Step, BuildStep, RunModelStep, Builder, Filter
10 OPTIMIZATION = [ 'O1', 'O2', 'Ofast', 'Os', 'Oz' ]
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" } }
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" ]
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()) ]
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']))
118 cmd.appendOutput("Storing results failed!");
121 def add_options(step, config, cmd):
122 cmd._options['optimize'] = CC_OPT[config['compiler']][config['optimize']]
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.")
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
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
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']]
144 filterAC5 = Filter().addAxis(compilerAxis, Compiler.AC5).addAxis(deviceAxis, "CM[23]3*")
145 filterAC6LTM = Filter().addAxis(compilerAxis, Compiler.AC6LTM).addAxis(deviceAxis, "CM[23]3*")
148 builder.addAxis([ compilerAxis, deviceAxis, optimizeAxis ])
149 builder.addStep([ buildStep, runStep, debugStep ])
150 builder.addFilter([ filterAC5, filterAC6LTM ])
154 def complete(builder, success):
155 builder.saveJunitResult("build_{now}.junit".format(now = datetime.now().strftime("%Y%m%d%H%M%S")))