summaryrefslogtreecommitdiff
path: root/xmake/modules/private/action/require/impl/utils/requirekey.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-08-15 23:38:15 +0800
committerruki <[email protected]>2021-08-15 23:38:15 +0800
commitdd717cd8219f0774ecb717f44d6ba3f182f29c99 (patch)
tree231579ec6d522722e9854a90c2282ce935e036aa /xmake/modules/private/action/require/impl/utils/requirekey.lua
parent28c02f2323aaa4595b8474c6a01e6ffc28181396 (diff)
improve xmake-requires.lock
Diffstat (limited to 'xmake/modules/private/action/require/impl/utils/requirekey.lua')
-rw-r--r--xmake/modules/private/action/require/impl/utils/requirekey.lua50
1 files changed, 50 insertions, 0 deletions
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