summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-05-11 09:07:01 +0800
committerruki <[email protected]>2024-05-11 09:07:07 +0800
commit15e79877b449b729a96a1205033f3bda61bdb898 (patch)
treed89736540ac75ae1b54ff378c00679f9092b6de8
parent2e3a31be034dd4fab8cd0cb206efa30a35897020 (diff)
add check script for package
-rw-r--r--xmake/core/package/package.lua1
-rw-r--r--xmake/modules/private/action/require/impl/actions/check.lua34
-rw-r--r--xmake/modules/private/action/require/impl/install_packages.lua3
3 files changed, 38 insertions, 0 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 48c84145b..2d0fe989d 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -2663,6 +2663,7 @@ function package.apis()
-- package.on_xxx
"package.on_load"
, "package.on_fetch"
+ , "package.on_check"
, "package.on_download"
, "package.on_install"
, "package.on_test"
diff --git a/xmake/modules/private/action/require/impl/actions/check.lua b/xmake/modules/private/action/require/impl/actions/check.lua
new file mode 100644
index 000000000..2087b7a36
--- /dev/null
+++ b/xmake/modules/private/action/require/impl/actions/check.lua
@@ -0,0 +1,34 @@
+--!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 check.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.config")
+
+-- check the given package
+function main(package, opt)
+ opt = opt or {}
+ local script = package:script("check")
+ if script then
+ script(package)
+ end
+end
+
+
diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua
index 359392f71..bcd0169b1 100644
--- a/xmake/modules/private/action/require/impl/install_packages.lua
+++ b/xmake/modules/private/action/require/impl/install_packages.lua
@@ -30,6 +30,7 @@ import("net.fasturl")
import("private.action.require.impl.package")
import("private.action.require.impl.lock_packages")
import("private.action.require.impl.register_packages")
+import("private.action.require.impl.actions.check", {alias = "action_check"})
import("private.action.require.impl.actions.install", {alias = "action_install"})
import("private.action.require.impl.actions.download", {alias = "action_download"})
@@ -477,6 +478,7 @@ function _install_packages(packages_install, packages_download, installdeps)
local downloaded = true
if packages_download[tostring(instance)] then
packages_downloading[index] = instance
+ action_check(instance)
downloaded = action_download(instance)
packages_downloading[index] = nil
end
@@ -488,6 +490,7 @@ function _install_packages(packages_install, packages_download, installdeps)
assert(instance:is_precompiled(), "package(%s) should be precompiled", instance:name())
-- we need to disable built and re-download and re-install it
instance:fallback_build()
+ action_check(instance)
action_download(instance)
action_install(instance)
end