summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-05-19 16:10:03 +0800
committerruki <[email protected]>2016-05-19 16:10:03 +0800
commit22ac398c3a818adebda11fcc57b3d87f737331cc (patch)
tree5099b7154cacf679a3f0fa211544af8fd1e4b362
parentf3ab20418a0b06f84c6afa22ecfebf7965fd646b (diff)
fix os.corun redirect log
-rwxr-xr-xxmake/actions/build/builder.lua45
-rwxr-xr-xxmake/actions/build/xmake.lua2
-rw-r--r--xmake/core/base/os.lua3
3 files changed, 11 insertions, 39 deletions
diff --git a/xmake/actions/build/builder.lua b/xmake/actions/build/builder.lua
index 9e7fe3c0f..8681a38aa 100755
--- a/xmake/actions/build/builder.lua
+++ b/xmake/actions/build/builder.lua
@@ -77,29 +77,11 @@ function _make_object(target, sourcefile, objectfile)
-- create directory if not exists
os.mkdir(path.directory(objectfile))
- -- run cmd
--- os.run(command)
+ -- run cmd with coroutine
os.corun(command)
end
-- make objects for the given target
-function _make_objects_(target)
-
- -- make all objects
- local i = 1
- local objectfiles = target:objectfiles()
- local sourcefiles = target:sourcefiles()
- for _, objectfile in ipairs(objectfiles) do
-
- -- make object
- _make_object(target, sourcefiles[i], objectfile)
-
- -- next
- i = i + 1
- end
-end
-
--- make objects for the given target
function _make_objects(target)
-- the object and source files
@@ -107,7 +89,7 @@ function _make_objects(target)
local sourcefiles = target:sourcefiles()
-- get the max job count
- local jobs = 4
+ local jobs = tonumber(option.get("jobs") or "4")
-- make objects
local index = 1
@@ -133,7 +115,7 @@ function _make_objects(target)
table.insert(finished, i)
else
-- resume it
- local ok, errors = coroutine.resume(job, target, sourcefiles[job_index], objectfiles[job_index])
+ local ok, errors = coroutine.resume(job, job_index)
if not ok then
raise(errors)
end
@@ -147,27 +129,18 @@ function _make_objects(target)
-- produce tasks
while #tasks < jobs and index <= total do
- table.insert(tasks, {coroutine.create(_make_object), index})
+ table.insert(tasks, {coroutine.create(function (index)
+
+ -- make object
+ _make_object(target, sourcefiles[index], objectfiles[index])
+
+ end), index})
index = index + 1
end
until #tasks == 0
end
-
---[[
- co = coroutine.create(function ()
- os.corun("echo hello world")
- end)
-
- while true do
- local ok = coroutine.resume(co)
- print(ok)
- if not ok then
- break
- end
- end
-]]
-- make the given target
function _make_target(target)
diff --git a/xmake/actions/build/xmake.lua b/xmake/actions/build/xmake.lua
index 90d11efed..a6bc1c8e4 100755
--- a/xmake/actions/build/xmake.lua
+++ b/xmake/actions/build/xmake.lua
@@ -44,7 +44,7 @@ task("build")
, {'r', "rebuild", "k", nil, "Rebuild the project." }
, {}
- , {'j', "jobs", "kv", nil, "Specifies the number of jobs to build simultaneously" }
+ , {'j', "jobs", "kv", "4", "Specifies the number of jobs to build simultaneously" }
, {}
, {nil, "target", "v", "all", "Build the given target." }
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index cdf8dcdfc..c3e3b70cb 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -260,9 +260,8 @@ end
-- run shell with coroutine
function os.corun(cmd)
- -- FIXME
-- make temporary log file
- local log = path.join(os.tmpdir(), "xmake.os.corun.log")
+ local log = os.tmpname()
-- open command
local p = process.open(cmd, log, log)