diff options
| author | ruki <[email protected]> | 2019-03-12 23:47:42 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-03-12 16:46:16 +0800 |
| commit | e763b2e433cee08eaa26ea00cd2af82bfd050a04 (patch) | |
| tree | fcdf47a00dfa0d0645ed87b31ea5dec9fb61388d | |
| parent | 66f35570b748dc88b8c1d4f6e15743c5369d1459 (diff) | |
add has_package
| -rw-r--r-- | xmake/core/project/project.lua | 1 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/has_package.lua | 37 |
2 files changed, 37 insertions, 1 deletions
diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 1e0403fc3..ec68d3ba1 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -783,7 +783,6 @@ end -- get requires info function project.requires() - if not project._REQUIRES then local requires, errors = project._load_requires() if not requires then diff --git a/xmake/core/sandbox/modules/has_package.lua b/xmake/core/sandbox/modules/has_package.lua new file mode 100644 index 000000000..7873a5d26 --- /dev/null +++ b/xmake/core/sandbox/modules/has_package.lua @@ -0,0 +1,37 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2019, TBOOX Open Source Group. +-- +-- @author ruki +-- @file has_package.lua +-- + +-- return module +return function (...) + require("sandbox/modules/import/core/sandbox/module").import("core.project.project") + local requires = project.requires() + if requires then + for _, name in ipairs(table.join(...)) do + local pkg = requires[name] + if pkg and pkg:enabled() then + return true + end + end + end +end |
