summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-10-01 22:06:13 +0800
committerGitHub <[email protected]>2025-10-01 22:06:13 +0800
commit291bfbea0f79aa76468285e0a4cb40475fc80133 (patch)
treee746a904c2fc4ca6954141751e91ac4139263a64
parentc5a738cfb37fab1c2aed211f1abe26ef0444923f (diff)
parent8b2d1c28e69ab41cc6a1535bd4a2bce769fd7869 (diff)
Merge pull request #6876 from Shiffted/fix-package-version-list
add versionfiles checker
-rw-r--r--xmake/core/package/package.lua2
-rw-r--r--xmake/modules/private/action/require/impl/actions/download.lua3
-rw-r--r--xmake/modules/private/action/require/impl/check_api.lua6
-rw-r--r--xmake/modules/private/action/require/impl/package.lua2
-rw-r--r--xmake/modules/private/check/checker.lua1
-rw-r--r--xmake/modules/private/check/checkers/api/package/versionfiles.lua39
6 files changed, 49 insertions, 4 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 2c42a4c94..7a1d8e24b 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -1458,7 +1458,7 @@ function _instance:_versions_list()
if not path.is_absolute(versionfile) then
local subpath = versionfile
versionfile = path.join(self:scriptdir(), subpath)
- if not os.isfile(versionfile) then
+ if not os.isfile(versionfile) and self:base() then
versionfile = path.join(self:base():scriptdir(), subpath)
end
end
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua
index 47690273e..25c9d1b56 100644
--- a/xmake/modules/private/action/require/impl/actions/download.lua
+++ b/xmake/modules/private/action/require/impl/actions/download.lua
@@ -27,6 +27,7 @@ import("core.project.config")
import("core.package.package", {alias = "core_package"})
import("lib.detect.find_file")
import("lib.detect.find_directory")
+import("private.action.require.impl.check_api")
import("private.action.require.impl.utils.filter")
import("private.action.require.impl.utils.url_filename")
import("net.http")
@@ -406,6 +407,8 @@ function main(package, opt)
{
function (errors)
+ check_api(package, {download_failure = true})
+
-- show or save the last errors
if errors then
if (option.get("verbose") or option.get("diagnosis")) then
diff --git a/xmake/modules/private/action/require/impl/check_api.lua b/xmake/modules/private/action/require/impl/check_api.lua
index 7fd5459c1..63637ac25 100644
--- a/xmake/modules/private/action/require/impl/check_api.lua
+++ b/xmake/modules/private/action/require/impl/check_api.lua
@@ -21,10 +21,12 @@
import("private.check.checker")
import("private.check.show")
-function main(package)
+function main(package, opt)
+ opt = opt or {}
+
local checkers = checker.checkers()
for name, info in table.orderpairs(checkers) do
- if info.load then
+ if (info.load and opt.load) or (info.download_failure and opt.download_failure) then
local check = import("private.check.checkers." .. name, {anonymous = true})
check({package = package, show = show.wshow})
end
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index 11b06d381..1e64d8b47 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -1129,7 +1129,7 @@ function _load_package(packagename, requireinfo, opt)
-- load environments from the manifest to enable the environments of on_install()
package:envs_load()
- check_api(package)
+ check_api(package, {load = true})
-- save this package package to cache
_memcache():set2("packages", packagekey, package)
diff --git a/xmake/modules/private/check/checker.lua b/xmake/modules/private/check/checker.lua
index 923c35809..6ff8b3864 100644
--- a/xmake/modules/private/check/checker.lua
+++ b/xmake/modules/private/check/checker.lua
@@ -28,6 +28,7 @@ function checkers()
checkers = {
-- package api checkers
["api.package.kind"] = {description = "Check kind configuration in package.", load = true},
+ ["api.package.versionfiles"] = {description = "Check versionfiles configuration in package.", download_failure = true},
-- target api checkers
["api.target.version"] = {description = "Check version configuration in target."},
["api.target.kind"] = {description = "Check kind configuration in target.", build = true},
diff --git a/xmake/modules/private/check/checkers/api/package/versionfiles.lua b/xmake/modules/private/check/checkers/api/package/versionfiles.lua
new file mode 100644
index 000000000..d9224630b
--- /dev/null
+++ b/xmake/modules/private/check/checkers/api/package/versionfiles.lua
@@ -0,0 +1,39 @@
+--!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, Xmake Open Source Community.
+--
+-- @author Shiffted
+-- @file versionfiles.lua
+--
+
+import(".api_checker")
+
+function main(opt)
+ opt = opt or {}
+ api_checker.check_packages("versionfiles", table.join(opt, {check = function(package, value)
+ local versionfile_path = value
+ if not path.is_absolute(versionfile_path) then
+ local subpath = versionfile_path
+ versionfile_path = path.join(package:scriptdir(), subpath)
+ if not os.isfile(versionfile_path) and package:base() then
+ versionfile_path = path.join(package:base():scriptdir(), subpath)
+ end
+ end
+ if not os.isfile(versionfile_path) then
+ return false, string.format("versionfile '%s' not found", value)
+ end
+ return true
+ end}))
+end