diff options
| author | ruki <[email protected]> | 2019-03-17 21:36:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-03-17 21:36:51 +0800 |
| commit | e35215c72fa78df798a88ca1cd9bed9bb36013d5 (patch) | |
| tree | 03e949b5e3eed833b3e04c869faa4a3f08b15ced | |
| parent | fb572ca825d47b0dd3612f824aefbd7eed7ba36a (diff) | |
bind package envs
| -rw-r--r-- | xmake/actions/require/impl/action/install.lua | 10 | ||||
| -rw-r--r-- | xmake/actions/require/impl/environment.lua | 4 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/irpairs.lua | 72 | ||||
| -rw-r--r-- | xmake/repository/packages/c/cmake/xmake.lua | 12 | ||||
| -rw-r--r-- | xmake/repository/packages/g/git/xmake.lua | 1 |
5 files changed, 97 insertions, 2 deletions
diff --git a/xmake/actions/require/impl/action/install.lua b/xmake/actions/require/impl/action/install.lua index 133b03b7d..9150e30a4 100644 --- a/xmake/actions/require/impl/action/install.lua +++ b/xmake/actions/require/impl/action/install.lua @@ -93,6 +93,11 @@ function main(package) -- clean install directory first os.tryrm(package:installdir()) + -- enter the environments of all package dependencies + for _, dep in ipairs(package:orderdeps()) do + dep:envs_enter() + end + -- do install for i = 1, 3 do local script = scripts[i] @@ -101,6 +106,11 @@ function main(package) end end + -- leave the environments of all package dependencies + for _, dep in irpairs(package:orderdeps()) do + dep:envs_leave() + end + -- save the package info to the manifest file package:manifest_save() need_test = true diff --git a/xmake/actions/require/impl/environment.lua b/xmake/actions/require/impl/environment.lua index 13a50c44b..b303f631a 100644 --- a/xmake/actions/require/impl/environment.lua +++ b/xmake/actions/require/impl/environment.lua @@ -127,13 +127,13 @@ end function leave() -- leave the environments of installed packages - for _, instance in ipairs(_g._PACKAGES) do + for _, instance in irpairs(_g._PACKAGES) do instance:envs_leave() end _g._PACKAGES = nil -- leave the environments of git and 7z - _leave_packages("git", "7z") + _leave_packages("7z", "git") -- restore search pathes of toolchains environment.leave("toolchains") diff --git a/xmake/core/sandbox/modules/irpairs.lua b/xmake/core/sandbox/modules/irpairs.lua new file mode 100644 index 000000000..e498ae363 --- /dev/null +++ b/xmake/core/sandbox/modules/irpairs.lua @@ -0,0 +1,72 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015 - 2019, TBOOX Open Source Group. +-- +-- @author ruki +-- @file irpairs.lua +-- + +-- load modules +local table = require("base/table") + +-- irpairs +-- +-- .e.g +-- +-- @code +-- +-- for idx, val in irpairs({"a", "b", "c", "d", "e", "f"}) do +-- print("%d %s", idx, val) +-- end +-- +-- for idx, val in irpairs({"a", "b", "c", "d", "e", "f"}, function (v) return v:upper() end) do +-- print("%d %s", idx, val) +-- end +-- +-- for idx, val in irpairs({"a", "b", "c", "d", "e", "f"}, function (v, a, b) return v:upper() .. a .. b end, "a", "b") do +-- print("%d %s", idx, val) +-- end +-- +-- @endcode +function sandbox_irpairs(t, filter, ...) + + -- has filter? + local has_filter = type(filter) == "function" + + -- init iterator + local args = {...} + local iter = function (t, i) + if i > 1 then + i = i - 1 + local v = t[i] + if has_filter then + v = filter(v, unpack(args)) + end + return i, v + end + end + + -- return iterator and initialized state + t = table.wrap(t) + return iter, t, #t + 1 +end + +-- load module +return sandbox_irpairs + diff --git a/xmake/repository/packages/c/cmake/xmake.lua b/xmake/repository/packages/c/cmake/xmake.lua index e0994cf52..fd1b22be2 100644 --- a/xmake/repository/packages/c/cmake/xmake.lua +++ b/xmake/repository/packages/c/cmake/xmake.lua @@ -6,16 +6,28 @@ package("cmake") if is_host("macosx") then add_urls("https://cmake.org/files/v3.11/cmake-3.11.4-Darwin-x86_64.tar.gz") + add_urls("https://github.com/Kitware/CMake/releases/download/v3.11.4/cmake-3.11.4-Darwin-x86_64.tar.gz") + add_urls("https://gitlab.com/xmake-mirror/cmake-releases/raw/master/cmake-3.11.4-Darwin-x86_64.tar.gz") + add_urls("https://dev.tencent.com/u/waruqi/p/cmake-releases/git/raw/master/cmake-3.11.4-Darwin-x86_64.tar.gz") add_versions("3.11.4", "2b5eb705f036b1906a5e0bce996e9cd56d43d73bdee8318ece3e5ce31657b812") elseif is_host("linux") and is_arch("x86_64") then add_urls("https://cmake.org/files/v3.11/cmake-3.11.4-Linux-x86_64.tar.gz") + add_urls("https://github.com/Kitware/CMake/releases/download/v3.11.4/cmake-3.11.4-Linux-x86_64.tar.gz") + add_urls("https://gitlab.com/xmake-mirror/cmake-releases/raw/master/cmake-3.11.4-Linux-x86_64.tar.gz") + add_urls("https://dev.tencent.com/u/waruqi/p/cmake-releases/git/raw/master/cmake-3.11.4-Linux-x86_64.tar.gz") add_versions("3.11.4", "6dab016a6b82082b8bcd0f4d1e53418d6372015dd983d29367b9153f1a376435") elseif is_host("windows") then if os.arch() == "x64" then add_urls("https://cmake.org/files/v3.11/cmake-3.11.4-win64-x64.zip", {excludes = "*/doc/*"}) + add_urls("https://github.com/Kitware/CMake/releases/download/v3.11.4/cmake-3.11.4-win64-x64.zip", {excludes = "*/doc/*"}) + add_urls("https://gitlab.com/xmake-mirror/cmake-releases/raw/master/cmake-3.11.4-win64-x64.zip", {excludes = "*/doc/*"}) + add_urls("https://dev.tencent.com/u/waruqi/p/cmake-releases/git/raw/master/cmake-3.11.4-win64-x64.zip", {excludes = "*/doc/*"}) add_versions("3.11.4", "d3102abd0ded446c898252b58857871ee170312d8e7fd5cbff01fbcb1068a6e5") else add_urls("https://cmake.org/files/v3.11/cmake-3.11.4-win32-x86.zip", {excludes = "*/doc/*"}) + add_urls("https://github.com/Kitware/CMake/releases/download/v3.11.4/cmake-3.11.4-win32-x86.zip", {excludes = "*/doc/*"}) + add_urls("https://gitlab.com/xmake-mirror/cmake-releases/raw/master/cmake-3.11.4-win32-x86.zip", {excludes = "*/doc/*"}) + add_urls("https://dev.tencent.com/u/waruqi/p/cmake-releases/git/raw/master/cmake-3.11.4-win32-x86.zip", {excludes = "*/doc/*"}) add_versions("3.11.4", "b068001ff879f86e704977c50a8c5917e4b4406c66242366dba2674abe316579") end end diff --git a/xmake/repository/packages/g/git/xmake.lua b/xmake/repository/packages/g/git/xmake.lua index 74f000b65..f14d0c71b 100644 --- a/xmake/repository/packages/g/git/xmake.lua +++ b/xmake/repository/packages/g/git/xmake.lua @@ -27,6 +27,7 @@ package("git") end on_load("windows", function (package) + package:addenv("PATH", path.join("share", "MinGit", "mingw32", "bin")) package:addenv("PATH", path.join("share", "MinGit", "cmd")) end) |
