Skip to content

Commit 8a93187

Browse files
author
Martin Valgur
committed
cc65: fix MSVC build
1 parent 0411590 commit 8a93187

File tree

1 file changed

+32
-52
lines changed

1 file changed

+32
-52
lines changed

recipes/cc65/all/conanfile.py

Lines changed: 32 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from conan.tools.layout import basic_layout
99
from conan.tools.microsoft import MSBuild, is_msvc, msvs_toolset, MSBuildToolchain
1010

11-
required_conan_version = ">=1.47.0"
11+
required_conan_version = ">=1.53.0"
1212

1313

1414
class Cc65Conan(ConanFile):
@@ -33,7 +33,7 @@ def layout(self):
3333
basic_layout(self, src_folder="src")
3434

3535
def package_id(self):
36-
if str(self.info.settings.compiler) in ["msvc", "Visual Studio"]:
36+
if is_msvc(self.info):
3737
if self.info.settings.arch == "x86_64":
3838
self.info.settings.arch = "x86"
3939
del self.info.settings.compiler
@@ -45,7 +45,7 @@ def validate(self):
4545
"cc65 needs to be able to run the built executables during the build process"
4646
)
4747
if is_msvc(self):
48-
if self.settings.arch not in ("x86", "x86_64"):
48+
if self.settings.arch not in ["x86", "x86_64"]:
4949
raise ConanInvalidConfiguration(f"{self.settings.arch} is not supported on MSVC")
5050
if self.settings.arch == "x86_64":
5151
self.output.info("This recipe will build x86 instead of x86_64 (the binaries are compatible)")
@@ -71,32 +71,12 @@ def generate(self):
7171
tc.make_args.append("EXE_SUFFIX=.exe")
7272
tc.generate()
7373

74-
def _build_msvc(self):
75-
msbuild = MSBuild(self)
76-
msbuild.build(sln=os.path.join(self.source_folder, "src", "cc65.sln"))
77-
with chdir(self, os.path.join(self.source_folder, "libsrc")):
78-
autotools = Autotools(self)
79-
autotools.configure()
80-
autotools.make()
81-
82-
def _build_autotools(self):
83-
with chdir(self, self.source_folder):
84-
autotools = Autotools(self)
85-
autotools.make()
86-
8774
def _patch_sources(self):
8875
apply_conandata_patches(self)
8976
if is_msvc(self):
90-
with chdir(self, os.path.join(self.source_folder, "src")):
91-
for fn in os.listdir("."):
92-
if not fn.endswith(".vcxproj"):
93-
continue
94-
replace_in_file(self, fn, "v141", msvs_toolset(self))
95-
replace_in_file(self, fn,
96-
("<WindowsTargetPlatformVersion>"
97-
"10.0.16299.0"
98-
"</WindowsTargetPlatformVersion>"),
99-
"")
77+
for vcxproj in self.source_path.joinpath("src").rglob("*.vcxproj"):
78+
replace_in_file(self, vcxproj, "v141", msvs_toolset(self))
79+
replace_in_file(self, vcxproj, "<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>", "")
10080
if self.settings.os == "Windows":
10181
# Add ".exe" suffix to calls from cl65 to other utilities
10282
for fn, var in [
@@ -108,41 +88,41 @@ def _patch_sources(self):
10888
]:
10989
v = f"{var},".ljust(5)
11090
replace_in_file(self, os.path.join(self.source_folder, "src", "cl65", "main.c"),
111-
f'CmdInit (&{v} CmdPath, "{fn}");',
112-
f'CmdInit (&{v} CmdPath, "{fn}.exe");')
91+
f'CmdInit (&{v} CmdPath, "{fn}");',
92+
f'CmdInit (&{v} CmdPath, "{fn}.exe");')
11393

11494
def build(self):
11595
self._patch_sources()
11696
if is_msvc(self):
117-
self._build_msvc()
97+
msbuild = MSBuild(self)
98+
msbuild.platform = "Win32"
99+
msbuild.build_type = "Debug" if self.settings.build_type == "Debug" else "Release"
100+
msbuild.build(sln=os.path.join(self.source_folder, "src", "cc65.sln"))
101+
with chdir(self, os.path.join(self.source_folder, "libsrc")):
102+
autotools = Autotools(self)
103+
autotools.make()
118104
else:
119-
self._build_autotools()
120-
121-
def _package_msvc(self):
122-
copy(self, "*.exe",
123-
dst=os.path.join(self.package_folder, "bin"),
124-
src=os.path.join(self.source_folder, "bin"),
125-
keep_path=False)
126-
for dir in ("asminc", "cfg", "include", "lib", "target"):
127-
copy(self, "*",
128-
dst=os.path.join(self.package_folder, "bin", "share", "cc65", dir),
129-
src=os.path.join(self.source_folder, dir))
130-
131-
def _package_autotools(self):
132-
with chdir(self, os.path.join(self.source_folder)):
133-
autotools = Autotools(self)
134-
autotools.install()
135-
rmdir(self, os.path.join(self.package_path, "samples"))
136-
rmdir(self, os.path.join(self.package_folder, "share"))
105+
with chdir(self, self.source_folder):
106+
autotools = Autotools(self)
107+
autotools.make()
137108

138109
def package(self):
139-
copy(self, "LICENSE",
140-
dst=os.path.join(self.package_folder, "licenses"),
141-
src=self.source_folder)
110+
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
142111
if is_msvc(self):
143-
self._package_msvc()
112+
copy(self, "*.exe",
113+
dst=os.path.join(self.package_folder, "bin"),
114+
src=os.path.join(self.source_folder, "bin"),
115+
keep_path=False)
116+
for dir in ("asminc", "cfg", "include", "lib", "target"):
117+
copy(self, "*",
118+
dst=os.path.join(self.package_folder, "bin", "share", "cc65", dir),
119+
src=os.path.join(self.source_folder, dir))
144120
else:
145-
self._package_autotools()
121+
with chdir(self, os.path.join(self.source_folder)):
122+
autotools = Autotools(self)
123+
autotools.install()
124+
rmdir(self, os.path.join(self.package_path, "samples"))
125+
rmdir(self, os.path.join(self.package_folder, "share"))
146126

147127
def package_info(self):
148128
self.cpp_info.frameworkdirs = []

0 commit comments

Comments
 (0)