diff options
| author | ruki <[email protected]> | 2018-12-14 23:17:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-12-14 13:47:09 +0800 |
| commit | 107f81a48da61d37ecbffac4e2f816b9cfedb21c (patch) | |
| tree | c38a0ee5baef7bf7b17918df605775bde60fab16 /xmake/actions/run/main.lua | |
| parent | 1912316fee7a21c13842532d316e50a315ba6e9b (diff) | |
sperate install, run and build
Diffstat (limited to 'xmake/actions/run/main.lua')
| -rw-r--r-- | xmake/actions/run/main.lua | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/xmake/actions/run/main.lua b/xmake/actions/run/main.lua index 74896a189..5fe94c658 100644 --- a/xmake/actions/run/main.lua +++ b/xmake/actions/run/main.lua @@ -152,21 +152,56 @@ end -- run the all dependent targets function _run_deps(target) - - -- run target deps for _, dep in ipairs(target:orderdeps()) do _run(dep) end end +-- check targets +function _check_targets(targetname) + + -- get targets + local targets = {} + if targetname and not targetname:startswith("__") then + table.insert(targets, project.target(targetname)) + else + -- install default or all 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 + table.insert(targets, target) + end + end + end + + -- filter and check targets with builtin-run script + local targetnames = {} + for _, target in ipairs(targets) do + if not target:isphony() and target:get("enabled") ~= false and not target:script("run") then + local targetfile = target:targetfile() + if targetfile and not os.isfile(targetfile) then + table.insert(targetnames, target:name()) + end + end + end + + -- there are targets that have not yet been built? + if #targetnames > 0 then + raise("please run `$xmake [target]` to build the following targets first:\n -> " .. table.concat(targetnames, '\n -> ')) + end +end + -- main function main() -- get the target name local targetname = option.get("target") - -- build it first - task.run("build", {target = targetname, all = option.get("all")}) + -- config it first + task.run("config", {target = targetname, require = "n"}) + + -- check targets first + _check_targets(targetname) -- enter project directory local oldir = os.cd(project.directory()) |
