diff options
| author | ruki <[email protected]> | 2016-05-19 16:10:03 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2016-05-19 16:10:03 +0800 |
| commit | 22ac398c3a818adebda11fcc57b3d87f737331cc (patch) | |
| tree | 5099b7154cacf679a3f0fa211544af8fd1e4b362 /xmake/actions/build/builder.lua | |
| parent | f3ab20418a0b06f84c6afa22ecfebf7965fd646b (diff) | |
fix os.corun redirect log
Diffstat (limited to 'xmake/actions/build/builder.lua')
| -rwxr-xr-x | xmake/actions/build/builder.lua | 45 |
1 files changed, 9 insertions, 36 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) |
