Skip to content

Commit f74366a

Browse files
author
Martin Valgur
committed
cc65: cross-compiling is limited to native architectures only
1 parent 9e89cd3 commit f74366a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

recipes/cc65/all/conanfile.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from conan import ConanFile
44
from conan.errors import ConanInvalidConfiguration
5+
from conan.tools.build import can_run
56
from conan.tools.files import apply_conandata_patches, chdir, copy, export_conandata_patches, get, replace_in_file, rmdir
67
from conan.tools.gnu import Autotools, AutotoolsToolchain
78
from conan.tools.layout import basic_layout
@@ -27,11 +28,6 @@ def export_sources(self):
2728
def configure(self):
2829
self.settings.rm_safe("compiler.libcxx")
2930
self.settings.rm_safe("compiler.cppstd")
30-
if is_msvc(self):
31-
if self.settings.arch not in ("x86", "x86_64"):
32-
raise ConanInvalidConfiguration("Invalid arch")
33-
if self.settings.arch == "x86_64":
34-
self.output.info("This recipe will build x86 instead of x86_64 (the binaries are compatible)")
3531

3632
def layout(self):
3733
basic_layout(self, src_folder="src")
@@ -42,9 +38,21 @@ def package_id(self):
4238
self.info.settings.arch = "x86"
4339
del self.info.settings.compiler
4440

41+
def validate(self):
42+
if not can_run(self):
43+
raise ConanInvalidConfiguration(
44+
f"Compiling for {self.settings.arch} is not supported. "
45+
"cc65 needs to be able to run the built executables during the build process"
46+
)
47+
if is_msvc(self):
48+
if self.settings.arch not in ("x86", "x86_64"):
49+
raise ConanInvalidConfiguration(f"{self.settings.arch} is not supported on MSVC")
50+
if self.settings.arch == "x86_64":
51+
self.output.info("This recipe will build x86 instead of x86_64 (the binaries are compatible)")
52+
4553
def build_requirements(self):
4654
if is_msvc(self):
47-
self.tool_requires("make/4.3")
55+
self.tool_requires("make/4.4")
4856

4957
def source(self):
5058
get(self, **self.conan_data["sources"][self.version], strip_root=True)

0 commit comments

Comments
 (0)