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' ]
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" } }
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" ]
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()) ]
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']))
111 cmd.appendOutput("Storing results failed!");
114 def add_options(step, config, cmd):
115 cmd._options['optimize'] = CC_OPT[config['compiler']][config['optimize']]
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.")
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
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
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']]
137 filterAC5 = Filter().addAxis(compilerAxis, Compiler.AC5).addAxis(deviceAxis, "CM[23]3*")
138 filterAC6LTM = Filter().addAxis(compilerAxis, Compiler.AC6LTM).addAxis(deviceAxis, "CM[23]3*")
141 builder.addAxis([ compilerAxis, deviceAxis, optimizeAxis ])
142 builder.addStep([ buildStep, runStep, debugStep ])
143 builder.addFilter([ filterAC5, filterAC6LTM ])
147 def complete(builder, success):
148 builder.saveJunitResult("build_{now}.junit".format(now = datetime.now().strftime("%Y%m%d%H%M%S")))