summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-10-11 00:55:26 +0800
committerruki <[email protected]>2024-10-11 00:55:26 +0800
commitd023f3501a95bcd2c7475b578bed7585d8ed60d3 (patch)
tree8471660ffd078779e04ba09c2a67ae178e1eb65e
parentc189bb54bc616f219d7881c032a207fdaa385a17 (diff)
rename to strhash
-rw-r--r--xmake/core/base/hash.lua8
-rw-r--r--xmake/core/sandbox/modules/hash.lua8
-rw-r--r--xmake/includes/xrepo/xmake.lua4
-rw-r--r--xmake/modules/private/action/require/impl/repository.lua2
-rw-r--r--xmake/modules/private/action/require/impl/utils/requirekey.lua2
-rw-r--r--xmake/plugins/pack/nsis/main.lua2
6 files changed, 13 insertions, 13 deletions
diff --git a/xmake/core/base/hash.lua b/xmake/core/base/hash.lua
index be831c205..44502ad19 100644
--- a/xmake/core/base/hash.lua
+++ b/xmake/core/base/hash.lua
@@ -101,13 +101,13 @@ function hash.uuid(str)
return hash.uuid4(str)
end
--- generate hash32, e.g. "91e8ecf1"
-function hash.hash32(str)
+-- generate hash32 from string, e.g. "91e8ecf1"
+function hash.strhash32(str)
return hash.uuid4(str):split("-", {plain = true})[1]:lower()
end
--- generate hash128, e.g. "91e8ecf1417f4edfa574e22d7d8d204a"
-function hash.hash128(str)
+-- generate hash128 from string, e.g. "91e8ecf1417f4edfa574e22d7d8d204a"
+function hash.strhash128(str)
return hash.uuid4(str):replace("-", "", {plain = true}):lower()
end
diff --git a/xmake/core/sandbox/modules/hash.lua b/xmake/core/sandbox/modules/hash.lua
index 45fc5fb43..50e2100cc 100644
--- a/xmake/core/sandbox/modules/hash.lua
+++ b/xmake/core/sandbox/modules/hash.lua
@@ -89,8 +89,8 @@ function sandbox_hash.xxhash128(file_or_data)
end
-- generate hash32 from string
-function sandbox_hash.hash32(str)
- local hash32, errors = hash.hash32(str)
+function sandbox_hash.strhash32(str)
+ local hash32, errors = hash.strhash32(str)
if not hash32 then
raise("cannot generate hash32 for %s, %s", str, errors or "unknown errors")
end
@@ -98,8 +98,8 @@ function sandbox_hash.hash32(str)
end
-- generate hash128 from string
-function sandbox_hash.hash128(str)
- local hash128, errors = hash.hash128(str)
+function sandbox_hash.strhash128(str)
+ local hash128, errors = hash.strhash128(str)
if not hash128 then
raise("cannot generate hash128 for %s, %s", str, errors or "unknown errors")
end
diff --git a/xmake/includes/xrepo/xmake.lua b/xmake/includes/xrepo/xmake.lua
index 9b3e0abaa..2810dc5a8 100644
--- a/xmake/includes/xrepo/xmake.lua
+++ b/xmake/includes/xrepo/xmake.lua
@@ -32,7 +32,7 @@
-- @endcode
--
function xrepo_addenvs(envs)
- local packagename = "__xrepo_addenvs_" .. hash.hash32(tostring(envs))
+ local packagename = "__xrepo_addenvs_" .. hash.strhash32(tostring(envs))
package(packagename)
on_load(function (package)
if type(envs) == "function" then
@@ -61,7 +61,7 @@ end
--
function xrepo_addenv(name, ...)
local args = table.pack(...)
- local packagename = "__xrepo_addenv_" .. name .. hash.hash32(table.concat(args))
+ local packagename = "__xrepo_addenv_" .. name .. hash.strhash32(table.concat(args))
package(packagename)
on_load(function (package)
package:addenv(name, table.unpack(args))
diff --git a/xmake/modules/private/action/require/impl/repository.lua b/xmake/modules/private/action/require/impl/repository.lua
index 001d2ec0a..74b97efda 100644
--- a/xmake/modules/private/action/require/impl/repository.lua
+++ b/xmake/modules/private/action/require/impl/repository.lua
@@ -38,7 +38,7 @@ function _get_packagedir_from_locked_repo(packagename, locked_repo)
break
end
end
- local reponame = hash.hash128(locked_repo.url .. (locked_repo.commit or "")) .. ".lock"
+ local reponame = hash.strhash128(locked_repo.url .. (locked_repo.commit or "")) .. ".lock"
-- get local repodir
local repodir_local
diff --git a/xmake/modules/private/action/require/impl/utils/requirekey.lua b/xmake/modules/private/action/require/impl/utils/requirekey.lua
index a8f435cdf..13d31cd3a 100644
--- a/xmake/modules/private/action/require/impl/utils/requirekey.lua
+++ b/xmake/modules/private/action/require/impl/utils/requirekey.lua
@@ -78,7 +78,7 @@ function main(requireinfo, opt)
if key == "" then
key = "_" -- we need to generate a fixed hash value
end
- return hash.hash32(key)
+ return hash.strhash32(key)
else
return key
end
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index 1b49da3b5..64c002042 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -83,7 +83,7 @@ end
-- get unique tag
function _get_unique_tag(content)
- return hash.hash32(content)
+ return hash.strhash32(content)
end
-- translate the file path