From 27a4f44de566641ead97e98e61b0772044a0467c Mon Sep 17 00:00:00 2001 From: evhub Date: Mon, 16 Jun 2014 12:07:11 -0700 Subject: [PATCH] Process switches with regex in VSProject generator: * Handles "DisableSpecificWarnings" switches --- Builds/VisualStudio2013/RippleD.vcxproj | 6 +++-- SConstruct | 7 +++--- src/beast/site_scons/site_tools/VSProject.py | 25 ++++++++++++++++---- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index eac472d486..a0292880c7 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -52,6 +52,7 @@ _WIN32_WINNT=0x6000;DEBUG;WIN32_CONSOLE;_CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;_DEBUG;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) ..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\protobuf\src;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;%(AdditionalIncludeDirectories) + 4018;4244;4267;4800 Async True True @@ -71,7 +72,7 @@ True True False - /FS /bigobj /wd"4018" /wd"4244" /wd"4267" %(AdditionalOptions) + /FS /bigobj %(AdditionalOptions) Shlwapi.lib;advapi32.lib;comdlg32.lib;gdi32.lib;kernel32.lib;libeay32MT.lib;odbc32.lib;odbccp32.lib;ole32.lib;oleaut32.lib;shell32.lib;ssleay32MT.lib;user32.lib;uuid.lib;winspool.lib;%(AdditionalDependencies) @@ -89,6 +90,7 @@ _WIN32_WINNT=0x6000;NDEBUG;WIN32_CONSOLE;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) ..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\protobuf\src;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;%(AdditionalIncludeDirectories) + 4018;4244;4267;4800 Async True Cdecl @@ -106,7 +108,7 @@ True True False - /FS /bigobj /wd"4018" /wd"4244" /wd"4267" %(AdditionalOptions) + /FS /bigobj %(AdditionalOptions) Shlwapi.lib;advapi32.lib;comdlg32.lib;gdi32.lib;kernel32.lib;libeay32MT.lib;odbc32.lib;odbccp32.lib;ole32.lib;oleaut32.lib;shell32.lib;ssleay32MT.lib;user32.lib;uuid.lib;winspool.lib;%(AdditionalDependencies) diff --git a/SConstruct b/SConstruct index cd08e621df..4e21d93daa 100644 --- a/SConstruct +++ b/SConstruct @@ -359,9 +359,10 @@ def config_env(toolchain, variant, env): #'/Fd${TARGET}.pdb', # Path: Program Database (.pdb) '/W3', # Warning level 3 '/WX-', # Disable warnings as errors - '/wd"4018"', # Disable warning C4018 - '/wd"4244"', # Disable warning C4244 - '/wd"4267"', # Disable warning 4267 + '/wd"4018"', + '/wd"4244"', + '/wd"4267"', + '/wd"4800"', # Disable C4800 (int to bool performance) ]) env.Append(CPPDEFINES={ '_WIN32_WINNT' : '0x6000', diff --git a/src/beast/site_scons/site_tools/VSProject.py b/src/beast/site_scons/site_tools/VSProject.py index 58d18d77c0..65cdcbb27f 100644 --- a/src/beast/site_scons/site_tools/VSProject.py +++ b/src/beast/site_scons/site_tools/VSProject.py @@ -112,7 +112,7 @@ def itemList(items, sep): class SwitchConverter(object): '''Converts command line switches to MSBuild XML, using tables''' - def __init__(self, table, booltable): + def __init__(self, table, booltable, retable=None): self.table = {} for key in table: self.table[key] = table[key] @@ -120,11 +120,26 @@ class SwitchConverter(object): value = booltable[key] self.table[key] = [value[0], 'True'] self.table[key + '-'] = [value[0], 'False'] + if retable != None: + self.retable = retable + else: + self.retable = [] def getXml(self, switches, prefix = ''): - if type(switches) != list: + if not isinstance(switches, list): switches = list(switches) xml = [] + for regex, tag in self.retable: + matches = [] + for switch in switches[:]: + match = regex.match(switch) + if None != match: + matches.append(match.group(1)) + switches.remove(switch) + if len(matches) > 0: + xml.append ( + '%s<%s>%s\r\n' % ( + prefix, tag, ';'.join(matches), tag)) unknown = [] for switch in switches: try: @@ -236,12 +251,14 @@ class ClSwitchConverter(SwitchConverter): '/errorReport:queue' : ['ErrorReporting', 'Queue'], '/errorReport:send' : ['ErrorReporting', 'Send'], } + retable = [ + (re.compile(r'/wd\"(\d+)\"'), 'DisableSpecificWarnings'), + ] # Ideas from Google's Generate Your Project ''' _Same(_compile, 'AdditionalIncludeDirectories', _folder_list) # /I _Same(_compile, 'PreprocessorDefinitions', _string_list) # /D - _Same(_compile, 'DisableSpecificWarnings', _string_list) # /wd _Same(_compile, 'ProgramDataBaseFileName', _file_name) # /Fd _Same(_compile, 'AdditionalOptions', _string_list) @@ -264,7 +281,7 @@ class ClSwitchConverter(SwitchConverter): _MSBuildOnly(_compile, 'TreatSpecificWarningsAsErrors', _string_list) # /we _MSBuildOnly(_compile, 'PreprocessOutputPath', _string) # /Fi ''' - SwitchConverter.__init__(self, table, booltable) + SwitchConverter.__init__(self, table, booltable, retable) class LinkSwitchConverter(SwitchConverter): def __init__(self):