Skip to content

Commit 24afaa8

Browse files
committed
modules/windows: Also search for llvm-rc and llvm-windres
Fixes #15011
1 parent e0ea239 commit 24afaa8

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

mesonbuild/modules/windows.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,36 @@ def _find_resource_compiler(self, state: 'ModuleState') -> T.Tuple[ExternalProgr
6868
# Take a parameter instead of the hardcoded definition below
6969
for_machine = MachineChoice.HOST
7070

71+
import pdb
72+
pdb.set_trace()
73+
7174
if self._rescomp:
7275
return self._rescomp
7376

7477
# Will try cross / native file and then env var
7578
rescomp = ExternalProgram.from_bin_list(state.environment, for_machine, 'windres')
7679

7780
if not rescomp or not rescomp.found():
81+
def search_programs(names) -> T.Optional[ExternalProgram]:
82+
for name in names:
83+
program = ExternalProgram(name, silent=True)
84+
if program.found():
85+
return program
86+
return None
87+
88+
def find_rc_like_compiler() -> T.Optional[ExternalProgram]:
89+
return search_programs(['rc', 'llvm-rc'])
90+
91+
def find_windres_like_compiler() -> T.Optional[ExternalProgram]:
92+
return search_programs(['windres', 'llvm-windres'])
93+
7894
comp = self.detect_compiler(state.environment.coredata.compilers[for_machine])
7995
if comp.id in {'msvc', 'clang-cl', 'intel-cl'} or (comp.linker and comp.linker.id in {'link', 'lld-link'}):
80-
# Microsoft compilers uses rc irrespective of the frontend
81-
rescomp = ExternalProgram('rc', silent=True)
96+
rescomp = find_rc_like_compiler() or find_windres_like_compiler()
8297
else:
83-
rescomp = ExternalProgram('windres', silent=True)
98+
rescomp = find_windres_like_compiler() or find_rc_like_compiler()
8499

85-
if not rescomp.found():
100+
if not rescomp:
86101
raise MesonException('Could not find Windows resource compiler')
87102

88103
for (arg, match, rc_type) in [

0 commit comments

Comments
 (0)