summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-04-24 00:37:12 +0800
committerruki <[email protected]>2018-04-23 21:43:15 +0800
commit1164a551c97d8166b1106155272aef217a109b7f (patch)
tree155191c7f0f4357c66f98ed406c18140813b8f7d
parent2292e7c370a929a8c46f4d803ed13bf66844c064 (diff)
improve run search directories
-rw-r--r--xmake/actions/run/main.lua29
1 files changed, 25 insertions, 4 deletions
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua
index 0fb0a578a..4baf81384 100644
--- a/xmake/actions/run/main.lua
+++ b/xmake/actions/run/main.lua
@@ -54,14 +54,34 @@ function _on_run_target(target)
-- enter the target directory
local oldir = os.cd(path.directory(target:targetfile()))
+ -- add search directories for all dependent shared libraries on windows
+ if is_plat("windows") or (is_plat("mingw") and is_host("windows")) then
+ local searchdirs = {}
+ for _, linkdir in ipairs(target:get("linkdirs")) do
+ print(1, linkdir)
+ if not searchdirs[linkdir] then
+ searchdirs[linkdir] = true
+ os.addenv("PATH", linkdir)
+ end
+ end
+ for _, dep in ipairs(target:orderdeps()) do
+ if dep:targetkind() == "shared" then
+ local depdir = dep:targetdir()
+ if not path.is_absolute(depdir) then
+ depdir = path.absolute(depdir, os.projectdir())
+ end
+ if not searchdirs[depdir] then
+ searchdirs[depdir] = true
+ os.addenv("PATH", depdir)
+ end
+ end
+ end
+ end
+
-- debugging?
if option.get("debug") then
-
- -- debug it
debugger.run(targetfile, option.get("arguments"))
else
-
- -- run it
os.execv(targetfile, option.get("arguments"))
end
@@ -145,3 +165,4 @@ function main()
-- leave project directory
os.cd(oldir)
end
+