Skip to content

Commit

Permalink
rename to check importfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jan 10, 2025
1 parent 4bd329e commit 4810c79
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 44 deletions.
8 changes: 4 additions & 4 deletions xmake/core/package/package.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2712,14 +2712,14 @@ function _instance:check_fcsnippets(snippets, opt)
return sandbox_module.import("lib.detect.check_fcsnippets", {anonymous = true})(snippets, opt)
end

-- check the given pkgconfig file?
-- check the given importfiles?
--
-- @param name the .pc filename (without .pc extension)
-- @param names the import filenames (without .pc/.cmake extension), e.g. pkgconfig::libxml-2.0, cmake::CURL
-- @param opt the argument options
--
-- @return true or false, errors
--
function _instance:check_pkgconfig(name, opt)
function _instance:check_importfiles(names, opt)
opt = opt or {}
if opt.configdirs == nil then
local configdirs = {}
Expand All @@ -2730,7 +2730,7 @@ function _instance:check_pkgconfig(name, opt)
end
opt.configdirs = configdirs
end
return sandbox_module.import("lib.detect.check_pkgconfig", {anonymous = true})(name or self:name(), opt)
return sandbox_module.import("lib.detect.check_importfiles", {anonymous = true})(names or ("pkgconfig::" .. self:name()), opt)
end

-- the current mode is belong to the given modes?
Expand Down
56 changes: 56 additions & 0 deletions xmake/modules/lib/detect/check_importfiles.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
--!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_importfiles.lua
--

-- imports
import("core.base.option")
import("lib.detect.pkgconfig")

-- check the given importfiles for pkgconfig/cmake
--
-- @param names the import filenames (without .pc/.cmake suffix), e.g. pkgconfig::libxml-2.0, cmake::CURL
-- @param opt the argument options, e.g. { verbose = true, configdirs = {"lib"}}
--
function main(names, opt)
for _, name in ipairs(names) do
local kind
local parts = name:split("::")
if #parts == 2 then
kind = parts[1]
name = parts[2]
end
if kind == nil then
kind = "pkgconfig"
end
if kind == "pkgconfig" then
local result = pkgconfig.libinfo(name, opt)
if opt.verbose or option.get("verbose") or option.get("diagnosis") then
cprint("${dim}> checking for pkgconfig/%s.pc", name)
if result then
print(result)
end
end
if not result then
return false, string.format("pkgconfig/%s.pc not found!", name)
end
end
end
return true
end

40 changes: 0 additions & 40 deletions xmake/modules/lib/detect/check_pkgconfig.lua

This file was deleted.

0 comments on commit 4810c79

Please sign in to comment.