From 5d6d36e0db45d90dfa7f0cdf2937d989de683833 Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Mon, 5 May 2025 17:13:25 +0200 Subject: (C++ module support) improve jobgraph support --- xmake/rules/c++/modules/config.lua | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'xmake/rules/c++/modules/config.lua') 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 -- cgit v1.3.1