summaryrefslogtreecommitdiff
path: root/xmake/scripts/base
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-16 18:27:00 +0800
committerruki <[email protected]>2015-06-16 18:27:00 +0800
commitd549aaedf96e6d6eb77e9d588dc0a0269cd1ae71 (patch)
tree51d971fe326561b62895743a38a1544af6df2dff /xmake/scripts/base
parent608602d0de1056f856e0b6bfe33b3f5fbe641b63 (diff)
fix the command is too long for nmake
Diffstat (limited to 'xmake/scripts/base')
-rw-r--r--xmake/scripts/base/compiler.lua16
-rw-r--r--xmake/scripts/base/linker.lua10
-rw-r--r--xmake/scripts/base/makefile.lua19
3 files changed, 21 insertions, 24 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