From a54bcd6f17133be87732cbaf5f5dfd092757c54a Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 17 Sep 2022 00:32:10 +0800 Subject: add is cross compilation --- xmake/modules/private/action/trybuild/autotools.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/xmake/modules/private/action/trybuild/autotools.lua b/xmake/modules/private/action/trybuild/autotools.lua index bacd24a04..11f455c62 100644 --- a/xmake/modules/private/action/trybuild/autotools.lua +++ b/xmake/modules/private/action/trybuild/autotools.lua @@ -66,7 +66,7 @@ end -- get the build environments function _get_buildenvs() local envs = {} - if is_plat(os.subhost()) then + if not _is_cross_compilation() then local cflags = table.join(table.wrap(_get_buildenv("cxflags")), _get_buildenv("cflags")) local cxxflags = table.join(table.wrap(_get_buildenv("cxflags")), _get_buildenv("cxxflags")) local asflags = table.copy(table.wrap(_get_buildenv("asflags"))) @@ -131,6 +131,17 @@ function _get_buildenvs() return envs end +-- is cross compilation? +function _is_cross_compilation() + if not is_plat(os.subhost()) then + return true + end + if is_plat("macosx") and not is_arch(os.subarch()) then + return true + end + return false +end + -- get configs function _get_configs(artifacts_dir) @@ -147,8 +158,8 @@ function _get_configs(artifacts_dir) end -- add host for cross-complation - if not is_plat(os.subhost()) then - if is_plat("iphoneos") then + if _is_cross_compilation() then + if is_plat("iphoneos", "macosx") then local triples = { arm64 = "aarch64-apple-darwin", -- cgit v1.3.1