summaryrefslogtreecommitdiff
path: root/xmake/modules/private/detect/find_platform.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-07-20 22:47:58 +0800
committerruki <[email protected]>2021-07-20 22:47:58 +0800
commit801cc4d75f3aee6f845f69e9be7c55d70614071c (patch)
tree2d99f35493aa1f63e5335fa6ca5dae31dbf7b2fb /xmake/modules/private/detect/find_platform.lua
parent4451461655f1f725aa1667a9287fb9a0367c291b (diff)
set allowed modes and archs
Diffstat (limited to 'xmake/modules/private/detect/find_platform.lua')
-rw-r--r--xmake/modules/private/detect/find_platform.lua53
1 files changed, 29 insertions, 24 deletions
diff --git a/xmake/modules/private/detect/find_platform.lua b/xmake/modules/private/detect/find_platform.lua
index 590ff9b11..317d11ce9 100644
--- a/xmake/modules/private/detect/find_platform.lua
+++ b/xmake/modules/private/detect/find_platform.lua
@@ -20,6 +20,7 @@
-- imports
import("core.project.config")
+import("core.project.project")
import("detect.sdks.find_cross_toolchain")
-- find platform
@@ -81,28 +82,30 @@ end
function _find_arch(plat, arch)
arch = arch or config.get("arch")
if not arch then
- if plat == "android" then
- arch = "armeabi-v7a"
- elseif plat == "iphoneos" or plat == "appletvos" then
- arch = "arm64"
- elseif plat == "watchos" then
- arch = "armv7k"
- elseif plat == "wasm" then
- arch = "wasm32"
- elseif plat == "mingw" then
- local mingw_chost = nil
- if is_subhost("msys") then
- mingw_chost = os.getenv("MINGW_CHOST")
- end
- if mingw_chost == "i686-w64-mingw32" then
- arch = "i386"
+ if not arch then
+ if plat == "android" then
+ arch = "armeabi-v7a"
+ elseif plat == "iphoneos" or plat == "appletvos" then
+ arch = "arm64"
+ elseif plat == "watchos" then
+ arch = "armv7k"
+ elseif plat == "wasm" then
+ arch = "wasm32"
+ elseif plat == "mingw" then
+ local mingw_chost = nil
+ if is_subhost("msys") then
+ mingw_chost = os.getenv("MINGW_CHOST")
+ end
+ if mingw_chost == "i686-w64-mingw32" then
+ arch = "i386"
+ else
+ arch = "x86_64"
+ end
+ elseif plat == "cross" then
+ arch = _find_arch_from_cross()
else
- arch = "x86_64"
+ arch = os.subarch()
end
- elseif plat == "cross" then
- arch = _find_arch_from_cross()
- else
- arch = os.subarch()
end
end
return arch
@@ -126,17 +129,19 @@ end
--
function main(opt)
- -- find plat and arch
+ -- find platform
opt = opt or {}
local plat = _find_plat(opt.plat)
- local arch = _find_arch(plat, opt.arch)
-
- -- save the local configuration if be global
if opt.global then
if not opt.plat and not config.get("plat") then
config.set("plat", plat)
cprint("checking for platform ... ${color.success}%s", plat)
end
+ end
+
+ -- find architecture
+ local arch = _find_arch(plat, opt.arch)
+ if opt.global then
if not opt.arch and not config.get("arch") then
config.set("arch", arch)
cprint("checking for architecture ... ${color.success}%s", arch)