@@ -165,55 +165,45 @@ def get_vs_versions():
165
165
166
166
def get_newest_msbuild (min_ver = None ):
167
167
versions = get_vs_versions ()
168
-
169
- min_ver_float = 0.0
170
- if isinstance (min_ver , str ):
171
- # value of min_ver is string. such as : "12.0", "14.0"
172
- min_ver_float = float (min_ver )
173
- elif isinstance (min_ver , int ) and min_ver in VS_VERSION_MAP .keys ():
168
+ cmp = cocos .version_compare
169
+ if isinstance (min_ver , int ) and min_ver in VS_VERSION_MAP .keys ():
174
170
# value of min_ver is int. such as : 2013, 2015
175
- min_ver_float = float ( VS_VERSION_MAP [min_ver ])
171
+ min_ver = VS_VERSION_MAP [min_ver ]
176
172
177
173
find_ver = None
178
174
find_path = None
179
- for v in versions :
180
- cur_v = float (v )
181
- if cur_v < min_ver_float :
175
+ for cur_ver in versions :
176
+ if cmp (cur_ver , "<" , min_ver ):
182
177
continue
183
178
184
179
v_path = get_msbuild_path (v )
185
180
if v_path is not None :
186
- if (find_ver is None ) or ( cur_v > find_ver ):
187
- find_ver = cur_v
181
+ if (find_ver is None ) or cmp ( cur_ver , ">" , find_ver ):
182
+ find_ver = cur_ver
188
183
find_path = v_path
189
184
190
185
return find_path
191
186
192
187
def get_newest_devenv (min_ver = None ):
193
188
versions = get_vs_versions ()
194
-
195
- min_ver_float = 0.0
196
- if isinstance (min_ver , str ):
197
- # value of min_ver is string. such as : "12.0", "14.0"
198
- min_ver_float = float (min_ver )
199
- elif isinstance (min_ver , int ) and min_ver in VS_VERSION_MAP .keys ():
189
+ cmp = cocos .version_compare
190
+ if isinstance (min_ver , int ) and min_ver in VS_VERSION_MAP .keys ():
200
191
# value of min_ver is int. such as : 2013, 2015
201
- min_ver_float = float ( VS_VERSION_MAP [min_ver ])
192
+ min_ver = VS_VERSION_MAP [min_ver ]
202
193
203
194
find_ver = None
204
195
find_path = None
205
- for v in versions :
206
- cur_v = float (v )
207
- if cur_v < min_ver_float :
196
+ for cur_ver in versions :
197
+ if cmp (cur_ver , "<" , min_ver ):
208
198
continue
209
199
210
- v_path = get_devenv_path (v )
200
+ v_path = get_devenv_path (cur_ver )
211
201
if v_path is not None :
212
- if (find_ver is None ) or ( cur_v > find_ver ):
213
- find_ver = cur_v
202
+ if (find_ver is None ) or cmp ( cur_ver , ">" , find_ver ):
203
+ find_ver = cur_ver
214
204
find_path = v_path
215
205
216
- if min_ver_float > 0 and find_ver > min_ver_float :
206
+ if cmp ( min_ver , ">" , 0 ) and cmp ( find_ver , ">" , min_ver ) :
217
207
need_upgrade = True
218
208
else :
219
209
need_upgrade = False
0 commit comments