diff options
| author | ruki <[email protected]> | 2023-02-15 22:46:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-15 22:46:13 +0800 |
| commit | e288951c41b72f3ccf3cfed495417fea7dee1e79 (patch) | |
| tree | 085099794d03376e60680ae594697a3669f6fbf5 | |
| parent | 0936ad49411c55cf4130793750336e011366ebbf (diff) | |
add snippet to has_flags
| -rw-r--r-- | xmake/modules/detect/tools/cl/has_flags.lua | 6 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/gcc/has_flags.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/nvcc/has_flags.lua | 6 |
3 files changed, 9 insertions, 8 deletions
diff --git a/xmake/modules/detect/tools/cl/has_flags.lua b/xmake/modules/detect/tools/cl/has_flags.lua index fe57e38b0..e1e986303 100644 --- a/xmake/modules/detect/tools/cl/has_flags.lua +++ b/xmake/modules/detect/tools/cl/has_flags.lua @@ -54,10 +54,10 @@ end function _check_try_running(flags, opt) -- make an stub source file - local tmpdir = path.join(os.tmpdir(), "detect") - local sourcefile = path.join(tmpdir, "cl_has_flags" .. _get_extension(opt)) + local snippet = opt.snippet or "int main(int argc, char** argv)\n{return 0;}" + local sourcefile = os.tmpfile("cl_has_flags:" .. snippet) .. _get_extension(opt) if not os.isfile(sourcefile) then - io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}") + io.writefile(sourcefile, snippet) end -- check it diff --git a/xmake/modules/detect/tools/gcc/has_flags.lua b/xmake/modules/detect/tools/gcc/has_flags.lua index 64fa70df8..6ab7ce810 100644 --- a/xmake/modules/detect/tools/gcc/has_flags.lua +++ b/xmake/modules/detect/tools/gcc/has_flags.lua @@ -77,9 +77,10 @@ end function _check_try_running(flags, opt, islinker) -- make an stub source file - local sourcefile = path.join(os.tmpdir(), "detect", "gcc_has_flags" .. _get_extension(opt)) + local snippet = opt.snippet or "int main(int argc, char** argv)\n{return 0;}" + local sourcefile = os.tmpfile("gcc_has_flags:" .. snippet) .. _get_extension(opt) if not os.isfile(sourcefile) then - io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}") + io.writefile(sourcefile, snippet) end -- check flags for linker diff --git a/xmake/modules/detect/tools/nvcc/has_flags.lua b/xmake/modules/detect/tools/nvcc/has_flags.lua index d96ffdfe8..c75f6e114 100644 --- a/xmake/modules/detect/tools/nvcc/has_flags.lua +++ b/xmake/modules/detect/tools/nvcc/has_flags.lua @@ -101,13 +101,13 @@ end function _check_try_running(flags, opt, islinker) -- make an stub source file - local sourcefile = path.join(os.tmpdir(), "detect", "nvcc_has_flags.cu") + local snippet = opt.snippet or "int main(int argc, char** argv)\n{return 0;}" + local sourcefile = os.tmpfile("nvcc_has_flags:" .. snippet) .. ".cu" if not os.isfile(sourcefile) then - io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}") + io.writefile(sourcefile, snippet) end local args = table.join("-o", os.nuldev(), sourcefile) - if not islinker then table.insert(args, 1, "-c") end |
