From fdc78354fdb5fada3c1db0c7cd1ccd803f9d36c1 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 19 Dec 2022 22:53:39 +0800 Subject: improve batchcmds for modules --- xmake/rules/c++/modules/modules_support/msvc.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support') diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index e5c37ea38..07de952cb 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -69,6 +69,13 @@ function _compile(target, flags) os.vrunv(compinst:program(), winos.cmdargv(table.join(compinst:compflags({target = target}), flags)), {envs = msvc:runenvs()}) end +-- do compile for batchcmds +function _batchcmds_compile(batchcmds, target, flags) + local compinst = target:compiler("cxx") + local compflags = compinst:compflags({target = target}) + batchcmds:vrunv(compinst:program(), table.join(compflags or {}, flags), {envs = compinst:runenvs()}) +end + -- add an objectfile to the linker flags -- -- e.g @@ -246,11 +253,9 @@ end -- generate header unit module bmi for batchcmds function generate_headerunit_for_batchcmds(target, name, flags, objectfile, batchcmds, opt) - local compinst = target:compiler("cxx") - local msvc = target:toolchain("msvc") local common_flags = {"-TP", "-c"} batchcmds:show_progress(opt.progress, "${color.build.object}compiling.headerunit.$(mode) %s", name) - batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_flags, flags), {envs = msvc:runenvs()}) + _batchcmds_compile(batchcmds, target, table.join(common_flags, flags)) _add_objectfile_to_link_arguments(target, objectfile) end @@ -520,8 +525,6 @@ end -- build module files for batchcmds function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, opt) - local compinst = target:compiler("cxx") - local msvc = target:toolchain("msvc") -- get flags local ifcoutputflag = get_ifcoutputflag(target) @@ -570,7 +573,7 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op batchcmds:show_progress(opt.progress, "${color.build.object}compiling.module.$(mode) %s", name or cppfile) batchcmds:mkdir(path.directory(objectfile)) - batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), table.join(flags, requiresflags or {})), {envs = msvc:runenvs()}) + _batchcmds_compile(batchcmds, target, table.join(flags, requiresflags or {})) batchcmds:add_depfiles(cppfile) _add_objectfile_to_link_arguments(target, path(objectfile)) if provide then -- cgit v1.3.1