summaryrefslogtreecommitdiff
path: root/tests/projects
diff options
context:
space:
mode:
authorChristian Rendina <[email protected]>2025-04-10 09:50:37 +0200
committerChristian Rendina <[email protected]>2025-04-10 09:50:37 +0200
commit78723913d76fb8b615df34541236b8ea588d30db (patch)
treeb6b6ff550e4a2f73d94c63a61876cec31a4b3ae3 /tests/projects
parent2051c13f735a626f7b6fd8b98aa69f01fd9cef7e (diff)
parentfd49b7754c6709a87b5beb5526788bbc1a663965 (diff)
Merge branch 'dev' of https://github.com/xmake-io/xmake into dev
Diffstat (limited to 'tests/projects')
-rw-r--r--tests/projects/c++/modules/hello_with_pch/src/hello.mpp10
-rw-r--r--tests/projects/c++/modules/hello_with_pch/src/main.cpp8
-rw-r--r--tests/projects/c++/modules/hello_with_pch/src/test.h1
-rw-r--r--tests/projects/c++/modules/hello_with_pch/xmake.lua7
-rw-r--r--tests/projects/c++/modules/test_pch.lua31
-rw-r--r--tests/projects/other/build_deps/xmake.lua6
-rw-r--r--tests/projects/other/merge_archive/xmake.lua3
-rw-r--r--tests/projects/other/merge_object/xmake.lua2
8 files changed, 63 insertions, 5 deletions
diff --git a/tests/projects/c++/modules/hello_with_pch/src/hello.mpp b/tests/projects/c++/modules/hello_with_pch/src/hello.mpp
new file mode 100644
index 000000000..124bd72bc
--- /dev/null
+++ b/tests/projects/c++/modules/hello_with_pch/src/hello.mpp
@@ -0,0 +1,10 @@
+module;
+#include <cstdio>
+
+export module hello;
+
+export namespace hello {
+ void say(const char* str) {
+ printf("%s\n", str);
+ }
+}
diff --git a/tests/projects/c++/modules/hello_with_pch/src/main.cpp b/tests/projects/c++/modules/hello_with_pch/src/main.cpp
new file mode 100644
index 000000000..739309dd4
--- /dev/null
+++ b/tests/projects/c++/modules/hello_with_pch/src/main.cpp
@@ -0,0 +1,8 @@
+#include "test.h"
+
+import hello;
+
+int main() {
+ hello::say("hello module!");
+ return 0;
+}
diff --git a/tests/projects/c++/modules/hello_with_pch/src/test.h b/tests/projects/c++/modules/hello_with_pch/src/test.h
new file mode 100644
index 000000000..d5a732287
--- /dev/null
+++ b/tests/projects/c++/modules/hello_with_pch/src/test.h
@@ -0,0 +1 @@
+#include <string>
diff --git a/tests/projects/c++/modules/hello_with_pch/xmake.lua b/tests/projects/c++/modules/hello_with_pch/xmake.lua
new file mode 100644
index 000000000..79ddb6b58
--- /dev/null
+++ b/tests/projects/c++/modules/hello_with_pch/xmake.lua
@@ -0,0 +1,7 @@
+add_rules("mode.release", "mode.debug")
+set_languages("c++20")
+
+target("hello")
+ set_kind("binary")
+ set_pcxxheader("src/test.h")
+ add_files("src/*.cpp", "src/*.mpp")
diff --git a/tests/projects/c++/modules/test_pch.lua b/tests/projects/c++/modules/test_pch.lua
new file mode 100644
index 000000000..98286c229
--- /dev/null
+++ b/tests/projects/c++/modules/test_pch.lua
@@ -0,0 +1,31 @@
+import("lib.detect.find_tool")
+import("core.base.semver")
+import("detect.sdks.find_vstudio")
+import("utils.ci.is_running", {alias = "ci_is_running"})
+
+function _build()
+ if ci_is_running() then
+ os.run("xmake -rvD")
+ else
+ os.run("xmake -r")
+ end
+ local outdata = os.iorun("xmake")
+ if outdata then
+ if outdata:find("compiling") or outdata:find("linking") or outdata:find("generating") then
+ raise("Modules incremental compilation does not work\n%s", outdata)
+ end
+ end
+end
+
+function main(t)
+ -- TODO c++ modules with pch does not work for gcc now.
+ if is_host("linux") then
+ local clang = find_tool("clang", {version = true})
+ if clang then
+ os.exec("xmake f --toolchain=clang -c --yes --policies=build.c++.modules.std:n,build.c++.clang.fallbackscanner")
+ _build()
+ end
+ else
+ _build()
+ end
+end
diff --git a/tests/projects/other/build_deps/xmake.lua b/tests/projects/other/build_deps/xmake.lua
index 5729b5c8f..b2324e3dd 100644
--- a/tests/projects/other/build_deps/xmake.lua
+++ b/tests/projects/other/build_deps/xmake.lua
@@ -4,7 +4,7 @@ target("dep1")
set_kind("static")
add_deps("dep3")
add_files("src/dep1.c")
- set_policy("build.across_targets_in_parallel", false)
+ set_policy("build.fence", true)
after_load(function (target)
os.rm(target:targetfile())
os.rm(target:dep("dep3"):targetfile())
@@ -21,7 +21,7 @@ target("dep2")
set_kind("static")
add_deps("dep3")
add_files("src/dep2.c")
- set_policy("build.across_targets_in_parallel", false)
+ set_policy("build.fence", true)
after_load(function (target)
os.rm(target:targetfile())
os.rm(target:dep("dep3"):targetfile())
@@ -38,7 +38,7 @@ target("dep3")
set_kind("static")
add_files("src/dep3.c")
add_deps("dep4", "dep5")
- set_policy("build.across_targets_in_parallel", false)
+ set_policy("build.fence", true)
after_load(function (target)
os.rm(target:targetfile())
os.rm(target:dep("dep4"):targetfile())
diff --git a/tests/projects/other/merge_archive/xmake.lua b/tests/projects/other/merge_archive/xmake.lua
index 11092dec9..7cf74471d 100644
--- a/tests/projects/other/merge_archive/xmake.lua
+++ b/tests/projects/other/merge_archive/xmake.lua
@@ -3,18 +3,19 @@ add_rules("mode.debug", "mode.release")
target("add")
set_kind("static")
add_files("src/add.c")
+ set_policy("build.fence", true)
set_targetdir("$(buildir)/merge_archive")
target("sub")
set_kind("static")
add_files("src/sub.c")
+ set_policy("build.fence", true)
set_targetdir("$(buildir)/merge_archive")
target("mul")
set_kind("static")
add_deps("add", "sub")
add_files("src/mul.c")
- set_policy("build.across_targets_in_parallel", false)
if is_plat("windows") then
add_files("$(buildir)/merge_archive/*.lib")
else
diff --git a/tests/projects/other/merge_object/xmake.lua b/tests/projects/other/merge_object/xmake.lua
index b8799a0b8..bbd7c1f98 100644
--- a/tests/projects/other/merge_object/xmake.lua
+++ b/tests/projects/other/merge_object/xmake.lua
@@ -1,9 +1,9 @@
add_rules("mode.debug", "mode.release")
-set_policy("build.across_targets_in_parallel", false)
target("merge_object")
set_kind("static")
add_files("src/interface.c")
+ set_policy("build.fence", true)
after_build_file(function (target, sourcefile)
os.cp(target:objectfile(sourcefile), "$(buildir)/merge_object/")
end)