|
1 | 1 | from conan import ConanFile |
2 | 2 | from conan.errors import ConanInvalidConfiguration |
3 | 3 | from conan.tools.apple import fix_apple_shared_install_name, is_apple_os |
4 | | -from conan.tools.files import copy, export_conandata_patches, get, patch, rm, rmdir |
| 4 | +from conan.tools.build import cross_building |
| 5 | +from conan.tools.files import copy, export_conandata_patches, get, patch, replace_in_file, rm, rmdir |
5 | 6 | from conan.tools.gnu import Autotools, AutotoolsToolchain |
6 | 7 | from conan.tools.layout import basic_layout |
7 | 8 | from conan.tools.microsoft import check_min_vs, is_msvc, unix_path |
@@ -78,8 +79,9 @@ def build_requirements(self): |
78 | 79 | if not self.conf.get("tools.microsoft.bash:path", check_type=str): |
79 | 80 | self.tool_requires("msys2/cci.latest") |
80 | 81 | if is_msvc(self): |
81 | | - self.tool_requires("yasm/1.3.0") # Needed for determining 32-bit word size |
82 | 82 | self.tool_requires("automake/1.16.5") # Needed for lib-wrapper |
| 83 | + if self.settings.arch in ["x86", "x86_64"]: |
| 84 | + self.tool_requires("yasm/1.3.0") # Needed for determining 32-bit word size |
83 | 85 |
|
84 | 86 | def source(self): |
85 | 87 | get(self, **self.conan_data["sources"][self.version], strip_root=True) |
@@ -110,11 +112,12 @@ def generate(self): |
110 | 112 | yasm_machine = { |
111 | 113 | "x86": "x86", |
112 | 114 | "x86_64": "amd64", |
113 | | - }[str(self.settings.arch)] |
| 115 | + }.get(str(self.settings.arch), None) |
114 | 116 | ar_wrapper = unix_path(self, self.conf.get("user.automake:lib-wrapper")) |
115 | 117 | dumpbin_nm = unix_path(self, os.path.join(self.source_folder, "dumpbin_nm.py")) |
116 | 118 | env.define("CC", "cl -nologo") |
117 | | - env.define("CCAS", f"{yasm_wrapper} -a x86 -m {yasm_machine} -p gas -r raw -f win32 -g null -X gnu") |
| 119 | + if yasm_machine: |
| 120 | + env.define("CCAS", f"{yasm_wrapper} -a x86 -m {yasm_machine} -p gas -r raw -f win32 -g null -X gnu") |
118 | 121 | env.define("CXX", "cl -nologo") |
119 | 122 | env.define("LD", "link -nologo") |
120 | 123 | env.define("AR", f'{ar_wrapper} "lib -nologo"') |
@@ -142,6 +145,11 @@ def build(self): |
142 | 145 | self._patch_sources() |
143 | 146 | autotools = Autotools(self) |
144 | 147 | autotools.configure() |
| 148 | + if self.settings.os == "Macos" and cross_building(self): |
| 149 | + # LD flags are not passed properly by the scripts - in particular '-arch x86_64' when crossbuilding |
| 150 | + # and invoking libtool to generate one of the libraries. Being conservative here, but there's a chance |
| 151 | + # this may need to be generalised |
| 152 | + replace_in_file(self, os.path.join(self.build_folder, "libtool"), 'archive_cmds="\$CC ', 'archive_cmds="\$CC $LDFLAGS ') |
145 | 153 | autotools.make() |
146 | 154 | # INFO: According to the gmp readme file, make check should not be omitted, but it causes timeouts on the CI server. |
147 | 155 | if self.options.run_checks: |
|
0 commit comments