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' ]
30 Device.CM0 : { 'cmd': "FVP_MPS2_Cortex-M0", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM0_config.txt" } },
31 Device.CM0PLUS : { 'cmd': "FVP_MPS2_Cortex-M0plus", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM0plus_config.txt" } },
32 Device.CM3 : { 'cmd': "FVP_MPS2_Cortex-M3", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM3_config.txt" } },
33 Device.CM4 : { 'cmd': "FVP_MPS2_Cortex-M4", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM4_config.txt" } },
34 Device.CM4FP : { 'cmd': "FVP_MPS2_Cortex-M4", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM4FP_config.txt" } },
35 Device.CM7 : { 'cmd': "FVP_MPS2_Cortex-M7", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM7_config.txt" } },
36 Device.CM7SP : { 'cmd': "FVP_MPS2_Cortex-M7", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM7SP_config.txt" } },
37 Device.CM7DP : { 'cmd': "FVP_MPS2_Cortex-M7", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM7DP_config.txt" } },
38 Device.CM23 : { 'cmd': "FVP_MPS2_Cortex-M23", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM23_config.txt", 'target': "cpu0" } },
39 Device.CM33 : { 'cmd': "FVP_MPS2_Cortex-M33", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM33_config.txt", 'target': "cpu0" } },
40 Device.CM23NS : { 'cmd': "FVP_MPS2_Cortex-M23", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM23_TZ_config.txt", 'target': "cpu0" } },
41 Device.CM33NS : { 'cmd': "FVP_MPS2_Cortex-M33", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM33_DSP_FP_TZ_config.txt", 'target': "cpu0" } },
42 Device.CM23S : { 'cmd': "FVP_MPS2_Cortex-M23", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM23_TZ_config.txt", 'target': "cpu0" } },
43 Device.CM33S : { 'cmd': "FVP_MPS2_Cortex-M33", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCM33_DSP_FP_TZ_config.txt", 'target': "cpu0" } },
44 Device.CA5 : { 'cmd': "FVP_VE_Cortex-A5x1", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA5_config.txt" } },
45 Device.CA7 : { 'cmd': "FVP_VE_Cortex-A7x1", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA7_config.txt" } },
46 Device.CA9 : { 'cmd': "FVP_VE_Cortex-A9x1", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA9_config.txt" } },
47 Device.CA5NEON : { 'cmd': "FVP_VE_Cortex-A5x1", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA5neon_config.txt" } },
48 Device.CA7NEON : { 'cmd': "FVP_VE_Cortex-A7x1", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA7neon_config.txt" } },
49 Device.CA9NEON : { 'cmd': "FVP_VE_Cortex-A9x1", 'args': { 'timeout': 60, 'limit': "1000000000", 'config': "config/ARMCA9neon_config.txt" } }
52 def projects(step, config):
53 rtebuild = str(config['compiler']).lower()+".rtebuild"
56 def images(step, config):
57 binary = "build/arm{dev}/arm{dev}.elf".format(dev=config['device'].value[1].lower())
60 def storeResult(step, config, cmd):
61 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"))
62 resultfile = step.storeJunitResult(cmd, result, "{cc}.{dev}.{opt}".format(dev=config['device'], cc=config['compiler'], opt=config['optimize']))
64 cmd.appendOutput("Storing results failed!");
67 def add_options(step, config, cmd):
68 cmd._options['optimize'] = config['optimize']
71 deviceAxis = Axis("device", abbrev="d", values=Device, desc="Device(s) to be considered.")
72 compilerAxis = Axis("compiler", abbrev="c", values=Compiler, desc="Compiler(s) to be considered.")
73 optimizeAxis = Axis("optimize", abbrev="o", values=OPTIMIZATION , desc="Optimization level(s) to be considered.")
75 buildStep = BuildStep("build", abbrev="b", desc="Build the selected configurations.")
76 buildStep.projects = projects
77 buildStep.target = lambda step, config: "arm"+config['device'].value[1].lower()
78 buildStep.pre = add_options
80 runStep = RunModelStep("run", abbrev="r", desc="Run the selected configurations.")
81 runStep.images = images
82 runStep.model = lambda step, config: FVP_MODELS[config['device']]
83 runStep.post = storeResult
85 debugStep = RunModelStep("debug", abbrev="d", desc="Debug the selected configurations.")
86 debugStep.images = images
87 debugStep.args = lambda step, config: { 'cadi' : True }
88 debugStep.model = lambda step, config: FVP_MODELS[config['device']]
90 filterAC5 = Filter().addAxis(compilerAxis, Compiler.AC5).addAxis(deviceAxis, "CM[23]3*")
91 filterAC6LTM = Filter().addAxis(compilerAxis, Compiler.AC6LTM).addAxis(deviceAxis, "CM[23]3*")
94 builder.addAxis([ compilerAxis, deviceAxis, optimizeAxis ])
95 builder.addStep([ buildStep, runStep, debugStep ])
96 builder.addFilter([ filterAC5, filterAC6LTM ])
100 def complete(builder, success):
101 builder.saveJunitResult("build_{now}.junit".format(now = datetime.now().strftime("%Y%m%d%H%M%S")))