diff options
| author | star9029 <[email protected]> | 2025-03-01 16:10:36 +0800 |
|---|---|---|
| committer | star9029 <[email protected]> | 2025-03-01 16:10:36 +0800 |
| commit | 7891b045d299686fe743bcdd3aea90eb85c2ce87 (patch) | |
| tree | 55563c07c1503d215ac6923c4cc338e7694dd3fe /xmake/rules/c++/modules/modules_support | |
| parent | a3556e3de438a2e874bf80914c955b822c425562 (diff) | |
Support msstl modules for clang
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
4 files changed, 19 insertions, 16 deletions
diff --git a/xmake/rules/c++/modules/modules_support/builder.lua b/xmake/rules/c++/modules/modules_support/builder.lua index 60e1112d8..a71e2c392 100644 --- a/xmake/rules/c++/modules/modules_support/builder.lua +++ b/xmake/rules/c++/modules/modules_support/builder.lua @@ -235,7 +235,7 @@ function _builder(target) local cachekey = tostring(target) local builder = compiler_support.memcache():get2("builder", cachekey) if builder == nil then - if target:has_tool("cxx", "clang", "clangxx") then + if target:has_tool("cxx", "clang", "clangxx", "clang_cl") then builder = import("clang.builder", {anonymous = true}) elseif target:has_tool("cxx", "gcc", "gxx") then builder = import("gcc.builder", {anonymous = true}) diff --git a/xmake/rules/c++/modules/modules_support/clang/compiler_support.lua b/xmake/rules/c++/modules/modules_support/clang/compiler_support.lua index 56bfb5f25..66714089f 100644 --- a/xmake/rules/c++/modules/modules_support/clang/compiler_support.lua +++ b/xmake/rules/c++/modules/modules_support/clang/compiler_support.lua @@ -247,6 +247,9 @@ function get_clang_scan_deps(target) if program and toolname:startswith("clang") then local dir = path.directory(program) local basename = path.basename(program) + if basename == "clang-cl" then + basename = "clang" + end local extension = path.extension(program) program = (basename:rtrim("+"):gsub("clang", "clang-scan-deps")) .. extension if dir and dir ~= "." and os.isdir(dir) then @@ -284,19 +287,19 @@ function get_stdmodules(target) -- libstdc++ doesn't have a std module file atm elseif cpplib == "msstl" then -- msstl std module file is not compatible with llvm <= 19 - -- local toolchain = target:toolchain("clang") - -- local msvc = import("core.tool.toolchain", {anonymous = true}).load("msvc", {plat = toolchain:plat(), arch = toolchain:arch()}) - -- if msvc then - -- local vcvars = msvc:config("vcvars") - -- if vcvars.VCInstallDir and vcvars.VCToolsVersion then - -- modules = {} - -- - -- local stdmodulesdir = path.join(vcvars.VCInstallDir, "Tools", "MSVC", vcvars.VCToolsVersion, "modules") - -- assert(stdmodulesdir, "Can't enable C++23 std modules, directory missing !") - -- - -- return {path.join(stdmodulesdir, "std.ixx"), path.join(stdmodulesdir, "std.compat.ixx")} - -- end - -- end + local toolchain = target:toolchain("clang") or target:toolchain("clang-cl") + local msvc = import("core.tool.toolchain", {anonymous = true}).load("msvc", {plat = toolchain:plat(), arch = toolchain:arch()}) + if msvc then + local vcvars = msvc:config("vcvars") + if vcvars.VCInstallDir and vcvars.VCToolsVersion then + modules = {} + + local stdmodulesdir = path.join(vcvars.VCInstallDir, "Tools", "MSVC", vcvars.VCToolsVersion, "modules") + assert(stdmodulesdir, "Can't enable C++23 std modules, directory missing !") + + return {path.join(stdmodulesdir, "std.ixx"), path.join(stdmodulesdir, "std.compat.ixx")} + end + end end end wprint("std and std.compat modules not found! maybe try to add --sdk=<PATH/TO/LLVM> or install libc++") diff --git a/xmake/rules/c++/modules/modules_support/compiler_support.lua b/xmake/rules/c++/modules/modules_support/compiler_support.lua index 7c4e665d0..cf64a08bb 100644 --- a/xmake/rules/c++/modules/modules_support/compiler_support.lua +++ b/xmake/rules/c++/modules/modules_support/compiler_support.lua @@ -29,7 +29,7 @@ function _compiler_support(target) local cachekey = tostring(target) local compiler_support = memcache():get2("compiler_support", cachekey) if compiler_support == nil then - if target:has_tool("cxx", "clang", "clangxx") then + if target:has_tool("cxx", "clang", "clangxx", "clang_cl") then compiler_support = import("clang.compiler_support", {anonymous = true}) elseif target:has_tool("cxx", "gcc", "gxx") then compiler_support = import("gcc.compiler_support", {anonymous = true}) diff --git a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/dependency_scanner.lua index 3287628ef..9d552d0fd 100644 --- a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua +++ b/xmake/rules/c++/modules/modules_support/dependency_scanner.lua @@ -31,7 +31,7 @@ function _dependency_scanner(target) local cachekey = tostring(target) local dependency_scanner = compiler_support.memcache():get2("dependency_scanner", cachekey) if dependency_scanner == nil then - if target:has_tool("cxx", "clang", "clangxx") then + if target:has_tool("cxx", "clang", "clangxx", "clang_cl") then dependency_scanner = import("clang.dependency_scanner", {anonymous = true}) elseif target:has_tool("cxx", "gcc", "gxx") then dependency_scanner = import("gcc.dependency_scanner", {anonymous = true}) |
