diff options
| author | Arthur LAURENT <[email protected]> | 2022-08-05 05:11:14 +0200 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2022-08-05 05:11:14 +0200 |
| commit | e4179556134ffba995299eb3e949c48ad80d8678 (patch) | |
| tree | 7ee90edf404693fb61d1ad09d5b227d3896f4040 /xmake/rules/c++ | |
| parent | 4cdf4838df5d5903b8d2ac31c9a169c5d88a2ebb (diff) | |
Fix incorrect usage of set_depmtime/set_depcache
Diffstat (limited to 'xmake/rules/c++')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 35 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/gcc.lua | 29 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/msvc.lua | 34 |
3 files changed, 62 insertions, 36 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index cc6e2f927..c91decb97 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -141,6 +141,8 @@ function generate_stl_headerunits(target, batchcmds, headerunits, opt) -- build headerunits local projectdir = os.projectdir() local flags = {} + local bmifiles = {} + local depmtime = 0 for i, headerunit in ipairs(headerunits) do local bmifile = path.join(stlcachedir, headerunit.name .. get_bmi_extension()) if not os.isfile(bmifile) then @@ -149,11 +151,12 @@ function generate_stl_headerunits(target, batchcmds, headerunits, opt) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args)) end - batchcmds:set_depmtime(os.mtime(bmifile)) - batchcmds:set_depcache(target:dependfile(bmifile)) - table.insert(flags, modulefileflag .. bmifile) + table.append(bmifiles, bmifile) + depmtime = math.max(depmtime, os.mtime(bmifile)) end + batchcmds:set_depmtime(depmtime) + batchcmds:set_depcache(target:dependfile(bmifiles)) return flags end @@ -174,6 +177,8 @@ function generate_user_headerunits(target, batchcmds, headerunits, opt) local objectfiles = {} local flags = {} local projectdir = os.projectdir() + local bmifiles = {} + local depmtime = 0 for _, headerunit in ipairs(headerunits) do local file = path.relative(headerunit.path, target:scriptdir()) local objectfile = target:objectfile(file) @@ -201,11 +206,13 @@ function generate_user_headerunits(target, batchcmds, headerunits, opt) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args)) batchcmds:add_depfiles(headerunit.path) - batchcmds:set_depmtime(os.mtime(bmifile)) - batchcmds:set_depcache(target:dependfile(bmifile)) table.insert(flags, modulefileflag .. bmifile) + table.append(bmifiles, bmifile) + depmtime = math.max(depmtime, os.mtime(bmifile)) end + batchcmds:set_depmtime(depmtime) + batchcmds:set_depcache(target:dependfile(bmifiles)) return flags end @@ -229,7 +236,10 @@ function build_modules(target, batchcmds, objectfiles, modules, opt) end end + -- build modules local common_args = {modulecachepathflag .. cachedir} + local bmifiles = {} + local depmtime = 0 for _, objectfile in ipairs(objectfiles) do local m = modules[objectfile] if m then @@ -237,34 +247,33 @@ function build_modules(target, batchcmds, objectfiles, modules, opt) local args = { emitmoduleinterfaceflag } local bmiflags = {} - local bmifiles = {} + local bmifiles_ = {} for name, provide in pairs(m.provides) do batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.module.bmi %s", name) local bmifile = provide.bmi table.join2(args, { "-c", "-x", "c++-module", "--precompile", provide.sourcefile, "-o", bmifile }) - table.join2(bmifiles, bmifile) + table.append(bmifiles_, bmifile) batchcmds:add_depfiles(provide.sourcefile) - batchcmds:set_depmtime(os.mtime(bmifile)) - batchcmds:set_depcache(target:dependfile(bmifile)) table.join2(bmiflags, {modulefileflag .. bmifile}) + depmtime = math.max(depmtime, os.mtime(bmifile)) end batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, args)) - batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, bmifiles, {"-c", "-o", objectfile})) - - batchcmds:set_depmtime(os.mtime(objectfile)) - batchcmds:set_depcache(target:dependfile(objectfile)) + batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, bmifiles_, {"-c", "-o", objectfile})) target:add("cxxflags", bmiflags, {public = true, force = true}) target:add("objectfiles", objectfile) for _, f in ipairs(bmiflags) do target:data_add("cxx.modules.flags", f) end + table.join2(bmifiles, bmifiles_) end end + batchcmds:set_depmtime(depmtime) + batchcmds:set_depcache(target:dependfile(bmifiles)) end function get_bmi_extension() diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua index 1c53d22b5..c23ced122 100644 --- a/xmake/rules/c++/modules/modules_support/gcc.lua +++ b/xmake/rules/c++/modules/modules_support/gcc.lua @@ -159,6 +159,8 @@ function generate_stl_headerunits(target, batchcmds, headerunits, opt) -- build headerunits local projectdir = os.projectdir() + local bmifiles = {} + local depmtime = 0 for i, headerunit in ipairs(headerunits) do local bmifile = path.join(stlcachedir, headerunit.name .. get_bmi_extension()) if _add_module_to_mapper(mapper_file, headerunit.path, path.absolute(bmifile, projectdir)) then @@ -166,11 +168,12 @@ function generate_stl_headerunits(target, batchcmds, headerunits, opt) batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.headerunit.bmi %s", headerunit.name) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args)) - - batchcmds:set_depmtime(os.mtime(bmifile)) - batchcmds:set_depcache(target:dependfile(bmifile)) end + table.append(bmifiles, bmifile) + depmtime = math.max(depmtime, os.mtime(bmifile)) end + batchcmds:set_depmtime(depmtime) + batchcmds:set_depcache(target:dependfile(bmifiles)) end -- generate target user header units @@ -183,6 +186,8 @@ function generate_user_headerunits(target, batchcmds, headerunits, opt) -- build headerunits local projectdir = os.projectdir() + local bmifiles = {} + local depmtime = 0 for _, headerunit in ipairs(headerunits) do local file = path.relative(headerunit.path, projectdir) local objectfile = target:objectfile(file) @@ -215,10 +220,12 @@ function generate_user_headerunits(target, batchcmds, headerunits, opt) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args)) batchcmds:add_depfiles(headerunit.path) - batchcmds:set_depmtime(os.mtime(bmifile)) - batchcmds:set_depcache(target:dependfile(bmifile)) end + table.append(bmifiles, bmifile) + depmtime = math.max(depmtime, os.mtime(bmifile)) end + batchcmds:set_depmtime(depmtime) + batchcmds:set_depcache(target:dependfile(bmifiles)) end -- build module files @@ -230,7 +237,10 @@ function build_modules(target, batchcmds, objectfiles, modules, opt) -- get cachedirs local cachedir = common.modules_cachedir(target) + -- build modules local projectdir = os.projectdir() + local bmifiles = {} + local depmtime = 0 for _, objectfile in ipairs(objectfiles) do local m = modules[objectfile] if m then @@ -245,19 +255,18 @@ function build_modules(target, batchcmds, objectfiles, modules, opt) table.join2(args, {"-c", provide.sourcefile}) batchcmds:add_depfiles(provide.sourcefile) - batchcmds:set_depmtime(os.mtime(bmifile)) - batchcmds:set_depcache(target:dependfile(bmifile)) end + table.append(bmifiles, bmifile) + depmtime = math.max(depmtime, os.mtime(bmifile)) end batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, args)) - batchcmds:set_depmtime(os.mtime(objectfile)) - batchcmds:set_depcache(target:dependfile(objectfile)) - target:add("objectfiles", objectfile) end end + batchcmds:set_depmtime(depmtime) + batchcmds:set_depcache(target:dependfile(bmifiles)) end function get_bmi_extension() diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index 3f371c5c7..89cc35f6b 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -129,6 +129,8 @@ function generate_stl_headerunits(target, batchcmds, headerunits, opt) local common_args = {"/TP", exportheaderflag, "/c"} local objectfiles = {} local flags = {} + local bmifiles = {} + local depmtime = 0 for _, headerunit in ipairs(headerunits) do local bmifile = path.join(stlcachedir, headerunit.name .. get_bmi_extension()) if not os.isfile(bmifile) then @@ -137,12 +139,14 @@ function generate_stl_headerunits(target, batchcmds, headerunits, opt) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args), {envs = vcvars}) end - batchcmds:set_depmtime(os.mtime(bmifile)) - batchcmds:set_depcache(target:dependfile(bmifile)) - local flag = {headerunitflag .. ":angle", headerunit.name .. "=" .. headerunit.name .. get_bmi_extension()} table.join2(flags, flag) + + table.append(bmifiles, bmifile) + depmtime = math.max(depmtime, os.mtime(bmifile)) end + batchcmds:set_depmtime(depmtime) + batchcmds:set_depcache(target:dependfile(bmifiles)) return flags end @@ -167,6 +171,8 @@ function generate_user_headerunits(target, batchcmds, headerunits, opt) local objectfiles = {} local flags = {} local projectdir = os.projectdir() + local bmifiles = {} + local depmtime = 0 for _, headerunit in ipairs(headerunits) do local file = path.relative(headerunit.path, target:scriptdir()) local objectfile = target:objectfile(file) @@ -188,15 +194,16 @@ function generate_user_headerunits(target, batchcmds, headerunits, opt) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, args), {envs = vcvars}) batchcmds:add_depfiles(headerunit.path) - batchcmds:set_depmtime(os.mtime(bmifile)) - batchcmds:set_depcache(target:dependfile(bmifile)) - batchcmds:set_depmtime(os.mtime(objectfile)) - batchcmds:set_depcache(target:dependfile(objectfile)) local flag = {headerunitflag .. headerunit.type, headerunit.name .. "=" .. path.relative(bmifile, cachedir)} table.join2(flags, flag) target:add("objectfiles", objectfile) + + table.append(bmifiles, bmifile) + depmtime = math.max(depmtime, os.mtime(bmifile)) end + batchcmds:set_depmtime(depmtime) + batchcmds:set_depcache(target:dependfile(bmifiles)) return flags end @@ -221,8 +228,10 @@ function build_modules(target, batchcmds, objectfiles, modules, opt) end end - -- compile module files to bmi files + -- build modules local common_args = {"/TP"} + local bmifiles = {} + local depmtime = 0 for _, objectfile in ipairs(objectfiles) do local m = modules[objectfile] if m then @@ -237,17 +246,14 @@ function build_modules(target, batchcmds, objectfiles, modules, opt) table.join2(args, {interfaceflag, ifcoutputflag, bmifile, provide.sourcefile}) batchcmds:add_depfiles(provide.sourcefile) - batchcmds:set_depmtime(os.mtime(bmifile)) - batchcmds:set_depcache(target:dependfile(bmifile)) table.join2(bmiflags, {referenceflag, name .. "=" .. path.filename(bmifile)}) + table.append(bmifiles, bmifile) + depmtime = math.max(depmtime, os.mtime(bmifile)) end batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, args, bmi_args), {envs = vcvars}) - batchcmds:set_depmtime(os.mtime(objectfile)) - batchcmds:set_depcache(target:dependfile(objectfile)) - target:add("cxxflags", bmiflags, {force = true, expand = false}) for _, f in ipairs(bmiflags) do target:data_add("cxx.modules.flags", f) @@ -255,6 +261,8 @@ function build_modules(target, batchcmds, objectfiles, modules, opt) target:add("objectfiles", objectfile) end end + batchcmds:set_depmtime(depmtime) + batchcmds:set_depcache(target:dependfile(bmifiles)) end function get_bmi_extension() |
