diff options
Diffstat (limited to 'tools/gyp/pylib/gyp/MSVSUtil.py')
-rw-r--r-- | tools/gyp/pylib/gyp/MSVSUtil.py | 81 |
1 files changed, 68 insertions, 13 deletions
diff --git a/tools/gyp/pylib/gyp/MSVSUtil.py b/tools/gyp/pylib/gyp/MSVSUtil.py index 5afcd1f2a..62e8d260d 100644 --- a/tools/gyp/pylib/gyp/MSVSUtil.py +++ b/tools/gyp/pylib/gyp/MSVSUtil.py @@ -10,7 +10,8 @@ import os _TARGET_TYPE_EXT = { 'executable': '.exe', - 'shared_library': '.dll' + 'loadable_module': '.dll', + 'shared_library': '.dll', } @@ -121,6 +122,46 @@ def ShardTargets(target_list, target_dicts): return (new_target_list, new_target_dicts) +def _GetPdbPath(target_dict, config_name, vars): + """Returns the path to the PDB file that will be generated by a given + configuration. + + The lookup proceeds as follows: + - Look for an explicit path in the VCLinkerTool configuration block. + - Look for an 'msvs_large_pdb_path' variable. + - Use '<(PRODUCT_DIR)/<(product_name).(exe|dll).pdb' if 'product_name' is + specified. + - Use '<(PRODUCT_DIR)/<(target_name).(exe|dll).pdb'. + + Arguments: + target_dict: The target dictionary to be searched. + config_name: The name of the configuration of interest. + vars: A dictionary of common GYP variables with generator-specific values. + Returns: + The path of the corresponding PDB file. + """ + config = target_dict['configurations'][config_name] + msvs = config.setdefault('msvs_settings', {}) + + linker = msvs.get('VCLinkerTool', {}) + + pdb_path = linker.get('ProgramDatabaseFile') + if pdb_path: + return pdb_path + + variables = target_dict.get('variables', {}) + pdb_path = variables.get('msvs_large_pdb_path', None) + if pdb_path: + return pdb_path + + + pdb_base = target_dict.get('product_name', target_dict['target_name']) + pdb_base = '%s%s.pdb' % (pdb_base, _TARGET_TYPE_EXT[target_dict['type']]) + pdb_path = vars['PRODUCT_DIR'] + '/' + pdb_base + + return pdb_path + + def InsertLargePdbShims(target_list, target_dicts, vars): """Insert a shim target that forces the linker to use 4KB pagesize PDBs. @@ -138,6 +179,7 @@ def InsertLargePdbShims(target_list, target_dicts, vars): targets_to_shim = [] for t in target_dicts: target_dict = target_dicts[t] + # We only want to shim targets that have msvs_large_pdb enabled. if not int(target_dict.get('msvs_large_pdb', 0)): continue @@ -162,7 +204,7 @@ def InsertLargePdbShims(target_list, target_dicts, vars): # GYP and the project may be on different drives), and Ninja hates absolute # paths (it ends up generating the .obj and .obj.d alongside the source # file, polluting GYPs tree). - copy_suffix = '_large_pdb_copy' + copy_suffix = 'large_pdb_copy' copy_target_name = target_name + '_' + copy_suffix full_copy_target_name = _SuffixName(t, copy_suffix) shim_cc_basename = os.path.basename(large_pdb_shim_cc) @@ -179,7 +221,7 @@ def InsertLargePdbShims(target_list, target_dicts, vars): # This is the dict for the PDB generating shim target. It depends on the # copy target. - shim_suffix = '_large_pdb_shim' + shim_suffix = 'large_pdb_shim' shim_target_name = target_name + '_' + shim_suffix full_shim_target_name = _SuffixName(t, shim_suffix) shim_dict = copy.deepcopy(base_dict) @@ -190,19 +232,32 @@ def InsertLargePdbShims(target_list, target_dicts, vars): # Set up the shim to output its PDB to the same location as the final linker # target. - for config in shim_dict.get('configurations').itervalues(): - msvs = config.setdefault('msvs_settings') + for config_name, config in shim_dict.get('configurations').iteritems(): + pdb_path = _GetPdbPath(target_dict, config_name, vars) - linker = msvs.pop('VCLinkerTool') # We want to clear this dict. - pdb_path = linker.get('ProgramDatabaseFile') + # A few keys that we don't want to propagate. + for key in ['msvs_precompiled_header', 'msvs_precompiled_source', 'test']: + config.pop(key, None) - compiler = msvs.setdefault('VCCLCompilerTool', {}) - compiler.setdefault('DebugInformationFormat', '3') - compiler.setdefault('ProgramDataBaseFileName', pdb_path) + msvs = config.setdefault('msvs_settings', {}) - # Add the new targets. - target_list.append(full_copy_target_name) - target_list.append(full_shim_target_name) + # Update the compiler directives in the shim target. + compiler = msvs.setdefault('VCCLCompilerTool', {}) + compiler['DebugInformationFormat'] = '3' + compiler['ProgramDataBaseFileName'] = pdb_path + + # Set the explicit PDB path in the appropriate configuration of the + # original target. + config = target_dict['configurations'][config_name] + msvs = config.setdefault('msvs_settings', {}) + linker = msvs.setdefault('VCLinkerTool', {}) + linker['GenerateDebugInformation'] = 'true' + linker['ProgramDatabaseFile'] = pdb_path + + # Add the new targets. They must go to the beginning of the list so that + # the dependency generation works as expected in ninja. + target_list.insert(0, full_copy_target_name) + target_list.insert(0, full_shim_target_name) target_dicts[full_copy_target_name] = copy_dict target_dicts[full_shim_target_name] = shim_dict |