summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-06-06 00:34:00 +0800
committerruki <[email protected]>2019-06-05 21:24:01 +0800
commit783dce4adabedce2062a90f3231e2b2f7e4942e2 (patch)
tree0471a45b0173a9a6f697c4cc5906a38708fcff39
parent06dba0daf4968b9632ebc00a9018c6af044422df (diff)
add target.set_rundir api
-rw-r--r--xmake/actions/run/main.lua8
-rw-r--r--xmake/core/project/target.lua6
2 files changed, 10 insertions, 4 deletions
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua
index ae5bf997e..aab49ad50 100644
--- a/xmake/actions/run/main.lua
+++ b/xmake/actions/run/main.lua
@@ -32,14 +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 run directory of target
+ local rundir = target:rundir()
-- get the absolute target file path
local targetfile = path.absolute(target:targetfile())
- -- enter the work directory
- local oldir = os.cd(workdir)
+ -- enter the run directory
+ local oldir = os.cd(rundir)
-- add search directories for all dependent shared libraries on windows
if is_plat("windows") or (is_plat("mingw") and is_host("windows")) then
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index f4809f424..b2a77644d 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -736,6 +736,11 @@ function _instance:configdir()
return self:get("configdir") or config.buildir()
end
+-- get run directory
+function _instance:rundir()
+ return baseoption.get("workdir") or self:get("rundir") or path.directory(self:targetfile())
+end
+
-- get install directory
function _instance:installdir()
@@ -1552,6 +1557,7 @@ function target.apis()
, "target.set_dependir"
, "target.set_configdir"
, "target.set_installdir"
+ , "target.set_rundir"
-- target.add_xxx
, "target.add_files"
, "target.add_configfiles"