diff options
| author | ruki <[email protected]> | 2025-11-04 22:30:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-07 15:01:57 +0800 |
| commit | 5511722baa97e852b83227c2fde12039108fbbc1 (patch) | |
| tree | 3e4b70cb44dd367dda62338ccc94d413f7419acd | |
| parent | 9d1775d653a98559e9b51b639fd70e93760c268d (diff) | |
fix bin2c thread
| -rw-r--r-- | xmake/core/base/os.lua | 5 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/xmake.lua | 17 | ||||
| -rw-r--r-- | xmake/modules/utils/run_script.lua | 11 |
3 files changed, 21 insertions, 12 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 27d352056..a8338f470 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -646,7 +646,10 @@ function os.cd(dir) assert(dir) -- we can only change directory in main thread - assert(xmake.in_main_thread()) + if not xmake.in_main_thread() then + local thread = require("base/thread") + os.raise("we cannot change directory in non-main thread(%s)", thread.running()) + end -- support path instance dir = tostring(dir) diff --git a/xmake/core/sandbox/modules/xmake.lua b/xmake/core/sandbox/modules/xmake.lua index 8c040a9a0..b83536f4a 100644 --- a/xmake/core/sandbox/modules/xmake.lua +++ b/xmake/core/sandbox/modules/xmake.lua @@ -25,14 +25,15 @@ local xmake = require("base/xmake") local sandbox_xmake = sandbox_xmake or {} -- inherit some builtin interfaces -sandbox_xmake.arch = xmake.arch -sandbox_xmake.version = xmake.version -sandbox_xmake.branch = xmake.branch -sandbox_xmake.programdir = xmake.programdir -sandbox_xmake.programfile = xmake.programfile -sandbox_xmake.luajit = xmake.luajit -sandbox_xmake.is_embed = xmake.is_embed -sandbox_xmake.argv = xmake.argv +sandbox_xmake.arch = xmake.arch +sandbox_xmake.version = xmake.version +sandbox_xmake.branch = xmake.branch +sandbox_xmake.programdir = xmake.programdir +sandbox_xmake.programfile = xmake.programfile +sandbox_xmake.luajit = xmake.luajit +sandbox_xmake.is_embed = xmake.is_embed +sandbox_xmake.in_main_thread = xmake.in_main_thread +sandbox_xmake.argv = xmake.argv -- return module return sandbox_xmake diff --git a/xmake/modules/utils/run_script.lua b/xmake/modules/utils/run_script.lua index a5ab2fa50..82fa8cb0d 100644 --- a/xmake/modules/utils/run_script.lua +++ b/xmake/modules/utils/run_script.lua @@ -150,14 +150,19 @@ function _run(script, opt) option.set("quiet", true, {force = true}) end - local curdir = opt.curdir or os.workingdir() - local oldir = os.cd(curdir) + local oldir + if xmake.in_main_thread() then + local curdir = opt.curdir or os.workingdir() + oldir = os.cd(curdir) + end if opt.command then _run_commanad(script, _get_args(opt), opt) else _run_script(script, _get_args(opt), opt) end - os.cd(oldir) + if oldir then + os.cd(oldir) + end if opt.quiet then option.restore() |
