diff options
| author | ruki <[email protected]> | 2022-11-25 22:52:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-11-25 22:52:30 +0800 |
| commit | 6aea0d82f240f27d500ee16701eb8d253533cf16 (patch) | |
| tree | 25dc076978067f5b40875c1a0d6069a666caf06f /xmake/modules/core/tools/cl.lua | |
| parent | 4b3232ce7d067f5ec760b80c16978f261918ffe1 (diff) | |
improve to run cl.exe
Diffstat (limited to 'xmake/modules/core/tools/cl.lua')
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index a20e4d85b..12b1be79c 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -500,16 +500,24 @@ function _preprocess(program, argv, opt) end table.insert(cppflags, sourcefile) return try{ function() - local outfile = os.tmpfile() .. ".i.out" + -- https://github.com/xmake-io/xmake/issues/2902#issuecomment-1326934902 + local outfile = cppfile local errfile = os.tmpfile() .. ".i.err" + local inherit_handles_safely = true + if not winos.inherit_handles_safely() then + outfile = os.tmpfile() .. ".i.out" + inherit_handles_safely = false + end os.execv(program, winos.cmdargv(cppflags), table.join(opt, {stdout = outfile, stderr = errfile})) local errdata if os.isfile(errfile) then errdata = io.readfile(errfile) end - os.cp(outfile, cppfile) os.tryrm(errfile) - os.tryrm(outfile) + if not inherit_handles_safely then + os.cp(outfile, cppfile) + os.tryrm(outfile) + end -- includes information will be output to stderr instead of stdout now return {outdata = errdata, errdata = errdata, sourcefile = sourcefile, objectfile = objectfile, cppfile = cppfile, cppflags = flags, |
