summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/config.lua
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2025-05-05 17:13:25 +0200
committerArthur LAURENT <[email protected]>2025-05-09 15:56:33 +0200
commit5d6d36e0db45d90dfa7f0cdf2937d989de683833 (patch)
tree2d1fbb82ee8d38921af1863fd3ce968f7c5cea75 /xmake/rules/c++/modules/config.lua
parentd88bd9c5ace6c64981420569fb886f7c646135c0 (diff)
(C++ module support) improve jobgraph support
Diffstat (limited to 'xmake/rules/c++/modules/config.lua')
-rw-r--r--xmake/rules/c++/modules/config.lua33
1 files changed, 21 insertions, 12 deletions
diff --git a/xmake/rules/c++/modules/config.lua b/xmake/rules/c++/modules/config.lua
index 4edbe1e1b..9daa1bfd0 100644
--- a/xmake/rules/c++/modules/config.lua
+++ b/xmake/rules/c++/modules/config.lua
@@ -1,5 +1,3 @@
---!A cross-platform build utility based on Lua
---
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
@@ -18,22 +16,22 @@
-- @file config.lua
--
+import("core.project.project")
+import("core.base.semver")
import("support")
-
+
function main(target)
- -- we disable to build across targets in parallel, because the source files may depend on other target modules
- -- @see https://github.com/xmake-io/xmake/issues/1858
if support.contains_modules(target) then
-
- -- unity build can't work with modules
- assert(not target:rule("c++.unity_build"), "C++ unity build is not compatible with C++ modules")
-
+ -- when jobgraph is policy is set to false, we disable to build across targets in parallel, because the source files may depend on other target modules
+ -- @see https://github.com/xmake-io/xmake/issues/1858
-- @note this will cause cross-parallel builds to be disabled for all sub-dependent targets,
-- 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.fence", true)
+ if not target:policy("build.jobgraph") then
+ target:set("policy", "build.fence", true)
+ end
+
+ assert(not target:rule("c++.unity_build"), "C++ unity build is not compatible with C++ modules")
-- disable ccache for this target
--
@@ -80,3 +78,14 @@ function main(target)
end
end
end
+
+function insert_stdmodules(target)
+ if target:data("cxx.has_modules") then
+ -- add std modules to sourcebatch
+ local stdmodules = support.get_stdmodules(target)
+ for _, sourcefile in ipairs(stdmodules) do
+ table.insert(target:sourcebatches()["c++.build.modules.scanner"].sourcefiles, sourcefile)
+ table.insert(target:sourcebatches()["c++.build.modules.builder"].sourcefiles, sourcefile)
+ end
+ end
+end