@@ -75,14 +75,28 @@ def _find_resource_compiler(self, state: 'ModuleState') -> T.Tuple[ExternalProgr
7575 rescomp = ExternalProgram .from_bin_list (state .environment , for_machine , 'windres' )
7676
7777 if not rescomp or not rescomp .found ():
78+ def search_programs (names ) -> T .Optional [ExternalProgram ]:
79+ for name in names :
80+ program = ExternalProgram (name , silent = True )
81+ if program .found ():
82+ return program
83+ return None
84+
85+ def find_rc_like_compiler () -> T .Optional [ExternalProgram ]:
86+ return search_programs (['rc' , 'llvm-rc' ])
87+
88+ def find_windres_like_compiler () -> T .Optional [ExternalProgram ]:
89+ # LLVM always provides 'llvm-windres' and 'llvm-rc'. 'windres' is provided
90+ # only if LLVM was built with -D LLVM_INSTALL_BINUTILS_SYMLINKS=ON
91+ return search_programs (['windres' , 'llvm-windres' ])
92+
7893 comp = self .detect_compiler (state .environment .coredata .compilers [for_machine ])
7994 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 )
95+ rescomp = find_rc_like_compiler () or find_windres_like_compiler ()
8296 else :
83- rescomp = ExternalProgram ( 'windres' , silent = True )
97+ rescomp = find_windres_like_compiler () or find_rc_like_compiler ( )
8498
85- if not rescomp . found () :
99+ if not rescomp :
86100 raise MesonException ('Could not find Windows resource compiler' )
87101
88102 for (arg , match , rc_type ) in [
0 commit comments