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 | |
| parent | 0b97a1c0f52a1f9cf563bc1ec2fe41555ed173be (diff) | |
fix os.nuldev on gcc/mingw
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/core/_xmake_main.lua | 1 | ||||
| -rw-r--r-- | xmake/core/base/os.lua | 38 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/gcc/has_flags.lua | 2 |
3 files changed, 36 insertions, 5 deletions
diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua index e9a23f491..a35d8b52b 100644 --- a/xmake/core/_xmake_main.lua +++ b/xmake/core/_xmake_main.lua @@ -27,7 +27,6 @@ xmake = xmake or {} xmake._ARGV = _ARGV xmake._HOST = _HOST xmake._ARCH = _ARCH -xmake._NULDEV = _NULDEV xmake._VERSION = _VERSION xmake._VERSION_SHORT = _VERSION_SHORT xmake._PROGRAM_DIR = _PROGRAM_DIR 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 diff --git a/xmake/modules/detect/tools/gcc/has_flags.lua b/xmake/modules/detect/tools/gcc/has_flags.lua index aa02557e8..fc7a8d2a6 100644 --- a/xmake/modules/detect/tools/gcc/has_flags.lua +++ b/xmake/modules/detect/tools/gcc/has_flags.lua @@ -105,7 +105,7 @@ function _check_try_running(flags, opt, islinker) end -- check flags for compiler - return try { function () os.runv(opt.program, table.join(flags, "-S", "-o", os.nuldev(), "-x" .. lang, os.nuldev())); return true end } + return try { function () os.runv(opt.program, table.join(flags, "-S", "-o", os.nuldev(), "-x" .. lang, os.nuldev(true))); return true end } end -- has_flags(flags)? |
