From 43c3b8607775f7ee5b52e24a7f785b4c7a5ab292 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 6 Apr 2025 22:03:58 +0800 Subject: add modules with pch test --- tests/projects/c++/modules/hello_with_pch/src/hello.mpp | 10 ++++++++++ tests/projects/c++/modules/hello_with_pch/src/main.cpp | 8 ++++++++ tests/projects/c++/modules/hello_with_pch/src/test.h | 1 + tests/projects/c++/modules/hello_with_pch/test.lua | 1 + tests/projects/c++/modules/hello_with_pch/xmake.lua | 7 +++++++ 5 files changed, 27 insertions(+) create mode 100644 tests/projects/c++/modules/hello_with_pch/src/hello.mpp create mode 100644 tests/projects/c++/modules/hello_with_pch/src/main.cpp create mode 100644 tests/projects/c++/modules/hello_with_pch/src/test.h create mode 100644 tests/projects/c++/modules/hello_with_pch/test.lua create mode 100644 tests/projects/c++/modules/hello_with_pch/xmake.lua (limited to 'tests/projects') 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 + +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 diff --git a/tests/projects/c++/modules/hello_with_pch/test.lua b/tests/projects/c++/modules/hello_with_pch/test.lua new file mode 100644 index 000000000..7717f8049 --- /dev/null +++ b/tests/projects/c++/modules/hello_with_pch/test.lua @@ -0,0 +1 @@ +inherit(".test_base") 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") -- cgit v1.3.1 From b2d2727fdcc1d955b4095c57b6d02ff665bcbfd9 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 6 Apr 2025 23:02:59 +0800 Subject: disable module and pch for gcc --- tests/projects/c++/modules/hello_with_pch/test.lua | 2 +- tests/projects/c++/modules/test_pch.lua | 31 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/projects/c++/modules/test_pch.lua (limited to 'tests/projects') diff --git a/tests/projects/c++/modules/hello_with_pch/test.lua b/tests/projects/c++/modules/hello_with_pch/test.lua index 7717f8049..16ef46834 100644 --- a/tests/projects/c++/modules/hello_with_pch/test.lua +++ b/tests/projects/c++/modules/hello_with_pch/test.lua @@ -1 +1 @@ -inherit(".test_base") +inherit(".test_pch") 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 -- cgit v1.3.1 From 72870df34c9a3278fe4a92fa5591f6738f80ada6 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 6 Apr 2025 23:16:28 +0800 Subject: Delete tests/projects/c++/modules/hello_with_pch/test.lua --- tests/projects/c++/modules/hello_with_pch/test.lua | 1 - 1 file changed, 1 deletion(-) delete mode 100644 tests/projects/c++/modules/hello_with_pch/test.lua (limited to 'tests/projects') diff --git a/tests/projects/c++/modules/hello_with_pch/test.lua b/tests/projects/c++/modules/hello_with_pch/test.lua deleted file mode 100644 index 16ef46834..000000000 --- a/tests/projects/c++/modules/hello_with_pch/test.lua +++ /dev/null @@ -1 +0,0 @@ -inherit(".test_pch") -- cgit v1.3.1 From c091d7b4d8f13ed4b17d23df8867ec30e8003c4c Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 7 Apr 2025 22:36:14 +0800 Subject: remove across_targets_in_parallel policy --- tests/projects/other/build_deps/xmake.lua | 6 +++--- tests/projects/other/merge_archive/xmake.lua | 3 ++- tests/projects/other/merge_object/xmake.lua | 2 +- xmake/rules/c++/modules/xmake.lua | 2 +- xmake/rules/fortran/xmake.lua | 2 +- xmake/rules/go/xmake.lua | 2 +- xmake/rules/vala/xmake.lua | 2 +- xmake/rules/xcode/application/xmake.lua | 13 ------------- 8 files changed, 10 insertions(+), 22 deletions(-) (limited to 'tests/projects') 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) diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua index d0c0e0387..a27633182 100644 --- a/xmake/rules/c++/modules/xmake.lua +++ b/xmake/rules/c++/modules/xmake.lua @@ -37,7 +37,7 @@ rule("c++.build.modules") -- even if some sub-targets do not contain C++ modules. -- -- maybe we will have a more fine-grained configuration strategy to disable it in the future. - target:set("policy", "build.across_targets_in_parallel", false) + target:set("policy", "build.fence", true) -- disable ccache for this target -- diff --git a/xmake/rules/fortran/xmake.lua b/xmake/rules/fortran/xmake.lua index 4ab11906d..d10993a91 100644 --- a/xmake/rules/fortran/xmake.lua +++ b/xmake/rules/fortran/xmake.lua @@ -35,7 +35,7 @@ rule("fortran.build") add_deps("fortran.build.modules") on_load(function (target) -- we disable to build across targets in parallel, because the source files may depend on other target modules - target:set("policy", "build.across_targets_in_parallel", false) + target:set("policy", "build.fence", true) end) on_build_files(function (target, sourcebatch, opt) import("private.action.build.object").build(target, sourcebatch, opt) diff --git a/xmake/rules/go/xmake.lua b/xmake/rules/go/xmake.lua index 58890e260..fd4cdfb4a 100644 --- a/xmake/rules/go/xmake.lua +++ b/xmake/rules/go/xmake.lua @@ -23,7 +23,7 @@ rule("go.build") add_deps("go.env") on_load(function (target) -- we disable to build across targets in parallel, because the source files may depend on other target modules - target:set("policy", "build.across_targets_in_parallel", false) + target:set("policy", "build.fence", true) -- xxx.a if target:is_static() then target:set("prefixname", "") diff --git a/xmake/rules/vala/xmake.lua b/xmake/rules/vala/xmake.lua index caebab9d8..e2262a9ec 100644 --- a/xmake/rules/vala/xmake.lua +++ b/xmake/rules/vala/xmake.lua @@ -26,7 +26,7 @@ rule("vala.build") set_sourcekinds("cc") on_load(function (target) -- we disable to build across targets in parallel, because the source files may depend on other target modules - target:set("policy", "build.across_targets_in_parallel", false) + target:set("policy", "build.fence", true) -- get vapi file local vapifile = target:data("vala.vapifile") diff --git a/xmake/rules/xcode/application/xmake.lua b/xmake/rules/xcode/application/xmake.lua index b4969b3df..7d5edc668 100644 --- a/xmake/rules/xcode/application/xmake.lua +++ b/xmake/rules/xcode/application/xmake.lua @@ -27,19 +27,6 @@ rule("xcode.application") -- we must set kind before target.on_load(), may we will use target in on_load() on_load("load") - -- depend xcode.framework? we need to disable `build.across_targets_in_parallel` policy - after_load(function (target) - local across_targets_in_parallel - for _, dep in ipairs(target:orderdeps()) do - if dep:rule("xcode.framework") then - across_targets_in_parallel = false - end - end - if across_targets_in_parallel ~= nil then - target:set("policy", "build.across_targets_in_parallel", across_targets_in_parallel) - end - end) - -- build *.app after_build("build") -- cgit v1.3.1