summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-12 21:24:00 +0800
committerruki <[email protected]>2017-05-12 21:24:00 +0800
commitb4caa8534e0cf8216dc1807ae17bb1045ade7474 (patch)
treef82cf64a857ecf27f9842c7770d279579bb624ac
parent9c763d55994030f5e31ce16979a94fbf868f59fb (diff)
run target and deps
-rw-r--r--xmake/actions/run/main.lua49
1 files changed, 21 insertions, 28 deletions
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua
index b2b13ae96..f7664f1fb 100644
--- a/xmake/actions/run/main.lua
+++ b/xmake/actions/run/main.lua
@@ -31,41 +31,23 @@ import("core.project.project")
import("core.platform.platform")
import("core.tool.debugger")
--- run binary target
-function _run_binary(target)
-
- -- debugging?
- if option.get("debug") then
-
- -- debug it
- debugger.run(target:targetfile(), option.get("arguments"))
- else
-
- -- run it
- os.execv(target:targetfile(), option.get("arguments"))
- end
-end
-
-- run target
function _run_target(target)
-- get kind
- local kind = target:get("kind")
- if not kind then
- return
- end
+ if target:targetkind() == "binary" then
- -- get script
- local scripts =
- {
- binary = _run_binary
- }
+ -- debugging?
+ if option.get("debug") then
- -- check
- assert(scripts[kind], "this target(%s) with kind(%s) can not be executed!", target:name(), kind)
+ -- debug it
+ debugger.run(target:targetfile(), option.get("arguments"))
+ else
- -- run it
- scripts[kind](target)
+ -- run it
+ os.execv(target:targetfile(), option.get("arguments"))
+ end
+ end
end
-- run the given target
@@ -88,6 +70,15 @@ function _run(target)
end
end
+-- run the all dependent targets
+function _run_deps(target)
+
+ -- run target deps
+ for _, dep in ipairs(target:deps()) do
+ _run(dep)
+ end
+end
+
-- main
function main()
@@ -102,12 +93,14 @@ function main()
-- run the given target?
if targetname then
+ _run_deps(project.target(targetname))
_run(project.target(targetname))
else
-- run default or all binary targets
for _, target in pairs(project.targets()) do
local default = target:get("default")
if (default == nil or default == true or option.get("all")) and target:get("kind") == "binary" then
+ _run_deps(target)
_run(target)
end
end