Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: pylib/gyp/msvs_emulation.py

Issue 10228016: ninja windows: fix expansion of some VS macros (Closed) Base URL: https://gyp.googlecode.com/svn/trunk
Patch Set: refactor test to not include case normalization Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pylib/gyp/generator/ninja.py ('k') | test/ninja/normalize-paths-win/gyptest-normalize-paths.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 on other VS settings.""" 213 on other VS settings."""
214 defines = [] 214 defines = []
215 if self._ConfigAttrib(['CharacterSet'], config) == '1': 215 if self._ConfigAttrib(['CharacterSet'], config) == '1':
216 defines.extend(('_UNICODE', 'UNICODE')) 216 defines.extend(('_UNICODE', 'UNICODE'))
217 if self._ConfigAttrib(['CharacterSet'], config) == '2': 217 if self._ConfigAttrib(['CharacterSet'], config) == '2':
218 defines.append('_MBCS') 218 defines.append('_MBCS')
219 defines.extend(self._Setting( 219 defines.extend(self._Setting(
220 ('VCCLCompilerTool', 'PreprocessorDefinitions'), config, default=[])) 220 ('VCCLCompilerTool', 'PreprocessorDefinitions'), config, default=[]))
221 return defines 221 return defines
222 222
223 def GetOutputName(self, spec, config): 223 def GetOutputName(self, config, expand_special):
224 """Gets the explicitly overridden output name for a target or returns None 224 """Gets the explicitly overridden output name for a target or returns None
225 if it's not overridden.""" 225 if it's not overridden."""
226 type = spec['type'] 226 type = self.spec['type']
227 root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool' 227 root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool'
228 # TODO(scottmg): Handle OutputDirectory without OutputFile. 228 # TODO(scottmg): Handle OutputDirectory without OutputFile.
229 output_file = self._Setting((root, 'OutputFile'), config) 229 output_file = self._Setting((root, 'OutputFile'), config)
230 if output_file: 230 if output_file:
231 output_file = os.path.normpath(self.ConvertVSMacros(output_file)) 231 output_file = expand_special(self.ConvertVSMacros(output_file))
232 return output_file 232 return output_file
233 233
234 def GetCflags(self, config): 234 def GetCflags(self, config):
235 """Returns the flags that need to be added to .c and .cc compilations.""" 235 """Returns the flags that need to be added to .c and .cc compilations."""
236 cflags = [] 236 cflags = []
237 cflags.extend(['/wd' + w for w in self.msvs_disabled_warnings[config]]) 237 cflags.extend(['/wd' + w for w in self.msvs_disabled_warnings[config]])
238 cl = self._GetWrapper(self, self.msvs_settings[config], 238 cl = self._GetWrapper(self, self.msvs_settings[config],
239 'VCCLCompilerTool', append=cflags) 239 'VCCLCompilerTool', append=cflags)
240 cl('Optimization', map={'0': 'd', '2': 's'}, prefix='/O') 240 cl('Optimization', map={'0': 'd', '2': 's'}, prefix='/O')
241 cl('InlineFunctionExpansion', prefix='/Ob') 241 cl('InlineFunctionExpansion', prefix='/Ob')
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 """.def files get implicitly converted to a ModuleDefinitionFile for the 290 """.def files get implicitly converted to a ModuleDefinitionFile for the
291 linker in the VS generator. Emulate that behaviour here.""" 291 linker in the VS generator. Emulate that behaviour here."""
292 def_file = '' 292 def_file = ''
293 if spec['type'] in ('shared_library', 'loadable_module', 'executable'): 293 if spec['type'] in ('shared_library', 'loadable_module', 'executable'):
294 def_files = [s for s in spec.get('sources', []) if s.endswith('.def')] 294 def_files = [s for s in spec.get('sources', []) if s.endswith('.def')]
295 if len(def_files) == 1: 295 if len(def_files) == 1:
296 ldflags.append('/DEF:"%s"' % gyp_to_build_path(def_files[0])) 296 ldflags.append('/DEF:"%s"' % gyp_to_build_path(def_files[0]))
297 elif len(def_files) > 1: 297 elif len(def_files) > 1:
298 raise Exception("Multiple .def files") 298 raise Exception("Multiple .def files")
299 299
300 def GetLdflags(self, config, product_dir, gyp_to_build_path): 300 def GetLdflags(self, config, gyp_to_build_path, expand_special):
301 """Returns the flags that need to be added to link commands.""" 301 """Returns the flags that need to be added to link commands."""
302 ldflags = [] 302 ldflags = []
303 ld = self._GetWrapper(self, self.msvs_settings[config], 303 ld = self._GetWrapper(self, self.msvs_settings[config],
304 'VCLinkerTool', append=ldflags) 304 'VCLinkerTool', append=ldflags)
305 self._GetDefFileAsLdflags(self.spec, ldflags, gyp_to_build_path) 305 self._GetDefFileAsLdflags(self.spec, ldflags, gyp_to_build_path)
306 ld('GenerateDebugInformation', map={'true': '/DEBUG'}) 306 ld('GenerateDebugInformation', map={'true': '/DEBUG'})
307 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:') 307 ld('TargetMachine', map={'1': 'X86', '17': 'X64'}, prefix='/MACHINE:')
308 ldflags.extend(self._GetAdditionalLibraryDirectories( 308 ldflags.extend(self._GetAdditionalLibraryDirectories(
309 'VCLinkerTool', config, gyp_to_build_path)) 309 'VCLinkerTool', config, gyp_to_build_path))
310 ld('DelayLoadDLLs', prefix='/DELAYLOAD:') 310 ld('DelayLoadDLLs', prefix='/DELAYLOAD:')
311 out = self._Setting(('VCLinkerTool', 'OutputFile'), config, prefix='/OUT:') 311 out = self.GetOutputName(config, expand_special)
312 if out: 312 if out:
313 ldflags.append(self.ConvertVSMacros(out)) 313 ldflags.append('/OUT:' + out)
314 ld('AdditionalOptions', prefix='') 314 ld('AdditionalOptions', prefix='')
315 ld('SubSystem', map={'1': 'CONSOLE', '2': 'WINDOWS'}, prefix='/SUBSYSTEM:') 315 ld('SubSystem', map={'1': 'CONSOLE', '2': 'WINDOWS'}, prefix='/SUBSYSTEM:')
316 ld('LinkIncremental', map={'1': ':NO', '2': ''}, prefix='/INCREMENTAL') 316 ld('LinkIncremental', map={'1': ':NO', '2': ''}, prefix='/INCREMENTAL')
317 ld('FixedBaseAddress', map={'1': ':NO', '2': ''}, prefix='/FIXED') 317 ld('FixedBaseAddress', map={'1': ':NO', '2': ''}, prefix='/FIXED')
318 ld('RandomizedBaseAddress', 318 ld('RandomizedBaseAddress',
319 map={'1': ':NO', '2': ''}, prefix='/DYNAMICBASE') 319 map={'1': ':NO', '2': ''}, prefix='/DYNAMICBASE')
320 ld('DataExecutionPrevention', 320 ld('DataExecutionPrevention',
321 map={'1': ':NO', '2': ''}, prefix='/NXCOMPAT') 321 map={'1': ':NO', '2': ''}, prefix='/NXCOMPAT')
322 ld('OptimizeReferences', map={'1': 'NOREF', '2': 'REF'}, prefix='/OPT:') 322 ld('OptimizeReferences', map={'1': 'NOREF', '2': 'REF'}, prefix='/OPT:')
323 ld('EnableCOMDATFolding', map={'1': 'NOICF', '2': 'ICF'}, prefix='/OPT:') 323 ld('EnableCOMDATFolding', map={'1': 'NOICF', '2': 'ICF'}, prefix='/OPT:')
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 midl_get = self._GetWrapper(self, self.msvs_settings[config], 'VCMIDLTool') 404 midl_get = self._GetWrapper(self, self.msvs_settings[config], 'VCMIDLTool')
405 def midl(name, default=None): 405 def midl(name, default=None):
406 return self.ConvertVSMacros(midl_get(name, default=default)) 406 return self.ConvertVSMacros(midl_get(name, default=default))
407 tlb = midl('TypeLibraryName', default='${root}.tlb') 407 tlb = midl('TypeLibraryName', default='${root}.tlb')
408 header = midl('HeaderFileName', default='${root}.h') 408 header = midl('HeaderFileName', default='${root}.h')
409 dlldata = midl('DLLDataFileName', default='dlldata.c') 409 dlldata = midl('DLLDataFileName', default='dlldata.c')
410 iid = midl('InterfaceIdentifierFileName', default='${root}_i.c') 410 iid = midl('InterfaceIdentifierFileName', default='${root}_i.c')
411 proxy = midl('ProxyFileName', default='${root}_p.c') 411 proxy = midl('ProxyFileName', default='${root}_p.c')
412 # Note that .tlb is not included in the outputs as it is not always 412 # Note that .tlb is not included in the outputs as it is not always
413 # generated depending on the content of the input idl file. 413 # generated depending on the content of the input idl file.
414 outdir = midl('OutputDirectory') 414 outdir = midl('OutputDirectory', default='')
415 output = [header, dlldata, iid, proxy] 415 output = [header, dlldata, iid, proxy]
416 variables = [('tlb', tlb), 416 variables = [('tlb', tlb),
417 ('h', header), 417 ('h', header),
418 ('dlldata', dlldata), 418 ('dlldata', dlldata),
419 ('iid', iid), 419 ('iid', iid),
420 ('proxy', proxy)] 420 ('proxy', proxy)]
421 # TODO(scottmg): Are there configuration settings to set these flags? 421 # TODO(scottmg): Are there configuration settings to set these flags?
422 flags = ['/char', 'signed', '/env', 'win32', '/Oicf'] 422 flags = ['/char', 'signed', '/env', 'win32', '/Oicf']
423 return outdir, output, variables, flags 423 return outdir, output, variables, flags
424 424
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 vs.Path(), r'Common7\Tools\vsvars32.bat')) 468 vs.Path(), r'Common7\Tools\vsvars32.bat'))
469 469
470 def ExpandMacros(string, expansions): 470 def ExpandMacros(string, expansions):
471 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv 471 """Expand $(Variable) per expansions dict. See MsvsSettings.GetVSMacroEnv
472 for the canonical way to retrieve a suitable dict.""" 472 for the canonical way to retrieve a suitable dict."""
473 if '$' in string: 473 if '$' in string:
474 for old, new in expansions.iteritems(): 474 for old, new in expansions.iteritems():
475 assert '$(' not in new, new 475 assert '$(' not in new, new
476 string = string.replace(old, new) 476 string = string.replace(old, new)
477 return string 477 return string
OLDNEW
« no previous file with comments | « pylib/gyp/generator/ninja.py ('k') | test/ninja/normalize-paths-win/gyptest-normalize-paths.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698