summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support/common.lua
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2022-08-05 04:41:46 +0200
committerArthur LAURENT <[email protected]>2022-08-05 04:41:46 +0200
commit9051b99608fe2f339eea7ac4c9eab8b799e230df (patch)
tree0c366c9a9592ac3c311d0564cf33dbea6f8d9542 /xmake/rules/c++/modules/modules_support/common.lua
parentb370625fbf37fe5e957677ec4c04ec3503d0da90 (diff)
Move headerunits extracting into a dedicated function
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/common.lua')
-rw-r--r--xmake/rules/c++/modules/modules_support/common.lua31
1 files changed, 29 insertions, 2 deletions
diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua
index a8b36e0fa..18647ded1 100644
--- a/xmake/rules/c++/modules/modules_support/common.lua
+++ b/xmake/rules/c++/modules/modules_support/common.lua
@@ -26,6 +26,7 @@ import("core.tool.compiler")
import("core.cache.memcache", {alias = "_memcache"})
import("core.project.project")
import("lib.detect.find_file")
+import("stl_headers")
-- get memcache
function memcache()
@@ -53,12 +54,38 @@ function modules_cachedir(target)
return cachedir
end
+-- get headerunits info
+function get_headerunits(target, sourcebatch)
+ local headerunits
+ local stl_headerunits
+ local modules = target:data("cxx.modules")
+ for _, objectfile in ipairs(sourcebatch.objectfiles) do
+ local m = modules[objectfile]
+ if m then
+ for name, r in pairs(m.requires) do
+ if r.method ~= "by-name" then
+ local unittype = r.method == "include-angle" and ":angle" or ":quote"
+
+ if stl_headers.is_stl_header(name) then
+ stl_headerunits = stl_headerunits or {}
+ table.insert(stl_headerunits, {name = name, path = r.path, type = unittype})
+ else
+ headerunits = headerunits or {}
+ table.insert(headerunits, {name = name, path = r.path, type = unittype})
+ end
+ end
+ end
+ end
+ end
+ return headerunits, stl_headerunits
+end
+
-- patch sourcebatch
function patch_sourcebatch(target, sourcebatch, opt)
local cachedir = modules_cachedir(target)
sourcebatch.sourcekind = "cxx"
- sourcebatch.objectfiles = sourcebatch.objectfiles or {}
- sourcebatch.dependfiles = sourcebatch.dependfiles or {}
+ sourcebatch.objectfiles = {}
+ sourcebatch.dependfiles = {}
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
local objectfile = target:objectfile(sourcefile)
local dependfile = target:dependfile(objectfile)