Sort visual studio versions by version number #2352

This commit is contained in:
Thomas Nagy 2022-05-22 11:25:33 +02:00
parent 247916d640
commit 1af97c71f5
2 changed files with 12 additions and 9 deletions

View File

@ -9,7 +9,7 @@ def configure(ctx):
def test(ctx):
errors = []
msvc_versions = ['wsdk 6.1', 'winphone 8.0', 'msvc 9.0', 'msvc 16.6', 'msvc 16.0', 'msvc 15.9', 'msvc 15.0', 'msvc 14.0', 'msvc 12.0', 'msvc 11.0']
sorted_versions = ['wsdk 6.1', 'winphone 8.0', 'msvc 16.6', 'msvc 16.0', 'msvc 15.9', 'msvc 15.0', 'msvc 14.0', 'msvc 12.0', 'msvc 11.0', 'msvc 9.0']
sorted_versions = ['msvc 16.6', 'msvc 16.0', 'msvc 15.9', 'msvc 15.0', 'msvc 14.0', 'msvc 12.0', 'msvc 11.0', 'msvc 9.0', 'winphone 8.0', 'wsdk 6.1']
def tt(msg, result, expected):
color = 'RED'

View File

@ -109,15 +109,20 @@ def options(opt):
opt.add_option('--msvc_targets', type='string', help = 'msvc targets, eg: "x64,arm"', default='')
opt.add_option('--no-msvc-lazy', action='store_false', help = 'lazily check msvc target environments', default=True, dest='msvc_lazy')
class MSVCVersion:
class MSVCVersion(object):
def __init__(self, ver):
x = ver.split()
self.a = x[0]
self.b = float(x[1])
m = re.search('^(.*)\s+(\d+[.]\d+)', ver)
if m:
self.name = m.group(1)
self.number = float(m.group(2))
else:
self.name = ver
self.number = 0.
def __lt__(self, other):
if self.a == other.a: return self.b < other.b
return self.a < other.a
if self.number == other.number:
return self.name < other.name
return self.number < other.number
@conf
def setup_msvc(conf, versiondict):
@ -135,8 +140,6 @@ def setup_msvc(conf, versiondict):
platforms=Utils.to_list(conf.env.MSVC_TARGETS) or [i for i,j in all_msvc_platforms+all_icl_platforms+all_wince_platforms]
desired_versions = getattr(Options.options, 'msvc_version', '').split(',')
if desired_versions == ['']:
def versionkey(x):
return float(x.split()[1])
desired_versions = conf.env.MSVC_VERSIONS or list(sorted(versiondict.keys(), key=MSVCVersion, reverse=True))
# Override lazy detection by evaluating after the fact.