summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support
diff options
context:
space:
mode:
authorruki <[email protected]>2022-08-04 22:37:59 +0800
committerruki <[email protected]>2022-08-04 22:37:59 +0800
commit0e52b4967cd20677c1dcc7656e2016c076ed2647 (patch)
tree67d13c3ee93e036a3429c269b9578a3ddaab625b /xmake/rules/c++/modules/modules_support
parentcc8ee163098a464937769641377fd98c33bdfca2 (diff)
improve load modules
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
-rw-r--r--xmake/rules/c++/modules/modules_support/clang.lua24
-rw-r--r--xmake/rules/c++/modules/modules_support/common.lua2
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc.lua8
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc.lua24
4 files changed, 23 insertions, 35 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua
index e1e136c97..04ea0ab6e 100644
--- a/xmake/rules/c++/modules/modules_support/clang.lua
+++ b/xmake/rules/c++/modules/modules_support/clang.lua
@@ -27,20 +27,8 @@ import("utils.progress")
import("private.action.build.object", {alias = "objectbuilder"})
import("common")
--- load parent target with modules files
-function load_parent(target, opt)
- local cachedir = common.modules_cachedir(target)
-
- local prebuiltmodulepathflag = get_prebuiltmodulepathflag(target)
-
- for _, dep in ipairs(target:orderdeps()) do
- cachedir = common.modules_cachedir(dep)
- target:add("cxxflags", prebuiltmodulepathflag .. cachedir, {force = true})
- end
-end
-
--- check C++20 module support
-function check_module_support(target)
+-- load module support for the current target
+function load(target)
local compinst = compiler.load("cxx", {target = target})
local cachedir = common.modules_cachedir(target)
local stlcachedir = common.stlmodules_cachedir(target)
@@ -57,8 +45,14 @@ function check_module_support(target)
-- add the module cache directory
target:add("cxxflags", implicitmodulesflag, {force = true})
target:add("cxxflags", implicitmodulemapsflag, {force = true})
-
target:add("cxxflags", prebuiltmodulepathflag .. cachedir, prebuiltmodulepathflag .. stlcachedir, {force = true})
+
+ -- add module cachedirs of all dependent targets with modules
+ -- this target maybe does not contain module files
+ for _, dep in ipairs(target:orderdeps()) do
+ cachedir = common.modules_cachedir(dep)
+ target:add("cxxflags", prebuiltmodulepathflag .. cachedir, {force = true})
+ end
end
function toolchain_include_directories(target)
diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua
index 57b9c0c7c..ae3de7493 100644
--- a/xmake/rules/c++/modules/modules_support/common.lua
+++ b/xmake/rules/c++/modules/modules_support/common.lua
@@ -108,7 +108,7 @@ function contains_modules(target)
end
-- load module infos
-function load(target, sourcebatch, opt)
+function load_moduleinfos(target, sourcebatch, opt)
local moduleinfos
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
local dependfile = target:dependfile(sourcefile)
diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua
index 9812115b8..fc346d753 100644
--- a/xmake/rules/c++/modules/modules_support/gcc.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc.lua
@@ -52,12 +52,8 @@ function add_module_to_mapper(file, module, bmi)
return true
end
--- load parent target with modules files
-function load_parent(target, opt)
-end
-
--- check C++20 module support
-function check_module_support(target)
+-- load module support for the current target
+function load(target)
local compinst = compiler.load("cxx", {target = target})
local modulesflag = get_modulesflag(target)
diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua
index c7a6f6c15..98d244626 100644
--- a/xmake/rules/c++/modules/modules_support/msvc.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc.lua
@@ -14,7 +14,7 @@
--
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
--- @author ruki
+-- @author ruki, Arthapz
-- @file msvc.lua
--
@@ -26,18 +26,8 @@ import("utils.progress")
import("private.action.build.object", {alias = "objectbuilder"})
import("common")
--- load parent target with modules files
-function load_parent(target, opt)
- local ifcsearchdirflag = get_ifcsearchdirflag(target)
-
- for _, dep in ipairs(target:orderdeps()) do
- cachedir = common.modules_cachedir(dep)
- target:add("cxxflags", {ifcsearchdirflag, cachedir}, {force = true, expand = false})
- end
-end
-
--- check C++20 module support
-function check_module_support(target)
+-- load module support for the current target
+function load(target)
local compinst = target:compiler("cxx")
local cachedir = common.modules_cachedir(target)
local stlcachedir = common.stlmodules_cachedir(target)
@@ -65,6 +55,14 @@ function check_module_support(target)
break
end
end
+
+ -- add module cachedirs of all dependent targets with modules
+ -- this target maybe does not contain module files
+ local ifcsearchdirflag = get_ifcsearchdirflag(target)
+ for _, dep in ipairs(target:orderdeps()) do
+ cachedir = common.modules_cachedir(dep)
+ target:add("cxxflags", {ifcsearchdirflag, cachedir}, {force = true, expand = false})
+ end
end
-- provide toolchain include dir for stl headerunit when p1689 is not supported