SCons: Fix get_compiler_version() to return ints

Otherwise comparisons would fail for compiler versions above 10.
Also simplified code somewhat to avoid using subprocess too much
needlessly.

(cherry picked from commits c7dc5142b5
and df7ecfc4a7)
This commit is contained in:
Rémi Verschelde
2020-02-26 13:23:37 +01:00
parent c34b351b24
commit 75164169c4
3 changed files with 23 additions and 16 deletions

View File

@@ -350,12 +350,13 @@ if selected_platform in platform_list:
# Force to use Unicode encoding
env.Append(MSVC_FLAGS=['/utf8'])
else: # Rest of the world
version = methods.get_compiler_version(env) or [-1, -1]
shadow_local_warning = []
all_plus_warnings = ['-Wwrite-strings']
if methods.using_gcc(env):
version = methods.get_compiler_version(env)
if version != None and version[0] >= '7':
if version[0] >= 7:
shadow_local_warning = ['-Wshadow-local']
if (env["warnings"] == 'extra'):
@@ -369,8 +370,7 @@ if selected_platform in platform_list:
'-Wduplicated-branches', '-Wduplicated-cond',
'-Wstringop-overflow=4', '-Wlogical-op'])
env.Append(CXXFLAGS=['-Wnoexcept', '-Wplacement-new=1'])
version = methods.get_compiler_version(env)
if version != None and version[0] >= '9':
if version[0] >= 9:
env.Append(CCFLAGS=['-Wattribute-alias=2'])
elif (env["warnings"] == 'all'):
env.Append(CCFLAGS=['-Wall'] + shadow_local_warning)