]> begriffs open source - cmsis/blob - CMSIS/Core/Test/build.py
IAR compiler abstraction fixes
[cmsis] / CMSIS / Core / Test / build.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 import logging
5
6 from datetime import datetime
7 from enum import Enum
8
9 from matrix_runner import main, matrix_axis, matrix_action, matrix_command, matrix_filter, \
10     FileReport, JUnitReport
11
12
13 @matrix_axis("device", "d", "Device(s) to be considered.")
14 class DeviceAxis(Enum):
15     CM0 = ('Cortex-M0', 'CM0')
16     CM0plus = ('Cortex-M0plus', 'CM0plus')
17     CM3 = ('Cortex-M3', 'CM3')
18     CM4 = ('Cortex-M4', 'CM4')
19     CM4FP = ('Cortex-M4FP', 'CM4FP')
20     CM7 = ('Cortex-M7', 'CM7')
21     CM7SP = ('Cortex-M7SP', 'CM7SP')
22     CM7DP = ('Cortex-M7DP', 'CM7DP')
23     CM23 = ('Cortex-M23', 'CM23')
24     CM23S = ('Cortex-M23S', 'CM23S')
25     CM23NS = ('Cortex-M23NS', 'CM23NS')
26     CM33 = ('Cortex-M33', 'CM33')
27     CM33S = ('Cortex-M33S', 'CM33S')
28     CM33NS = ('Cortex-M33NS', 'CM33NS')
29     CM35P = ('Cortex-M35P', 'CM35P')
30     CM35PS = ('Cortex-M35PS', 'CM35PS')
31     CM35PNS = ('Cortex-M35PNS', 'CM35PNS')
32     CM55 = ('Cortex-M55', 'CM55')
33     CM55S = ('Cortex-M55S', 'CM55S')
34     CM55NS = ('Cortex-M55NS', 'CM55NS')
35     CM85 = ('Cortex-M85', 'CM85')
36     CM85S = ('Cortex-M85S', 'CM85S')
37     CM85NS = ('Cortex-M85NS', 'CM85NS')
38     CA5 = ('Cortex-A5', 'CA5')
39     CA7 = ('Cortex-A7', 'CA7')
40     CA9 = ('Cortex-A9', 'CA9')
41     CA5NEON = ('Cortex-A5neon', 'CA5neon')
42     CA7NEON = ('Cortex-A7neon', 'CA7neon')
43     CA9NEON = ('Cortex-A9neon', 'CA9neon')
44
45
46 @matrix_axis("compiler", "c", "Compiler(s) to be considered.")
47 class CompilerAxis(Enum):
48     AC6 = ('AC6')
49     GCC = ('GCC')
50     IAR = ('IAR')
51     CLANG = ('Clang')
52
53
54 @matrix_axis("optimize", "o", "Optimization level(s) to be considered.")
55 class OptimizationAxis(Enum):
56     NONE = ('none')
57     BALANCED = ('balanced')
58     SPEED = ('speed')
59     SIZE = ('size')
60
61
62 def timestamp():
63     return datetime.now().strftime('%Y%m%d%H%M%S')
64
65
66 @matrix_action
67 def lit(config, results, extra_args = None):
68     """Run tests for the selected configurations using llvm's lit."""
69     yield run_lit(config.compiler[0], config.device[1], config.optimize[0], extra_args)
70     results[0].test_report.write(f"lit-{config.compiler[0]}-{config.optimize[0]}-{config.device[1]}-{timestamp()}.xunit")
71
72
73 def timestamp():
74     return datetime.now().strftime('%Y%m%d%H%M%S')
75
76
77 @matrix_command(test_report=FileReport(f"lit.xml") | JUnitReport())
78 def run_lit(toolchain, device, optimize, extra_args = None):
79     if not extra_args:
80         extra_args = ["src"]    
81     return ["lit", "--xunit-xml-output", f"lit.xml", "-D", f"toolchain={toolchain}", "-D", f"device={device}", "-D", f"optimize={optimize}"]+extra_args
82
83
84 if __name__ == "__main__":
85     main()