summaryrefslogtreecommitdiff
path: root/xmake/actions/build/main.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-10-07 10:21:33 +0800
committerruki <[email protected]>2023-10-07 10:21:33 +0800
commitebb301cf17c2aa25b1f698ce2e5bd2eb753a9bc5 (patch)
treeea5f1de7c1a6c79339e3c1bdf43ae7418588acf7 /xmake/actions/build/main.lua
parentc12127b37c2d967a928cb039187d1ea65d958803 (diff)
auto build targets for tests
Diffstat (limited to 'xmake/actions/build/main.lua')
-rw-r--r--xmake/actions/build/main.lua96
1 files changed, 51 insertions, 45 deletions
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua
index 58456ba70..43897578a 100644
--- a/xmake/actions/build/main.lua
+++ b/xmake/actions/build/main.lua
@@ -129,61 +129,26 @@ function _on_exit(ok, errors)
end
end
--- main
-function main()
-
- -- try building it using third-party buildsystem if xmake.lua not exists
- if not os.isfile(project.rootfile()) and _try_build() then
- return
- end
-
- -- post statistics before locking project
- statistics.post()
-
- -- do action for remote?
- if remote_build_action.enabled() then
- return remote_build_action()
- end
-
- -- lock the whole project
- project.lock()
-
- -- config it first
- local targetname
- local group_pattern = option.get("group")
- if group_pattern then
- group_pattern = "^" .. path.pattern(group_pattern) .. "$"
- else
- targetname = option.get("target")
- end
- task.run("config", {}, {disable_dump = true})
-
- -- enter project directory
- local oldir = os.cd(project.directory())
-
- -- clean up temporary files once a day
- cleaner.cleanup()
+-- build targets
+function build_targets(targetnames, opt)
+ opt = opt or {}
-- register exit callbacks
os.atexit(_on_exit)
- local build_time
+ local group_pattern = opt.group_pattern
try
{
function ()
- local time = os.mclock()
-- do rules before building
_do_project_rules("build_before")
-- do build
- _do_build(targetname, group_pattern)
+ _do_build(targetnames, group_pattern)
-- do check
- check_targets(targetname, {build = true})
-
- -- get build time
- build_time = os.mclock() - time
+ check_targets(targetnames, {build = true})
-- dump cache stats
if option.get("diagnosis") then
@@ -206,8 +171,9 @@ function main()
raise(errors)
elseif group_pattern then
raise("build targets with group(%s) failed!", group_pattern)
- elseif targetname then
- raise("build target: %s failed!", targetname)
+ elseif targetnames then
+ targetnames = table.wrap(targetnames)
+ raise("build target: %s failed!", table.concat(targetnames, ", "))
else
raise("build target failed!")
end
@@ -217,13 +183,53 @@ function main()
-- do rules after building
_do_project_rules("build_after")
+end
- -- unlock the whole project
- project.unlock()
+function main()
+
+ -- try building it using third-party buildsystem if xmake.lua not exists
+ if not os.isfile(project.rootfile()) and _try_build() then
+ return
+ end
+
+ -- post statistics before locking project
+ statistics.post()
+
+ -- do action for remote?
+ if remote_build_action.enabled() then
+ return remote_build_action()
+ end
+
+ -- lock the whole project
+ project.lock()
+
+ -- config it first
+ local targetname
+ local group_pattern = option.get("group")
+ if group_pattern then
+ group_pattern = "^" .. path.pattern(group_pattern) .. "$"
+ else
+ targetname = option.get("target")
+ end
+ task.run("config", {}, {disable_dump = true})
+
+ -- enter project directory
+ local oldir = os.cd(project.directory())
+
+ -- clean up temporary files once a day
+ cleaner.cleanup()
+
+ -- build targets
+ local build_time = os.mclock()
+ build_targets(targetname, {group_pattern = group_pattern})
+ build_time = os.mclock() - build_time
-- leave project directory
os.cd(oldir)
+ -- unlock the whole project
+ project.unlock()
+
-- trace
local str = ""
if build_time then