From a01adb5915ba8d370267edf02a2a7559ab628c19 Mon Sep 17 00:00:00 2001 From: fallen ink Date: Wed, 28 Apr 2021 10:33:56 +0800 Subject: [DEV] add more plats,archs mapping for vcpkg --- xmake/modules/package/manager/vcpkg/find_package.lua | 15 +++++++++++++++ xmake/modules/package/manager/vcpkg/install_package.lua | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/xmake/modules/package/manager/vcpkg/find_package.lua b/xmake/modules/package/manager/vcpkg/find_package.lua index f9579fd66..b3466ad94 100644 --- a/xmake/modules/package/manager/vcpkg/find_package.lua +++ b/xmake/modules/package/manager/vcpkg/find_package.lua @@ -79,11 +79,26 @@ function main(name, opt) local arch = opt.arch local plat = opt.plat local mode = opt.mode + + -- mapping plat if plat == "macosx" then plat = "osx" end + + -- mapping arch if arch == "x86_64" then arch = "x64" + elseif arch == "i386" then + arch = "x86" + -- android: armeabi armeabi-v7a arm64-v8a x86 x86_64 mips mip64 + -- vcpkg triplets not support plat_android, but offers a doc: https://github.com/microsoft/vcpkg/blob/master/docs/users/android.md + elseif arch == "arm64-v8a" then + arch = "arm64" + elseif arch == "armeabi-v7a" then + arch = "arm" + -- ios: arm64 armv7 armv7s i386 + elseif arch == "armv7" or arch == "armv7s" then + arch = "arm" end -- get the vcpkg installed directory diff --git a/xmake/modules/package/manager/vcpkg/install_package.lua b/xmake/modules/package/manager/vcpkg/install_package.lua index d44c6e849..115493b35 100644 --- a/xmake/modules/package/manager/vcpkg/install_package.lua +++ b/xmake/modules/package/manager/vcpkg/install_package.lua @@ -41,11 +41,26 @@ function main(name, opt) local arch = opt.arch local plat = opt.plat local mode = opt.mode + + -- mapping plat if plat == "macosx" then plat = "osx" end + + -- mapping arch if arch == "x86_64" then arch = "x64" + elseif arch == "i386" then + arch = "x86" + -- android: armeabi armeabi-v7a arm64-v8a x86 x86_64 mips mip64 + -- vcpkg triplets not support plat_android, but offers a doc: https://github.com/microsoft/vcpkg/blob/master/docs/users/android.md + elseif arch == "arm64-v8a" then + arch = "arm64" + elseif arch == "armeabi-v7a" then + arch = "arm" + -- ios: arm64 armv7 armv7s i386 + elseif arch == "armv7" or arch == "armv7s" then + arch = "arm" end -- init triplet -- cgit v1.3.1 From a2577fc01bf133f866b6c92b504b8991bb679034 Mon Sep 17 00:00:00 2001 From: fallenink Date: Thu, 29 Apr 2021 15:25:03 +0800 Subject: [DEV] refactor `if else` to `table` --- .../modules/package/manager/vcpkg/find_package.lua | 28 ++++++++++++---------- .../package/manager/vcpkg/install_package.lua | 28 ++++++++++++---------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/xmake/modules/package/manager/vcpkg/find_package.lua b/xmake/modules/package/manager/vcpkg/find_package.lua index b3466ad94..34df916af 100644 --- a/xmake/modules/package/manager/vcpkg/find_package.lua +++ b/xmake/modules/package/manager/vcpkg/find_package.lua @@ -85,21 +85,23 @@ function main(name, opt) plat = "osx" end - -- mapping arch - if arch == "x86_64" then - arch = "x64" - elseif arch == "i386" then - arch = "x86" + -- archs mapping for vcpkg + local archs = { + x86_64 = "x64", + i386 = "x86", + -- android: armeabi armeabi-v7a arm64-v8a x86 x86_64 mips mip64 - -- vcpkg triplets not support plat_android, but offers a doc: https://github.com/microsoft/vcpkg/blob/master/docs/users/android.md - elseif arch == "arm64-v8a" then - arch = "arm64" - elseif arch == "armeabi-v7a" then - arch = "arm" + -- Offers a doc: https://github.com/microsoft/vcpkg/blob/master/docs/users/android.md + ["armeabi-v7a"] = "arm", + ["arm64-v8a"] = "arm64", + -- ios: arm64 armv7 armv7s i386 - elseif arch == "armv7" or arch == "armv7s" then - arch = "arm" - end + armv7 = "arm", + armv7s = "arm", + arm64 = "arm64", + } + -- mapping arch + arch = archs[arch] or arch -- get the vcpkg installed directory local installdir = path.join(vcpkgdir, "installed") diff --git a/xmake/modules/package/manager/vcpkg/install_package.lua b/xmake/modules/package/manager/vcpkg/install_package.lua index 115493b35..eaf28710e 100644 --- a/xmake/modules/package/manager/vcpkg/install_package.lua +++ b/xmake/modules/package/manager/vcpkg/install_package.lua @@ -47,21 +47,23 @@ function main(name, opt) plat = "osx" end - -- mapping arch - if arch == "x86_64" then - arch = "x64" - elseif arch == "i386" then - arch = "x86" + -- archs mapping for vcpkg + local archs = { + x86_64 = "x64", + i386 = "x86", + -- android: armeabi armeabi-v7a arm64-v8a x86 x86_64 mips mip64 - -- vcpkg triplets not support plat_android, but offers a doc: https://github.com/microsoft/vcpkg/blob/master/docs/users/android.md - elseif arch == "arm64-v8a" then - arch = "arm64" - elseif arch == "armeabi-v7a" then - arch = "arm" + -- Offers a doc: https://github.com/microsoft/vcpkg/blob/master/docs/users/android.md + ["armeabi-v7a"] = "arm", + ["arm64-v8a"] = "arm64", + -- ios: arm64 armv7 armv7s i386 - elseif arch == "armv7" or arch == "armv7s" then - arch = "arm" - end + armv7 = "arm", + armv7s = "arm", + arm64 = "arm64", + } + -- mapping arch + arch = archs[arch] or arch -- init triplet local triplet = arch .. "-" .. plat -- cgit v1.3.1