1 2def cross_building(conanfile=None, skip_x64_x86=False): 3 4 build_os, build_arch, host_os, host_arch = get_cross_building_settings(conanfile) 5 6 if skip_x64_x86 and host_os is not None and (build_os == host_os) and \ 7 host_arch is not None and ((build_arch == "x86_64") and (host_arch == "x86") or 8 (build_arch == "sparcv9") and (host_arch == "sparc") or 9 (build_arch == "ppc64") and (host_arch == "ppc32")): 10 return False 11 12 if host_os is not None and (build_os != host_os): 13 return True 14 if host_arch is not None and (build_arch != host_arch): 15 return True 16 17 return False 18 19 20def get_cross_building_settings(conanfile): 21 os_host = conanfile.settings.get_safe("os") 22 arch_host = conanfile.settings.get_safe("arch") 23 24 if hasattr(conanfile, 'settings_build'): 25 return (conanfile.settings_build.get_safe('os'), conanfile.settings_build.get_safe('arch'), 26 os_host, arch_host) 27 else: 28 return os_host, arch_host, os_host, arch_host 29