summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-03 17:32:55 +0800
committerruki <[email protected]>2015-06-03 17:32:55 +0800
commit81970742272dc8b6f406f91f216374777786d256 (patch)
tree86a3983dc24558015b7d7356ecd1ddb905355078 /xmake/scripts
parentfc3638d5128d6f652d79df8985ca5efcb104d22f (diff)
redirect building output
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/action/_build.lua5
-rw-r--r--xmake/scripts/base/io.lua17
-rw-r--r--xmake/scripts/base/makefile.lua24
-rw-r--r--xmake/scripts/base/rule.lua11
-rw-r--r--xmake/scripts/platform/platform.lua4
-rw-r--r--xmake/scripts/platform/windows/_maker.lua4
6 files changed, 49 insertions, 16 deletions
diff --git a/xmake/scripts/action/_build.lua b/xmake/scripts/action/_build.lua
index 1a821e406..d07005eab 100644
--- a/xmake/scripts/action/_build.lua
+++ b/xmake/scripts/action/_build.lua
@@ -24,6 +24,7 @@
local _build = _build or {}
-- load modules
+local rule = require("base/rule")
local utils = require("base/utils")
local clean = require("base/clean")
local config = require("base/config")
@@ -46,7 +47,9 @@ function _build.done()
-- build target for makefile
if not makefile.build(target_name) then
-- error
- utils.error("build target: %s failed!", target_name)
+ print("")
+ io.cat(rule.logfile())
+ utils.error("build target: %s failed!\n", target_name)
return false
end
diff --git a/xmake/scripts/base/io.lua b/xmake/scripts/base/io.lua
index 28bc5f24d..a1ac152ce 100644
--- a/xmake/scripts/base/io.lua
+++ b/xmake/scripts/base/io.lua
@@ -100,5 +100,22 @@ function io.save(file, object, prefix)
return io._save_with_level(file, object, 0)
end
+-- cat the given file
+function io.cat(filepath)
+
+ -- open file
+ local file = io.open(filepath, "r")
+ if file then
+
+ -- show file
+ for line in file:lines() do
+ print(line)
+ end
+
+ -- exit file
+ file:close()
+ end
+end
+
-- return module: io
return io
diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua
index 1624af101..1c2261629 100644
--- a/xmake/scripts/base/makefile.lua
+++ b/xmake/scripts/base/makefile.lua
@@ -56,7 +56,7 @@ function makefile._make_object(file, target, srcfile, objfile)
-- make body
file:write(string.format("\t@echo [%s]: compiling %s\n", config.get("mode"), srcfile))
file:write(string.format("\t@xmake l mkdir %s\n", path.directory(objfile)))
- file:write(string.format("\t@%s\n", c:make(target, filetype, srcfile, objfile)))
+ file:write(string.format("\t@%s > %s 2>&1\n", c:make(target, filetype, srcfile, objfile), makefile._LOGFILE))
-- make tail
file:write("\n")
@@ -129,7 +129,7 @@ function makefile._make_target(file, name, target)
-- make body
file:write(string.format("\t@echo [%s]: linking %s\n", config.get("mode"), path.filename(targetfile)))
file:write(string.format("\t@xmake l mkdir %s\n", path.directory(targetfile)))
- file:write(string.format("\t@%s\n", l:make(target, objfiles, targetfile)))
+ file:write(string.format("\t@%s > %s 2>&1\n", l:make(target, objfiles, targetfile), makefile._LOGFILE))
-- make tail
file:write("\n")
@@ -189,6 +189,16 @@ function makefile.make()
assert(os.mkdir(buildir))
end
+ -- init the log file
+ local logfile = rule.logfile()
+ if logfile and os.isfile(logfile) then
+ os.rmfile(logfile)
+ end
+
+ -- save the log file
+ makefile._LOGFILE = logfile
+ assert(logfile)
+
-- open the makefile
local path = buildir .. "/makefile"
local file = io.open(path, "w")
@@ -232,15 +242,7 @@ function makefile.build(target)
assert(buildir)
-- done build
- local ok = platform.build(buildir .. "/makefile", target)
- if not ok then
- -- error
- utils.error("build target: %s failed!", target)
- return false
- end
-
- -- ok
- return true
+ return platform.build(buildir .. "/makefile", target)
end
-- return module: makefile
diff --git a/xmake/scripts/base/rule.lua b/xmake/scripts/base/rule.lua
index 106c12eda..bd2271549 100644
--- a/xmake/scripts/base/rule.lua
+++ b/xmake/scripts/base/rule.lua
@@ -31,6 +31,17 @@ local config = require("base/config")
local project = require("base/project")
local platform = require("platform/platform")
+-- get the building log file path
+function rule.logfile()
+
+ -- the logdir
+ local logdir = config.get("buildir") or os.tmpdir()
+ assert(logdir)
+
+ -- get it
+ return path.translate(logdir .. "/.build.log")
+end
+
-- get the filename from the given name and kind
function rule.filename(name, kind)
diff --git a/xmake/scripts/platform/platform.lua b/xmake/scripts/platform/platform.lua
index 01728106b..3748fa218 100644
--- a/xmake/scripts/platform/platform.lua
+++ b/xmake/scripts/platform/platform.lua
@@ -301,9 +301,9 @@ function platform.build(mkfile, target)
-- make command
local cmd = nil
if mkfile and os.isfile(mkfile) then
- cmd = string.format("make -f %s %s", mkfile, target or "")
+ cmd = string.format("make -j4 -f %s %s", mkfile, target or "")
else
- cmd = string.format("make %s", target or "")
+ cmd = string.format("make -j4 %s", target or "")
end
-- done
diff --git a/xmake/scripts/platform/windows/_maker.lua b/xmake/scripts/platform/windows/_maker.lua
index f7bdddbf3..40df24e17 100644
--- a/xmake/scripts/platform/windows/_maker.lua
+++ b/xmake/scripts/platform/windows/_maker.lua
@@ -79,9 +79,9 @@ function _maker.done(mkfile, target)
-- make command
local cmd = nil
if mkfile and os.isfile(mkfile) then
- cmd = string.format("nmake /f %s %s", mkfile, target or "")
+ cmd = string.format("nmake /f %s %s 2> nul", mkfile, target or "")
else
- cmd = string.format("nmake %s", target or "")
+ cmd = string.format("nmake %s 2> nul", target or "")
end
-- done