diff options
| author | Arthur LAURENT <[email protected]> | 2024-07-22 20:19:56 +0200 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2024-07-22 21:08:50 +0200 |
| commit | ab6ee69bce2bd78596f4713ec4300301e025a56f (patch) | |
| tree | 9cc7a84494d74257bbbc36b05554504921cf3dac /xmake/rules/c++/modules/modules_support | |
| parent | 261185f6819174884debb649cf7f7678b8130b2a (diff) | |
simplify objectfile handling
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
5 files changed, 23 insertions, 76 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang/builder.lua b/xmake/rules/c++/modules/modules_support/clang/builder.lua index 174599229..91534a11e 100644 --- a/xmake/rules/c++/modules/modules_support/clang/builder.lua +++ b/xmake/rules/c++/modules/modules_support/clang/builder.lua @@ -207,11 +207,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt) job = batchjobs:newjob(name or opt.cppfile, function(index, total, jobopt) local mapped_bmi if provide and compiler_support.memcache():get2(target:name() .. name, "reuse") then - if not target:is_binary() then - return - else - mapped_bmi = get_from_target_mapper(target, name).bmi - end + mapped_bmi = get_from_target_mapper(target, name).bmi end local build, dependinfo @@ -256,13 +252,8 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt) _compile_bmi_step(target, bmifile, opt.cppfile, {std = (name == "std" or name == "std.compat")}) end else - if mapped_bmi then - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) - _compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile) - else - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat")}) - end + progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat")}) end else os.tryrm(opt.objectfile) -- force rebuild for .cpp files @@ -280,11 +271,7 @@ function make_module_buildcmds(target, batchcmds, opt) local mapped_bmi if provide and compiler_support.memcache():get2(target:name() .. name, "reuse") then - if not target:is_binary() then - return - else - mapped_bmi = get_from_target_mapper(target, name).bmi - end + mapped_bmi = get_from_target_mapper(target, name).bmi end -- append requires flags @@ -306,13 +293,8 @@ function make_module_buildcmds(target, batchcmds, opt) _compile_bmi_step(target, bmifile, opt.cppfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds}) end else - if mapped_bmi then - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) - _compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds}) - else - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds}) - end + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, {std = (name == "std" or name == "std.compat"), batchcmds = batchcmds}) end else batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files diff --git a/xmake/rules/c++/modules/modules_support/compiler_support.lua b/xmake/rules/c++/modules/modules_support/compiler_support.lua index ecc085358..8e9cf7ab6 100644 --- a/xmake/rules/c++/modules/modules_support/compiler_support.lua +++ b/xmake/rules/c++/modules/modules_support/compiler_support.lua @@ -90,13 +90,14 @@ function cull_objectfiles(target, modules, sourcebatch) for _, sourcefile in ipairs(sourcebatch.sourcefiles) do local objectfile = target:objectfile(sourcefile) local module = modules[objectfile] - local _, provide, _ = get_provided_module(module) + local name, provide, _ = get_provided_module(module) if provide then local fileconfig = target:fileconfig(sourcefile) local public = fileconfig and fileconfig.public local external = fileconfig and fileconfig.external local from_moduleonly = external and external.moduleonly - if not external or from_moduleonly then + local dont_cull = fileconfig and fileconfig.cull ~= nil and not fileconfig.cull + if (provide and not external) or public or from_moduleonly or dont_cull then table.insert(sourcebatch.objectfiles, objectfile) end else diff --git a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/dependency_scanner.lua index fe6e0fc9f..c67e18a79 100644 --- a/xmake/rules/c++/modules/modules_support/dependency_scanner.lua +++ b/xmake/rules/c++/modules/modules_support/dependency_scanner.lua @@ -434,8 +434,8 @@ function sort_modules_by_dependencies(target, objectfiles, modules) local dont_cull = fileconfig and fileconfig.cull ~= nil and not fileconfig.cull if not provide or public or from_moduleonly or dont_cull then table.insert(result, objectfile) - elseif not external and not dont_cull then - wprint("%s has been culled because it's not consumed by its target nor flagged as a public module (add_files(\"xxx.cppm\", {public = true}))", cppfile) + elseif not external then + wprint("%s has been culled because it's not consumed by its target (%s) nor flagged as a public module (add_files(\"xxx.cppm\", {public = true}))", cppfile, target:name()) end else table.insert(result, objectfile) diff --git a/xmake/rules/c++/modules/modules_support/gcc/builder.lua b/xmake/rules/c++/modules/modules_support/gcc/builder.lua index 5866ad044..a0a43db5a 100644 --- a/xmake/rules/c++/modules/modules_support/gcc/builder.lua +++ b/xmake/rules/c++/modules/modules_support/gcc/builder.lua @@ -187,11 +187,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt) job = batchjobs:newjob(name or opt.cppfile, function(index, total, jobopt) local mapped_bmi if provide and compiler_support.memcache():get2(target:name() .. name, "reuse") then - if not target:is_binary() then - return - else - mapped_bmi = get_from_target_mapper(target, name).bmi - end + mapped_bmi = get_from_target_mapper(target, name).bmi end -- generate and append module mapper file @@ -227,13 +223,8 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt) sourcefile = opt.cppfile end else - if mapped_bmi then - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) - sourcefile = bmifile - else - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - sourcefile = opt.cppfile - end + progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + sourcefile = opt.cppfile end if option.get("diagnosis") then print("mapper file --------\n%s--------", io.readfile(module_mapper)) @@ -259,11 +250,7 @@ function make_module_buildcmds(target, batchcmds, opt) local mapped_bmi if provide and compiler_support.memcache():get2(target:name() .. name, "reuse") then - if not target:is_binary() then - return - else - mapped_bmi = get_from_target_mapper(target, name).bmi - end + mapped_bmi = get_from_target_mapper(target, name).bmi end -- generate and append module mapper file @@ -291,13 +278,8 @@ function make_module_buildcmds(target, batchcmds, opt) sourcefile = opt.cppfile end else - if mapped_bmi then - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) - sourcefile = bmifile - else - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - sourcefile = opt.cppfile - end + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + sourcefile = opt.cppfile end if option.get("diagnosis") then batchcmds:print("mapper file: %s", io.readfile(module_mapper)) diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/modules_support/msvc/builder.lua index 737721bcd..89d9b6b60 100644 --- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua +++ b/xmake/rules/c++/modules/modules_support/msvc/builder.lua @@ -271,11 +271,7 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt) local mapped_bmi if provide and compiler_support.memcache():get2(target:name() .. name, "reuse") then - if not target:is_binary() then - return - else - mapped_bmi = get_from_target_mapper(target, name).bmi - end + mapped_bmi = get_from_target_mapper(target, name).bmi end local build, dependinfo @@ -320,13 +316,8 @@ function make_module_buildjobs(target, batchjobs, job_name, deps, opt) _compile_bmi_step(target, bmifile, opt.cppfile, opt.objectfile, provide) end else - if mapped_bmi then - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) - _compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile, provide) - else - progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide) - end + progress.show(jobopt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide) end else os.tryrm(opt.objectfile) -- force rebuild for .cpp files @@ -344,11 +335,7 @@ function make_module_buildcmds(target, batchcmds, opt) local mapped_bmi if provide and compiler_support.memcache():get2(target:name() .. name, "reuse") then - if not target:is_binary() then - return - else - mapped_bmi = get_from_target_mapper(target, name).bmi - end + mapped_bmi = get_from_target_mapper(target, name).bmi end -- append requires flags @@ -371,13 +358,8 @@ function make_module_buildcmds(target, batchcmds, opt) _compile_bmi_step(target, bmifile, opt.cppfile, provide, {batchcmds = batchcmds}) end else - if mapped_bmi then - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.objectfile.$(mode) %s", target:name(), name or opt.cppfile) - _compile_objectfile_step(target, bmifile, opt.cppfile, opt.objectfile, provide, {batchcmds = batchcmds}) - else - batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) - _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide, {batchcmds = batchcmds}) - end + batchcmds:show_progress(opt.progress, "${color.build.target}<%s> ${clear}${color.build.object}compiling.module.$(mode) %s", target:name(), name or opt.cppfile) + _compile_one_step(target, bmifile, opt.cppfile, opt.objectfile, provide, {batchcmds = batchcmds}) end else batchcmds:rm(opt.objectfile) -- force rebuild for .cpp files |
