diff options
| author | ruki <[email protected]> | 2021-08-21 15:50:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-08-21 15:50:39 +0800 |
| commit | 03edbeb91a3b4e5d6d113949d433424497431613 (patch) | |
| tree | c28135ebfa884a45c2c1118aaf114d904a5a915f | |
| parent | e8facd596d72db42a0a20233cde0d543d9384e9c (diff) | |
improve requireslock format
4 files changed, 135 insertions, 170 deletions
diff --git a/tests/projects/package/multiconfig/xmake-requires.lock b/tests/projects/package/multiconfig/xmake-requires.lock index e8621f5b3..6b10a5235 100644 --- a/tests/projects/package/multiconfig/xmake-requires.lock +++ b/tests/projects/package/multiconfig/xmake-requires.lock @@ -2,40 +2,33 @@ __meta__ = { version = "1.0" }, - ["zlib#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "x86_64", - buildhash = "b76a297309d14c09b42cfe3927260a51", - name = "zlib", - plat = "macosx", - repo = { - branch = "master", - commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9", - url = "https://gitee.com/tboox/xmake-repo.git" + ["macosx|x86_64"] = { + ["zlib#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "b76a297309d14c09b42cfe3927260a51", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "1.2.11" }, - version = "1.2.11" - }, - ["zlib~debug#d72a8a937b694e449bce540c8eb65a8a"] = { - arch = "x86_64", - buildhash = "e6a6fa6a86ad4fc7ae3c2cf7c60cc084", - name = "zlib", - plat = "macosx", - repo = { - branch = "master", - commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "1.2.11" - }, - ["zlib~shared#b286744a1898416faad2e5cab0104b2f"] = { - arch = "x86_64", - buildhash = "8e5b898b0f344715bac89cc6a1577506", - name = "zlib", - plat = "macosx", - repo = { - branch = "master", - commit = "df6cad5cf5701de3705c7afce54d732e1f5b14b9", - url = "https://gitee.com/tboox/xmake-repo.git" + ["zlib~debug#d72a8a937b694e449bce540c8eb65a8a"] = { + buildhash = "e6a6fa6a86ad4fc7ae3c2cf7c60cc084", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "1.2.11" }, - version = "1.2.11" + ["zlib~shared#b286744a1898416faad2e5cab0104b2f"] = { + buildhash = "8e5b898b0f344715bac89cc6a1577506", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + 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 764165028..906fba5ed 100644 --- a/tests/projects/package/toolchain_muslcc/xmake-requires.lock +++ b/tests/projects/package/toolchain_muslcc/xmake-requires.lock @@ -2,148 +2,114 @@ __meta__ = { version = "1.0" }, - ["autoconf#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "x86_64", - buildhash = "cd4169a7cb484832b2f70d2174072ca2", - name = "autoconf", - plat = "macosx", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" + ["macosx|x86_64"] = { + ["autoconf#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "cd4169a7cb484832b2f70d2174072ca2", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "2.71" }, - version = "2.71" - }, - ["automake#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "x86_64", - buildhash = "7a090c93706241f983f0d821a162e8a5", - name = "automake", - plat = "macosx", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" - }, - version = "1.16.1" - }, - ["cmake#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "x86_64", - buildhash = "a6d18f8c0bf347d980f8bb762583c91a", - name = "cmake", - plat = "macosx", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" + ["automake#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "7a090c93706241f983f0d821a162e8a5", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "1.16.1" }, - version = "3.21.0" - }, - ["gmp#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "x86_64", - buildhash = "7dd9c224447e46698ac73d29f58b1d73", - name = "gmp", - plat = "macosx", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" + ["cmake#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "a6d18f8c0bf347d980f8bb762583c91a", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "3.21.0" }, - version = "6.2.1" - }, - ["libisl 0.22#3dd996fa365042e39791030c4e1cad52"] = { - arch = "x86_64", - buildhash = "f649e1fb365e442e8f79f372fd91483b", - name = "libisl", - plat = "macosx", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" + ["gmp#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "7dd9c224447e46698ac73d29f58b1d73", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "6.2.1" }, - version = "0.22" - }, - ["libogg#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "arm", - buildhash = "d894fc29f2fb4c45a0f48bc2c6ece273", - name = "libogg", - plat = "cross", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" + ["libisl 0.22#3dd996fa365042e39791030c4e1cad52"] = { + buildhash = "f649e1fb365e442e8f79f372fd91483b", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "0.22" }, - version = "v1.3.4" - }, - ["libplist#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "arm", - buildhash = "0c01b22920be4876b1de74629194eb8f", - name = "libplist", - plat = "cross", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" + ["libogg#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "d894fc29f2fb4c45a0f48bc2c6ece273", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "v1.3.4" }, - version = "2.2.0" - }, - ["libtool#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "x86_64", - buildhash = "64584ec84a4743ecb740b598b263ffa6", - name = "libtool", - plat = "macosx", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" + ["libplist#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "0c01b22920be4876b1de74629194eb8f", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "2.2.0" }, - version = "2.4.6" - }, - ["m4#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "x86_64", - buildhash = "fd0e83e5759b442a970327ebb1c89793", - name = "m4", - plat = "macosx", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" + ["libtool#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "64584ec84a4743ecb740b598b263ffa6", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "2.4.6" }, - version = "1.4.19" - }, - ["muslcc#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "x86_64", - buildhash = "11062c09ebeb484594488ad73ddbcd1f", - name = "muslcc", - plat = "macosx", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" + ["m4#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "fd0e83e5759b442a970327ebb1c89793", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "1.4.19" }, - version = "20210202" - }, - ["pkg-config#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "x86_64", - buildhash = "84fd7f9b9f7a47709512cfc85cd9e5f7", - name = "pkg-config", - plat = "macosx", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" + ["muslcc#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "11062c09ebeb484594488ad73ddbcd1f", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "20210202" }, - version = "0.29.2" - }, - ["zlib#ddbdd8b8f76d455a8c0ef45fffe37160"] = { - arch = "arm", - buildhash = "be90a245b8bb48e6b08a1a15bdcad467", - name = "zlib", - plat = "cross", - repo = { - branch = "master", - commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", - url = "https://gitee.com/tboox/xmake-repo.git" + ["pkg-config#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "84fd7f9b9f7a47709512cfc85cd9e5f7", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "0.29.2" }, - version = "1.2.11" + ["zlib#ddbdd8b8f76d455a8c0ef45fffe37160"] = { + buildhash = "be90a245b8bb48e6b08a1a15bdcad467", + repo = { + branch = "master", + commit = "d0e1f98585a4ec31b056fe3bda65a4fe37e0b375", + url = "https://gitee.com/tboox/xmake-repo.git" + }, + version = "1.2.11" + } } }
\ No newline at end of file diff --git a/xmake/modules/private/action/require/impl/lock_packages.lua b/xmake/modules/private/action/require/impl/lock_packages.lua index c891d73cc..3eba5d00f 100644 --- a/xmake/modules/private/action/require/impl/lock_packages.lua +++ b/xmake/modules/private/action/require/impl/lock_packages.lua @@ -35,9 +35,6 @@ end function _lock_package(instance) local result = {} local repo = instance:repo() - result.name = instance:name() - result.plat = instance:plat() - result.arch = instance:arch() result.version = instance:version_str() result.buildhash = instance:buildhash() result.branch = instance:branch() @@ -56,12 +53,16 @@ end -- lock all required packages function main(packages) if project.policy("package.requires_lock") then + local plat = config.plat() or os.subhost() + local arch = config.arch() or so.subarch() + local key = plat .. "|" .. arch local results = os.isfile(project.requireslock()) and io.load(project.requireslock()) or {} results.__meta__ = results.__meta__ or {} results.__meta__.version = project.requireslock_version() + results[key] = {} for _, instance in ipairs(packages) do local packagelock_key = _get_packagelock_key(instance) - results[packagelock_key] = _lock_package(instance) + results[key][packagelock_key] = _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 95a54a008..d5d893658 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -224,7 +224,12 @@ function _get_locked_requires(requirekey) _memcache():set("requireslock", requireslock or false) end if requireslock then - return requireslock[requirekey], requireslock.__meta__.version + local plat = config.plat() or os.subhost() + local arch = config.arch() or so.subarch() + local key = plat .. "|" .. arch + if requireslock[key] then + return requireslock[key][requirekey], requireslock.__meta__.version + end end end |
