From e5ba7a1d14ef6f8afa2491b4dc0131169aaa4a76 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 21 Jul 2024 16:48:40 +0200 Subject: add a policy to disable module culling --- tests/projects/c++/modules/culling/src/hello.mpp | 10 ++++++++++ tests/projects/c++/modules/culling/test.lua | 1 + tests/projects/c++/modules/culling/xmake.lua | 7 +++++++ 3 files changed, 18 insertions(+) create mode 100644 tests/projects/c++/modules/culling/src/hello.mpp create mode 100644 tests/projects/c++/modules/culling/test.lua create mode 100644 tests/projects/c++/modules/culling/xmake.lua (limited to 'tests/projects/c++/modules') diff --git a/tests/projects/c++/modules/culling/src/hello.mpp b/tests/projects/c++/modules/culling/src/hello.mpp new file mode 100644 index 000000000..124bd72bc --- /dev/null +++ b/tests/projects/c++/modules/culling/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/culling/test.lua b/tests/projects/c++/modules/culling/test.lua new file mode 100644 index 000000000..7717f8049 --- /dev/null +++ b/tests/projects/c++/modules/culling/test.lua @@ -0,0 +1 @@ +inherit(".test_base") diff --git a/tests/projects/c++/modules/culling/xmake.lua b/tests/projects/c++/modules/culling/xmake.lua new file mode 100644 index 000000000..33d3934b9 --- /dev/null +++ b/tests/projects/c++/modules/culling/xmake.lua @@ -0,0 +1,7 @@ +add_rules("mode.release", "mode.debug") +set_languages("c++20") + +target("culling") + set_kind("static") + add_files("src/*.mpp") + set_policy("build.c++.modules.culling", false) -- cgit v1.3.1 From 0314af9533bab0d687bc31a2c2cc7c97416fe814 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Sun, 21 Jul 2024 18:49:22 +0200 Subject: add a fileconfig entry to disable module culling --- tests/projects/c++/modules/culling2/src/hello.mpp | 10 ++++++++++ tests/projects/c++/modules/culling2/test.lua | 1 + tests/projects/c++/modules/culling2/xmake.lua | 6 ++++++ xmake/rules/c++/modules/modules_support/dependency_scanner.lua | 3 ++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/projects/c++/modules/culling2/src/hello.mpp create mode 100644 tests/projects/c++/modules/culling2/test.lua create mode 100644 tests/projects/c++/modules/culling2/xmake.lua (limited to 'tests/projects/c++/modules') diff --git a/tests/projects/c++/modules/culling2/src/hello.mpp b/tests/projects/c++/modules/culling2/src/hello.mpp new file mode 100644 index 000000000..124bd72bc --- /dev/null +++ b/tests/projects/c++/modules/culling2/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/culling2/test.lua b/tests/projects/c++/modules/culling2/test.lua new file mode 100644 index 000000000..7717f8049 --- /dev/null +++ b/tests/projects/c++/modules/culling2/test.lua @@ -0,0 +1 @@ +inherit(".test_base") diff --git a/tests/projects/c++/modules/culling2/xmake.lua b/tests/projects/c++/modules/culling2/xmake.lua new file mode 100644 index 000000000..9a4d682bd --- /dev/null +++ b/tests/projects/c++/modules/culling2/xmake.lua @@ -0,0 +1,6 @@ +add_rules("mode.release", "mode.debug") +set_languages("c++20") + +target("culling") + set_kind("static") + add_files("src/*.mpp", {cull = false}) diff --git a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/dependency_scanner.lua index cef55fbd5..6c513242b 100644 --- a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua +++ b/xmake/rules/c++/modules/modules_support/dependency_scanner.lua @@ -427,7 +427,8 @@ function sort_modules_by_dependencies(target, objectfiles, modules) local _, provide, cppfile = compiler_support.get_provided_module(modules[objectfile]) local fileconfig = target:fileconfig(cppfile) local public = fileconfig and fileconfig.public - if not provide or public then + local dont_cull = fileconfig and fileconfig.cull ~= nil and not fileconfig.cull + if not provide or public or dont_cull then table.insert(result, objectfile) end else -- cgit v1.3.1