From eab12862d905574ada90a75af8ccf246be152ea4 Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 16 Mar 2020 23:41:46 +0800 Subject: fix link errors output --- xmake/modules/core/tools/cl.lua | 2 +- xmake/modules/core/tools/link.lua | 25 +++++++++++++++++++++++-- xmake/modules/core/tools/ml.lua | 24 ++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index 9ff2ffce3..fc701d5d8 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -353,7 +353,7 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) { function (errors) - -- use cl/stdout as errors first from os.iorunv() + -- use cl/stdout as errors first from vstool.iorunv() if type(errors) == "table" then local errs = errors.stdout or "" if #errs:trim() == 0 then diff --git a/xmake/modules/core/tools/link.lua b/xmake/modules/core/tools/link.lua index c9df9c630..b45f3c7a9 100644 --- a/xmake/modules/core/tools/link.lua +++ b/xmake/modules/core/tools/link.lua @@ -113,7 +113,28 @@ function link(self, objectfiles, targetkind, targetfile, flags, opt) -- ensure the target directory os.mkdir(path.directory(targetfile)) - -- use vstool to link and enable vs_unicode_output @see https://github.com/xmake-io/xmake/issues/528 - vstool.runv(linkargv(self, objectfiles, targetkind, targetfile, flags, opt)) + try + { + function () + + -- use vstool to link and enable vs_unicode_output @see https://github.com/xmake-io/xmake/issues/528 + vstool.runv(linkargv(self, objectfiles, targetkind, targetfile, flags, opt)) + end, + catch + { + function (errors) + + -- use link/stdout as errors first from vstool.iorunv() + if type(errors) == "table" then + local errs = errors.stdout or "" + if #errs:trim() == 0 then + errs = errors.stderr or "" + end + errors = errs + end + os.raise(tostring(errors)) + end + } + } end diff --git a/xmake/modules/core/tools/ml.lua b/xmake/modules/core/tools/ml.lua index 2c67ef740..24ee3ecab 100644 --- a/xmake/modules/core/tools/ml.lua +++ b/xmake/modules/core/tools/ml.lua @@ -101,8 +101,28 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags) -- ensure the object directory os.mkdir(path.directory(objectfile)) - -- use vstool to compile and enable vs_unicode_output @see https://github.com/xmake-io/xmake/issues/528 - vstool.runv(_compargv1(self, sourcefile, objectfile, flags)) + try + { + function () + -- use vstool to compile and enable vs_unicode_output @see https://github.com/xmake-io/xmake/issues/528 + vstool.runv(_compargv1(self, sourcefile, objectfile, flags)) + end, + catch + { + function (errors) + + -- use link/stdout as errors first from vstool.iorunv() + if type(errors) == "table" then + local errs = errors.stdout or "" + if #errs:trim() == 0 then + errs = errors.stderr or "" + end + errors = errs + end + os.raise(tostring(errors)) + end + } + } end -- make the compile arguments list -- cgit v1.3.1