summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-03-08 19:01:32 +0800
committerruki <[email protected]>2020-03-08 19:01:32 +0800
commitfb3610ea1dbfbb31cc05d7dc272fa0dd7c825893 (patch)
tree1c3e737cbb51d2b5dde89a4b5ae359acb11701b1
parentafc3cc3fd10f5b5622ff9c431162000720cb05de (diff)
add builtin jobs for rules
-rw-r--r--xmake/actions/build/build.lua27
1 files changed, 17 insertions, 10 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua
index 563f98db8..cfbd75880 100644
--- a/xmake/actions/build/build.lua
+++ b/xmake/actions/build/build.lua
@@ -47,19 +47,26 @@ end
-- add builtin build jobs
function _add_buildjobs_builtin(buildjobs, rootjob, target)
- -- build target with rules
- local done = false
- for _, r in ipairs(target:orderules()) do
- local on_build = r:script("build")
- if on_build then
- on_build(target, opt)
- done = true
+ -- uses the rules script?
+ local job
+ for _, r in irpairs(target:orderules()) do -- reverse rules order for buildjobs:addjob()
+ local script = r:script("build")
+ if script then
+ if r:extraconf("build", "batch") then -- TODO extraconf/rule
+ job = assert(script(target, buildjobs, {rootjob = job or rootjob}), "rule(%s):on_build(): no returned job!", r:name())
+ else
+ job = buildjobs:addjob(r:name() .. "/build", function (index, total)
+ script(target, {progress = (index * 100) / total})
+ end, job or rootjob)
+ end
end
end
- if done then return end
- -- do build
- _do_build_target(target, opt)
+ -- uses the builtin target script
+ if not job then
+ -- _do_build_target(target, opt)
+ end
+ return job
end
-- add build jobs