~hjd/ubuntu/wily/gyp/debian-merged

« back to all changes in this revision

Viewing changes to pylib/gyp/MSVSSettings.py

  • Committer: Hans Joachim Desserud
  • Date: 2015-10-31 12:46:59 UTC
  • mfrom: (6.2.6 sid)
  • Revision ID: hans_joachim_desserud-20151031124659-lzxekr6woskh4k0b
Merge latest Debian version

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# Use of this source code is governed by a BSD-style license that can be
3
3
# found in the LICENSE file.
4
4
 
5
 
"""Code to validate and convert settings of the Microsoft build tools.
 
5
r"""Code to validate and convert settings of the Microsoft build tools.
6
6
 
7
7
This file contains code to validate and convert settings of the Microsoft
8
8
build tools.  The function ConvertToMSBuildSettings(), ValidateMSVSSettings(),
314
314
    name: the name of the setting.
315
315
    setting_type: the type of this setting.
316
316
  """
 
317
 
 
318
  def _Translate(value, msbuild_settings):
 
319
    # Let msbuild-only properties get translated as-is from msvs_settings.
 
320
    tool_settings = msbuild_settings.setdefault(tool.msbuild_name, {})
 
321
    tool_settings[name] = value
 
322
 
317
323
  _msbuild_validators[tool.msbuild_name][name] = setting_type.ValidateMSBuild
 
324
  _msvs_to_msbuild_converters[tool.msvs_name][name] = _Translate
318
325
 
319
326
 
320
327
def _ConvertedToAdditionalOption(tool, msvs_name, flag):
367
374
  r'(\$\((?:%s)\))(?:[\\/]+)' % "|".join(fix_vc_macro_slashes_regex_list)
368
375
)
369
376
 
 
377
# Regular expression to detect keys that were generated by exclusion lists
 
378
_EXCLUDED_SUFFIX_RE = re.compile('^(.*)_excluded$')
 
379
 
 
380
 
 
381
def _ValidateExclusionSetting(setting, settings, error_msg, stderr=sys.stderr):
 
382
  """Verify that 'setting' is valid if it is generated from an exclusion list.
 
383
 
 
384
  If the setting appears to be generated from an exclusion list, the root name
 
385
  is checked.
 
386
 
 
387
  Args:
 
388
      setting:   A string that is the setting name to validate
 
389
      settings:  A dictionary where the keys are valid settings
 
390
      error_msg: The message to emit in the event of error
 
391
      stderr:    The stream receiving the error messages.
 
392
  """
 
393
  # This may be unrecognized because it's an exclusion list. If the
 
394
  # setting name has the _excluded suffix, then check the root name.
 
395
  unrecognized = True
 
396
  m = re.match(_EXCLUDED_SUFFIX_RE, setting)
 
397
  if m:
 
398
    root_setting = m.group(1)
 
399
    unrecognized = root_setting not in settings
 
400
 
 
401
  if unrecognized:
 
402
    # We don't know this setting. Give a warning.
 
403
    print >> stderr, error_msg
 
404
 
 
405
 
370
406
def FixVCMacroSlashes(s):
371
407
  """Replace macros which have excessive following slashes.
372
408
 
388
424
  if '$' in s:
389
425
    replace_map = {
390
426
        '$(ConfigurationName)': '$(Configuration)',
391
 
        '$(InputDir)': '%(RootDir)%(Directory)',
 
427
        '$(InputDir)': '%(RelativeDir)',
392
428
        '$(InputExt)': '%(Extension)',
393
429
        '$(InputFileName)': '%(Filename)%(Extension)',
394
430
        '$(InputName)': '%(Filename)',
395
 
        '$(InputPath)': '%(FullPath)',
 
431
        '$(InputPath)': '%(Identity)',
396
432
        '$(ParentName)': '$(ProjectFileName)',
397
433
        '$(PlatformName)': '$(Platform)',
398
434
        '$(SafeInputName)': '%(Filename)',
429
465
            print >> stderr, ('Warning: while converting %s/%s to MSBuild, '
430
466
                              '%s' % (msvs_tool_name, msvs_setting, e))
431
467
        else:
432
 
          # We don't know this setting.  Give a warning.
433
 
          print >> stderr, ('Warning: unrecognized setting %s/%s '
434
 
                            'while converting to MSBuild.' %
435
 
                            (msvs_tool_name, msvs_setting))
 
468
          _ValidateExclusionSetting(msvs_setting,
 
469
                                    msvs_tool,
 
470
                                    ('Warning: unrecognized setting %s/%s '
 
471
                                     'while converting to MSBuild.' %
 
472
                                     (msvs_tool_name, msvs_setting)),
 
473
                                    stderr)
436
474
    else:
437
475
      print >> stderr, ('Warning: unrecognized tool %s while converting to '
438
476
                        'MSBuild.' % msvs_tool_name)
483
521
            print >> stderr, ('Warning: for %s/%s, %s' %
484
522
                              (tool_name, setting, e))
485
523
        else:
486
 
          print >> stderr, ('Warning: unrecognized setting %s/%s' %
487
 
                            (tool_name, setting))
 
524
          _ValidateExclusionSetting(setting,
 
525
                                    tool_validators,
 
526
                                    ('Warning: unrecognized setting %s/%s' %
 
527
                                     (tool_name, setting)),
 
528
                                    stderr)
 
529
 
488
530
    else:
489
531
      print >> stderr, ('Warning: unrecognized tool %s' % tool_name)
490
532
 
496
538
_rc = _Tool('VCResourceCompilerTool', 'ResourceCompile')
497
539
_lib = _Tool('VCLibrarianTool', 'Lib')
498
540
_manifest = _Tool('VCManifestTool', 'Manifest')
 
541
_masm = _Tool('MASM', 'MASM')
499
542
 
500
543
 
501
544
_AddTool(_compile)
504
547
_AddTool(_rc)
505
548
_AddTool(_lib)
506
549
_AddTool(_manifest)
 
550
_AddTool(_masm)
507
551
# Add sections only found in the MSBuild settings.
508
552
_msbuild_validators[''] = {}
509
553
_msbuild_validators['ProjectReference'] = {}
567
611
_Same(_compile, 'CallingConvention',
568
612
      _Enumeration(['Cdecl',  # /Gd
569
613
                    'FastCall',  # /Gr
570
 
                    'StdCall']))  # /Gz
 
614
                    'StdCall',  # /Gz
 
615
                    'VectorCall']))  # /Gv
571
616
_Same(_compile, 'CompileAs',
572
617
      _Enumeration(['Default',
573
618
                    'CompileAsC',  # /TC
581
626
_Same(_compile, 'EnableEnhancedInstructionSet',
582
627
      _Enumeration(['NotSet',
583
628
                    'StreamingSIMDExtensions',  # /arch:SSE
584
 
                    'StreamingSIMDExtensions2']))  # /arch:SSE2
 
629
                    'StreamingSIMDExtensions2',  # /arch:SSE2
 
630
                    'AdvancedVectorExtensions',  # /arch:AVX (vs2012+)
 
631
                    'NoExtensions',  # /arch:IA32 (vs2012+)
 
632
                    # This one only exists in the new msbuild format.
 
633
                    'AdvancedVectorExtensions2',  # /arch:AVX2 (vs2013r2+)
 
634
                    ]))
585
635
_Same(_compile, 'ErrorReporting',
586
636
      _Enumeration(['None',  # /errorReport:none
587
637
                    'Prompt',  # /errorReport:prompt
658
708
_MSBuildOnly(_compile, 'BuildingInIDE', _boolean)
659
709
_MSBuildOnly(_compile, 'CompileAsManaged',
660
710
             _Enumeration([], new=['false',
661
 
                                   'true',  # /clr
662
 
                                   'Pure',  # /clr:pure
663
 
                                   'Safe',  # /clr:safe
664
 
                                   'OldSyntax']))  # /clr:oldSyntax
 
711
                                   'true']))  # /clr
665
712
_MSBuildOnly(_compile, 'CreateHotpatchableImage', _boolean)  # /hotpatch
666
713
_MSBuildOnly(_compile, 'MultiProcessorCompilation', _boolean)  # /MP
667
714
_MSBuildOnly(_compile, 'PreprocessOutputPath', _string)  # /Fi
812
859
      _Enumeration(['AsInvoker',  # /level='asInvoker'
813
860
                    'HighestAvailable',  # /level='highestAvailable'
814
861
                    'RequireAdministrator']))  # /level='requireAdministrator'
 
862
_Same(_link, 'MinimumRequiredVersion', _string)
 
863
_Same(_link, 'TreatLinkerWarningAsErrors', _boolean)  # /WX
815
864
 
816
865
 
817
866
# Options found in MSVS that have been renamed in MSBuild.
834
883
# MSVS options not found in MSBuild.
835
884
_MSVSOnly(_link, 'OptimizeForWindows98', _newly_boolean)
836
885
_MSVSOnly(_link, 'UseUnicodeResponseFiles', _boolean)
837
 
# These settings generate correctly in the MSVS output files when using
838
 
# e.g. DelayLoadDLLs! or AdditionalDependencies! to exclude files from
839
 
# configuration entries, but result in spurious artifacts which can be
840
 
# safely ignored here.  See crbug.com/246570
841
 
_MSVSOnly(_link, 'AdditionalLibraryDirectories_excluded', _folder_list)
842
 
_MSVSOnly(_link, 'DelayLoadDLLs_excluded', _file_list)
843
 
_MSVSOnly(_link, 'AdditionalDependencies_excluded', _file_list)
844
886
 
845
887
# MSBuild options not found in MSVS.
846
888
_MSBuildOnly(_link, 'BuildingInIDE', _boolean)
850
892
_MSBuildOnly(_link, 'PreventDllBinding', _boolean)  # /ALLOWBIND
851
893
_MSBuildOnly(_link, 'SupportNobindOfDelayLoadedDLL', _boolean)  # /DELAY:NOBIND
852
894
_MSBuildOnly(_link, 'TrackerLogDirectory', _folder_name)
853
 
_MSBuildOnly(_link, 'TreatLinkerWarningAsErrors', _boolean)  # /WX
854
 
_MSBuildOnly(_link, 'MinimumRequiredVersion', _string)
855
895
_MSBuildOnly(_link, 'MSDOSStubFileName', _file_name)  # /STUB Visible='false'
856
896
_MSBuildOnly(_link, 'SectionAlignment', _integer)  # /ALIGN
857
897
_MSBuildOnly(_link, 'SpecifySectionAttributes', _string)  # /SECTION
985
1025
_Same(_lib, 'SuppressStartupBanner', _boolean)  # /NOLOGO
986
1026
_Same(_lib, 'UseUnicodeResponseFiles', _boolean)
987
1027
_Same(_lib, 'LinkTimeCodeGeneration', _boolean)  # /LTCG
 
1028
_Same(_lib, 'TargetMachine', _target_machine_enumeration)
988
1029
 
989
1030
# TODO(jeanluc) _link defines the same value that gets moved to
990
1031
# ProjectReference.  We may want to validate that they are consistent.
991
1032
_Moved(_lib, 'LinkLibraryDependencies', 'ProjectReference', _boolean)
992
1033
 
993
 
# TODO(jeanluc) I don't think these are genuine settings but byproducts of Gyp.
994
 
_MSVSOnly(_lib, 'AdditionalLibraryDirectories_excluded', _folder_list)
995
 
 
996
1034
_MSBuildOnly(_lib, 'DisplayLibrary', _string)  # /LIST Visible='false'
997
1035
_MSBuildOnly(_lib, 'ErrorReporting',
998
1036
             _Enumeration([], new=['PromptImmediately',  # /ERRORREPORT:PROMPT
1003
1041
_MSBuildOnly(_lib, 'Name', _file_name)  # /NAME
1004
1042
_MSBuildOnly(_lib, 'RemoveObjects', _file_list)  # /REMOVE
1005
1043
_MSBuildOnly(_lib, 'SubSystem', _subsystem_enumeration)
1006
 
_MSBuildOnly(_lib, 'TargetMachine', _target_machine_enumeration)
1007
1044
_MSBuildOnly(_lib, 'TrackerLogDirectory', _folder_name)
1008
1045
_MSBuildOnly(_lib, 'TreatLibWarningAsErrors', _boolean)  # /WX
1009
1046
_MSBuildOnly(_lib, 'Verbose', _boolean)
1049
1086
_MSBuildOnly(_manifest, 'OutputResourceManifests', _string)  # /outputresource
1050
1087
_MSBuildOnly(_manifest, 'SuppressDependencyElement', _boolean)  # /nodependency
1051
1088
_MSBuildOnly(_manifest, 'TrackerLogDirectory', _folder_name)
 
1089
 
 
1090
 
 
1091
# Directives for MASM.
 
1092
# See "$(VCTargetsPath)\BuildCustomizations\masm.xml" for the schema of the
 
1093
# MSBuild MASM settings.
 
1094
 
 
1095
# Options that have the same name in MSVS and MSBuild.
 
1096
_Same(_masm, 'UseSafeExceptionHandlers', _boolean)  # /safeseh