diff options
| author | ruki <[email protected]> | 2024-10-11 00:51:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-10-11 00:51:16 +0800 |
| commit | 09ee92711986cb729d89c23c1802156bd335a602 (patch) | |
| tree | af92c74314e9d978c20303067225055cdcec40f2 | |
| parent | 687beddbf316b1565a55b68934c3681320a1d51f (diff) | |
improve hash module
| -rw-r--r-- | xmake/core/base/hash.lua | 5 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/hash.lua | 14 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/interpreter/hash.lua | 23 |
3 files changed, 37 insertions, 5 deletions
diff --git a/xmake/core/base/hash.lua b/xmake/core/base/hash.lua index 74bbfd4cd..d5fa685b5 100644 --- a/xmake/core/base/hash.lua +++ b/xmake/core/base/hash.lua @@ -96,5 +96,10 @@ function hash.xxhash128(file_or_data) return hashstr, errors end +-- make uuid +function hash.uuid(str) + return hash.uuid4(str) +end + -- return module: hash return hash diff --git a/xmake/core/sandbox/modules/hash.lua b/xmake/core/sandbox/modules/hash.lua index 0827f072f..6b91f9f25 100644 --- a/xmake/core/sandbox/modules/hash.lua +++ b/xmake/core/sandbox/modules/hash.lua @@ -26,15 +26,19 @@ local raise = require("sandbox/modules/raise") local sandbox_hash = sandbox_hash or {} -- make a new uuid -function sandbox_hash.uuid(name) - return sandbox_hash.uuid4(name) +function sandbox_hash.uuid(str) + local uuid = hash.uuid(str) + if not uuid then + raise("cannot make uuid %s", str) + end + return uuid end -- make a new uuid v4 -function sandbox_hash.uuid4(name) - local uuid = hash.uuid4(name) +function sandbox_hash.uuid4(str) + local uuid = hash.uuid4(str) if not uuid then - raise("cannot make uuid %s", name) + raise("cannot make uuid4 %s", str) end return uuid end diff --git a/xmake/core/sandbox/modules/interpreter/hash.lua b/xmake/core/sandbox/modules/interpreter/hash.lua new file mode 100644 index 000000000..83d7f2fd3 --- /dev/null +++ b/xmake/core/sandbox/modules/interpreter/hash.lua @@ -0,0 +1,23 @@ +--!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 hash.lua +-- + +-- load module +return require("sandbox/modules/hash") + |
