diff options
| author | ruki <[email protected]> | 2016-04-28 11:14:04 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-04-28 11:14:04 +0800 |
| commit | 3571f65949d94560efbb2ae26703e0f5ac8a5f13 (patch) | |
| tree | 270eccf3ff12e44673fde8bcb0bc5c5a0dc93682 | |
| parent | 52eb26701de17e800ae69cc495ac665a39d5d1dd (diff) | |
add link and nmake tools for windows
| -rw-r--r-- | xmake/core/tool/tool.lua | 3 | ||||
| -rwxr-xr-x | xmake/tools/lib.lua | 65 | ||||
| -rwxr-xr-x | xmake/tools/link.lua | 3 | ||||
| -rw-r--r-- | xmake/tools/make.lua | 10 | ||||
| -rwxr-xr-x | xmake/tools/ml.lua | 146 | ||||
| -rw-r--r-- | xmake/tools/nmake.lua | 75 |
6 files changed, 295 insertions, 7 deletions
diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua index 2c8ef6ee0..0bbcd9e09 100644 --- a/xmake/core/tool/tool.lua +++ b/xmake/core/tool/tool.lua @@ -76,6 +76,9 @@ function tool._find(root, name) -- make the lower name name = name:lower() + -- remove arguments: -xxx or --xxx + name = (name:gsub("%s%-+%w+", " ")) + -- get all tool files local file_ok = nil local score_maxn = 0 diff --git a/xmake/tools/lib.lua b/xmake/tools/lib.lua new file mode 100755 index 000000000..a54a69d89 --- /dev/null +++ b/xmake/tools/lib.lua @@ -0,0 +1,65 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> +-- +-- Copyright (C) 2015 - 2016, ruki All rights reserved. +-- +-- @author ruki +-- @file lib.lua +-- + +-- imports +import("utils.vsenv") + +-- init it +function init(shellname) + + -- save the shell name + _g.shellname = shellname or "lib.exe" +end + +-- get the property +function get(name) + + -- get it + return _g[name] +end + +-- run command +function run(...) + + -- enter vs envirnoment + vsenv.enter() + + -- run it + os.run(...) + + -- leave vs envirnoment + vsenv.leave() +end + +-- check the given flags +function check(flags) + + -- enter vs envirnoment + vsenv.enter() + + -- check it + os.run("%s", _g.shellname, ifelse(flags, flags, "")) + + -- leave vs envirnoment + vsenv.leave() +end + diff --git a/xmake/tools/link.lua b/xmake/tools/link.lua index f31cdaef5..7ebbbfc91 100755 --- a/xmake/tools/link.lua +++ b/xmake/tools/link.lua @@ -128,10 +128,9 @@ function check(flags) local srcfile = path.join(os.tmpdir(), "xmake.cl.c") io.write(srcfile, "int main(int argc, char** argv)\n{return 0;}") - -- TODO import compiler -- check it os.run("cl -c -Fo%s %s", objfile, srcfile) - os.run("%s %s -out:%s %s", _g.shellname, flags, exefile, objfile) + os.run("%s %s -out:%s %s", _g.shellname, ifelse(flags, flags, ""), exefile, objfile) -- remove files os.rm(objfile) diff --git a/xmake/tools/make.lua b/xmake/tools/make.lua index a95685478..0fe4a727a 100644 --- a/xmake/tools/make.lua +++ b/xmake/tools/make.lua @@ -56,7 +56,7 @@ function run(makefile, target, jobs) local verbose = ifelse(option.get("verbose"), "-v", "") -- run it - local ok = nil + local ok = -1 if makefile and os.isfile(makefile) then ok = os.execute("%s -r %s -f %s %s VERBOSE=%s", _g.shellname, jobs, makefile, target or "", verbose) else @@ -86,12 +86,12 @@ end function check(flags) -- make an empty makefile - local tmpfile = path.join(os.tmpdir(), "xmake.checker.make") - io.write(tmpfile, "all:\n") + local makefile = path.join(os.tmpdir(), "xmake.checker.make") + io.write(makefile, "all:\n") -- check it - os.run("%s %s -f %s", _g.shellname, ifelse(flags, flags, ""), tmpfile) + os.run("%s %s -f %s", _g.shellname, ifelse(flags, flags, ""), makefile) -- remove this makefile - os.rm(tmpfile) + os.rm(makefile) end diff --git a/xmake/tools/ml.lua b/xmake/tools/ml.lua new file mode 100755 index 000000000..88b8d0da7 --- /dev/null +++ b/xmake/tools/ml.lua @@ -0,0 +1,146 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> +-- +-- Copyright (C) 2015 - 2016, ruki All rights reserved. +-- +-- @author ruki +-- @file ml.lua +-- + +-- imports +import("utils.vsenv") + +-- init it +function init(shellname) + + -- save name + _g.shellname = shellname or "ml.exe" + + -- init asflags + _g.asflags = { "-nologo", "-Gd", "-MP4", "-D_MBCS", "-D_CRT_SECURE_NO_WARNINGS"} + + -- init flags map + _g.mapflags = + { + -- optimize + ["-O0"] = "-Od" + , ["-O3"] = "-Ot" + , ["-Ofast"] = "-Ox" + , ["-fomit-frame-pointer"] = "-Oy" + + -- symbols + , ["-g"] = "-Z7" + , ["-fvisibility=.*"] = "" + + -- warnings + , ["-Wall"] = "-W3" -- = "-Wall" will enable too more warnings + , ["-W1"] = "-W1" + , ["-W2"] = "-W2" + , ["-W3"] = "-W3" + , ["-Werror"] = "-WX" + , ["%-Wno%-error=.*"] = "" + + -- vectorexts + , ["-mmmx"] = "-arch:MMX" + , ["-msse"] = "-arch:SSE" + , ["-msse2"] = "-arch:SSE2" + , ["-msse3"] = "-arch:SSE3" + , ["-mssse3"] = "-arch:SSSE3" + , ["-mavx"] = "-arch:AVX" + , ["-mavx2"] = "-arch:AVX2" + , ["-mfpu=.*"] = "" + + -- others + , ["-ftrapv"] = "" + , ["-fsanitize=address"] = "" + } + +end + +-- get the property +function get(name) + + -- get it + return _g[name] +end + +-- make the define flag +function define(macro) + + -- make it + return "-D" .. macro:gsub("\"", "\\\"") +end + +-- make the undefine flag +function undefine(macro) + + -- make it + return "-U" .. macro +end + +-- make the includedir flag +function includedir(dir) + + -- make it + return "-I" .. dir +end + +-- make the complie command +function compcmd(srcfile, objfile, flags, logfile) + + -- redirect + local redirect = "" + if logfile then redirect = format(" > %s 2>&1", logfile) end + + -- make it + return format("%s -c %s -Fo%s %s%s", _g.shellname, flags, objfile, srcfile, redirect) +end + +-- run command +function run(...) + + -- enter vs envirnoment + vsenv.enter() + + -- run it + os.run(...) + + -- leave vs envirnoment + vsenv.leave() +end + +-- check the given flags +function check(flags) + + -- enter vs envirnoment + vsenv.enter() + + -- make an stub source file + local objfile = path.join(os.tmpdir(), "xmake.ml.obj") + local srcfile = path.join(os.tmpdir(), "xmake.ml.asm") + io.write(srcfile, "end") + + -- check it + os.run("%s -c %s -Fo%s %s", _g.shellname, ifelse(flags, flags, ""), objfile, srcfile) + + -- remove files + os.rm(objfile) + os.rm(srcfile) + + -- leave vs envirnoment + vsenv.leave() +end + diff --git a/xmake/tools/nmake.lua b/xmake/tools/nmake.lua new file mode 100644 index 000000000..d62b785b0 --- /dev/null +++ b/xmake/tools/nmake.lua @@ -0,0 +1,75 @@ +--!The Automatic Cross-platform Build Tool +-- +-- XMake is free software; you can redistribute it and/or modify +-- it under the terms of the GNU Lesser General Public License as published by +-- the Free Software Foundation; either version 2.1 of the License, or +-- (at your option) any later version. +-- +-- XMake is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public License +-- along with XMake; +-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> +-- +-- Copyright (C) 2015 - 2016, ruki All rights reserved. +-- +-- @author ruki +-- @file nmake.lua +-- + +-- imports +import("utils.vsenv") +import("core.base.option") + +-- init it +function init(shellname) + + -- save name + _g.shellname = shellname or "nmake.exe" + +end + +-- get the property +function get(name) + + -- get it + return _g[name] +end + +-- run it +function run(makefile, target, jobs) + + -- is verbose? + local verbose = ifelse(option.get("verbose"), "-v", "") + + -- enter vs envirnoment + vsenv.enter() + + -- run command + if makefile and os.isfile(makefile) then + os.run("%s /nologo /f %s %s VERBOSE=%s", _g.shellname, makefile, target or "", verbose) + else + os.run("%s /nologo %s VERBOSE=%s", _g.shellname, target or "", verbose) + end + + -- leave vs envirnoment + vsenv.leave() +end + +-- check the given flags +function check(flags) + + -- make an empty makefile + local makefile = path.join(os.tmpdir(), "xmake.checker.nmake") + io.write(makefile, "all:\n") + + -- check it + os.run("%s /nologo %s /f %s", _g.shellname, ifelse(flags, flags, ""), makefile) + + -- remove this makefile + os.rm(makefile) +end + |
