8
8
from conan .tools .layout import basic_layout
9
9
from conan .tools .microsoft import MSBuild , is_msvc , msvs_toolset , MSBuildToolchain
10
10
11
- required_conan_version = ">=1.47 .0"
11
+ required_conan_version = ">=1.53 .0"
12
12
13
13
14
14
class Cc65Conan (ConanFile ):
@@ -33,7 +33,7 @@ def layout(self):
33
33
basic_layout (self , src_folder = "src" )
34
34
35
35
def package_id (self ):
36
- if str (self .info . settings . compiler ) in [ "msvc" , "Visual Studio" ] :
36
+ if is_msvc (self .info ) :
37
37
if self .info .settings .arch == "x86_64" :
38
38
self .info .settings .arch = "x86"
39
39
del self .info .settings .compiler
@@ -45,7 +45,7 @@ def validate(self):
45
45
"cc65 needs to be able to run the built executables during the build process"
46
46
)
47
47
if is_msvc (self ):
48
- if self .settings .arch not in ( "x86" , "x86_64" ) :
48
+ if self .settings .arch not in [ "x86" , "x86_64" ] :
49
49
raise ConanInvalidConfiguration (f"{ self .settings .arch } is not supported on MSVC" )
50
50
if self .settings .arch == "x86_64" :
51
51
self .output .info ("This recipe will build x86 instead of x86_64 (the binaries are compatible)" )
@@ -71,32 +71,12 @@ def generate(self):
71
71
tc .make_args .append ("EXE_SUFFIX=.exe" )
72
72
tc .generate ()
73
73
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
-
87
74
def _patch_sources (self ):
88
75
apply_conandata_patches (self )
89
76
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>" , "" )
100
80
if self .settings .os == "Windows" :
101
81
# Add ".exe" suffix to calls from cl65 to other utilities
102
82
for fn , var in [
@@ -108,41 +88,41 @@ def _patch_sources(self):
108
88
]:
109
89
v = f"{ var } ," .ljust (5 )
110
90
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");' )
113
93
114
94
def build (self ):
115
95
self ._patch_sources ()
116
96
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 ()
118
104
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 ()
137
108
138
109
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" ))
142
111
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 ))
144
120
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" ))
146
126
147
127
def package_info (self ):
148
128
self .cpp_info .frameworkdirs = []
0 commit comments