From deae6419ab7da5071c6072c65bb9dac7ee942035 Mon Sep 17 00:00:00 2001 From: A2va <49582555+A2va@users.noreply.github.com> Date: Sat, 2 Dec 2023 19:05:01 +0100 Subject: Set binaries only if the user configured a toolchain --- xmake/modules/package/tools/meson.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index 498ef45e0..635ca1a8d 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -188,6 +188,15 @@ function _insert_cross_configs(package, file, opt) end end +-- is the toolchain compatible with the host? +function _is_toolchain_compatible_with_host(package) + for _, name in ipairs(package:config("toolchains")) do + if toolchain_utils.is_compatible_with_host(name) then + return true + end + end +end + -- get cross file function _get_configs_file(package, opt) opt = opt or {} @@ -270,7 +279,7 @@ function _get_configs_file(package, opt) file:print("cpp_link_args=['%s']", table.concat(linkflags, "', '")) end - if package:is_cross() then + if package:is_cross() or opt.cross then file:print("") _insert_cross_configs(package, file, opt) file:print("") @@ -315,8 +324,13 @@ function _get_configs(package, configs, opt) -- add cross file if package:is_cross() then table.insert(configs, "--cross-file=" .. _get_configs_file(package, opt)) - else - table.insert(configs, "--native-file=" .. _get_configs_file(package, opt)) + else if package:config("toolchains") then + if _is_toolchain_compatible_with_host(package) then + table.insert(configs, "--native-file=" .. _get_configs_file(package, opt)) + else + opt.cross = true + table.insert(configs, "--cross-file=" .. _get_configs_file(package, opt)) + end end -- add build directory -- cgit v1.3.1