summaryrefslogtreecommitdiff
path: root/tests/projects/c++/modules
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2025-09-25 17:51:15 +0200
committerArthur LAURENT <[email protected]>2025-09-25 17:51:15 +0200
commitbcc3c5617baad62989a45a44aa2890fda5eba0f3 (patch)
treea1a7afb64d7eb4798eaba2932dc3342e0564cf16 /tests/projects/c++/modules
parentf270a7cf4823d723299bef4999493e25b7ac4f38 (diff)
nfc(C++ modules) apply PR suggestion
Diffstat (limited to 'tests/projects/c++/modules')
-rw-r--r--tests/projects/c++/modules/add_move_remove_module/test.lua4
-rw-r--r--tests/projects/c++/modules/multiple_runtimes/test.lua75
-rw-r--r--tests/projects/c++/modules/multiple_runtimes/xmake.lua39
3 files changed, 66 insertions, 52 deletions
diff --git a/tests/projects/c++/modules/add_move_remove_module/test.lua b/tests/projects/c++/modules/add_move_remove_module/test.lua
index 627688f6c..ad8c4833b 100644
--- a/tests/projects/c++/modules/add_move_remove_module/test.lua
+++ b/tests/projects/c++/modules/add_move_remove_module/test.lua
@@ -5,10 +5,10 @@ CLANG_MIN_VER = is_subhost("windows") and "19" or "17"
GCC_MIN_VER = "11"
MSVC_MIN_VER = "14.29"
-function _build(check_outdata)
+function _build(_)
local flags = ""
if ci_is_running() then
- flags = "-vD"
+ flags = "-vD"
end
os.run("xmake -r " .. flags)
io.writefile("src/bar.mpp", "export module bar;\n export {\n inline int bar() { return 0; }\n}")
diff --git a/tests/projects/c++/modules/multiple_runtimes/test.lua b/tests/projects/c++/modules/multiple_runtimes/test.lua
index 2050445f3..ad2585efa 100644
--- a/tests/projects/c++/modules/multiple_runtimes/test.lua
+++ b/tests/projects/c++/modules/multiple_runtimes/test.lua
@@ -7,61 +7,64 @@ CLANG_MIN_VER = "19"
GCC_MIN_VER = "15"
MSVC_MIN_VER = "14.35"
-function main(_)
- if not is_subhost("windows") and not is_host("linux") then
- return
+function _check_tool_version(name, min_ver)
+ local tool = find_tool(name, {version = true})
+ if not (tool and tool.version and semver.compare(tool.version, min_ver) >= 0) then
+ return false
+ end
+ return true
+end
+
+
+function _check_msvc_version(min_ver)
+ local msvc = toolchain.load("msvc")
+ if not msvc or not msvc:check() then
+ return false
+ end
+ local vcvars = msvc:config("vcvars")
+ if not vcvars or not vcvars.VCInstallDir or not vcvars.VCToolsVersion then
+ return false
+ end
+ local version = vcvars.VCToolsVersion
+ if not version or not (semver.compare(version, min_ver) >= 0) then
+ return false
end
+ return true
+end
+function main(_)
if is_subhost("windows") then
- local msvc = toolchain.load("msvc")
- if not msvc or not msvc:check() then
- wprint("msvc not found, skipping tests")
- return
- end
- local vcvars = msvc:config("vcvars")
- if not vcvars or not vcvars.VCInstallDir or not vcvars.VCToolsVersion then
- wprint("msvc not found, skipping tests")
- return
- end
- local version = vcvars.VCToolsVersion
- if not version or not (semver.compare(version, MSVC_MIN_VER) >= 0) then
+ if not _check_msvc_version(MSVC_MIN_VER) then
return
end
-- on windows, llvm libc++ std module is currently not supported, uncommend when supported
- local clang = find_tool("clang", {version = true})
- if not (clang and clang.version and semver.compare(clang.version, CLANG_MIN_VER) >= 0) then
+ -- if not check_tool_version("clang", CLANG_MIN_VER) then
+ -- return
+ -- end
+ elseif is_host("linux") then
+ if not _check_tool_version("gcc", GCC_MIN_VER) or not _check_tool_version("clang", CLANG_MIN_VER) then
return
end
else
- local gcc = find_tool("gcc", {version = true})
- if not (gcc and gcc.version and semver.compare(gcc.version, GCC_MIN_VER) >= 0) then
- return
- end
- local clang = find_tool("clang", {version = true})
- if not (clang and clang.version and semver.compare(clang.version, CLANG_MIN_VER) >= 0) then
- return
- end
+ return
end
local cl_str = "modules\\std.ixx"
local clang_str = is_host("windows") and "v1\\std.cppm" or "v1/std.cppm"
local gcc_str = "v1/std.cppm"
- local flags = ""
- if ci_is_running() then
- flags = "-vD"
- end
+ local flags = true and "-vD" or ""
local outdata
- outdata = os.iorun("xmake -r " .. flags)
+ outdata = os.iorun("xmake b " .. flags)
if outdata then
- local error = true
+ local success = false
-- on windows, llvm libc++ std module is currently not supported, uncommend when supported
- if is_host("windows") and outdata:find(cl_str, 1, true) and outdata:find(clang_str, 1, true) then
- error = false
- elseif outdata:find(clang_str, 1, true) and outdata:find(gcc_str, 1, true) then
- error = false
+ if is_subhost("windows") then
+ success = outdata:find(cl_str, 1, true) -- and outdata:find(clang_str, 1, true)
+ else
+ success = outdata:find(gcc_str, 1, true) and outdata:find(clang_str, 1, true)
end
- if error then
+ if not success then
raise("Multiple runtimes doesn't work\n%s", outdata)
end
end
diff --git a/tests/projects/c++/modules/multiple_runtimes/xmake.lua b/tests/projects/c++/modules/multiple_runtimes/xmake.lua
index 736079687..f67ab211b 100644
--- a/tests/projects/c++/modules/multiple_runtimes/xmake.lua
+++ b/tests/projects/c++/modules/multiple_runtimes/xmake.lua
@@ -1,29 +1,40 @@
add_rules("mode.debug", "mode.release")
-add_files("src/*.cpp")
set_languages("c++23")
set_encodings("utf-8")
-target("llvm")
- set_kind("binary")
- set_toolchains("clang")
- set_runtimes("c++_shared")
- set_policy("build.c++.modules", true)
- add_files("src/main.cpp")
+if is_plat("windows") then
+ -- on windows, llvm libc++ std module is currently not supported, uncommend when supported
+ -- target("llvm")
+ -- set_kind("binary")
+ -- set_toolchains("clang")
+ -- set_runtimes("c++_shared")
+ -- set_policy("build.c++.modules", true)
+ -- add_files("src/main.cpp")
-if is_plat("linux") or is_plat("mingw") then
- target("gnu")
+ target("llvm-msvc")
set_kind("binary")
- set_toolchains("gcc")
- set_runtimes("stdc++_shared")
+ set_toolchains("clang")
set_policy("build.c++.modules", true)
- set_policy("build.c++.modules.gcc.cxx11abi", true)
add_files("src/main.cpp")
-end
-if is_plat("windows") then
target("msvc")
set_kind("binary")
set_toolchains("msvc")
set_policy("build.c++.modules", true)
add_files("src/main.cpp")
+else
+ target("llvm")
+ set_kind("binary")
+ set_toolchains("clang")
+ set_runtimes("c++_shared")
+ set_policy("build.c++.modules", true)
+ add_files("src/main.cpp")
+
+ target("gnu")
+ set_kind("binary")
+ set_toolchains("gcc")
+ set_runtimes("stdc++_shared")
+ set_policy("build.c++.modules", true)
+ set_policy("build.c++.modules.gcc.cxx11abi", true)
+ add_files("src/main.cpp")
end