OLD | NEW |
---|---|
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """ | 5 """ |
6 This module helps emulate Visual Studio 2008 behavior on top of other | 6 This module helps emulate Visual Studio 2008 behavior on top of other |
7 build systems, primarily ninja. | 7 build systems, primarily ninja. |
8 """ | 8 """ |
9 | 9 |
10 import os | 10 import os |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 """Gets the explicitly overridden output name for a target or returns None | 237 """Gets the explicitly overridden output name for a target or returns None |
238 if it's not overridden.""" | 238 if it's not overridden.""" |
239 type = self.spec['type'] | 239 type = self.spec['type'] |
240 root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool' | 240 root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool' |
241 # TODO(scottmg): Handle OutputDirectory without OutputFile. | 241 # TODO(scottmg): Handle OutputDirectory without OutputFile. |
242 output_file = self._Setting((root, 'OutputFile'), config) | 242 output_file = self._Setting((root, 'OutputFile'), config) |
243 if output_file: | 243 if output_file: |
244 output_file = expand_special(self.ConvertVSMacros(output_file)) | 244 output_file = expand_special(self.ConvertVSMacros(output_file)) |
245 return output_file | 245 return output_file |
246 | 246 |
247 def GetCflags(self, config): | 247 def GetCflags(self, config, gyp_to_build_path): |
248 """Returns the flags that need to be added to .c and .cc compilations.""" | 248 """Returns the flags that need to be added to .c and .cc compilations.""" |
249 cflags = [] | 249 cflags = [] |
250 cflags.extend(['/wd' + w for w in self.msvs_disabled_warnings[config]]) | 250 cflags.extend(['/wd' + w for w in self.msvs_disabled_warnings[config]]) |
251 cl = self._GetWrapper(self, self.msvs_settings[config], | 251 cl = self._GetWrapper(self, self.msvs_settings[config], |
252 'VCCLCompilerTool', append=cflags) | 252 'VCCLCompilerTool', append=cflags) |
253 cl('Optimization', | 253 cl('Optimization', |
254 map={'0': 'd', '1': '1', '2': '2', '3': 'x'}, prefix='/O') | 254 map={'0': 'd', '1': '1', '2': '2', '3': 'x'}, prefix='/O') |
255 cl('InlineFunctionExpansion', prefix='/Ob') | 255 cl('InlineFunctionExpansion', prefix='/Ob') |
256 cl('OmitFramePointers', map={'false': '-', 'true': ''}, prefix='/Oy') | 256 cl('OmitFramePointers', map={'false': '-', 'true': ''}, prefix='/Oy') |
257 cl('FavorSizeOrSpeed', map={'1': 't', '2': 's'}, prefix='/O') | 257 cl('FavorSizeOrSpeed', map={'1': 't', '2': 's'}, prefix='/O') |
258 cl('WholeProgramOptimization', map={'true': '/GL'}) | 258 cl('WholeProgramOptimization', map={'true': '/GL'}) |
259 cl('WarningLevel', prefix='/W') | 259 cl('WarningLevel', prefix='/W') |
260 cl('WarnAsError', map={'true': '/WX'}) | 260 cl('WarnAsError', map={'true': '/WX'}) |
261 cl('DebugInformationFormat', | 261 cl('DebugInformationFormat', |
262 map={'1': '7', '3': 'i', '4': 'I'}, prefix='/Z') | 262 map={'1': '7', '3': 'i', '4': 'I'}, prefix='/Z') |
263 cl('RuntimeTypeInfo', map={'true': '/GR', 'false': '/GR-'}) | 263 cl('RuntimeTypeInfo', map={'true': '/GR', 'false': '/GR-'}) |
264 cl('EnableFunctionLevelLinking', map={'true': '/Gy', 'false': '/Gy-'}) | 264 cl('EnableFunctionLevelLinking', map={'true': '/Gy', 'false': '/Gy-'}) |
265 cl('MinimalRebuild', map={'true': '/Gm'}) | 265 cl('MinimalRebuild', map={'true': '/Gm'}) |
266 cl('BufferSecurityCheck', map={'true': '/GS', 'false': '/GS-'}) | 266 cl('BufferSecurityCheck', map={'true': '/GS', 'false': '/GS-'}) |
267 cl('BasicRuntimeChecks', map={'1': 's', '2': 'u', '3': '1'}, prefix='/RTC') | 267 cl('BasicRuntimeChecks', map={'1': 's', '2': 'u', '3': '1'}, prefix='/RTC') |
268 cl('RuntimeLibrary', | 268 cl('RuntimeLibrary', |
269 map={'0': 'T', '1': 'Td', '2': 'D', '3': 'Dd'}, prefix='/M') | 269 map={'0': 'T', '1': 'Td', '2': 'D', '3': 'Dd'}, prefix='/M') |
270 cl('ExceptionHandling', map={'1': 'sc','2': 'a'}, prefix='/EH') | 270 cl('ExceptionHandling', map={'1': 'sc','2': 'a'}, prefix='/EH') |
271 cl('AdditionalIncludeDirectories', prefix='/I', map=gyp_to_build_path) | |
Nico
2012/05/23 20:38:33
I would've expected that in AdjustIncludeDirs, but
| |
271 cl('AdditionalOptions', prefix='') | 272 cl('AdditionalOptions', prefix='') |
272 # ninja handles parallelism by itself, don't have the compiler do it too. | 273 # ninja handles parallelism by itself, don't have the compiler do it too. |
273 cflags = filter(lambda x: not x.startswith('/MP'), cflags) | 274 cflags = filter(lambda x: not x.startswith('/MP'), cflags) |
274 return cflags | 275 return cflags |
275 | 276 |
276 def GetCflagsC(self, config): | 277 def GetCflagsC(self, config): |
277 """Returns the flags that need to be added to .c compilations.""" | 278 """Returns the flags that need to be added to .c compilations.""" |
278 return [] | 279 return [] |
279 | 280 |
280 def GetCflagsCC(self, config): | 281 def GetCflagsCC(self, config): |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 return vs.SetupScript() | 469 return vs.SetupScript() |
469 | 470 |
470 def ExpandMacros(string, expansions): | 471 def ExpandMacros(string, expansions): |
471 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv | 472 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv |
472 for the canonical way to retrieve a suitable dict.""" | 473 for the canonical way to retrieve a suitable dict.""" |
473 if '$' in string: | 474 if '$' in string: |
474 for old, new in expansions.iteritems(): | 475 for old, new in expansions.iteritems(): |
475 assert '$(' not in new, new | 476 assert '$(' not in new, new |
476 string = string.replace(old, new) | 477 string = string.replace(old, new) |
477 return string | 478 return string |
OLD | NEW |