diff options
| author | OpportunityLiu <[email protected]> | 2019-06-03 20:44:10 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-06-03 20:44:10 +0800 |
| commit | a674530614fbce03122c7d9c72712a6e7a23acb4 (patch) | |
| tree | e825849d62664bfbe4b2a04610468e828fbf6a17 | |
| parent | 79f7b27e45f43ad24c8589abb4a5928c1afcb52b (diff) | |
add -workdir
| -rw-r--r-- | xmake/actions/run/main.lua | 9 | ||||
| -rw-r--r-- | xmake/actions/run/xmake.lua | 13 |
2 files changed, 14 insertions, 8 deletions
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index d692a5644..ae5bf997e 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -32,11 +32,14 @@ import("devel.debugger") function _do_run_target(target) if target:targetkind() == "binary" then + -- get the work directory of target + local workdir = option.get("workdir") or path.directory(target:targetfile()) + -- get the absolute target file path local targetfile = path.absolute(target:targetfile()) - -- enter the target directory - local oldir = os.cd(path.directory(target:targetfile())) + -- enter the work directory + local oldir = os.cd(workdir) -- add search directories for all dependent shared libraries on windows if is_plat("windows") or (is_plat("mingw") and is_host("windows")) then @@ -78,7 +81,7 @@ function _on_run_target(target) -- has been disabled? if target:get("enabled") == false then - return + return end -- build target with rules diff --git a/xmake/actions/run/xmake.lua b/xmake/actions/run/xmake.lua index ccaea2029..791106662 100644 --- a/xmake/actions/run/xmake.lua +++ b/xmake/actions/run/xmake.lua @@ -41,12 +41,15 @@ task("run") -- options , options = { - {'d', "debug", "k", nil, "Run and debug the given target." } - , {'a', "all", "k", nil, "Run all targets." } - + {'d', "debug", "k", nil, "Run and debug the given target." } + , {'a', "all", "k", nil, "Run all targets." } + , {'w', "workdir", "kv", nil, "Work directory of runing targets, default is folder of targetfile", + "e.g.", + " --workdir=.", + " --workdir=`pwd`" } , {} - , {nil, "target", "v", nil, "Run the given target." } - , {nil, "arguments", "vs", nil, "The target arguments" } + , {nil, "target", "v", nil, "Run the given target." } + , {nil, "arguments", "vs", nil, "The target arguments" } } } |
