diff options
| author | ruki <[email protected]> | 2017-11-16 22:48:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-11-16 10:49:56 +0800 |
| commit | aecb5cbe755746baea1e0f3ec9c7a0cc0bdedd5b (patch) | |
| tree | 096b0d30f7ba64f3337b2081dad61d28a8e28540 /xmake/core/base | |
| parent | 0b97a1c0f52a1f9cf563bc1ec2fe41555ed173be (diff) | |
fix os.nuldev on gcc/mingw
Diffstat (limited to 'xmake/core/base')
| -rw-r--r-- | xmake/core/base/os.lua | 38 |
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 |
