Chromium Code Reviews| 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 import copy | 5 import copy |
| 6 import ntpath | 6 import ntpath |
| 7 import os | 7 import os |
| 8 import posixpath | 8 import posixpath |
| 9 import re | 9 import re |
| 10 import subprocess | 10 import subprocess |
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1099 | 1099 |
| 1100 Arguments: | 1100 Arguments: |
| 1101 p: The target project being generated. | 1101 p: The target project being generated. |
| 1102 spec: The target dictionary containing the properties of the target. | 1102 spec: The target dictionary containing the properties of the target. |
| 1103 config_type: The configuration type, a number as defined by Microsoft. | 1103 config_type: The configuration type, a number as defined by Microsoft. |
| 1104 config_name: The name of the configuration. | 1104 config_name: The name of the configuration. |
| 1105 config: The dictionary that defines the special processing to be done | 1105 config: The dictionary that defines the special processing to be done |
| 1106 for this configuration. | 1106 for this configuration. |
| 1107 """ | 1107 """ |
| 1108 # Get the information for this configuration | 1108 # Get the information for this configuration |
| 1109 include_dirs, resource_include_dirs = _GetIncludeDirs(config) | 1109 include_dirs, midl_include_dirs, resource_include_dirs = \ |
| 1110 _GetIncludeDirs(config) | |
| 1110 libraries = _GetLibraries(spec) | 1111 libraries = _GetLibraries(spec) |
| 1111 library_dirs = _GetLibraryDirs(config) | 1112 library_dirs = _GetLibraryDirs(config) |
| 1112 out_file, vc_tool, _ = _GetOutputFilePathAndTool(spec, msbuild=False) | 1113 out_file, vc_tool, _ = _GetOutputFilePathAndTool(spec, msbuild=False) |
| 1113 defines = _GetDefines(config) | 1114 defines = _GetDefines(config) |
| 1114 defines = [_EscapeCppDefineForMSVS(d) for d in defines] | 1115 defines = [_EscapeCppDefineForMSVS(d) for d in defines] |
| 1115 disabled_warnings = _GetDisabledWarnings(config) | 1116 disabled_warnings = _GetDisabledWarnings(config) |
| 1116 prebuild = config.get('msvs_prebuild') | 1117 prebuild = config.get('msvs_prebuild') |
| 1117 postbuild = config.get('msvs_postbuild') | 1118 postbuild = config.get('msvs_postbuild') |
| 1118 def_file = _GetModuleDefinition(spec) | 1119 def_file = _GetModuleDefinition(spec) |
| 1119 precompiled_header = config.get('msvs_precompiled_header') | 1120 precompiled_header = config.get('msvs_precompiled_header') |
| 1120 | 1121 |
| 1121 # Prepare the list of tools as a dictionary. | 1122 # Prepare the list of tools as a dictionary. |
| 1122 tools = dict() | 1123 tools = dict() |
| 1123 # Add in user specified msvs_settings. | 1124 # Add in user specified msvs_settings. |
| 1124 msvs_settings = config.get('msvs_settings', {}) | 1125 msvs_settings = config.get('msvs_settings', {}) |
| 1125 MSVSSettings.ValidateMSVSSettings(msvs_settings) | 1126 MSVSSettings.ValidateMSVSSettings(msvs_settings) |
| 1126 | 1127 |
| 1127 # Prevent default library inheritance from the environment. | 1128 # Prevent default library inheritance from the environment. |
| 1128 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', ['$(NOINHERIT)']) | 1129 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', ['$(NOINHERIT)']) |
| 1129 | 1130 |
| 1130 for tool in msvs_settings: | 1131 for tool in msvs_settings: |
| 1131 settings = config['msvs_settings'][tool] | 1132 settings = config['msvs_settings'][tool] |
| 1132 for setting in settings: | 1133 for setting in settings: |
| 1133 _ToolAppend(tools, tool, setting, settings[setting]) | 1134 _ToolAppend(tools, tool, setting, settings[setting]) |
| 1134 # Add the information to the appropriate tool | 1135 # Add the information to the appropriate tool |
| 1135 _ToolAppend(tools, 'VCCLCompilerTool', | 1136 _ToolAppend(tools, 'VCCLCompilerTool', |
| 1136 'AdditionalIncludeDirectories', include_dirs) | 1137 'AdditionalIncludeDirectories', include_dirs) |
| 1138 _ToolAppend(tools, 'VCMIDLTool', | |
| 1139 'AdditionalIncludeDirectories', midl_include_dirs) | |
| 1137 _ToolAppend(tools, 'VCResourceCompilerTool', | 1140 _ToolAppend(tools, 'VCResourceCompilerTool', |
| 1138 'AdditionalIncludeDirectories', resource_include_dirs) | 1141 'AdditionalIncludeDirectories', resource_include_dirs) |
| 1139 # Add in libraries. | 1142 # Add in libraries. |
| 1140 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', libraries) | 1143 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', libraries) |
| 1141 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalLibraryDirectories', | 1144 _ToolAppend(tools, 'VCLinkerTool', 'AdditionalLibraryDirectories', |
| 1142 library_dirs) | 1145 library_dirs) |
| 1143 if out_file: | 1146 if out_file: |
| 1144 _ToolAppend(tools, vc_tool, 'OutputFile', out_file, only_if_unset=True) | 1147 _ToolAppend(tools, vc_tool, 'OutputFile', out_file, only_if_unset=True) |
| 1145 # Add defines. | 1148 # Add defines. |
| 1146 _ToolAppend(tools, 'VCCLCompilerTool', 'PreprocessorDefinitions', defines) | 1149 _ToolAppend(tools, 'VCCLCompilerTool', 'PreprocessorDefinitions', defines) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1182 config: The dictionary that defines the special processing to be done | 1185 config: The dictionary that defines the special processing to be done |
| 1183 for this configuration. | 1186 for this configuration. |
| 1184 Returns: | 1187 Returns: |
| 1185 The list of directory paths. | 1188 The list of directory paths. |
| 1186 """ | 1189 """ |
| 1187 # TODO(bradnelson): include_dirs should really be flexible enough not to | 1190 # TODO(bradnelson): include_dirs should really be flexible enough not to |
| 1188 # require this sort of thing. | 1191 # require this sort of thing. |
| 1189 include_dirs = ( | 1192 include_dirs = ( |
| 1190 config.get('include_dirs', []) + | 1193 config.get('include_dirs', []) + |
| 1191 config.get('msvs_system_include_dirs', [])) | 1194 config.get('msvs_system_include_dirs', [])) |
| 1195 midl_include_dirs = config.get('midl_include_dirs', []) | |
|
scottmg
2014/09/25 16:53:10
should msvs_system_include_dirs be included here f
Shezan Baig (Bloomberg)
2014/09/25 17:00:21
Hmm, I didn't seem to need it in my test. I can a
scottmg
2014/09/25 17:05:31
I think by default midl uses cl /E, which means it
Shezan Baig (Bloomberg)
2014/09/25 17:15:59
Sounds good -- I've uploaded a new patch. I copie
| |
| 1192 resource_include_dirs = config.get('resource_include_dirs', include_dirs) | 1196 resource_include_dirs = config.get('resource_include_dirs', include_dirs) |
| 1193 include_dirs = _FixPaths(include_dirs) | 1197 include_dirs = _FixPaths(include_dirs) |
| 1198 midl_include_dirs = _FixPaths(midl_include_dirs) | |
| 1194 resource_include_dirs = _FixPaths(resource_include_dirs) | 1199 resource_include_dirs = _FixPaths(resource_include_dirs) |
| 1195 return include_dirs, resource_include_dirs | 1200 return include_dirs, midl_include_dirs, resource_include_dirs |
| 1196 | 1201 |
| 1197 | 1202 |
| 1198 def _GetLibraryDirs(config): | 1203 def _GetLibraryDirs(config): |
| 1199 """Returns the list of directories to be used for library search paths. | 1204 """Returns the list of directories to be used for library search paths. |
| 1200 | 1205 |
| 1201 Arguments: | 1206 Arguments: |
| 1202 config: The dictionary that defines the special processing to be done | 1207 config: The dictionary that defines the special processing to be done |
| 1203 for this configuration. | 1208 for this configuration. |
| 1204 Returns: | 1209 Returns: |
| 1205 The list of directory paths. | 1210 The list of directory paths. |
| (...skipping 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2907 | 2912 |
| 2908 def _FinalizeMSBuildSettings(spec, configuration): | 2913 def _FinalizeMSBuildSettings(spec, configuration): |
| 2909 if 'msbuild_settings' in configuration: | 2914 if 'msbuild_settings' in configuration: |
| 2910 converted = False | 2915 converted = False |
| 2911 msbuild_settings = configuration['msbuild_settings'] | 2916 msbuild_settings = configuration['msbuild_settings'] |
| 2912 MSVSSettings.ValidateMSBuildSettings(msbuild_settings) | 2917 MSVSSettings.ValidateMSBuildSettings(msbuild_settings) |
| 2913 else: | 2918 else: |
| 2914 converted = True | 2919 converted = True |
| 2915 msvs_settings = configuration.get('msvs_settings', {}) | 2920 msvs_settings = configuration.get('msvs_settings', {}) |
| 2916 msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings) | 2921 msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings) |
| 2917 include_dirs, resource_include_dirs = _GetIncludeDirs(configuration) | 2922 include_dirs, midl_include_dirs, resource_include_dirs = \ |
| 2923 _GetIncludeDirs(configuration) | |
| 2918 libraries = _GetLibraries(spec) | 2924 libraries = _GetLibraries(spec) |
| 2919 library_dirs = _GetLibraryDirs(configuration) | 2925 library_dirs = _GetLibraryDirs(configuration) |
| 2920 out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec, msbuild=True) | 2926 out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec, msbuild=True) |
| 2921 target_ext = _GetOutputTargetExt(spec) | 2927 target_ext = _GetOutputTargetExt(spec) |
| 2922 defines = _GetDefines(configuration) | 2928 defines = _GetDefines(configuration) |
| 2923 if converted: | 2929 if converted: |
| 2924 # Visual Studio 2010 has TR1 | 2930 # Visual Studio 2010 has TR1 |
| 2925 defines = [d for d in defines if d != '_HAS_TR1=0'] | 2931 defines = [d for d in defines if d != '_HAS_TR1=0'] |
| 2926 # Warn of ignored settings | 2932 # Warn of ignored settings |
| 2927 ignored_settings = ['msvs_tool_files'] | 2933 ignored_settings = ['msvs_tool_files'] |
| 2928 for ignored_setting in ignored_settings: | 2934 for ignored_setting in ignored_settings: |
| 2929 value = configuration.get(ignored_setting) | 2935 value = configuration.get(ignored_setting) |
| 2930 if value: | 2936 if value: |
| 2931 print ('Warning: The automatic conversion to MSBuild does not handle ' | 2937 print ('Warning: The automatic conversion to MSBuild does not handle ' |
| 2932 '%s. Ignoring setting of %s' % (ignored_setting, str(value))) | 2938 '%s. Ignoring setting of %s' % (ignored_setting, str(value))) |
| 2933 | 2939 |
| 2934 defines = [_EscapeCppDefineForMSBuild(d) for d in defines] | 2940 defines = [_EscapeCppDefineForMSBuild(d) for d in defines] |
| 2935 disabled_warnings = _GetDisabledWarnings(configuration) | 2941 disabled_warnings = _GetDisabledWarnings(configuration) |
| 2936 prebuild = configuration.get('msvs_prebuild') | 2942 prebuild = configuration.get('msvs_prebuild') |
| 2937 postbuild = configuration.get('msvs_postbuild') | 2943 postbuild = configuration.get('msvs_postbuild') |
| 2938 def_file = _GetModuleDefinition(spec) | 2944 def_file = _GetModuleDefinition(spec) |
| 2939 precompiled_header = configuration.get('msvs_precompiled_header') | 2945 precompiled_header = configuration.get('msvs_precompiled_header') |
| 2940 | 2946 |
| 2941 # Add the information to the appropriate tool | 2947 # Add the information to the appropriate tool |
| 2942 # TODO(jeanluc) We could optimize and generate these settings only if | 2948 # TODO(jeanluc) We could optimize and generate these settings only if |
| 2943 # the corresponding files are found, e.g. don't generate ResourceCompile | 2949 # the corresponding files are found, e.g. don't generate ResourceCompile |
| 2944 # if you don't have any resources. | 2950 # if you don't have any resources. |
| 2945 _ToolAppend(msbuild_settings, 'ClCompile', | 2951 _ToolAppend(msbuild_settings, 'ClCompile', |
| 2946 'AdditionalIncludeDirectories', include_dirs) | 2952 'AdditionalIncludeDirectories', include_dirs) |
| 2953 _ToolAppend(msbuild_settings, 'Midl', | |
| 2954 'AdditionalIncludeDirectories', midl_include_dirs) | |
| 2947 _ToolAppend(msbuild_settings, 'ResourceCompile', | 2955 _ToolAppend(msbuild_settings, 'ResourceCompile', |
| 2948 'AdditionalIncludeDirectories', resource_include_dirs) | 2956 'AdditionalIncludeDirectories', resource_include_dirs) |
| 2949 # Add in libraries, note that even for empty libraries, we want this | 2957 # Add in libraries, note that even for empty libraries, we want this |
| 2950 # set, to prevent inheriting default libraries from the enviroment. | 2958 # set, to prevent inheriting default libraries from the enviroment. |
| 2951 _ToolSetOrAppend(msbuild_settings, 'Link', 'AdditionalDependencies', | 2959 _ToolSetOrAppend(msbuild_settings, 'Link', 'AdditionalDependencies', |
| 2952 libraries) | 2960 libraries) |
| 2953 _ToolAppend(msbuild_settings, 'Link', 'AdditionalLibraryDirectories', | 2961 _ToolAppend(msbuild_settings, 'Link', 'AdditionalLibraryDirectories', |
| 2954 library_dirs) | 2962 library_dirs) |
| 2955 if out_file: | 2963 if out_file: |
| 2956 _ToolAppend(msbuild_settings, msbuild_tool, 'OutputFile', out_file, | 2964 _ToolAppend(msbuild_settings, msbuild_tool, 'OutputFile', out_file, |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3355 action_spec.extend( | 3363 action_spec.extend( |
| 3356 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3364 # TODO(jeanluc) 'Document' for all or just if as_sources? |
| 3357 [['FileType', 'Document'], | 3365 [['FileType', 'Document'], |
| 3358 ['Command', command], | 3366 ['Command', command], |
| 3359 ['Message', description], | 3367 ['Message', description], |
| 3360 ['Outputs', outputs] | 3368 ['Outputs', outputs] |
| 3361 ]) | 3369 ]) |
| 3362 if additional_inputs: | 3370 if additional_inputs: |
| 3363 action_spec.append(['AdditionalInputs', additional_inputs]) | 3371 action_spec.append(['AdditionalInputs', additional_inputs]) |
| 3364 actions_spec.append(action_spec) | 3372 actions_spec.append(action_spec) |
| OLD | NEW |