summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-09-17 00:38:22 +0800
committerruki <[email protected]>2022-09-17 00:38:22 +0800
commitaeda19b4032f790aa6e6915752ae5f06850ad56a (patch)
treed1375e306e6386d9dd9988c325df0880f8060016
parentb3b15ca2375dbe4f39d545c988c271331caf1a26 (diff)
improve vcpkg/triplet
-rw-r--r--xmake/modules/package/manager/vcpkg/configurations.lua15
-rw-r--r--xmake/modules/package/manager/vcpkg/find_package.lua17
-rw-r--r--xmake/modules/package/manager/vcpkg/install_package.lua25
3 files changed, 23 insertions, 34 deletions
diff --git a/xmake/modules/package/manager/vcpkg/configurations.lua b/xmake/modules/package/manager/vcpkg/configurations.lua
index 0a03f4d35..997f8fa35 100644
--- a/xmake/modules/package/manager/vcpkg/configurations.lua
+++ b/xmake/modules/package/manager/vcpkg/configurations.lua
@@ -46,6 +46,21 @@ function plat(plat)
return plats[plat] or plat
end
+-- get triplet
+function triplet(configs, plat, arch)
+ configs = configs or {}
+ local triplet = arch .. "-" .. plat
+ if plat == "windows" and configs.shared ~= true then
+ triplet = triplet .. "-static"
+ if configs.vs_runtime and configs.vs_runtime:startswith("MD") then
+ triplet = triplet .. "-md"
+ end
+ elseif plat == "mingw" then
+ triplet = triplet .. (configs.shared ~= true and "-static" or "-dynamic")
+ end
+ return triplet
+end
+
-- get configurations
function main()
return {
diff --git a/xmake/modules/package/manager/vcpkg/find_package.lua b/xmake/modules/package/manager/vcpkg/find_package.lua
index f4a23f57d..2853c87ee 100644
--- a/xmake/modules/package/manager/vcpkg/find_package.lua
+++ b/xmake/modules/package/manager/vcpkg/find_package.lua
@@ -65,17 +65,20 @@ end
function _find_package(vcpkgdir, name, opt)
+ -- get configs
+ local configs = opt.configs or {}
+
-- fix name, e.g. ffmpeg[x264] as ffmpeg
-- @see https://github.com/xmake-io/xmake/issues/925
name = name:gsub("%[.-%]", "")
- -- get arch, plat and mode
+ -- init triplet
local arch = opt.arch
local plat = opt.plat
local mode = opt.mode
-
plat = configurations.plat(plat)
arch = configurations.arch(arch)
+ local triplet = configurations.triplet(configs, plat, arch)
-- get the vcpkg info directories
local infodirs = {}
@@ -85,16 +88,6 @@ function _find_package(vcpkgdir, name, opt)
table.join2(infodirs, path.join(vcpkgdir, "installed", "vcpkg", "info"))
-- find the package info file, e.g. zlib_1.2.11-3_x86-windows[-static].list
- local triplet = arch .. "-" .. plat
- local configs = opt.configs or {}
- if opt.plat == "windows" and configs.shared ~= true then
- triplet = triplet .. "-static"
- if configs.vs_runtime and configs.vs_runtime:startswith("MD") then
- triplet = triplet .. "-md"
- end
- elseif opt.plat == "mingw" then
- triplet = triplet .. (configs.shared ~= true and "-static" or "-dynamic")
- end
local infofile = find_file(format("%s_*_%s.list", name, triplet), infodirs)
if not infofile then
return
diff --git a/xmake/modules/package/manager/vcpkg/install_package.lua b/xmake/modules/package/manager/vcpkg/install_package.lua
index 6a590a845..b0bf890fd 100644
--- a/xmake/modules/package/manager/vcpkg/install_package.lua
+++ b/xmake/modules/package/manager/vcpkg/install_package.lua
@@ -43,23 +43,12 @@ function _install_for_classic(vcpkg, name, opt)
-- get configs
local configs = opt.configs or {}
- -- get arch, plat and mode
+ -- init triplet
local arch = opt.arch
local plat = opt.plat
- local mode = opt.mode
plat = configurations.plat(plat)
arch = configurations.arch(arch)
-
- -- init triplet
- local triplet = arch .. "-" .. plat
- if opt.plat == "windows" and configs.shared ~= true then
- triplet = triplet .. "-static"
- if configs.vs_runtime and configs.vs_runtime:startswith("MD") then
- triplet = triplet .. "-md"
- end
- elseif opt.plat == "mingw" then
- triplet = triplet .. (configs.shared ~= true and "-static" or "-dynamic")
- end
+ local triplet = configurations.triplet(configs, plat, arch)
-- init argv
local argv = {"install", name .. ":" .. triplet}
@@ -82,15 +71,7 @@ function _install_for_manifest(vcpkg, name, opt)
local plat = opt.plat
plat = configurations.plat(plat)
arch = configurations.arch(arch)
- local triplet = arch .. "-" .. plat
- if opt.plat == "windows" and configs.shared ~= true then
- triplet = triplet .. "-static"
- if configs.vs_runtime and configs.vs_runtime:startswith("MD") then
- triplet = triplet .. "-md"
- end
- elseif opt.plat == "mingw" then
- triplet = triplet .. (configs.shared ~= true and "-static" or "-dynamic")
- end
+ local triplet = configurations.triplet(configs, plat, arch)
-- init argv
local argv = {"--feature-flags=\"versions\"", "install", "--x-wait-for-lock", "--triplet", triplet}