Skip to content

Commit

Permalink
fix os.nuldev()
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jul 1, 2019
1 parent 1d703c1 commit db0b2ae
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions xmake/core/base/os.lua
Original file line number Diff line number Diff line change
Expand Up @@ -788,39 +788,36 @@ end
-- get the system null device
function os.nuldev(input)

if os.host() == "windows" then
-- init the output nuldev
if xmake._NULDEV_OUTPUT == nil then
xmake._NULDEV_OUTPUT = os.tmpfile()
if input then
if os.host() == "windows" then
-- init the input nuldev
if xmake._NULDEV_INPUT == nil then
-- create an empty file
--
-- for fix issue on mingw:
-- $ gcc -fopenmp -S -o nul -xc nul
-- gcc: fatal error:input file 'nul' is the same as output file
--
local inputfile = os.tmpfile()
io.writefile(inputfile, "")
xmake._NULDEV_INPUT = inputfile
end
else
os.rm(xmake._NULDEV_OUTPUT)
end
-- init the input nuldev
if xmake._NULDEV_INPUT == nil then
-- create an empty file
--
-- for fix issue on mingw:
-- $ gcc -fopenmp -S -o nul -xc nul
-- gcc: fatal error:input file ‘nul’ is the same as output file
--
local inputfile = os.tmpfile()
io.writefile(inputfile, "")
xmake._NULDEV_INPUT = inputfile
end
else
if xmake._NULDEV_OUTPUT == nil then
xmake._NULDEV_OUTPUT = "/dev/null"
end
if xmake._NULDEV_INPUT == nil then
xmake._NULDEV_INPUT = "/dev/null"
if xmake._NULDEV_INPUT == nil then
xmake._NULDEV_INPUT = "/dev/null"
end
end
end

-- get nuldev
if input then
return xmake._NULDEV_INPUT
else
return xmake._NULDEV_OUTPUT
if os.host() == "windows" then
-- @note cannot cache this file path to avoid multi-processes writing to the same file at the same time
return os.tmpfile()
else
if xmake._NULDEV_OUTPUT == nil then
xmake._NULDEV_OUTPUT = "/dev/null"
end
return xmake._NULDEV_OUTPUT
end
end
end

Expand Down

0 comments on commit db0b2ae

Please sign in to comment.