diff options
| author | ruki <[email protected]> | 2018-09-13 23:42:19 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-09-13 16:13:58 +0800 |
| commit | fc10ebd8c1a21912c0159c54c151d8e10961d790 (patch) | |
| tree | 7e0386aec85e49f2aafa07c96699f5031c862969 | |
| parent | dac1984d3b770acab596703d1bed5e9a0aa38334 (diff) | |
find and install cmake package
| -rw-r--r-- | xmake/actions/require/action/download.lua | 13 | ||||
| -rw-r--r-- | xmake/actions/require/action/install.lua | 3 | ||||
| -rw-r--r-- | xmake/actions/require/environment.lua | 18 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 10 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/lib/detect/find_program.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_cmake.lua | 7 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_curl.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/package/builder/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/utils/archive/extract.lua | 2 | ||||
| -rw-r--r-- | xmake/repository/packages/c/cmake/xmake.lua | 13 | ||||
| -rw-r--r-- | xmake/repository/packages/g/git/xmake.lua | 14 |
11 files changed, 51 insertions, 40 deletions
diff --git a/xmake/actions/require/action/download.lua b/xmake/actions/require/action/download.lua index 66c989b24..6833f5df1 100644 --- a/xmake/actions/require/action/download.lua +++ b/xmake/actions/require/action/download.lua @@ -111,11 +111,14 @@ function _download(package, url, sourcedir, url_alias) -- extract package file os.rm(sourcedir .. ".tmp") - archive.extract(packagefile, sourcedir .. ".tmp") - - -- move to source directory - os.rm(sourcedir) - os.mv(sourcedir .. ".tmp", sourcedir) + if archive.extract(packagefile, sourcedir .. ".tmp") then + -- move to source directory + os.rm(sourcedir) + os.mv(sourcedir .. ".tmp", sourcedir) + end + + -- save original file path + package:originfile_set(path.absolute(packagefile)) -- trace printf("\r" .. _emptychars()) diff --git a/xmake/actions/require/action/install.lua b/xmake/actions/require/action/install.lua index 5d263d07f..c52679668 100644 --- a/xmake/actions/require/action/install.lua +++ b/xmake/actions/require/action/install.lua @@ -133,7 +133,8 @@ function main(package) oldir = os.cd(srcdir) break end - else + end + if not oldir then os.mkdir(workdir) oldir = os.cd(workdir) end diff --git a/xmake/actions/require/environment.lua b/xmake/actions/require/environment.lua index 73343006b..f340ab7eb 100644 --- a/xmake/actions/require/environment.lua +++ b/xmake/actions/require/environment.lua @@ -43,29 +43,11 @@ function enter() if not find_tool("git") then package.install_packages("git") end - - -- set the environment variables of toolchains - _g.toolenvs = {} - for _, name in ipairs("cc", "cxx", "mm", "mxx", "ld", "ar", "sh") do - local value = config.get(name) - if value then - _g.toolenvs[name] = os.getenv(name:upper()) or "" - os.setenv(name:upper(), value) - end - end end -- leave environment function leave() - -- restore the environment variables of toolchains - for _, name in ipairs("cc", "cxx", "mm", "mxx", "ld", "ar", "sh") do - local value = _g.toolenvs[name] - if value then - os.setenv(name:upper(), value) - end - end - -- restore search pathes of toolchains environment.leave("toolchains") end diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 532cc1e23..12e8ae621 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -172,6 +172,16 @@ function _instance:installdir() return path.join(self:cachedir(), "install") end +-- get the downloaded original file +function _instance:originfile() + return self._ORIGINFILE +end + +-- set the downloaded original file +function _instance:originfile_set(filepath) + self._ORIGINFILE = filepath +end + -- get the directory of this package function _instance:directory() return path.join(package.installdir(self:from("global")), self:name():sub(1, 1):lower(), self:name(), self:version_str()) diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 1e5d8a3dd..e59c12fdd 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -43,6 +43,11 @@ local checking = nil -- check program function sandbox_lib_detect_find_program._check(program, check) + -- is *.exe for windows? + if os.host() == "windows" and not program:find("%.exe") then + program = program .. ".exe" + end + -- no check script? attempt to run it directly if not check then return 0 == os.execv(program, {"--version"}, {stdout = os.nuldev(), stderr = os.nuldev()}) diff --git a/xmake/modules/detect/tools/find_cmake.lua b/xmake/modules/detect/tools/find_cmake.lua index bb6281a07..ebcc20347 100644 --- a/xmake/modules/detect/tools/find_cmake.lua +++ b/xmake/modules/detect/tools/find_cmake.lua @@ -34,8 +34,8 @@ import("lib.detect.find_programver") -- -- @code -- --- local git = find_cmake() --- local git, version = find_cmake({version = true}) +-- local cmake = find_cmake() +-- local cmake, version = find_cmake({version = true}) -- -- @endcode -- @@ -43,6 +43,9 @@ function main(opt) -- init options opt = opt or {} + if is_host("windows") then + opt.pathes = "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\CMake;InstallDir)\\bin" + end -- find program local program = find_program(opt.program or "cmake", opt) diff --git a/xmake/modules/detect/tools/find_curl.lua b/xmake/modules/detect/tools/find_curl.lua index faa9457d5..5bcd6381b 100644 --- a/xmake/modules/detect/tools/find_curl.lua +++ b/xmake/modules/detect/tools/find_curl.lua @@ -34,8 +34,8 @@ import("lib.detect.find_programver") -- -- @code -- --- local git = find_curl() --- local git, version = find_curl({version = true}) +-- local curl = find_curl() +-- local curl, version = find_curl({version = true}) -- -- @endcode -- diff --git a/xmake/modules/package/builder/xmake.lua b/xmake/modules/package/builder/xmake.lua index fbd8b81a0..2978cecc9 100644 --- a/xmake/modules/package/builder/xmake.lua +++ b/xmake/modules/package/builder/xmake.lua @@ -45,5 +45,5 @@ end -- install package function install(package) - os.vrun("xmake install -o %s", package:installdir()) + os.vrunv("xmake", {"install", "-o", package:installdir()}) end diff --git a/xmake/modules/utils/archive/extract.lua b/xmake/modules/utils/archive/extract.lua index 5e99e4eec..ff2c4c6bf 100644 --- a/xmake/modules/utils/archive/extract.lua +++ b/xmake/modules/utils/archive/extract.lua @@ -272,5 +272,5 @@ function main(archivefile, outputdir) local extension = _extension(archivefile, extractors) -- extract it - _extract(archivefile, outputdir, extension, extractors[extension]) + return _extract(archivefile, outputdir, extension, extractors[extension]) end diff --git a/xmake/repository/packages/c/cmake/xmake.lua b/xmake/repository/packages/c/cmake/xmake.lua index 2e3ab2c0e..a5f3da43c 100644 --- a/xmake/repository/packages/c/cmake/xmake.lua +++ b/xmake/repository/packages/c/cmake/xmake.lua @@ -4,6 +4,16 @@ 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") + else + add_urls("https://cmake.org/files/v3.11/cmake-3.11.4-win32-x86.msi") + add_versions("3.11.4", "72b3b82b6d2c2f3a375c0d2799c01819df8669dc55694c8b8daaf6232e873725") + end + end + on_build(function (package) end) @@ -12,7 +22,6 @@ package("cmake") end) on_install("windows", function (package) - -- the winenv with cmake has been installed when installing git - raise() + os.vrunv("msiexec.exe", {"/i", package:originfile(), "/quiet", "/qn", "/norestart"}) end) diff --git a/xmake/repository/packages/g/git/xmake.lua b/xmake/repository/packages/g/git/xmake.lua index f6bbe8102..92452f682 100644 --- a/xmake/repository/packages/g/git/xmake.lua +++ b/xmake/repository/packages/g/git/xmake.lua @@ -8,23 +8,21 @@ package("git") if os.arch() == "x64" then add_urls("https://github.com/tboox/xmake-win64env/archive/$(version).zip", {alias = "github"}) add_urls("https://gitlab.com/tboox/xmake-win64env/-/archive/$(version)/xmake-win64env-$(version).zip", {alias = "gitlab"}) - add_versions("github:v1.0.1", "95170b1d144ebb30961611fd87b1e9404bbe37d2d904adb15f3e202bb3e19c21") - add_versions("gitlab:v1.0.1", "00ec9a71d34725fb974fcdef3e6b21104a0b1681d0cd7d07ee64d4a73eed0c87") + add_versions("github:v1.0.2", "33c7876930dd12041f253b662c2ded7a07c387341b2f91776d385ea88c90653e") + add_versions("gitlab:v1.0.2", "733bcf61a32579d61f924f4910f686fbfcae4d6a83ad0ba05aada596cc6dc4ce") else add_urls("https://github.com/tboox/xmake-win32env/archive/$(version).zip", {alias = "github"}) add_urls("https://gitlab.com/tboox/xmake-win32env/-/archive/$(version)/xmake-win32env-$(version).zip", {alias = "gitlab"}) - add_versions("github:v1.0.1", "3c46983379329a246596a2b5f0ff971b55e3eccbbfd34272e7121e13fb346db5") - add_versions("gitlab:v1.0.1", "c9bd70a5394b9d943607268f876b81d29c360f7f2860375cec1e4146b44023bf") + add_versions("github:v1.0.2", "5d98239c2726885f6c9faafe7394c67cf7fbc4419a5596bcf85ca6256af50550") + add_versions("gitlab:v1.0.2", "1dd80a91602e857df2f6aa103adeb863c171955751ba04e53b7da9cc1ac64982") end - else - add_imports("package.manager.install") end on_build(function (package) end) - on_install(function (package) - install("git") + on_install("macosx", "linux", function (package) + import("package.manager.install")("git") end) on_install("windows", function (package) |
