Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the use of regexs to parse vcxproj flags #403

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/beast/site_scons/site_tools/VSProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,34 @@ def gen():
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]
for key in booltable:
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</%s>\r\n' % (
prefix, tag, ';'.join(matches), tag))
unknown = []
for switch in switches:
try:
Expand Down Expand Up @@ -236,12 +251,14 @@ def __init__(self):
'/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)
Expand All @@ -264,7 +281,7 @@ def __init__(self):
_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):
Expand Down