diff options
| -rw-r--r-- | xmake/actions/require/impl/action/download.lua | 12 | ||||
| -rw-r--r-- | xmake/actions/require/info.lua | 6 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 36 | ||||
| -rw-r--r-- | xmake/modules/package/manager/xmake/find_package.lua | 4 |
4 files changed, 28 insertions, 30 deletions
diff --git a/xmake/actions/require/impl/action/download.lua b/xmake/actions/require/impl/action/download.lua index a01d9aef2..9eba21afd 100644 --- a/xmake/actions/require/impl/action/download.lua +++ b/xmake/actions/require/impl/action/download.lua @@ -91,13 +91,13 @@ function _download(package, url, sourcedir, url_alias, url_excludes) -- get package file local packagefile = path.filename(url) - -- get sha256 - local sha256 = package:sha256(url_alias) - assert(sha256, "cannot get sha256 of %s in package(%s)", url, package:name()) + -- get sourcehash + local sourcehash = package:sourcehash(url_alias) + assert(sourcehash, "cannot get source hash of %s in package(%s)", url, package:name()) -- the package file have been downloaded? local cached = true - if option.get("force") or not os.isfile(packagefile) or sha256 ~= hash.sha256(packagefile) then + if option.get("force") or not os.isfile(packagefile) or sourcehash ~= hash.sha256(packagefile) then -- no cached cached = false @@ -109,7 +109,7 @@ function _download(package, url, sourcedir, url_alias, url_excludes) http.download(url, packagefile) -- check hash - if sha256 and sha256 ~= hash.sha256(packagefile) then + if sourcehash and sourcehash ~= hash.sha256(packagefile) then raise("unmatched checksum!") end end @@ -146,7 +146,7 @@ function _urls(package) for _, url in ipairs(package:urls()) do if git.checkurl(url) then table.insert(urls[1], url) - elseif package:sha256(package:url_alias(url)) then + elseif package:sourcehash(package:url_alias(url)) then table.insert(urls[2], url) end end diff --git a/xmake/actions/require/info.lua b/xmake/actions/require/info.lua index e75036df5..9e0ea691b 100644 --- a/xmake/actions/require/info.lua +++ b/xmake/actions/require/info.lua @@ -116,9 +116,9 @@ function main(package_names) cprint(" -> ${magenta}urls${clear}:") for _, url in ipairs(urls) do print(" -> %s", filter.handle(url, instance)) - local sha256 = instance:sha256(instance:url_alias(url)) - if sha256 then - cprint(" -> ${yellow}%s${clear}", sha256) + local sourcehash = instance:sourcehash(instance:url_alias(url)) + if sourcehash then + cprint(" -> ${yellow}%s${clear}", sourcehash) end end end diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index f230398c2..625969b89 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -167,30 +167,30 @@ function _instance:orderdeps() return self._ORDERDEPS end --- get sha256 of the url_alias@version_str -function _instance:sha256(url_alias) +-- get hash of the source package for the url_alias@version_str +function _instance:sourcehash(url_alias) - -- get sha256 + -- get sourcehash local versions = self:get("versions") local version_str = self:version_str() if versions and version_str then - local sha256 = nil + local sourcehash = nil if url_alias then - sha256 = versions[url_alias .. ":" ..version_str] + sourcehash = versions[url_alias .. ":" ..version_str] end - if not sha256 then - sha256 = versions[version_str] + if not sourcehash then + sourcehash = versions[version_str] end -- ok? - return sha256 + return sourcehash end end -- get revision(commit, tag, branch) of the url_alias@version_str, only for git url function _instance:revision(url_alias) - return self:sha256(url_alias) + return self:sourcehash(url_alias) end -- this package is from system/local/global? @@ -198,7 +198,6 @@ end -- @param kind the from kind -- -- system: from the system directories (.e.g /usr/local) --- local: from the local project package directories (.e.g projectdir/.xmake/packages) -- global: from the global package directories (.e.g ~/.xmake/packages) -- function _instance:from(kind) @@ -226,7 +225,7 @@ function _instance:installdir(...) -- make the given install directory local name = self:name():lower():gsub("::", "_") - local dir = path.join(package.installdir(), name:sub(1, 1):lower(), name, self:version_str(), self:configs_hash(), ...) + local dir = path.join(package.installdir(), name:sub(1, 1):lower(), name, self:version_str(), self:buildhash(), ...) -- ensure the install directory if not os.isdir(dir) then @@ -364,17 +363,17 @@ function _instance:configs() end end --- get the hash of configs -function _instance:configs_hash() - if self._CONFIGS_HASH == nil then +-- get the build hash +function _instance:buildhash() + if self._BUILDHASH == nil then local str = self:plat() .. self:arch() .. self:mode() local configs = self:configs() if configs then str = str .. string.serialize(configs, true) end - self._CONFIGS_HASH = hash.uuid(str):gsub('-', ''):lower() + self._BUILDHASH = hash.uuid(str):gsub('-', ''):lower() end - return self._CONFIGS_HASH + return self._BUILDHASH end -- get the group name @@ -526,11 +525,10 @@ function _instance:fetch(opt) -- only fetch it from the xmake repository first if not fetchinfo and system ~= true and not self:is3rd() then fetchinfo = self._find_package("xmake::" .. self:name(), {mode = self:mode(), - islocal = self:from("local"), version = require_ver, cachekey = "fetch_package_xmake", - configs_hash = self:configs_hash(), - force = opt.force or self:from("local")}) + buildhash = self:buildhash(), + force = opt.force}) if fetchinfo then fetchfrom = self._FROMKIND end end diff --git a/xmake/modules/package/manager/xmake/find_package.lua b/xmake/modules/package/manager/xmake/find_package.lua index cb00d5756..a3e907539 100644 --- a/xmake/modules/package/manager/xmake/find_package.lua +++ b/xmake/modules/package/manager/xmake/find_package.lua @@ -35,7 +35,7 @@ import("lib.detect.find_library") function _find_package_from_repo(name, opt) -- get build mode, e.g. debug_f7821231 - local mode = table.concat({opt.mode or "release", opt.configs_hash}, '_') + local mode = table.concat({opt.mode or "release", opt.buildhash}, '_') -- get the prefix directories local prefixdirs = table.wrap(opt.prefixdirs) @@ -247,7 +247,7 @@ end -- find package using the xmake package manager -- -- @param name the package name --- @param opt the options, .e.g {verbose = true, version = "1.12.x", configs_hash = "xxxxxx") +-- @param opt the options, .e.g {verbose = true, version = "1.12.x", buildhash = "xxxxxx") -- function main(name, opt) |
