diff options
| author | ruki <[email protected]> | 2022-11-25 12:18:12 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-25 12:18:12 +0800 |
| commit | a64cea90e22dd80dfec90701549cddf812cfa357 (patch) | |
| tree | d7dd6b10214bca72413d35cad193932762722ac2 /xmake/modules | |
| parent | 4b3232ce7d067f5ec760b80c16978f261918ffe1 (diff) | |
| parent | ca378b2af611a9851f05b51919b562f2be053f08 (diff) | |
Merge pull request #3101 from xmake-io/cl
Fix files or directories not access by another process occupied
Diffstat (limited to 'xmake/modules')
| -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, |
