summaryrefslogtreecommitdiff
path: root/xmake/core/base
diff options
context:
space:
mode:
authorSaikari <[email protected]>2025-10-04 23:09:26 +0300
committerGitHub <[email protected]>2025-10-04 23:09:26 +0300
commit4b643c4fa3792c834fe08d2e99104ea655b61584 (patch)
tree6f3b868645d3555cdf4bb50d901533d6b57b31b1 /xmake/core/base
parentcb087738d9cc3caf04f619b2524d4a848daee387 (diff)
parent82f581a047820d7136b7bf6b6a969b4d3a96e497 (diff)
Merge branch 'xmake-io:dev' into fix-sizeof-wasm
Diffstat (limited to 'xmake/core/base')
-rw-r--r--xmake/core/base/hash.lua11
-rw-r--r--xmake/core/base/os.lua29
2 files changed, 37 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 988d9e4bf..e6422c549 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -42,6 +42,7 @@ os._tmpdir = os._tmpdir or os.tmpdir
os._curdir = os._curdir or os.curdir
os._fscase = os._fscase or os.fscase
os._setenv = os._setenv or os.setenv
+os._getenvs = os._getenvs or os.getenvs
os._cpuinfo = os._cpuinfo or os.cpuinfo
os._meminfo = os._meminfo or os.meminfo
os._readlink = os._readlink or os.readlink
@@ -1300,6 +1301,34 @@ function os.term()
return require("base/tty").term()
end
+-- get all current environments variables
+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
+ local p = line:find('=', 1, true)
+ if p then
+ local key = line:sub(1, p - 1):trim()
+ -- only translate Path to PATH on windows
+ -- @see https://github.com/xmake-io/xmake/issues/3752
+ if os.host() == "windows" and key:lower() == "path" then
+ key = key:upper()
+ end
+ local values = line:sub(p + 1):trim()
+ if #key > 0 then
+ result[key] = values
+ end
+ end
+ end
+ envs = result
+ end
+ end
+ return envs
+end
+
-- set all current environment variables
-- e.g. envs["PATH"] = "/xxx:/yyy/foo"
function os.setenvs(envs)