summaryrefslogtreecommitdiff
path: root/xmake/modules/private/action/require/impl/utils
diff options
context:
space:
mode:
authorruki <[email protected]>2021-02-21 18:28:25 +0800
committerruki <[email protected]>2021-02-21 18:28:25 +0800
commitbedd0f49b1abf23fe3f7dc72b1d46bcf1c848cff (patch)
tree071cd474b4d6c1db4a8cf9b48492dcb447bf8281 /xmake/modules/private/action/require/impl/utils
parent4ef736be23496aac5a68beb3c4f36e94d5c5b3fd (diff)
add should_install module
Diffstat (limited to 'xmake/modules/private/action/require/impl/utils')
-rw-r--r--xmake/modules/private/action/require/impl/utils/should_install.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/xmake/modules/private/action/require/impl/utils/should_install.lua b/xmake/modules/private/action/require/impl/utils/should_install.lua
new file mode 100644
index 000000000..ca104787f
--- /dev/null
+++ b/xmake/modules/private/action/require/impl/utils/should_install.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, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file should_install.lua
+--
+
+
+-- should install?
+function _should_install(instance)
+ if instance:parents() then
+ -- if all the packages that depend on it already exist, then there is no need to install it
+ for _, parent in pairs(instance:parents()) do
+ if _should_install(parent) and not parent:exists() then
+ return true
+ end
+ end
+ else
+ return not instance:exists()
+ end
+end
+
+-- the given package should be install?
+function main(instance)
+ return _should_install(instance)
+end