diff options
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/builder.lua')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/builder.lua | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/xmake/rules/c++/modules/modules_support/builder.lua b/xmake/rules/c++/modules/modules_support/builder.lua index 741009af5..4ceb67b0b 100644 --- a/xmake/rules/c++/modules/modules_support/builder.lua +++ b/xmake/rules/c++/modules/modules_support/builder.lua @@ -47,24 +47,17 @@ function _build_modules(target, sourcebatch, modules, opt) local fileconfig = target:fileconfig(cppfile) local bmifile = provide and compiler_support.get_bmi_path(provide.bmi) - local build = _should_build(target, cppfile, bmifile, {objectfile = objectfile, requires = module.requires}) - -- add objectfile if module is not from external dep if not (fileconfig and fileconfig.external) then target:add("objectfiles", objectfile) end - -- needed to detect rebuild of dependencies - if provide and build then - _mark_build(target, name) - end - local deps = {} for _, dep in ipairs(table.keys(module.requires or {})) do table.insert(deps, opt.batchjobs and target:name() .. dep or dep) end - opt.build_module(deps, build, module, name, provide, objectfile, cppfile, fileconfig) + opt.build_module(deps, module, name, provide, objectfile, cppfile, fileconfig) ::CONTINUE:: end @@ -85,10 +78,10 @@ function _build_headerunits(target, headerunits, opt) end local bmifile = path.join(outputdir, path.filename(headerunit.name) .. compiler_support.get_bmi_extension(target)) local key = path.normalize(headerunit.path) - local build = _should_build(target, headerunit.path, bmifile, {key = key, headerunit = true}) + local build = should_build(target, headerunit.path, bmifile, {key = key, headerunit = true}) if build then - _mark_build(target, key) + mark_build(target, key) end opt.build_headerunit(headerunit, key, bmifile, outputdir, build) @@ -96,7 +89,7 @@ function _build_headerunits(target, headerunits, opt) end -- should we build this module or headerunit ? -function _should_build(target, sourcefile, bmifile, opt) +function should_build(target, sourcefile, bmifile, opt) -- force rebuild a module if any of its module dependency is rebuilt local requires = opt.requires @@ -112,23 +105,21 @@ function _should_build(target, sourcefile, bmifile, opt) end end - -- or rebuild it if the file changed for headerunit and namedmodules + -- or rebuild it if the file changed local objectfile = opt.objectfile - if compiler_support.has_module_extension(sourcefile) or (opt and opt.headerunit) then - local dryrun = option.get("dry-run") - local compinst = compiler.load("cxx", {target = target}) - local compflags = compinst:compflags({sourcefile = sourcefile, target = target}) + local dryrun = option.get("dry-run") + local compinst = compiler.load("cxx", {target = target}) + local compflags = compinst:compflags({sourcefile = sourcefile, target = target}) - local dependfile = target:dependfile(bmifile or objectfile) - local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {}) + local dependfile = target:dependfile(bmifile or objectfile) + local dependinfo = target:is_rebuilt() and {} or (depend.load(dependfile) or {}) - -- need build this object? - local depvalues = {compinst:program(), compflags} - local lastmtime = os.isfile(bmifile or objectfile) and os.mtime(dependfile) or 0 + -- need build this object? + local depvalues = {compinst:program(), compflags} + local lastmtime = os.isfile(bmifile or objectfile) and os.mtime(dependfile) or 0 - if dryrun or depend.is_changed(dependinfo, {lastmtime = lastmtime, values = depvalues}) then - return true - end + if dryrun or depend.is_changed(dependinfo, {lastmtime = lastmtime, values = depvalues}) then + return true end return false @@ -190,7 +181,7 @@ function _builder(target) return builder end -function _mark_build(target, name) +function mark_build(target, name) compiler_support.memcache():set2("should_build_in" .. target:name(), name, true) end @@ -207,10 +198,10 @@ function build_modules_for_batchjobs(target, batchjobs, sourcebatch, modules, op local modulesjobs = {} _build_modules(target, sourcebatch, modules, table.join(opt, { - build_module = function(deps, build, module, name, provide, objectfile, cppfile, fileconfig) + build_module = function(deps, module, name, provide, objectfile, cppfile, fileconfig) local job_name = name and target:name() .. name or cppfile - modulesjobs[job_name] = _builder(target).make_module_buildjobs(target, batchjobs, job_name, deps, {build = build, module = module, objectfile = objectfile, cppfile = cppfile}) + modulesjobs[job_name] = _builder(target).make_module_buildjobs(target, batchjobs, job_name, deps, {module = module, objectfile = objectfile, cppfile = cppfile}) if provide and fileconfig and fileconfig.public then batchjobs:addjob(name .. "_metafile", function(index, total) @@ -237,8 +228,8 @@ function build_modules_for_batchcmds(target, batchcmds, sourcebatch, modules, op -- build modules _build_modules(target, sourcebatch, modules, table.join(opt, { - build_module = function(_, build, module, name, provide, objectfile, cppfile, fileconfig) - depmtime = math.max(depmtime, _builder(target).make_module_buildcmds(target, batchcmds, {build = build, module = module, cppfile = cppfile, objectfile = objectfile, progress = opt.progress})) + build_module = function(_, module, name, provide, objectfile, cppfile, fileconfig) + depmtime = math.max(depmtime, _builder(target).make_module_buildcmds(target, batchcmds, {module = module, cppfile = cppfile, objectfile = objectfile, progress = opt.progress})) if provide and fileconfig and fileconfig.public then local metafilepath = compiler_support.get_metafile(target, cppfile) |
