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

Side by Side Diff: pylib/gyp/generator/msvs.py

Issue 118021: Add some basic validation of the msvs_guid to require upper-case hex... (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: '' Created 11 years, 6 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 3
4 import os 4 import os
5 import re 5 import re
6 import subprocess 6 import subprocess
7 import sys 7 import sys
8 import gyp.common 8 import gyp.common
9 import gyp.MSVSNew as MSVSNew 9 import gyp.MSVSNew as MSVSNew
10 import gyp.MSVSToolFile as MSVSToolFile 10 import gyp.MSVSToolFile as MSVSToolFile
11 import gyp.MSVSProject as MSVSProject 11 import gyp.MSVSProject as MSVSProject
12 import gyp.MSVSVersion as MSVSVersion 12 import gyp.MSVSVersion as MSVSVersion
13 13
14 14
15 # Regular expression for validating Visual Studio GUIDs. If the GUID
16 # contains lowercase hex letters, MSVS will be fine. However,
17 # IncrediBuild BuildConsole will parse the solution file, but then
18 # silently skip building the target causing hard to track down errors.
19 # Note that this only happens with the BuildConsole, and does not occur
20 # if IncrediBuild is executed from inside Visual Studio. This regex
21 # validates that the string looks like a GUID with all uppercase hex
22 # letters.
23 VALID_MSVS_GUID_CHARS = re.compile('^[A-F0-9\-]+$')
24
25
15 generator_default_variables = { 26 generator_default_variables = {
16 'EXECUTABLE_PREFIX': '', 27 'EXECUTABLE_PREFIX': '',
17 'EXECUTABLE_SUFFIX': '.exe', 28 'EXECUTABLE_SUFFIX': '.exe',
18 'INTERMEDIATE_DIR': '$(IntDir)', 29 'INTERMEDIATE_DIR': '$(IntDir)',
19 'SHARED_INTERMEDIATE_DIR': '$(OutDir)/obj/global_intermediate', 30 'SHARED_INTERMEDIATE_DIR': '$(OutDir)/obj/global_intermediate',
20 'OS': 'win', 31 'OS': 'win',
21 'PRODUCT_DIR': '$(OutDir)', 32 'PRODUCT_DIR': '$(OutDir)',
22 'RULE_INPUT_ROOT': '$(InputName)', 33 'RULE_INPUT_ROOT': '$(InputName)',
23 'RULE_INPUT_EXT': '$(InputExt)', 34 'RULE_INPUT_EXT': '$(InputExt)',
24 'RULE_INPUT_NAME': '$(InputFileName)', 35 'RULE_INPUT_NAME': '$(InputFileName)',
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 Arguments: 429 Arguments:
419 vcproj_filename: Filename of the vcproj file to generate. 430 vcproj_filename: Filename of the vcproj file to generate.
420 build_file: Filename of the .gyp file that the vcproj file comes from. 431 build_file: Filename of the .gyp file that the vcproj file comes from.
421 spec: The target dictionary containing the properties of the target. 432 spec: The target dictionary containing the properties of the target.
422 """ 433 """
423 #print 'Generating %s' % vcproj_filename 434 #print 'Generating %s' % vcproj_filename
424 435
425 p = MSVSProject.Writer(vcproj_filename, version=version) 436 p = MSVSProject.Writer(vcproj_filename, version=version)
426 default_config = spec['configurations'][spec['default_configuration']] 437 default_config = spec['configurations'][spec['default_configuration']]
427 guid = default_config.get('msvs_guid') 438 guid = default_config.get('msvs_guid')
428 if guid: guid = '{%s}' % guid 439 if guid:
440 if VALID_MSVS_GUID_CHARS.match(guid) == None:
441 raise ValueError('Invalid MSVS guid: "%s". Must match regex: "%s".' %
442 (guid, VALID_MSVS_GUID_CHARS.pattern))
443
444 guid = '{%s}' % guid
429 p.Create(spec['target_name'], guid=guid) 445 p.Create(spec['target_name'], guid=guid)
430 446
431 # Get directory project file is in. 447 # Get directory project file is in.
432 gyp_dir = os.path.split(vcproj_filename)[0] 448 gyp_dir = os.path.split(vcproj_filename)[0]
433 449
434 # Pick target configuration type. 450 # Pick target configuration type.
435 config_type = { 451 config_type = {
436 'executable': '1', 452 'executable': '1',
437 'shared_library': '2', 453 'shared_library': '2',
438 'loadable_module': '2', 454 'loadable_module': '2',
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 _ProjectObject(sln_path, p, project_objs, projects) 864 _ProjectObject(sln_path, p, project_objs, projects)
849 # Create folder hierarchy. 865 # Create folder hierarchy.
850 root_entries = _GatherSolutionFolders(project_objs) 866 root_entries = _GatherSolutionFolders(project_objs)
851 # Create solution. 867 # Create solution.
852 sln = MSVSNew.MSVSSolution(sln_path, 868 sln = MSVSNew.MSVSSolution(sln_path,
853 entries=root_entries, 869 entries=root_entries,
854 variants=configs, 870 variants=configs,
855 websiteProperties=False, 871 websiteProperties=False,
856 version=msvs_version) 872 version=msvs_version)
857 sln.Write() 873 sln.Write()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698