@@ -259,52 +259,53 @@ end
259259function get_stdmodules (target )
260260
261261 if target :policy (" build.c++.modules.std" ) then
262- local cpplib = _get_cpplibrary_name (target )
263- if cpplib then
264- if cpplib == " c++" then
265- -- libc++ module is found by parsing libc++.modules.json
266- local modules_json_path = _get_std_module_manifest_path (target )
267- if modules_json_path then
268- local modules_json = json .decode (io .readfile (modules_json_path ))
269- if modules_json and modules_json .modules and # modules_json .modules > 0 then
270- local std_module_directory = path .directory (modules_json .modules [1 ][" source-path" ])
271- if not path .is_absolute (std_module_directory ) then
272- std_module_directory = path .join (path .directory (modules_json_path ), std_module_directory )
273- end
274- if os .isdir (std_module_directory ) then
275- return {path .normalize (path .join (std_module_directory , " std.cppm" )), path .normalize (path .join (std_module_directory , " std.compat.cppm" ))}
276- end
262+ return
263+ end
264+ local cpplib = _get_cpplibrary_name (target )
265+ if cpplib then
266+ if cpplib == " c++" then
267+ -- libc++ module is found by parsing libc++.modules.json
268+ local modules_json_path = _get_std_module_manifest_path (target )
269+ if modules_json_path then
270+ local modules_json = json .decode (io .readfile (modules_json_path ))
271+ if modules_json and modules_json .modules and # modules_json .modules > 0 then
272+ local std_module_directory = path .directory (modules_json .modules [1 ][" source-path" ])
273+ if not path .is_absolute (std_module_directory ) then
274+ std_module_directory = path .join (path .directory (modules_json_path ), std_module_directory )
275+ end
276+ if os .isdir (std_module_directory ) then
277+ return {path .normalize (path .join (std_module_directory , " std.cppm" )), path .normalize (path .join (std_module_directory , " std.compat.cppm" ))}
277278 end
278279 end
279- elseif cpplib == " stdc++ " then
280- -- dont be greedy and don't enable stdc++ std module support for llvm < 19
281- local clang_version = get_clang_version ( target )
282- if clang_version and semver . compare ( clang_version , " 19.0 " ) >= 0 then
283- return import ( " .gcc.support " ). get_stdmodules ( target , { warn = false })
284- end
285- elseif cpplib == " msstl " then
286- -- msstl std module file is not compatible with llvm < 19
287- local clang_version = get_clang_version ( target )
288- if clang_version and semver . compare ( clang_version , " 19.0 " ) >= 0 then
289- local toolchain = target : toolchain ( " llvm " ) or target : toolchain ( " clang " ) or target : toolchain ( " clang-cl " )
290- local msvc = import ( " core.tool. toolchain" , { anonymous = true }). load ( " msvc " , { plat = toolchain : plat (), arch = toolchain : arch ()} )
291- if msvc and msvc : check ({ ignore_sdk = true }) then
292- local vcvars = msvc :config ( " vcvars " )
293- if vcvars . VCInstallDir and vcvars . VCToolsVersion then
294- local stdmodulesdir = path . join ( vcvars .VCInstallDir , " Tools " , " MSVC " , vcvars .VCToolsVersion , " modules " )
295- if os . isdir ( stdmodulesdir ) then
296- return { path . normalize ( path . join ( stdmodulesdir , " std.ixx " )), path . normalize ( path . join ( stdmodulesdir , " std.compat.ixx " ))}
297- end
280+ end
281+ elseif cpplib == " stdc++" then
282+ -- dont be greedy and don't enable stdc++ std module support for llvm < 19
283+ local clang_version = get_clang_version ( target )
284+ if clang_version and semver . compare ( clang_version , " 19.0 " ) >= 0 then
285+ return import ( " .gcc.support " ). get_stdmodules ( target , { dont_warn = true })
286+ end
287+ elseif cpplib == " msstl" then
288+ -- msstl std module file is not compatible with llvm < 19
289+ local clang_version = get_clang_version ( target )
290+ if clang_version and semver . compare ( clang_version , " 19.0 " ) >= 0 then
291+ local toolchain = target : toolchain ( " llvm " ) or target : toolchain ( " clang " ) or target : toolchain ( " clang-cl " )
292+ local msvc = import ( " core.tool.toolchain " , { anonymous = true }). load ( " msvc" , { plat = toolchain : plat (), arch = toolchain : arch ()})
293+ if msvc and msvc :check ({ ignore_sdk = true }) then
294+ local vcvars = msvc : config ( " vcvars" )
295+ if vcvars .VCInstallDir and vcvars .VCToolsVersion then
296+ local stdmodulesdir = path . join ( vcvars . VCInstallDir , " Tools " , " MSVC " , vcvars . VCToolsVersion , " modules " )
297+ if os . isdir ( stdmodulesdir ) then
298+ return { path . normalize ( path . join ( stdmodulesdir , " std.ixx " )), path . normalize ( path . join ( stdmodulesdir , " std.compat.ixx " ))}
298299 end
299300 end
300- else
301- wprint (" msstl std module file is not compatible with llvm < 19, please upgrade clang/clang-cl version!" )
302- return
303301 end
302+ else
303+ wprint (" msstl std module file is not compatible with llvm < 19, please upgrade clang/clang-cl version!" )
304+ return
304305 end
305306 end
306- wprint (" std and std.compat modules not found! maybe try to add --sdk=<PATH/TO/LLVM> or install libc++" )
307307 end
308+ wprint (" std and std.compat modules not found! maybe try to add --sdk=<PATH/TO/LLVM> or install libc++" )
308309end
309310
310311function get_bmi_extension ()
0 commit comments