From 2a95f6e1394c42f166ac4184ab2cf4d77b4ffa7a Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 12 Jul 2016 16:39:30 +0800 Subject: fix and optimizate to compile issues for cl.exe --- xmake/core/sandbox/modules/os.lua | 2 +- xmake/tools/cl.lua | 21 ++++++++++++++++++++- xmake/tools/gcc.lua | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index ab61d0866..03ffe7af0 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -242,7 +242,7 @@ function sandbox_os.iorun(cmd, ...) -- run it local ok, outdata, errdata = os.iorun(cmd) if not ok then - os.raise(errdata) + os.raise((outdata or "") .. (errdata or "")) end -- ok diff --git a/xmake/tools/cl.lua b/xmake/tools/cl.lua index 660c47ed8..0ec391e36 100755 --- a/xmake/tools/cl.lua +++ b/xmake/tools/cl.lua @@ -126,7 +126,26 @@ function compile(sourcefile, objectfile, incdepfile, flags) end -- compile it - local outdata = os.iorun(compcmd(sourcefile, objectfile, flags)) + local outdata = try + { + function () + return os.iorun(compcmd(sourcefile, objectfile, flags)) + end, + + catch + { + function (errors) + + -- filter includes notes + if errors then + errors = errors:gsub("Note: including file:%s*.-\r*\n", "") + end + os.raise(errors) + end + } + } + + -- parse include dependencies if incdepfile and outdata then -- translate it diff --git a/xmake/tools/gcc.lua b/xmake/tools/gcc.lua index 556e7ae40..02eb1abe5 100755 --- a/xmake/tools/gcc.lua +++ b/xmake/tools/gcc.lua @@ -158,7 +158,7 @@ function compile(sourcefile, objectfile, incdepfile, flags) local tmpfile = os.tmpfile() -- generate it - os.run(compcmd(sourcefile, tmpfile, (flags or "") .. " -MM")) + os.run("%s -c -MM %s -o %s %s", _g.shellname, flags or "", tmpfile, sourcefile) -- translate it local results = {} -- cgit v1.3.1