diff options
| author | ruki <[email protected]> | 2025-10-04 18:01:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-10-04 18:01:37 +0800 |
| commit | d31622c8fb0c962262f3397bc8cb1ac670abd001 (patch) | |
| tree | 965fbc5d83d69247f85cc3311aa5f8beeb30ad80 | |
| parent | cde688f2021845a23751eeb25aecd3b5194c6952 (diff) | |
improve hash
| -rw-r--r-- | xmake/core/base/hash.lua | 11 | ||||
| -rw-r--r-- | xmake/core/base/os.lua | 1 |
2 files changed, 9 insertions, 3 deletions
diff --git a/xmake/core/base/hash.lua b/xmake/core/base/hash.lua index e846ba302..9d7ca40ed 100644 --- a/xmake/core/base/hash.lua +++ b/xmake/core/base/hash.lua @@ -120,9 +120,14 @@ end -- generate hash32 from string, e.g. "91e8ecf1" function hash.strhash32(str) - local data = libc.ptraddr(libc.dataptr(str)) - local size = #str - return hash._xxhash(32, data, size) + if hash._rand32 then + local data = libc.ptraddr(libc.dataptr(str)) + local size = #str + return hash._xxhash(32, data, size) + else + -- we need to be compatible with the old binary core (<= v3.0.3) + return hash.uuid4(str):split("-", {plain = true})[1]:lower() + end end -- generate hash64 from string, e.g. "91e8ecf191e8ecf1" diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 8f56aa8e0..e6422c549 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -1305,6 +1305,7 @@ end function os.getenvs() local envs = os._getenvs() if envs then + -- we need to be compatible with the old binary core, if it's array (<= v3.0.3) if envs[1] ~= nil then local result = {} for _, line in ipairs(envs) do |
