diff options
| author | ruki <[email protected]> | 2024-03-12 22:53:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-03-12 22:53:41 +0800 |
| commit | f35a5e08721df2c61905e4258a5fb4a2f7295356 (patch) | |
| tree | 73f43b97d2ea65eb8c2f27c77a05ca9cf4c7981e | |
| parent | e1166c435b5715873ac5118beb6465f7fa22a4f7 (diff) | |
improve to find package for brew
| -rw-r--r-- | xmake/modules/package/manager/brew/find_package.lua | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/xmake/modules/package/manager/brew/find_package.lua b/xmake/modules/package/manager/brew/find_package.lua index 15940f9fb..953d34f4e 100644 --- a/xmake/modules/package/manager/brew/find_package.lua +++ b/xmake/modules/package/manager/brew/find_package.lua @@ -56,20 +56,20 @@ function _find_package_from_pkgconfig(name, opt) local nameinfo = name:split('/') local pcname = nameinfo[2] or nameinfo[1] - -- find package from pkg-config/*.pc, attempt to find it from `brew --prefix`/package first + -- find package from pkg-config/*.pc, + -- but we cannot find it from `brew --prefix`/package, because `brew --prefix` is too slow (> 3s) when it's not found. local result = nil - local pcfile = find_file(pcname .. ".pc", path.join(brew_pkg_rootdir, nameinfo[1], "*/lib/pkgconfig")) or - find_file(pcname .. ".pc", path.join(brew_pkg_rootdir, nameinfo[1], "*/share/pkgconfig")) - if not pcfile then - -- attempt to find it from `brew --prefix package` - local brew = find_tool("brew") - local brew_pkgdir = brew and try {function () return os.iorunv(brew.program, {"--prefix", nameinfo[1]}) end} - if brew_pkgdir then - brew_pkgdir = brew_pkgdir:trim() - pcfile = find_file(pcname .. ".pc", path.join(brew_pkgdir, "lib/pkgconfig")) or - find_file(pcname .. ".pc", path.join(brew_pkgdir, "share/pkgconfig")) - end + local paths = {} + table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], "lib/pkgconfig")) + table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], "share/pkgconfig")) + if opt.require_version then + table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], opt.require_version, "lib/pkgconfig")) + table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], opt.require_version, "share/pkgconfig")) + else + table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], "*/lib/pkgconfig")) + table.insert(paths, path.join(brew_pkg_rootdir, nameinfo[1], "*/share/pkgconfig")) end + local pcfile = find_file(pcname .. ".pc", paths) if pcfile then opt.configdirs = path.directory(pcfile) result = find_package("pkgconfig::" .. pcname, opt) |
