summaryrefslogtreecommitdiff
path: root/xmake/core/main.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-05 22:36:45 +0800
committerruki <[email protected]>2025-11-07 15:01:57 +0800
commitff868710ce0378664d89f63411eb1f9b75dc1781 (patch)
tree262f31b52ab4ce03bf40217beb50c6f148eeeeb4 /xmake/core/main.lua
parent73164da00f143002aba05d1d484fd31929448eb9 (diff)
fix os.cd in non-main thread
Diffstat (limited to 'xmake/core/main.lua')
-rw-r--r--xmake/core/main.lua58
1 files changed, 32 insertions, 26 deletions
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index cfde482fb..1c51342b9 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -52,9 +52,11 @@ local menu =
-- the tasks: xmake [task]
, function ()
local tasks = task.tasks() or {}
- local ok, project_tasks = pcall(project.tasks)
- if ok then
- table.join2(tasks, project_tasks)
+ if xmake.in_main_thread() then
+ local ok, project_tasks = pcall(project.tasks)
+ if ok then
+ table.join2(tasks, project_tasks)
+ end
end
return task.menu(tasks)
end
@@ -302,33 +304,36 @@ function main.entry()
return main._exit(ok, errors)
end
- -- check run command as root
- if main._limit_root() then
- if os.isroot() then
- errors = [[Running xmake as root is extremely dangerous and no longer supported.
-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(false, errors)
+ if xmake.in_main_thread() then
+
+ -- check run command as root
+ if main._limit_root() then
+ if os.isroot() then
+ errors = [[Running xmake as root is extremely dangerous and no longer supported.
+ 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(false, errors)
+ end
end
- end
- -- show help?
- if main._show_help() then
- return main._exit(true)
- end
+ -- show help?
+ if main._show_help() then
+ return main._exit(true)
+ end
- -- save command lines to history and we need to make sure that the .xmake directory is not generated everywhere
- local skip_history = (os.getenv('XMAKE_SKIP_HISTORY') or ''):trim()
- if os.projectfile() and os.isfile(os.projectfile()) and os.isdir(config.directory()) and skip_history == '' then
- local cmdlines = table.wrap(localcache.get("history", "cmdlines"))
- if #cmdlines > 64 then
- table.remove(cmdlines, 1)
+ -- save command lines to history and we need to make sure that the .xmake directory is not generated everywhere
+ local skip_history = (os.getenv('XMAKE_SKIP_HISTORY') or ''):trim()
+ if os.projectfile() and os.isfile(os.projectfile()) and os.isdir(config.directory()) and skip_history == '' then
+ local cmdlines = table.wrap(localcache.get("history", "cmdlines"))
+ if #cmdlines > 64 then
+ table.remove(cmdlines, 1)
+ end
+ table.insert(cmdlines, option.cmdline())
+ localcache.set("history", "cmdlines", cmdlines)
+ localcache.save("history")
end
- table.insert(cmdlines, option.cmdline())
- localcache.set("history", "cmdlines", cmdlines)
- localcache.save("history")
end
-- enable scheduler
@@ -362,3 +367,4 @@ end
-- return module: main
return main
+