summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2022-12-03 01:40:33 +0100
committerArthur LAURENT <[email protected]>2022-12-03 01:40:33 +0100
commit9129440bc0f65f7aea3ddd1fbfe4c977bac5eaac (patch)
tree484fdeadb40f4f860f192ff10016f5747a03f36a /xmake/rules/c++/modules/modules_support
parentcaa3b2d28d2aa0845bee1aee8c2239de8988c71b (diff)
fix msvc and refactor GCC
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc.lua57
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc.lua7
2 files changed, 27 insertions, 37 deletions
diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua
index cbdf9b1bf..3888644db 100644
--- a/xmake/rules/c++/modules/modules_support/gcc.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc.lua
@@ -379,58 +379,49 @@ end
-- build module files for batchjobs
function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, opt)
local mapper_file = _get_module_mapper()
- local cachedir = common.modules_cachedir(target)
-- build modules
local projectdir = os.projectdir()
local modulesjobs = {}
for _, objectfile in ipairs(objectfiles) do
- local m = modules[objectfile]
- if m then
- if m.provides then
+ local module = modules[objectfile]
+ if module then
+ local cppfile = module.cppfile
+ local name, provide
+ if module.provides then
-- assume there that provides is only one, until we encounter the case
local length = 0
- local name, provide
- for k, v in pairs(m.provides) do
+ for k, v in pairs(module.provides) do
length = length + 1
name = k
provide = v
+ cppfile = provide.sourcefile
if length > 1 then
raise("multiple provides are not supported now!")
end
end
+ end
+ local moduleinfo = table.copy(provide) or {}
+ table.join2(moduleinfo, {
+ name = name or cppfile,
+ deps = table.keys(module.requires or {}),
+ sourcefile = cppfile,
+ job = batchjobs:newjob(name or cppfile, function(index, total)
- local bmifile = provide.bmi
- local moduleinfo = table.copy(provide)
- moduleinfo.job = batchjobs:newjob(provide.sourcefile, function (index, total)
- _build_modulefile(target, provide.sourcefile, {
- objectfile = objectfile,
- dependfile = target:dependfile(bmifile),
- name = name,
- progress = (index * 100) / total})
- end)
- if m.requires then
- moduleinfo.deps = table.keys(m.requires)
- end
- moduleinfo.name = name
- modulesjobs[name] = moduleinfo
- _add_module_to_mapper(mapper_file, name, path.absolute(bmifile, projectdir))
- target:add("objectfiles", objectfile)
- elseif common.has_module_extension(m.cppfile) then
- modulesjobs[m.cppfile] = {
- name = m.cppfile,
- deps = table.keys(m.requires or {}),
- sourcefile = m.cppfile,
- job = batchjobs:newjob(m.cppfile, function(index, total)
- _build_modulefile(target, m.cppfile, {
+ local dependfile = (provide and provide.bmi) and target:dependfile(provide.bmi) or target:dependfile(objectfile)
+ if provide or common.has_module_extension(cppfile) then
+ _build_modulefile(target, cppfile, {
objectfile = objectfile,
- dependfile = target:dependfile(objectfile),
- name = m.cppfile,
+ dependfile = dependfile,
+ name = name or cppfile,
progress = (index * 100) / total})
target:add("objectfiles", objectfile)
- end)
- }
+ end
+ end)})
+ if provide then
+ _add_module_to_mapper(mapper_file, name, path.absolute(provide.bmi, projectdir))
end
+ modulesjobs[name or cppfile] = moduleinfo
end
end
diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua
index 6753021ab..9945185e6 100644
--- a/xmake/rules/c++/modules/modules_support/msvc.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc.lua
@@ -443,8 +443,8 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op
local modulesjobs = {}
for _, objectfile in ipairs(objectfiles) do
local module = modules[objectfile]
- local cppfile = module.cppfile
if module then
+ local cppfile = module.cppfile
local name, provide
if module.provides then
-- assume there that provides is only one, until we encounter the case
@@ -476,14 +476,13 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op
table.join2(flags, requiresflags or {})
table.join2(flags, (provide and provide.interface) and interfaceflag or {})
- local fileconfig = target:fileconfig(cppfile)
local dependfile = target:dependfile(objectfile)
if provide then
table.join2(flags, {ifcoutputflag, provide.bmi})
- dependfile = target:dependfile(provide and provide.bmi or objectfile)
+ dependfile = target:dependfile(provide.bmi)
end
- if provide then
+ if provide or common.has_module_extension(cppfile) then
_build_modulefile(target, cppfile, {
objectfile = objectfile,
dependfile = dependfile,