summaryrefslogtreecommitdiff
path: root/xmake/core/base/os.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core/base/os.lua')
-rw-r--r--xmake/core/base/os.lua38
1 files changed, 35 insertions, 3 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 20114e2de..6275c4e15 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -691,9 +691,41 @@ function os.arch()
return xmake._ARCH
end
--- get the system null device
-function os.nuldev()
- return xmake._NULDEV
+-- get the system null device
+function os.nuldev(input)
+
+ -- init the output nuldev
+ if xmake._NULDEV_OUTPUT == nil then
+ if os.host() == "windows" then
+ xmake._NULDEV_OUTPUT = "nul"
+ else
+ xmake._NULDEV_OUTPUT = "/dev/null"
+ end
+ end
+
+ -- init the input nuldev
+ if xmake._NULDEV_INPUT == nil then
+ if os.host() == "windows" 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
+ else
+ xmake._NULDEV_INPUT = "/dev/null"
+ end
+ end
+
+ -- get nuldev
+ if input then
+ return xmake._NULDEV_INPUT
+ else
+ return xmake._NULDEV_OUTPUT
+ end
end
-- get user agent