msvs_emulation.py: avoid string-int/float comparisons
This silently does a wrong thing on python2 (compares *type names*
instead of values, see "Objects of different types" note on
https://docs.python.org/2/library/stdtypes.html#comparisons), and throws
TypeError on python3.
Bug: 227327945
Change-Id: I70c831151f1eafde87b01a34b9d192785840ea3b
Reviewed-on: https://chromium-review.googlesource.com/c/external/gyp/+/3557379
Reviewed-by: Mark Mentovai <mark@chromium.org>
diff --git a/pylib/gyp/msvs_emulation.py b/pylib/gyp/msvs_emulation.py
index c01c135..f6bd2f7 100644
--- a/pylib/gyp/msvs_emulation.py
+++ b/pylib/gyp/msvs_emulation.py
@@ -28,6 +28,10 @@
windows_quoter_regex = re.compile(r'(\\*)"')
+def version_to_tuple(version_str):
+ return tuple(int(x) for x in version_str.split('.'))
+
+
def QuoteForRspFile(arg):
"""Quote a command line argument so that it appears as one argument when
processed via cmd.exe and parsed by CommandLineToArgvW (as is typical for
@@ -324,7 +328,7 @@
# first level is globally for the configuration (this is what we consider
# "the" config at the gyp level, which will be something like 'Debug' or
# 'Release'), VS2015 and later only use this level
- if self.vs_version.short_name >= 2015:
+ if int(self.vs_version.short_name) >= 2015:
return config
# and a second target-specific configuration, which is an
# override for the global one. |config| is remapped here to take into
@@ -488,7 +492,7 @@
prefix='/arch:')
cflags.extend(['/FI' + f for f in self._Setting(
('VCCLCompilerTool', 'ForcedIncludeFiles'), config, default=[])])
- if self.vs_version.project_version >= 12.0:
+ if version_to_tuple(self.vs_version.project_version) >= (12, 0):
# New flag introduced in VS2013 (project version 12.0) Forces writes to
# the program database (PDB) to be serialized through MSPDBSRV.EXE.
# https://msdn.microsoft.com/en-us/library/dn502518.aspx