summaryrefslogtreecommitdiff
path: root/xmake/core/main.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-05-09 21:51:32 +0800
committerruki <[email protected]>2021-05-09 21:51:32 +0800
commit8f4eef36192b28207133e40b4cea03f6dbc855ad (patch)
tree6eae05a491a39b107d1b8caab4a63f00b7b99037 /xmake/core/main.lua
parentb9527ce7f37c7455fd6beb1d07ad562f2e43b056 (diff)
improve main.exit
Diffstat (limited to 'xmake/core/main.lua')
-rw-r--r--xmake/core/main.lua24
1 files changed, 13 insertions, 11 deletions
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index bdea1ab2e..4664a1c40 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -180,13 +180,15 @@ function main._init()
end
-- exit main program
-function main._exit(errors)
+function main._exit(ok, errors)
-- show errors
local retval = 0
- if errors then
+ if not ok then
retval = -1
- utils.error(errors)
+ if errors then
+ utils.error(errors)
+ end
end
-- show warnings
@@ -205,13 +207,13 @@ function main.entry()
-- init
local ok, errors = main._init()
if not ok then
- return main._exit(errors)
+ return main._exit(ok, errors)
end
-- load global configuration
ok, errors = global.load()
if not ok then
- return main._exit(errors)
+ return main._exit(ok, errors)
end
-- load theme
@@ -223,7 +225,7 @@ function main.entry()
-- init option
ok, errors = option.init(menu)
if not ok then
- return main._exit(errors)
+ return main._exit(ok, errors)
end
-- check run command as root
@@ -235,7 +237,7 @@ As xmake does not drop privileges on installation you would be giving all
build scripts full access to your system.
Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily.
]]
- return main._exit(errors)
+ return main._exit(false, errors)
end
end
end
@@ -247,7 +249,7 @@ Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily.
-- show help?
if main._show_help() then
- return main._exit()
+ return main._exit(true)
end
-- save command lines to history and we need to make sure that the .xmake directory is not generated everywhere
@@ -266,7 +268,7 @@ Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily.
local taskname = option.taskname() or "build"
local taskinst = task.task(taskname) or project.task(taskname)
if not taskinst then
- return main._exit(string.format("do unknown task(%s)!", taskname))
+ return main._exit(false, string.format("do unknown task(%s)!", taskname))
end
-- run task
@@ -279,7 +281,7 @@ Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily.
end)
ok, errors = scheduler:runloop()
if not ok then
- return main._exit(errors)
+ return main._exit(ok, errors)
end
-- stop profiling
@@ -288,7 +290,7 @@ Or you can add `--root` option or XMAKE_ROOT=y to allow run as root temporarily.
end
-- exit normally
- return main._exit()
+ return main._exit(true)
end
-- return module: main