diff options
| author | ruki <[email protected]> | 2021-08-15 23:38:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-08-15 23:38:15 +0800 |
| commit | dd717cd8219f0774ecb717f44d6ba3f182f29c99 (patch) | |
| tree | 231579ec6d522722e9854a90c2282ce935e036aa | |
| parent | 28c02f2323aaa4595b8474c6a01e6ffc28181396 (diff) | |
improve xmake-requires.lock
6 files changed, 390 insertions, 43 deletions
diff --git a/tests/projects/package/multiconfig/xmake-requires.lock b/tests/projects/package/multiconfig/xmake-requires.lock index c5031a33c..78e911112 100644 --- a/tests/projects/package/multiconfig/xmake-requires.lock +++ b/tests/projects/package/multiconfig/xmake-requires.lock @@ -1,17 +1,53 @@ { - zlib = { + ["zlib#fd74da7781d54dddb234cfb6eae7be34"] = { + arch = "x86_64", buildhash = "b76a297309d14c09b42cfe3927260a51", + configs = { + debug = false, + pic = true, + shared = false + }, + is_built = true, name = "zlib", + plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "https://github.com/madler/zlib/archive/v1.2.11.tar.gz#629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff" + }, version = "1.2.11" }, - ["zlib~debug"] = { + ["zlib~debug#29572d10f2b44d76ad238aa6d9d886f0"] = { + arch = "x86_64", buildhash = "e6a6fa6a86ad4fc7ae3c2cf7c60cc084", + configs = { + debug = true, + pic = true, + shared = false + }, + is_built = true, name = "zlib", + plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "https://github.com/madler/zlib/archive/v1.2.11.tar.gz#629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff" + }, version = "1.2.11" }, - ["zlib~shared"] = { + ["zlib~shared#0aa7e77905524be8bf354384c68bdde7"] = { + arch = "x86_64", buildhash = "8e5b898b0f344715bac89cc6a1577506", + configs = { + debug = false, + pic = true, + shared = true + }, + is_built = true, name = "zlib", + plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "https://github.com/madler/zlib/archive/v1.2.11.tar.gz#629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff" + }, version = "1.2.11" } }
\ No newline at end of file diff --git a/tests/projects/package/toolchain_muslcc/xmake-requires.lock b/tests/projects/package/toolchain_muslcc/xmake-requires.lock index 8fa6e9982..779c320ff 100644 --- a/tests/projects/package/toolchain_muslcc/xmake-requires.lock +++ b/tests/projects/package/toolchain_muslcc/xmake-requires.lock @@ -1,93 +1,254 @@ { - autoconf = { + ["autoconf#fd74da7781d54dddb234cfb6eae7be34"] = { arch = "x86_64", buildhash = "01974c48f52d4d658f58852351743754", + configs = { + debug = false, + pic = true, + shared = false + }, + deps = { + "m4#fd74da7781d54dddb234cfb6eae7be34" + }, + is_built = true, kind = "binary", name = "autoconf", plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz#954bd69b391edc12d6a4a51a2dd1476543da5c6bbf05a95b59dc0dd6fd4c2969", + "https://mirrors.ustc.edu.cn/gnu/autoconf/autoconf-2.69.tar.gz#954bd69b391edc12d6a4a51a2dd1476543da5c6bbf05a95b59dc0dd6fd4c2969", + "git://git.sv.gnu.org/autoconf#2.69" + }, version = "2.69" }, - automake = { + ["automake#fd74da7781d54dddb234cfb6eae7be34"] = { arch = "x86_64", buildhash = "7a090c93706241f983f0d821a162e8a5", + configs = { + debug = false, + pic = true, + shared = false + }, + deps = { + "autoconf#fd74da7781d54dddb234cfb6eae7be34" + }, + is_built = true, kind = "binary", name = "automake", plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "http://ftp.gnu.org/gnu/automake/automake-1.16.1.tar.gz#608a97523f97db32f1f5d5615c98ca69326ced2054c9f82e65bade7fc4c9dea8", + "https://mirrors.ustc.edu.cn/gnu/automake/automake-1.16.1.tar.gz#608a97523f97db32f1f5d5615c98ca69326ced2054c9f82e65bade7fc4c9dea8" + }, version = "1.16.1" }, - cmake = { + ["cmake#fd74da7781d54dddb234cfb6eae7be34"] = { arch = "x86_64", buildhash = "a6d18f8c0bf347d980f8bb762583c91a", + configs = { + debug = false, + pic = true, + shared = false + }, + is_built = true, kind = "binary", name = "cmake", plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "https://cmake.org/files/v3.21/cmake-3.21.0-macos-universal-Darwin-x86_64.tar.gz#c1c6f19dfc9c658a48b5aed22806595b2337bb3aedb71ab826552f74f568719f", + "https://github.com/Kitware/CMake/releases/download/v3.21.0/cmake-3.21.0-macos-universal.tar.gz#c1c6f19dfc9c658a48b5aed22806595b2337bb3aedb71ab826552f74f568719f" + }, version = "3.21.0" }, - gmp = { + ["gmp#fd74da7781d54dddb234cfb6eae7be34"] = { arch = "x86_64", buildhash = "7dd9c224447e46698ac73d29f58b1d73", + configs = { + debug = false, + pic = true, + shared = false + }, + deps = { + "autoconf#fd74da7781d54dddb234cfb6eae7be34" + }, + is_built = true, name = "gmp", plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz#fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2" + }, version = "6.2.1" }, - libisl = { + ["libisl 0.22#11f62b7b062648cebf81bd6623721f7d"] = { arch = "x86_64", buildhash = "f649e1fb365e442e8f79f372fd91483b", + configs = { + debug = false, + pic = true, + shared = true + }, + deps = { + "autoconf#fd74da7781d54dddb234cfb6eae7be34", + "gmp#fd74da7781d54dddb234cfb6eae7be34" + }, + is_built = true, name = "libisl", plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "http://isl.gforge.inria.fr/isl-0.22.tar.xz#6c8bc56c477affecba9c59e2c9f026967ac8bad01b51bdd07916db40a517b9fa" + }, version = "0.22" }, - libogg = { + ["libogg#265260a3b33e47f189d65373131d1f08"] = { arch = "arm", buildhash = "d894fc29f2fb4c45a0f48bc2c6ece273", + configs = { + debug = false, + pic = true, + shared = false, + toolchains = "@muslcc" + }, + deps = { + "cmake#fd74da7781d54dddb234cfb6eae7be34" + }, + is_built = true, name = "libogg", plat = "cross", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "https://gitlab.xiph.org/xiph/ogg/-/archive/v1.3.4/ogg-v1.3.4.tar.gz#62cc64b9fd3cf57bde3a9033e94534ba34313d2bb9698029f623121a4e47bb9b", + "https://gitlab.xiph.org/xiph/ogg.git#v1.3.4" + }, version = "v1.3.4" }, - libplist = { + ["libplist#265260a3b33e47f189d65373131d1f08"] = { arch = "arm", buildhash = "0c01b22920be4876b1de74629194eb8f", + configs = { + debug = false, + pic = true, + shared = false, + toolchains = "@muslcc" + }, + deps = { + "autoconf#fd74da7781d54dddb234cfb6eae7be34", + "automake#fd74da7781d54dddb234cfb6eae7be34", + "libtool#fd74da7781d54dddb234cfb6eae7be34", + "pkg-config#fd74da7781d54dddb234cfb6eae7be34" + }, + is_built = true, name = "libplist", plat = "cross", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "https://github.com/libimobiledevice/libplist/archive/2.2.0.tar.gz#7e654bdd5d8b96f03240227ed09057377f06ebad08e1c37d0cfa2abe6ba0cee2", + "https://github.com/libimobiledevice/libplist.git#2.2.0" + }, version = "2.2.0" }, - libtool = { + ["libtool#fd74da7781d54dddb234cfb6eae7be34"] = { arch = "x86_64", buildhash = "64584ec84a4743ecb740b598b263ffa6", + configs = { + debug = false, + pic = true, + shared = false + }, + deps = { + "autoconf#fd74da7781d54dddb234cfb6eae7be34" + }, + is_built = true, kind = "binary", name = "libtool", plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz#e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3", + "https://mirrors.ustc.edu.cn/gnu/libtool/libtool-2.4.6.tar.gz#e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3", + "git://git.savannah.gnu.org/libtool.git#2.4.6" + }, version = "2.4.6" }, - m4 = { + ["m4#fd74da7781d54dddb234cfb6eae7be34"] = { arch = "x86_64", buildhash = "fd0e83e5759b442a970327ebb1c89793", + configs = { + debug = false, + pic = true, + shared = false + }, + is_built = true, kind = "binary", name = "m4", plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.xz#63aede5c6d33b6d9b13511cd0be2cac046f2e70fd0a07aa9573a04a82783af96", + "https://ftpmirror.gnu.org/m4/m4-1.4.19.tar.xz#63aede5c6d33b6d9b13511cd0be2cac046f2e70fd0a07aa9573a04a82783af96" + }, version = "1.4.19" }, - muslcc = { + ["muslcc#fd74da7781d54dddb234cfb6eae7be34"] = { arch = "x86_64", buildhash = "11062c09ebeb484594488ad73ddbcd1f", + configs = { + debug = false, + pic = true, + shared = false + }, + deps = { + "libisl 0.22#11f62b7b062648cebf81bd6623721f7d" + }, + is_built = true, kind = "toolchain", name = "muslcc", plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "https://github.com/xmake-mirror/musl.cc/releases/download/20210202/arm-linux-musleabi-cross.mac.tgz#a177df3f847181c0c7f2b34b9bd7725b4c556c11a347aa0ae36e09ebf23fb480" + }, version = "20210202" }, - ["pkg-config"] = { + ["pkg-config#fd74da7781d54dddb234cfb6eae7be34"] = { arch = "x86_64", buildhash = "84fd7f9b9f7a47709512cfc85cd9e5f7", + configs = { + debug = false, + pic = true, + shared = false + }, + is_built = true, kind = "binary", name = "pkg-config", plat = "macosx", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz#6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591", + "http://fco.it.distfiles.macports.org/mirrors/macports-distfiles/pkgconfig/pkg-config-0.29.2.tar.gz#6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591" + }, version = "0.29.2" }, - zlib = { + ["zlib#265260a3b33e47f189d65373131d1f08"] = { arch = "arm", buildhash = "be90a245b8bb48e6b08a1a15bdcad467", + configs = { + debug = false, + pic = true, + shared = false, + toolchains = "@muslcc" + }, + is_built = true, name = "zlib", plat = "cross", + repo = "https://gitee.com/tboox/xmake-repo.git#327b5dd6a61e5345c3e10d758e342a73a8e6c54e", + urls = { + "https://github.com/madler/zlib/archive/v1.2.11.tar.gz#629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff" + }, version = "1.2.11" } }
\ No newline at end of file diff --git a/xmake/modules/devel/git/lastcommit.lua b/xmake/modules/devel/git/lastcommit.lua new file mode 100644 index 000000000..876812f86 --- /dev/null +++ b/xmake/modules/devel/git/lastcommit.lua @@ -0,0 +1,77 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed 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-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file lastcommit.lua +-- + +-- imports +import("core.base.option") +import("lib.detect.find_tool") +import("net.proxy") + +-- get last commit in git repository +-- +-- @param opt the options, e.g. {repodir = ..} +-- +-- @return the last commit +-- +-- @code +-- +-- import("devel.git") +-- +-- local lastcommit = git.lastcommit({repodir = ..}) +-- +-- @endcode +-- +function main(opt) + + -- find git + local git = assert(find_tool("git"), "git not found!") + + -- init arguments + local argv = {"rev-parse", "HEAD"} + + -- trace + if option.get("verbose") then + print("%s %s", git.program, os.args(argv)) + end + + -- use proxy? + local envs + local proxy_conf = proxy.config(url) + if proxy_conf then + envs = {ALL_PROXY = proxy_conf} + end + + -- enter repository directory + local oldir = nil + if opt.repodir then + oldir = os.cd(opt.repodir) + end + + -- get last commit + local lastcommit = os.iorunv(git.program, argv, {envs = envs}) + if lastcommit then + lastcommit = lastcommit:trim() + end + + -- leave repository directory + if oldir then + os.cd(oldir) + end + return lastcommit +end diff --git a/xmake/modules/private/action/require/impl/lock_packages.lua b/xmake/modules/private/action/require/impl/lock_packages.lua index 8d1e0ebdd..972c5c48b 100644 --- a/xmake/modules/private/action/require/impl/lock_packages.lua +++ b/xmake/modules/private/action/require/impl/lock_packages.lua @@ -20,16 +20,53 @@ -- imports import("core.project.project") +import("devel.git") +import("private.action.require.impl.utils.filter") +import("private.action.require.impl.utils.requirekey") + +-- get package key +function _get_packagekey(instance) + local requireinfo = instance:requireinfo() + local requirestr = requireinfo.originstr + local plat = instance:plat() + local arch = instance:arch() + local key = requirekey(requireinfo, {plat = instance:plat(), arch = instance:arch()}) + return string.format("%s#%s", requirestr, key) +end -- lock package function _lock_package(instance) - local result = {} - result.name = instance:name() - result.plat = instance:plat() - result.arch = instance:arch() - result.kind = instance:kind() - result.buildhash = instance:buildhash() - result.version = instance:version_str() + local result = {} + local repo = instance:repo() + result.name = instance:name() + result.plat = instance:plat() + result.arch = instance:arch() + result.kind = instance:kind() + result.version = instance:version_str() + result.buildhash = instance:buildhash() + result.configs = instance:configs() + result.is_built = instance:is_built() + if repo then + local lastcommit = git.lastcommit({repodir = repo:directory()}) + result.repo = repo:url() .. "#" .. lastcommit + end + for _, url in ipairs(instance:urls()) do + result.urls = result.urls or {} + local url_alias = instance:url_alias(url) + url = filter.handle(url, instance) + if git.asgiturl(url) then + local revision = instance:revision(url_alias) or instance:tag() or instance:version_str() + url = url .. "#" .. revision + else + local sourcehash = instance:sourcehash(url_alias) + url = url .. "#" .. sourcehash + end + table.insert(result.urls, url) + end + for _, dep in ipairs(instance:plaindeps()) do + result.deps = result.deps or {} + table.insert(result.deps, _get_packagekey(dep)) + end return result end @@ -37,7 +74,8 @@ end function main(packages) local results = {} for _, instance in ipairs(packages) do - results[instance:displayname()] = _lock_package(instance) + local packagekey = _get_packagekey(instance) + results[packagekey] = _lock_package(instance) end io.writefile(project.requireslock(), string.serialize(results, {orderkeys = true})) end diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 612911429..d94629ce8 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -30,6 +30,7 @@ import("core.tool.toolchain") import("core.package.package", {alias = "core_package"}) import("devel.git") import("private.action.require.impl.repository") +import("private.action.require.impl.utils.requirekey") -- get memcache function _memcache() @@ -477,26 +478,10 @@ end -- get package key function _get_packagekey(packagename, requireinfo, version) - local key = packagename .. "/" .. (version or requireinfo.version) - if requireinfo.plat then - key = key .. "/" .. requireinfo.plat - end - if requireinfo.arch then - key = key .. "/" .. requireinfo.arch - end - if requireinfo.label then - key = key .. "/" .. requireinfo.label - end - local configs = requireinfo.configs - if configs then - local configs_order = {} - for k, v in pairs(configs) do - table.insert(configs_order, k .. "=" .. tostring(v)) - end - table.sort(configs_order) - key = key .. ":" .. string.serialize(configs_order, true) - end - return key + return requirekey(requireinfo, {name = packagename, + plat = requireinfo.plat, + arch = requireinfo.arch, + version = version or requireinfo.version}) end -- inherit some builtin configs of parent package if these config values are not default value diff --git a/xmake/modules/private/action/require/impl/utils/requirekey.lua b/xmake/modules/private/action/require/impl/utils/requirekey.lua new file mode 100644 index 000000000..e39da12ba --- /dev/null +++ b/xmake/modules/private/action/require/impl/utils/requirekey.lua @@ -0,0 +1,50 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed 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-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file requirekey.lua +-- + +-- get require key from requireinfo +function main(requireinfo, opt) + opt = opt or {} + local key = "" + if opt.name then + key = key .. "/" .. opt.name + end + if opt.plat then + key = key .. "/" .. opt.plat + end + if opt.arch then + key = key .. "/" .. opt.arch + end + if opt.version then + key = key .. "/" .. opt.version + end + if requireinfo.label then + key = key .. "/" .. requireinfo.label + end + local configs = requireinfo.configs + if configs then + local configs_order = {} + for k, v in pairs(configs) do + table.insert(configs_order, k .. "=" .. tostring(v)) + end + table.sort(configs_order) + key = key .. ":" .. string.serialize(configs_order, true) + end + return hash.uuid(key):gsub("%-", ""):lower() +end |
