summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2024-02-02 14:20:55 +0100
committerArthur LAURENT <[email protected]>2024-02-02 14:20:55 +0100
commit99197a6ffd65bebd814845033548e4012875c313 (patch)
treeaa0dda3e2267ce4c1034c38a6c4dabd7d413baf0 /xmake/rules/c++/modules/modules_support
parente449836c75d31664d14ad237c65d8416447bbf87 (diff)
support libc++ std module
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
-rw-r--r--xmake/rules/c++/modules/modules_support/clang/compiler_support.lua26
1 files changed, 19 insertions, 7 deletions
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 64bd70dd1..3005621d0 100644
--- a/xmake/rules/c++/modules/modules_support/clang/compiler_support.lua
+++ b/xmake/rules/c++/modules/modules_support/clang/compiler_support.lua
@@ -20,6 +20,8 @@
-- imports
import("core.base.semver")
+import("core.base.option")
+import("core.base.json")
import("lib.detect.find_tool")
import(".compiler_support", {inherit = true})
@@ -142,8 +144,8 @@ function get_clang_path(target)
local clang_path = _g.clang_path
if not clang_path then
local program, toolname = target:tool("cxx")
- if program and (toolname == "clang" or toolname == "clangxx") then
- local clang = find_tool("clang", {program = program})
+ if program and toolname:startswith("clang") then
+ local clang = find_tool(toolname, {program = program})
if clang then
clang_path = clang.program
end
@@ -159,8 +161,8 @@ function get_clang_version(target)
local clang_version = _g.clang_version
if not clang_version then
local program, toolname = target:tool("cxx")
- if program and (toolname == "clang" or toolname == "clangxx") then
- local clang = find_tool("clang", {program = program, version = true})
+ if program and toolname:startswith("clang") then
+ local clang = find_tool(toolname, {program = program, version = true})
if clang then
clang_version = clang.version
end
@@ -176,7 +178,7 @@ function get_clang_scan_deps(target)
local clang_scan_deps = _g.clang_scan_deps
if not clang_scan_deps then
local program, toolname = target:tool("cxx")
- if program and (toolname == "clang" or toolname == "clangxx") then
+ if program and toolname:startswith("clang") then
local dir = path.directory(program)
local basename = path.basename(program)
local extension = path.extension(program)
@@ -201,7 +203,18 @@ function get_stdmodules(target)
local cpplib = _get_cpplibrary_name(target)
if cpplib then
if cpplib == "c++" then
- -- TODO support libc++ std module file when https://github.com/xmake-io/xmake/pull/4630
+ local clang_path = path.directory(get_clang_path(target))
+ local clang_lib_path = path.normalize(path.join(clang_path, "..", "lib"))
+ local modules_json_path = os.files(path.join(clang_lib_path, "**.modules.json"))[1]
+ if modules_json_path then
+ local modules_json = json.decode(io.readfile(modules_json_path))
+
+ local std_module_directory = path.directory(modules_json.modules[1]["source-path"])
+ if not path.is_absolute(std_module_directory) then
+ std_module_directory = path.join(path.directory(modules_json_path), std_module_directory)
+ end
+ return {path.join(std_module_directory, "std.cppm"), path.join(std_module_directory, "std.compat.cppm")}
+ end
elseif cpplib == "stdc++" then
-- libstdc++ doesn't have a std module file atm
elseif cpplib == "msstl" then
@@ -222,7 +235,6 @@ function get_stdmodules(target)
end
end
end
- return {}
end
function get_bmi_extension()