diff options
| author | ruki <[email protected]> | 2018-09-13 23:59:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-09-13 17:59:09 +0800 |
| commit | 9b9f4ca9fe943bbc9e32aa5d6eb1ffb5f87841df (patch) | |
| tree | 9c86121db8c4df232e461d635eeb48a326597070 | |
| parent | fc10ebd8c1a21912c0159c54c151d8e10961d790 (diff) | |
improve to install cmake package
| -rw-r--r-- | xmake/actions/require/action/install.lua | 12 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 30 | ||||
| -rw-r--r-- | xmake/repository/packages/c/cmake/xmake.lua | 31 | ||||
| -rw-r--r-- | xmake/repository/packages/g/git/xmake.lua | 3 |
4 files changed, 62 insertions, 14 deletions
diff --git a/xmake/actions/require/action/install.lua b/xmake/actions/require/action/install.lua index c52679668..278e7c0b4 100644 --- a/xmake/actions/require/action/install.lua +++ b/xmake/actions/require/action/install.lua @@ -168,7 +168,7 @@ function main(package) local installtask = function () -- prepare the install and package directories - _prepare_directories(package:installdir(), package:directory()) + _prepare_directories(package:directory(), package:installdir()) -- build it build(package) @@ -181,8 +181,14 @@ function main(package) end end - -- make package from the install directory - if package:kind() ~= "binary" then + -- add search path for program + if package:kind() == "binary" then + local bindir = path.join(package:installdir(), "bin") + if os.isdir(bindir) then + os.addenv("PATH", bindir) + end + else + -- make package from the install directory _make_package(package) end diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 12e8ae621..8a286b2cc 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -169,7 +169,7 @@ end -- get the installed directory of this package function _instance:installdir() - return path.join(self:cachedir(), "install") + return path.join(self:directory(), "install") end -- get the downloaded original file @@ -389,6 +389,26 @@ function _instance:exists() return self._FETCHINFO end +-- the current mode is belong to the given modes? +function package._api_is_mode(interp, ...) + return config.is_mode(...) +end + +-- the current platform is belong to the given platforms? +function package._api_is_plat(interp, ...) + return config.is_plat(...) +end + +-- the current platform is belong to the given architectures? +function package._api_is_arch(interp, ...) + return config.is_arch(...) +end + +-- the current host is belong to the given hosts? +function package._api_is_host(interp, ...) + return os.is_host(...) +end + -- the interpreter function package._interpreter() @@ -450,6 +470,14 @@ function package.apis() -- package.add_xxx "package.add_versions" } + , custom = + { + -- is_xxx + { "is_host", package._api_is_host } + , { "is_mode", package._api_is_mode } + , { "is_plat", package._api_is_plat } + , { "is_arch", package._api_is_arch } + } } end diff --git a/xmake/repository/packages/c/cmake/xmake.lua b/xmake/repository/packages/c/cmake/xmake.lua index a5f3da43c..bfb6bd279 100644 --- a/xmake/repository/packages/c/cmake/xmake.lua +++ b/xmake/repository/packages/c/cmake/xmake.lua @@ -4,24 +4,35 @@ package("cmake") set_homepage("https://cmake.org") set_description("A cross-platform family of tool designed to build, test and package software") - if os.host() == "windows" then - if os.arch() == "x64" then - add_urls("https://cmake.org/files/v3.11/cmake-3.11.4-win64-x64.msi") - add_versions("3.11.4", "56e3605b8e49cd446f3487da88fcc38cb9c3e9e99a20f5d4bd63e54b7a35f869") + if is_host("macosx") then + add_urls("https://cmake.org/files/v3.11/cmake-3.11.4-Darwin-x86_64.tar.gz") + add_versions("3.11.4", "2b5eb705f036b1906a5e0bce996e9cd56d43d73bdee8318ece3e5ce31657b812") + elseif is_host("linux") then + add_urls("https://cmake.org/files/v3.11/cmake-3.11.4-Linux-x86_64.tar.gz") + add_versions("3.11.4", "6dab016a6b82082b8bcd0f4d1e53418d6372015dd983d29367b9153f1a376435") + elseif is_host("windows") then + if is_arch("x64") then + add_urls("https://cmake.org/files/v3.11/cmake-3.11.4-win64-x64.zip") + add_versions("3.11.4", "d3102abd0ded446c898252b58857871ee170312d8e7fd5cbff01fbcb1068a6e5") else - add_urls("https://cmake.org/files/v3.11/cmake-3.11.4-win32-x86.msi") - add_versions("3.11.4", "72b3b82b6d2c2f3a375c0d2799c01819df8669dc55694c8b8daaf6232e873725") + add_urls("https://cmake.org/files/v3.11/cmake-3.11.4-win32-x86.zip") + add_versions("3.11.4", "b068001ff879f86e704977c50a8c5917e4b4406c66242366dba2674abe316579") end end on_build(function (package) end) - on_install("macosx", "linux", function (package) - import("package.manager.install")("cmake") + on_install("macosx", function (package) + os.cp("CMake.app/Contents/bin", package:installdir()) + os.cp("CMake.app/Contents/share", package:installdir()) end) - on_install("windows", function (package) - os.vrunv("msiexec.exe", {"/i", package:originfile(), "/quiet", "/qn", "/norestart"}) + on_install(function (package) + os.cp("bin", package:installdir()) + os.cp("share", package:installdir()) end) + on_test(function (package) + os.vrun("cmake --version") + end) diff --git a/xmake/repository/packages/g/git/xmake.lua b/xmake/repository/packages/g/git/xmake.lua index 92452f682..22b5d24dc 100644 --- a/xmake/repository/packages/g/git/xmake.lua +++ b/xmake/repository/packages/g/git/xmake.lua @@ -36,3 +36,6 @@ package("git") import("winenv", {rootdir = winenv_dir})(winenv_dir) end) + on_test(function (package) + os.vrun("git --version") + end) |
