From a2ccc580a274200d889d199094e7201076594f0d Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Tue, 30 Jan 2024 17:04:35 +0100 Subject: use try{} instead of assert to preserve iorunv error colors --- xmake/rules/c++/modules/modules_support/msvc/builder.lua | 2 +- xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support/msvc') diff --git a/xmake/rules/c++/modules/modules_support/msvc/builder.lua b/xmake/rules/c++/modules/modules_support/msvc/builder.lua index 3b295ca6b..929b0cd5d 100644 --- a/xmake/rules/c++/modules/modules_support/msvc/builder.lua +++ b/xmake/rules/c++/modules/modules_support/msvc/builder.lua @@ -86,7 +86,7 @@ function _compile(target, flags, sourcefile) if not dryrun then -- do compile - assert(os.iorunv(compinst:program(), flags, {envs = msvc:runenvs()})) + try{function() return os.iorunv(compinst:program(), flags, {envs = msvc:runenvs()}) end} end end diff --git a/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua b/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua index ed5027e22..6cf095a01 100644 --- a/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua +++ b/xmake/rules/c++/modules/modules_support/msvc/dependency_scanner.lua @@ -48,14 +48,14 @@ function generate_dependencies(target, sourcebatch, opt) local compinst = target:compiler("cxx") local msvc = target:toolchain("msvc") local compflags = table.join(compinst:compflags({sourcefile = sourcefile, target = target}) or {}, common_flags, flags) - os.vrunv(compinst:program(), winos.cmdargv(compflags), {envs = msvc:runenvs()}) + try{function() return os.iorunv(compinst:program(), winos.cmdargv(compflags), {envs = msvc:runenvs()}) end} else fallback_generate_dependencies(target, jsonfile, sourcefile, function(file) local compinst = target:compiler("cxx") local compflags = compinst:compflags({sourcefile = file, target = target}) local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i")) - os.vrunv(compinst:program(), table.join(compflags, - {"/P", "-TP", file, "/Fi" .. ifile}), {envs = msvc:runenvs()}) + try{function() return os.vrunv(compinst:program(), table.join(compflags, + {"/P", "-TP", file, "/Fi" .. ifile}), {envs = msvc:runenvs()}) end} local content = io.readfile(ifile) os.rm(ifile) return content -- cgit v1.3.1