From a02e5791bfe8d2bcfc1bd91c731c9194beaaa136 Mon Sep 17 00:00:00 2001 From: xq114 <1140735506@qq.com> Date: Fri, 17 Feb 2023 00:13:55 +0800 Subject: improve windows cross-compilation for meson --- xmake/modules/package/tools/meson.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index 218bbcec5..05e34883d 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -54,7 +54,7 @@ function _is_cross_compilation(package) if package:is_plat("macosx") and not package:is_arch(os.subarch()) then return true end - if package:is_plat("windows") and package:is_arch("arm64") then + if package:is_plat("windows") and not package:is_arch(os.arch()) then return true end return false @@ -200,6 +200,25 @@ function _get_cross_file(package, opt) file:print("cpu_family = '%s'", cpu_family) file:print("cpu = '%s'", cpu) file:print("endian = 'little'") + elseif package:is_plat("windows") then + local cpu + local cpu_family + if package:is_arch("arm64") then + cpu = "aarch64" + cpu_family = "aarch64" + elseif package:is_arch("x86") then + cpu = "x86" + cpu_family = "x86" + elseif package:is_arch("x64") then + cpu = "x86_64" + cpu_family = "x86_64" + else + raise("unsupported arch(%s)", package:arch()) + end + file:print("system = 'windows'") + file:print("cpu_family = '%s'", cpu_family) + file:print("cpu = '%s'", cpu) + file:print("endian = 'little'") elseif package:is_plat("wasm") then file:print("system = 'emscripten'") file:print("cpu_family = 'wasm32'") -- cgit v1.3.1 From 81dcdb846accbae3dc60803fe6af8a7375bdaafa Mon Sep 17 00:00:00 2001 From: xq114 <1140735506@qq.com> Date: Fri, 17 Feb 2023 09:38:45 +0800 Subject: use package:is_cross --- xmake/modules/package/tools/meson.lua | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index 05e34883d..cdfbc7fb1 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -46,20 +46,6 @@ function _map_linkflags(package, targetkind, sourcekinds, name, values) return linker.map_flags(targetkind, sourcekinds, name, values, {target = package}) end --- is cross compilation? -function _is_cross_compilation(package) - if not package:is_plat(os.subhost()) then - return true - end - if package:is_plat("macosx") and not package:is_arch(os.subarch()) then - return true - end - if package:is_plat("windows") and not package:is_arch(os.arch()) then - return true - end - return false -end - -- get pkg-config function _get_pkgconfig(package) if package:is_plat("windows") then @@ -271,7 +257,7 @@ function _get_configs(package, configs, opt) end -- add cross file - if _is_cross_compilation(package) then + if package:is_cross() then table.insert(configs, "--cross-file=" .. _get_cross_file(package, opt)) end -- cgit v1.3.1