summaryrefslogtreecommitdiff
path: root/xmake/modules/package
diff options
context:
space:
mode:
authorruki <[email protected]>2021-05-21 00:43:46 +0800
committerruki <[email protected]>2021-05-21 00:43:46 +0800
commite65399c1d6d2a3ecd4f13f82cfe18c70e41182f3 (patch)
tree5c2d3386111336a22c4e800767106df3e7829dfa /xmake/modules/package
parent16a421fdcae87814b8ca5fbb53c63ddfcd688380 (diff)
improve pacman::find_package
Diffstat (limited to 'xmake/modules/package')
-rw-r--r--xmake/modules/package/manager/find_package.lua6
-rw-r--r--xmake/modules/package/manager/pacman/find_package.lua21
2 files changed, 18 insertions, 9 deletions
diff --git a/xmake/modules/package/manager/find_package.lua b/xmake/modules/package/manager/find_package.lua
index 0f8013b9c..41c110796 100644
--- a/xmake/modules/package/manager/find_package.lua
+++ b/xmake/modules/package/manager/find_package.lua
@@ -56,6 +56,9 @@ function _find_package_with_builtin_rule(package_name, opt)
-- only support the current sub-host platform and sub-architecture, e.g. linux, macosx, or msys (subsystem)
if opt.plat == os.subhost() and opt.arch == os.subarch() then
+ -- find it from pkg-config
+ table.insert(managers, "pkgconfig")
+
-- find it from pacman
if is_subhost("linux", "msys") and not is_plat("windows") and find_tool("pacman") then
table.insert(managers, "pacman")
@@ -66,9 +69,6 @@ function _find_package_with_builtin_rule(package_name, opt)
table.insert(managers, "portage")
end
- -- find it from pkg-config
- table.insert(managers, "pkgconfig")
-
-- find it from system
table.insert(managers, "system")
end
diff --git a/xmake/modules/package/manager/pacman/find_package.lua b/xmake/modules/package/manager/pacman/find_package.lua
index ba5b58c21..8b1b01abe 100644
--- a/xmake/modules/package/manager/pacman/find_package.lua
+++ b/xmake/modules/package/manager/pacman/find_package.lua
@@ -51,15 +51,13 @@ function main(name, opt)
end
-- parse package files list
- local pkgconfig_dir = nil
- local pkgconfig_name = nil
local linkdirs = {}
local has_includes = false
+ local pkgconfig_files = {}
for _, line in ipairs(list:split('\n', {plain = true})) do
line = line:trim():split('%s+')[2]
if not pkgconfig_dir and line:find("/pkgconfig/", 1, true) and line:endswith(".pc") then
- pkgconfig_dir = path.directory(line)
- pkgconfig_name = path.basename(line)
+ pkgconfig_files[path.basename(line)] = line
end
if line:endswith(".so") or line:endswith(".a") or line:endswith(".lib") then
table.insert(linkdirs, path.directory(line))
@@ -68,12 +66,23 @@ function main(name, opt)
end
end
+ -- get pkgconfig file
+ local pkgconfig_file = pkgconfig_files[name]
+ if not pkgconfig_file then
+ for _, file in pairs(pkgconfig_files) do
+ pkgconfig_file = file
+ break
+ end
+ end
+
-- find package
local result = nil
- if pkgconfig_dir then
+ if pkgconfig_file then
+ local pkgconfig_dir = path.directory(pkgconfig_file)
+ local pkgconfig_name = path.basename(pkgconfig_file)
linkdirs = table.unique(linkdirs)
includedirs = table.unique(includedirs)
- result = find_package_from_pkgconfig(pkgconfig_name or name, {configdirs = pkgconfig_dir, linkdirs = linkdirs})
+ result = find_package_from_pkgconfig(pkgconfig_name, {configdirs = pkgconfig_dir, linkdirs = linkdirs})
if not result and has_includes then
-- header only and hidden /usr/include? we need only return empty {}
result = {}