From c9d05eaf022540940434ca60e4c800cc2b321e01 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 21 Aug 2018 23:17:50 +0800 Subject: improve to find_pcre/pcre2 package --- xmake/modules/detect/packages/find_pcre.lua | 16 ++++++++++++++++ xmake/modules/detect/packages/find_pcre2.lua | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/xmake/modules/detect/packages/find_pcre.lua b/xmake/modules/detect/packages/find_pcre.lua index 5e5db94c5..34a0e44ea 100644 --- a/xmake/modules/detect/packages/find_pcre.lua +++ b/xmake/modules/detect/packages/find_pcre.lua @@ -23,6 +23,7 @@ -- -- imports +import("lib.detect.vcpkg") import("lib.detect.pkg_config") -- find pcre @@ -33,6 +34,21 @@ import("lib.detect.pkg_config") -- function main(opt) + -- find package from vcpkg first + local result = vcpkg.find("pcre", opt) + if result then + local links = {} + for _, link in ipairs(result.links) do + links[link] = true + end + for _, width in ipairs({"", "16", "32"}) do + if links["pcre" .. width] then + result.links = {"pcre" .. width} + return result + end + end + end + -- find package from the current host platform if opt.plat == os.host() and opt.arch == os.arch() then for _, width in ipairs({"", "16", "32"}) do diff --git a/xmake/modules/detect/packages/find_pcre2.lua b/xmake/modules/detect/packages/find_pcre2.lua index 6ed5cfa8d..f36aad40e 100644 --- a/xmake/modules/detect/packages/find_pcre2.lua +++ b/xmake/modules/detect/packages/find_pcre2.lua @@ -23,6 +23,7 @@ -- -- imports +import("lib.detect.vcpkg") import("lib.detect.pkg_config") -- find pcre2 @@ -33,6 +34,22 @@ import("lib.detect.pkg_config") -- function main(opt) + -- find package from vcpkg first + local result = vcpkg.find("pcre2", opt) + if result then + local links = {} + for _, link in ipairs(result.links) do + links[link] = true + end + for _, width in ipairs({"8", "16", "32"}) do + if links["pcre2-" .. width] then + result.links = {"pcre2-" .. width} + result.defines = {"PCRE2_CODE_UNIT_WIDTH=" .. width} + return result + end + end + end + -- find package from the current host platform if opt.plat == os.host() and opt.arch == os.arch() then for _, width in ipairs({"8", "16", "32"}) do -- cgit v1.3.1