diff options
| author | Arthur LAURENT <[email protected]> | 2022-12-03 02:16:08 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2022-12-03 02:16:08 +0100 |
| commit | dd233c5b036b37994b661ef61387cdb3f67eb252 (patch) | |
| tree | c04a1f41cc3942aaef3e3b80ead41b3f83950793 | |
| parent | 9129440bc0f65f7aea3ddd1fbfe4c977bac5eaac (diff) | |
refactor clang
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 78 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/gcc.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/msvc.lua | 18 |
3 files changed, 46 insertions, 54 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 69419b4e2..adc4ac967 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -460,13 +460,13 @@ end -- build module files for batchjobs function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, opt) - local compinst = target:compiler("cxx") + + -- get flags local cachedir = common.modules_cachedir(target) local modulecachepathflag = get_modulecachepathflag(target) - local modulefileflag = get_modulefileflag(target) -- flush job - local flushjob = batchjobs:addjob(target:name() .. "_stl_flush_mapper", function(index, total) + local flushjob = batchjobs:addjob(target:name() .. "_modules", function(index, total) _flush_mapper(target) end, {rootjob = opt.rootjob}) @@ -476,22 +476,27 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op for _, objectfile in ipairs(objectfiles) do 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(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 - - local bmifile = provide.bmi - local moduleinfo = table.copy(provide) - moduleinfo.job = batchjobs:newjob(provide.sourcefile, function (index, total) + 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) -- append module mapper flags first -- @note we add it at the end to ensure that the full modulemap are already stored in the mapper local requiresflags @@ -499,53 +504,38 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op requiresflags = get_requiresflags(target, module.requires) end - _build_interfacemodulefile(target, provide.sourcefile, { - objectfile = objectfile, - dependfile = target:dependfile(bmifile), - bmifile = bmifile, - name = name, - common_args = common_args, - requiresflags = requiresflags, - progress = (index * 100) / total}) + if provide then + local bmifile = provide.bmi + _build_interfacemodulefile(target, provide.sourcefile, { + objectfile = objectfile, + dependfile = target:dependfile(bmifile), + bmifile = bmifile, + name = name, + common_args = common_args, + requiresflags = requiresflags, + progress = (index * 100) / total}) + target:add("objectfiles", objectfile) - _add_module_to_mapper(target, name, bmifile, requiresflags) - end) - if module.requires then - moduleinfo.deps = table.keys(module.requires) - end - moduleinfo.name = name - modulesjobs[name] = moduleinfo - target:add("objectfiles", objectfile) - else - modulesjobs[module.cppfile] = { - name = module.cppfile, - deps = table.keys(module.requires or {}), - sourcefile = module.cppfile, - job = batchjobs:newjob(module.cppfile, function(index, total) - local requiresflags - if module.requires then - requiresflags = get_requiresflags(target, module.requires) - end - - if common.has_module_extension(module.cppfile) then - _build_modulefile(target, module.cppfile, { + _add_module_to_mapper(target, name, bmifile, requiresflags) + else + if common.has_module_extension(cppfile) then + _build_modulefile(target, cppfile, { objectfile = objectfile, dependfile = target:dependfile(objectfile), requiresflags = requiresflags, progress = (index * 100) / total}) target:add("objectfiles", objectfile) elseif requiresflags then - -- append module mapper flags - -- @note we add it at the end to ensure that the full modulemap are already stored in the mapper - local requiresflags = get_requiresflags(target, module.requires) - target:fileconfig_add(module.cppfile, {force = {cxxflags = requiresflags}}) + target:fileconfig_add(cppfile, {force = {cxxflags = requiresflags}}) end - end) - } - end + end + end)}) + modulesjobs[name or cppfile] = moduleinfo end end + print(modulesjobs) + -- build batchjobs for modules common.build_batchjobs_for_modules(modulesjobs, batchjobs, flushjob) end diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua index 3888644db..c8a10da86 100644 --- a/xmake/rules/c++/modules/modules_support/gcc.lua +++ b/xmake/rules/c++/modules/modules_support/gcc.lua @@ -402,13 +402,13 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op end end local moduleinfo = table.copy(provide) or {} + local dependfile = (provide and provide.bmi) and target:dependfile(provide.bmi) or target:dependfile(objectfile) 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 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, @@ -425,6 +425,8 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op end end + print(modulesjobs) + -- build batchjobs for modules common.build_batchjobs_for_modules(modulesjobs, batchjobs, opt.rootjob) end diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index 9945185e6..a94820b4a 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -460,6 +460,15 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op end end local moduleinfo = table.copy(provide) or {} + local flags = {"-TP"} + table.join2(flags, (provide and provide.interface) and interfaceflag or {}) + local dependfile = target:dependfile(objectfile) + + if provide then + table.join2(flags, {ifcoutputflag, provide.bmi}) + dependfile = target:dependfile(provide.bmi) + end + table.join2(moduleinfo, { name = name or cppfile, deps = table.keys(module.requires or {}), @@ -471,16 +480,7 @@ function build_modules_for_batchjobs(target, batchjobs, objectfiles, modules, op if module.requires then requiresflags = get_requiresflags(target, module.requires, {expand = true}) end - - local flags = {"-TP"} table.join2(flags, requiresflags or {}) - table.join2(flags, (provide and provide.interface) and interfaceflag or {}) - - local dependfile = target:dependfile(objectfile) - if provide then - table.join2(flags, {ifcoutputflag, provide.bmi}) - dependfile = target:dependfile(provide.bmi) - end if provide or common.has_module_extension(cppfile) then _build_modulefile(target, cppfile, { |
