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 | |
| parent | 1912316fee7a21c13842532d316e50a315ba6e9b (diff) | |
sperate install, run and build
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | xmake/actions/install/main.lua | 45 | ||||
| -rw-r--r-- | xmake/actions/run/main.lua | 43 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 16 |
4 files changed, 92 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 79edcd2f7..90aacdc5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ### Bugs fixed * Fix cannot call `set_optimize()` to set optimization flags when exists `add_rules("mode.release")` +* [#289](https://github.com/tboox/xmake/issues/289): Fix unarchive gzip file failed on windows ## v2.2.3 @@ -545,6 +546,7 @@ ### Bugs修复 * 修复无法通过 `set_optimize()` 设置优化选项,如果存在`add_rules("mode.release")`的情况下 +* [#289](https://github.com/tboox/xmake/issues/289): 修复在windows下解压gzip文件失败 ## v2.2.3 diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua index 60ff38ff5..994e86e95 100644 --- a/xmake/actions/install/main.lua +++ b/xmake/actions/install/main.lua @@ -25,19 +25,57 @@ -- imports import("core.base.option") import("core.base.task") +import("core.project.project") import("core.platform.platform") import("core.base.privilege") import("privilege.sudo") import("install") +-- 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 targetname == "__all" then + table.insert(targets, target) + end + end + end + + -- filter and check targets with builtin-install script + local targetnames = {} + for _, target in ipairs(targets) do + if not target:isphony() and target:get("enabled") ~= false and not target:script("install") 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) -- attempt to install directly try @@ -56,6 +94,9 @@ function main() -- failed or not permission? request administrator permission and install it again function (errors) + -- trace + cprint(errors) + -- try get privilege if privilege.get() then local ok = try 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()) diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 8484c0712..2332fcf93 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -701,19 +701,19 @@ function target:installdir() -- DESTDIR: be compatible with https://www.gnu.org/prep/standards/html_node/DESTDIR.html installdir = baseoption.get("installdir") or os.getenv("INSTALLDIR") or os.getenv("DESTDIR") or platform.get("installdir") - assert(installdir, "unknown install directory!") - - -- append prefix - local prefix = baseoption.get("prefix") or os.getenv("PREFIX") - if prefix then - installdir = path.join(installdir, prefix) + if installdir then + -- append prefix + local prefix = baseoption.get("prefix") or os.getenv("PREFIX") + if prefix then + installdir = path.join(installdir, prefix) + end end end - self._INSTALLDIR = installdir + self._INSTALLDIR = installdir or false end -- ok - return installdir + return installdir or nil end -- get rules of the source file |
