Skip to content

Commit f0bd7b1

Browse files
committed
feat: add Ci compiler checks, so that the Ci never uses a version, that it is not supposed to use
1 parent fd17248 commit f0bd7b1

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

tools/options/meson.build

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,95 @@ graphics_lib = {
2323
'deps': [],
2424
}
2525

26+
# check if running in CI, than we only support certain versions, this helps in checking if the Ci installs the correct tool version in e.g. msys2
27+
if get_option('run_in_ci')
28+
29+
c = meson.get_compiler('c')
30+
31+
system_name = host_machine.system()
32+
33+
if meson.is_cross_build()
34+
system_name = 'cross_' + host_machine.system()
35+
36+
endif
37+
38+
ci_config = {
39+
'cross_android': {
40+
'compilers': [['clang', ['>=20', '<21']]],
41+
},
42+
'cross_3ds': {
43+
'compilers': [['clang', ['>=20', '<21']]],
44+
},
45+
'cross_switch': {
46+
'compilers': [['clang', ['>=20', '<21']]],
47+
},
48+
'cross_emscripten': {
49+
'compilers': [['clang', ['>=20', '<21']]],
50+
},
51+
'windows': {
52+
'compilers': [['clang', ['>=20', '<21']]],
53+
},
54+
'linux': {
55+
'compilers': [['clang', ['>=20', '<21']]],
56+
},
57+
'darwin': {
58+
'compilers': [['clang', ['>=20', '<21']]],
59+
},
60+
}
61+
62+
if not ci_config.has_key(system_name)
63+
error('CI config doesn\'t know what to expect from the system "' + system_name + '"')
64+
endif
65+
66+
config_for_system = ci_config.get(system_name)
67+
68+
compilers_for_system = config_for_system.get('compilers', [])
69+
70+
if compilers_for_system.length() == 0
71+
error('Expected the CI config to have at least one compiler')
72+
endif
73+
74+
found_compiler_for_ci_config = false
75+
76+
foreach compiler_for_system : compilers_for_system
77+
compiler_for_system_name = compiler_for_system[0]
78+
version_checks_for_compiler = compiler_for_system[1]
79+
80+
if c.get_id() != compiler_for_system_name
81+
continue
82+
endif
83+
84+
found_compiler_for_ci_config = true
85+
86+
if version_checks_for_compiler.length() == 0
87+
error('Expected the version checks for a compiler to not be empty')
88+
endif
89+
90+
compiler_version = c.version()
91+
92+
foreach version_check_for_compiler : version_checks_for_compiler
93+
94+
if not compiler_version.version_compare(version_check_for_compiler)
95+
error(
96+
'The compiler "' + c.get_id() + '" doesn\'t meet the version check ' + version_check_for_compiler
97+
)
98+
endif
99+
100+
endforeach
101+
102+
103+
endforeach
104+
105+
if not found_compiler_for_ci_config
106+
error(
107+
'Couldn\'t find a valid compiler for the CI config, compiler was: "' + c.get_id() + '"'
108+
)
109+
endif
110+
111+
endif
112+
113+
114+
26115
if meson.is_cross_build() and host_machine.system() == 'serenity'
27116
temp = core_lib.get('compile_args')
28117
temp += ['-D__SERENITY__', '-DINSTALL_FILES', '-DINSTALL_LOCATION=' + get_option('prefix')]

0 commit comments

Comments
 (0)