diff options
| author | ruki <[email protected]> | 2015-06-16 18:27:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-16 18:27:00 +0800 |
| commit | d549aaedf96e6d6eb77e9d588dc0a0269cd1ae71 (patch) | |
| tree | 51d971fe326561b62895743a38a1544af6df2dff /xmake/scripts | |
| parent | 608602d0de1056f856e0b6bfe33b3f5fbe641b63 (diff) | |
fix the command is too long for nmake
Diffstat (limited to 'xmake/scripts')
| -rw-r--r-- | xmake/scripts/base/compiler.lua | 16 | ||||
| -rw-r--r-- | xmake/scripts/base/linker.lua | 10 | ||||
| -rw-r--r-- | xmake/scripts/base/makefile.lua | 19 | ||||
| -rw-r--r-- | xmake/scripts/platform/windows/prober.lua | 4 | ||||
| -rw-r--r-- | xmake/scripts/platform/windows/tools/cl.lua | 12 | ||||
| -rw-r--r-- | xmake/scripts/platform/windows/tools/link.lua | 20 | ||||
| -rw-r--r-- | xmake/scripts/platform/windows/tools/nmake.lua | 4 | ||||
| -rw-r--r-- | xmake/scripts/tools/ar.lua | 8 | ||||
| -rw-r--r-- | xmake/scripts/tools/cat.lua | 43 | ||||
| -rw-r--r-- | xmake/scripts/tools/crun.lua | 60 | ||||
| -rw-r--r-- | xmake/scripts/tools/gcc.lua | 16 |
11 files changed, 172 insertions, 40 deletions
diff --git a/xmake/scripts/base/compiler.lua b/xmake/scripts/base/compiler.lua index 9a2f9eb43..0b7c5115d 100644 --- a/xmake/scripts/base/compiler.lua +++ b/xmake/scripts/base/compiler.lua @@ -416,7 +416,7 @@ function compiler.get(srcfile) end -- make the compile command -function compiler.make(module, target, srcfile, objfile) +function compiler.make(module, target, srcfile, objfile, logfile) -- check assert(module and target) @@ -439,7 +439,7 @@ function compiler.make(module, target, srcfile, objfile) compiler._addflags_from_config(module, flags, flagnames) -- make the compile command - return module:command_compile(srcfile, objfile, table.concat(flags, " "):trim()) + return module:command_compile(srcfile, objfile, table.concat(flags, " "):trim(), logfile) end -- check include for the project option @@ -487,12 +487,8 @@ function compiler.check_include(opt, include, srcpath, objpath) -- add flags from the configure compiler._addflags_from_config(module, flags, flagnames) - -- make the compile command - local cmd = string.format("%s > %s 2>&1", module:command_compile(srcpath, objpath, table.concat(flags, " "):trim()), xmake._NULDEV) - if not cmd then return end - -- execute the compile command - return module:main(cmd) + return module:main(module:command_compile(srcpath, objpath, table.concat(flags, " "):trim(), xmake._NULDEV)) end -- check function for the project option @@ -552,12 +548,8 @@ function compiler.check_function(opt, interface, srcpath, objpath) -- add flags from the configure compiler._addflags_from_config(module, flags, flagnames) - -- make the compile command - local cmd = string.format("%s > %s 2>&1", module:command_compile(srcpath, objpath, table.concat(flags, " "):trim()), xmake._NULDEV) - if not cmd then return end - -- execute the compile command - return module:main(cmd) + return module:main(module:command_compile(srcpath, objpath, table.concat(flags, " "):trim(), xmake._NULDEV)) end -- return module: compiler diff --git a/xmake/scripts/base/linker.lua b/xmake/scripts/base/linker.lua index caddaadc4..0f9ae1887 100644 --- a/xmake/scripts/base/linker.lua +++ b/xmake/scripts/base/linker.lua @@ -271,7 +271,7 @@ function linker.get(kind) end -- make the link command -function linker.make(module, target, objfiles, targetfile) +function linker.make(module, target, objfiles, targetfile, logfile) -- check assert(module and target) @@ -304,7 +304,7 @@ function linker.make(module, target, objfiles, targetfile) linker._addflags_from_config(module, flags, flagname) -- make the link command - return module:command_link(table.concat(objfiles, " "), targetfile, table.concat(flags, " "):trim()) + return module:command_link(table.concat(objfiles, " "), targetfile, table.concat(flags, " "):trim(), logfile) end -- check link for the project option @@ -333,12 +333,8 @@ function linker.check_links(opt, links, objectfile, targetfile) -- add flags from the configure linker._addflags_from_config(module, flags, "ldflags") - -- make the compile command - local cmd = string.format("%s > %s 2>&1", module:command_link(objectfile, targetfile, table.concat(flags, " "):trim()), xmake._NULDEV) - if not cmd then return end - -- execute the link command - return module:main(cmd) + return module:main(module:command_link(objectfile, targetfile, table.concat(flags, " "):trim(), xmake._NULDEV)) end -- return module: linker diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua index aae7696b0..6a6511b54 100644 --- a/xmake/scripts/base/makefile.lua +++ b/xmake/scripts/base/makefile.lua @@ -61,7 +61,7 @@ function makefile._make_object(file, target, srcfile, objfile) local ccache = platform.tool("ccache") -- make command - local cmd = compiler.make(c, target, srcfile, objfile) + local cmd = compiler.make(c, target, srcfile, objfile, makefile._LOGFILE) if ccache then cmd = ccache:append(cmd, " ") end @@ -76,7 +76,7 @@ function makefile._make_object(file, target, srcfile, objfile) file:write(string.format("\t@echo %scompiling%s %s\n", utils.ifelse(ccache, "ccache ", ""), mode, srcfile)) file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("[%s=\"]", function (w) return string.format("%%%x", w:byte()) end))) file:write(string.format("\t@xmake l mkdir %s\n", path.directory(objfile))) - file:write(string.format("\t@%s > %s 2>&1\n", cmd, makefile._LOGFILE)) + file:write(string.format("\t@%s\n", cmd)) -- make tail file:write("\n") @@ -155,13 +155,22 @@ function makefile._make_target(file, name, target) elseif mode == "debug" then mode = ".d" elseif mode == "profile" then mode = ".p" else mode = "" end + + -- make the command + local cmd = linker.make(l, target, objfiles, targetfile, makefile._LOGFILE) + + -- the verbose + local verbose = cmd:gsub("[%s=\"<]", function (w) return string.format("%%%x", w:byte()) end) + -- too long? + if verbose and #verbose > 256 then + verbose = verbose:sub(1, 256) .. " ..." + end -- make body - local cmd = linker.make(l, target, objfiles, targetfile) file:write(string.format("\t@echo linking%s %s\n", mode, path.filename(targetfile))) - file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("[%s=\"]", function (w) return string.format("%%%x", w:byte()) end))) + file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", verbose)) file:write(string.format("\t@xmake l mkdir %s\n", path.directory(targetfile))) - file:write(string.format("\t@%s > %s 2>&1\n", cmd, makefile._LOGFILE)) + file:write(string.format("\t@%s\n", cmd)) if srcheaders then local i = 1 for _, srcheader in ipairs(srcheaders) do diff --git a/xmake/scripts/platform/windows/prober.lua b/xmake/scripts/platform/windows/prober.lua index 764669a27..f4aacf9d2 100644 --- a/xmake/scripts/platform/windows/prober.lua +++ b/xmake/scripts/platform/windows/prober.lua @@ -236,8 +236,8 @@ function prober._probe_toolchains(configs) if not prober._probe_toolpath(configs, "cc", "cl.exe", "the c compiler") then return false end if not prober._probe_toolpath(configs, "cxx", "cl.exe", "the c++ compiler") then return false end if not prober._probe_toolpath(configs, "ld", "link.exe", "the linker") then return false end - if not prober._probe_toolpath(configs, "ar", "link.exe", "the static library linker") then return false end - if not prober._probe_toolpath(configs, "sh", "link.exe", "the shared library linker") then return false end + if not prober._probe_toolpath(configs, "ar", "link.exe -lib", "the static library linker") then return false end + if not prober._probe_toolpath(configs, "sh", "link.exe -dll", "the shared library linker") then return false end if not prober._probe_toolpath(configs, "make", "nmake.exe", "the make") then return false end -- leave envirnoment diff --git a/xmake/scripts/platform/windows/tools/cl.lua b/xmake/scripts/platform/windows/tools/cl.lua index 0d94f7800..e6306fccb 100644 --- a/xmake/scripts/platform/windows/tools/cl.lua +++ b/xmake/scripts/platform/windows/tools/cl.lua @@ -55,6 +55,10 @@ function cl.init(self, name) , ["-fvisibility=.*"] = "" -- warnings + , ["-Wall"] = "-Wall" + , ["-W1"] = "-W1" + , ["-W2"] = "-W2" + , ["-W3"] = "-W3" , ["-Werror"] = "-WX" , ["%-Wno%-error=.*"] = "" @@ -80,10 +84,14 @@ function cl.init(self, name) end -- make the compiler command -function cl.command_compile(self, srcfile, objfile, flags) +function cl.command_compile(self, srcfile, objfile, flags, logfile) + + -- redirect + local redirect = "" + if logfile then redirect = string.format(" > %s 2>&1", logfile) end -- make it - return string.format("%s -c %s -Fo%s %s", self._NAME, flags, objfile, srcfile) + return string.format("%s -c %s -Fo%s %s%s", self._NAME, flags, objfile, srcfile, redirect) end -- make the define flag diff --git a/xmake/scripts/platform/windows/tools/link.lua b/xmake/scripts/platform/windows/tools/link.lua index 7eb56ffc9..06be1ac47 100644 --- a/xmake/scripts/platform/windows/tools/link.lua +++ b/xmake/scripts/platform/windows/tools/link.lua @@ -52,10 +52,10 @@ function link.init(self, name) , flags_arch} -- init arflags - self.arflags = {"-lib", "-nologo", flags_arch} + self.arflags = {"-nologo", flags_arch} -- init shflags - self.shflags = {"-dll", "-nologo", flags_arch} + self.shflags = {"-nologo", flags_arch} -- init flags map self.mapflags = @@ -73,10 +73,22 @@ function link.init(self, name) end -- make the linker command -function link.command_link(self, objfiles, targetfile, flags) +function link.command_link(self, objfiles, targetfile, flags, logfile) + + -- redirect + local redirect = "" + if logfile then redirect = string.format(" > %s 2>&1", logfile) end -- make it - return string.format("%s %s -out:%s %s", self._NAME, flags, targetfile, objfiles) + local cmd = string.format("%s %s -out:%s %s%s", self._NAME, flags, targetfile, objfiles, redirect) + + -- too long? + if #cmd > 256 then + cmd = string.format("%s%s @<<\n%s -out:%s %s\n<<", self._NAME, redirect, flags, targetfile, objfiles) + end + + -- ok? + return cmd end -- make the link flag diff --git a/xmake/scripts/platform/windows/tools/nmake.lua b/xmake/scripts/platform/windows/tools/nmake.lua index f84f9ee6f..0ba2e32e3 100644 --- a/xmake/scripts/platform/windows/tools/nmake.lua +++ b/xmake/scripts/platform/windows/tools/nmake.lua @@ -55,9 +55,9 @@ function nmake.main(self, mkfile, target) -- make command local cmd = nil if mkfile and os.isfile(mkfile) then - cmd = string.format("%s /f %s %s VERBOSE=%s 2> %s", self._NAME, mkfile, target or "", self._VERBOSE, xmake._NULDEV) + cmd = string.format("%s /nologo /f %s %s VERBOSE=%s", self._NAME, mkfile, target or "", self._VERBOSE) else - cmd = string.format("%s %s VERBOSE=%s 2> %s", self._NAME, target or "", self._VERBOSE, xmake._NULDEV) + cmd = string.format("%s /nologo %s VERBOSE=%s", self._NAME, target or "", self._VERBOSE) end -- done diff --git a/xmake/scripts/tools/ar.lua b/xmake/scripts/tools/ar.lua index b2e2618eb..b80dc4ddf 100644 --- a/xmake/scripts/tools/ar.lua +++ b/xmake/scripts/tools/ar.lua @@ -40,10 +40,14 @@ function ar.init(self, name) end -- make the link command -function ar.command_link(self, objfiles, targetfile, flags) +function ar.command_link(self, objfiles, targetfile, flags, logfile) + + -- redirect + local redirect = "" + if logfile then redirect = string.format(" > %s 2>&1", logfile) end -- make it - return string.format("%s %s %s %s", self._NAME, flags, targetfile, objfiles) + return string.format("%s %s %s %s%s", self._NAME, flags, targetfile, objfiles, redirect) end -- the main function diff --git a/xmake/scripts/tools/cat.lua b/xmake/scripts/tools/cat.lua new file mode 100644 index 000000000..32fea4e24 --- /dev/null +++ b/xmake/scripts/tools/cat.lua @@ -0,0 +1,43 @@ +--!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) 2009 - 2015, ruki All rights reserved. +-- +-- @author ruki +-- @file cat.lua +-- + +-- define module: cat +local cat = cat or {} + +-- load modules +local io = require("base/io") +local os = require("base/os") + +-- the main function +function cat.main(self, ...) + + -- cat all + for _, v in ipairs(...) do + if os.isfile(v) then io.cat(v) end + end + + -- ok + return true +end + +-- return module: cat +return cat diff --git a/xmake/scripts/tools/crun.lua b/xmake/scripts/tools/crun.lua new file mode 100644 index 000000000..f8897cede --- /dev/null +++ b/xmake/scripts/tools/crun.lua @@ -0,0 +1,60 @@ +--!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) 2009 - 2015, ruki All rights reserved. +-- +-- @author ruki +-- @file crun.lua +-- + +-- define module: crun +local crun = crun or {} + +-- load modules +local io = require("base/io") +local os = require("base/os") + +-- the main function +function crun.main(self, ...) + + -- run all command files + local ok = -1 + for _, v in ipairs(...) do + + -- open file + local file = io.open(v, "r") + if file then + + -- read command + local cmd = file:read("*all") + if cmd and #cmd ~= 0 then + ok = os.execute(cmd) + end + + -- exit file + file:close() + + -- ok? + if ok ~= 0 then break end + end + end + + -- ok? + return ok +end + +-- return module: crun +return crun diff --git a/xmake/scripts/tools/gcc.lua b/xmake/scripts/tools/gcc.lua index 6a5fc9d82..d02384494 100644 --- a/xmake/scripts/tools/gcc.lua +++ b/xmake/scripts/tools/gcc.lua @@ -112,17 +112,25 @@ function gcc.init(self, name) end -- make the compile command -function gcc.command_compile(self, srcfile, objfile, flags) +function gcc.command_compile(self, srcfile, objfile, flags, logfile) + + -- redirect + local redirect = "" + if logfile then redirect = string.format(" > %s 2>&1", logfile) end -- make it - return string.format("%s -c %s -o %s %s", self._NAME, flags, objfile, srcfile) + return string.format("%s -c %s -o %s %s%s", self._NAME, flags, objfile, srcfile, redirect) end -- make the link command -function gcc.command_link(self, objfiles, targetfile, flags) +function gcc.command_link(self, objfiles, targetfile, flags, logfile) + + -- redirect + local redirect = "" + if logfile then redirect = string.format(" > %s 2>&1", logfile) end -- make it - return string.format("%s -o %s %s %s", self._NAME, targetfile, objfiles, flags) + return string.format("%s -o %s %s %s%s", self._NAME, targetfile, objfiles, flags, redirect) end -- make the define flag |
