diff options
| author | ruki <[email protected]> | 2022-06-30 22:44:28 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-06-30 22:44:28 +0800 |
| commit | 97e4973e25019418ffa7d2a30ab577d3bfb9031c (patch) | |
| tree | b58b2e2c11c89dee89c74324ed034df9b15b25bd /xmake/modules | |
| parent | a1e7315fae05c2f35821ea92429b08aaf0bc3672 (diff) | |
improve to find apt packages
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/package/manager/apt/find_package.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/xmake/modules/package/manager/apt/find_package.lua b/xmake/modules/package/manager/apt/find_package.lua index e2617b4ec..d71a34319 100644 --- a/xmake/modules/package/manager/apt/find_package.lua +++ b/xmake/modules/package/manager/apt/find_package.lua @@ -23,10 +23,12 @@ import("core.base.option") import("core.project.config") import("core.project.target") import("lib.detect.find_tool") +import("package.manager.pkgconfig.find_package", {alias = "find_package_from_pkgconfig"}) -- find package function _find_package(dpkg, name, opt) local result = nil + local pkgconfig_files = {} local listinfo = try {function () return os.iorunv(dpkg.program, {"--listfiles", name}) end} if listinfo then for _, line in ipairs(listinfo:split('\n', {plain = true})) do @@ -39,6 +41,11 @@ function _find_package(dpkg, name, opt) result = result or {} end + -- get pc files + if line:find("/pkgconfig/", 1, true) and line:endswith(".pc") then + table.insert(pkgconfig_files, line) + end + -- get linkdirs and links if line:endswith(".a") or line:endswith(".so") then result = result or {} @@ -52,6 +59,37 @@ function _find_package(dpkg, name, opt) end end + -- we iterate over each pkgconfig file to extract the required data + local foundpc = false + local pcresult = {includedirs = {}, linkdirs = {}, links = {}} + for _, pkgconfig_file in ipairs(pkgconfig_files) do + local pkgconfig_dir = path.directory(pkgconfig_file) + local pkgconfig_name = path.basename(pkgconfig_file) + local pcinfo = find_package_from_pkgconfig(pkgconfig_name, {configdirs = pkgconfig_dir, linkdirs = linkdirs}) + + -- the pkgconfig file has been parse successfully + if pcinfo then + for _, includedir in ipairs(pcinfo.includedirs) do + table.insert(pcresult.includedirs, includedir) + end + for _, linkdir in ipairs(pcinfo.linkdirs) do + table.insert(pcresult.linkdirs, linkdir) + end + for _, link in ipairs(pcinfo.links) do + table.insert(pcresult.links, link) + end + -- version should be the same if a pacman package contains multiples .pc + pcresult.version = pcinfo.version + foundpc = true + end + end + if foundpc == true then + pcresult.includedirs = table.unique(pcresult.includedirs) + pcresult.linkdirs = table.unique(pcresult.linkdirs) + pcresult.links = table.reverse_unique(pcresult.links) + result = pcresult + end + -- meta/alias package? e.g. libboost-dev -> libboost1.74-dev -- @see https://github.com/xmake-io/xmake/issues/1786 if not result then |
