diff options
| author | ruki <[email protected]> | 2024-01-14 00:00:18 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-01-14 00:00:18 +0800 |
| commit | 96f297418d869082e3f494c749754170fb3c8dac (patch) | |
| tree | b829231d700f18f95b782160ada2cff322fcb516 | |
| parent | 0d800690687871e2794e92fbcc8a6be7b6320355 (diff) | |
| parent | eaa8973f7386727f9fee1d5c42b2290b61e96300 (diff) | |
Merge pull request #4606 from xmake-io/versions
Improve package versions to add version list file
| -rw-r--r-- | xmake/core/package/package.lua | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 4190c43c1..d5e82b13f 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -307,7 +307,7 @@ end -- set artifacts info function _instance:artifacts_set(artifacts_info) - local versions = self:get("versions") + local versions = self:_versions_list() if versions then -- backup previous package configuration self._ARTIFACTS_BACKUP = { @@ -467,7 +467,7 @@ end -- get hash of the source package for the url_alias@version_str function _instance:sourcehash(url_alias) - local versions = self:get("versions") + local versions = self:_versions_list() local version_str = self:version_str() if versions and version_str then local sourcehash = nil @@ -1250,11 +1250,40 @@ function _instance:originfile_set(filepath) self._ORIGINFILE = filepath end +-- get versions list +function _instance:_versions_list() + if self._VERSIONS_LIST == nil then + local versions = table.wrap(self:get("versions")) + local versionfiles = self:get("versionfiles") + if versionfiles then + utils.dump(versionfiles) + for _, versionfile in ipairs(table.wrap(versionfiles)) do + if not os.isfile(versionfile) then + versionfile = path.join(self:scriptdir(), versionfile) + end + if os.isfile(versionfile) then + local list = io.readfile(versionfile) + for _, line in ipairs(list:split("\n")) do + local splitinfo = line:split("%s+") + if #splitinfo == 2 then + local version = splitinfo[1] + local shasum = splitinfo[2] + versions[version] = shasum + end + end + end + end + end + self._VERSIONS_LIST = versions + end + return self._VERSIONS_LIST +end + -- get versions function _instance:versions() if self._VERSIONS == nil then local versions = {} - for version, _ in pairs(table.wrap(self:get("versions"))) do + for version, _ in pairs(self:_versions_list()) do -- remove the url alias prefix if exists local pos = version:find(':', 1, true) if pos then @@ -2563,6 +2592,11 @@ function package.apis() , "package.add_patches" , "package.add_resources" } + , paths = + { + -- package.add_xxx + "package.add_versionfiles" + } , dictionary = { -- package.add_xxx |
