diff options
| author | ruki <[email protected]> | 2017-10-20 22:47:24 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-10-20 10:44:24 +0800 |
| commit | 365ce94fe03a3d5330bfd3f76b1e703afff73da8 (patch) | |
| tree | 6570299cde02e228f2bd853d10596736e61757a7 /xmake/actions/run/main.lua | |
| parent | 10bb94a674e52aee141ebec8badca5595bd5c409 (diff) | |
fix current directory when running target
Diffstat (limited to 'xmake/actions/run/main.lua')
| -rw-r--r-- | xmake/actions/run/main.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index e80072347..bd69d72f9 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -37,16 +37,25 @@ function _on_run_target(target) -- get kind if target:targetkind() == "binary" then + -- get the absolute target file path + local targetfile = path.absolute(target:targetfile()) + + -- enter the target directory + local oldir = os.cd(path.directory(target:targetfile())) + -- debugging? if option.get("debug") then -- debug it - debugger.run(target:targetfile(), option.get("arguments")) + debugger.run(targetfile, option.get("arguments")) else -- run it - os.execv(target:targetfile(), option.get("arguments")) + os.execv(targetfile, option.get("arguments")) end + + -- restore the previous directory + os.cd(oldir) end end |
