diff options
| author | ruki <[email protected]> | 2018-09-21 00:37:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-09-20 21:45:29 +0800 |
| commit | 9aec994cdb4e21ae2f765898de28dacf3467bd77 (patch) | |
| tree | e6dfc847786025fcc5306f9e546fc0222afffd15 /xmake/modules/lib | |
| parent | 034267c2787a77143bff2df14ea6ebc06f8f1817 (diff) | |
improve to find pkg_config package
Diffstat (limited to 'xmake/modules/lib')
| -rw-r--r-- | xmake/modules/lib/detect/pkg_config.lua | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/xmake/modules/lib/detect/pkg_config.lua b/xmake/modules/lib/detect/pkg_config.lua index fc991393d..e006a1cc5 100644 --- a/xmake/modules/lib/detect/pkg_config.lua +++ b/xmake/modules/lib/detect/pkg_config.lua @@ -58,17 +58,23 @@ function info(name, opt) return result and result or nil end - -- get pkg-config path from brew - local brew = find_brew() + -- attempt to find package without `brew --prefix` (brew is too slow!) + local flags = try { function () return os.iorunv(pkg_config, {"--libs", "--cflags", name}) end } + + -- attempt to get pkg-config path from `brew --prefix` if no flags + local brew = nil local brewprefix = nil local configdirs = opt.configdirs or {} - if brew then - brewprefix = try { function () return os.iorunv(brew, {"--prefix", name}) end } - if brewprefix then - brewprefix = brewprefix:trim() - local configdir = path.join(brewprefix, "lib", "pkgconfig") - if os.isdir(configdir) then - table.insert(configdirs, configdir) + if not flags then + brew = find_brew() + if brew then + brewprefix = try { function () return os.iorunv(brew, {"--prefix", name}) end } + if brewprefix then + brewprefix = brewprefix:trim() + local configdir = path.join(brewprefix, "lib", "pkgconfig") + if os.isdir(configdir) then + table.insert(configdirs, configdir) + end end end end @@ -81,7 +87,7 @@ function info(name, opt) end -- get libs and cflags - local flags = try { function () return os.iorunv(pkg_config, {"--libs", "--cflags", name}) end } + flags = flags or try { function () return os.iorunv(pkg_config, {"--libs", "--cflags", name}) end } if flags then -- init result |
