| 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 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 gyp_file = os.path.split(project.build_file)[1] | 911 gyp_file = os.path.split(project.build_file)[1] |
| 912 sources, excluded_sources = _PrepareListOfSources(spec, generator_flags, | 912 sources, excluded_sources = _PrepareListOfSources(spec, generator_flags, |
| 913 gyp_file) | 913 gyp_file) |
| 914 | 914 |
| 915 # Add rules. | 915 # Add rules. |
| 916 actions_to_add = {} | 916 actions_to_add = {} |
| 917 _GenerateRulesForMSVS(p, project_dir, options, spec, | 917 _GenerateRulesForMSVS(p, project_dir, options, spec, |
| 918 sources, excluded_sources, | 918 sources, excluded_sources, |
| 919 actions_to_add) | 919 actions_to_add) |
| 920 list_excluded = generator_flags.get('msvs_list_excluded_files', True) | 920 list_excluded = generator_flags.get('msvs_list_excluded_files', True) |
| 921 sources, excluded_sources, excluded_idl = ( | 921 sources, excluded_sources, excluded_custom_files = ( |
| 922 _AdjustSourcesAndConvertToFilterHierarchy( | 922 _AdjustSourcesAndConvertToFilterHierarchy( |
| 923 spec, options, project_dir, sources, excluded_sources, list_excluded)) | 923 spec, options, project_dir, sources, excluded_sources, list_excluded)) |
| 924 | 924 |
| 925 # Add in files. | 925 # Add in files. |
| 926 missing_sources = _VerifySourcesExist(sources, project_dir) | 926 missing_sources = _VerifySourcesExist(sources, project_dir) |
| 927 p.AddFiles(sources) | 927 p.AddFiles(sources) |
| 928 | 928 |
| 929 _AddToolFilesToMSVS(p, spec) | 929 _AddToolFilesToMSVS(p, spec) |
| 930 _HandlePreCompiledHeaders(p, sources, spec) | 930 _HandlePreCompiledHeaders(p, sources, spec) |
| 931 _AddActions(actions_to_add, spec, relative_path_of_gyp_file) | 931 _AddActions(actions_to_add, spec, relative_path_of_gyp_file) |
| 932 _AddCopies(actions_to_add, spec) | 932 _AddCopies(actions_to_add, spec) |
| 933 _WriteMSVSUserFile(project.path, version, spec) | 933 _WriteMSVSUserFile(project.path, version, spec) |
| 934 | 934 |
| 935 # NOTE: this stanza must appear after all actions have been decided. | 935 # NOTE: this stanza must appear after all actions have been decided. |
| 936 # Don't excluded sources with actions attached, or they won't run. | 936 # Don't excluded sources with actions attached, or they won't run. |
| 937 excluded_sources = _FilterActionsFromExcluded( | 937 excluded_sources = _FilterActionsFromExcluded( |
| 938 excluded_sources, actions_to_add) | 938 excluded_sources, actions_to_add) |
| 939 _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl, | 939 _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_custom_files, |
| 940 list_excluded) | 940 list_excluded) |
| 941 _AddAccumulatedActionsToMSVS(p, spec, actions_to_add) | 941 _AddAccumulatedActionsToMSVS(p, spec, actions_to_add) |
| 942 | 942 |
| 943 # Write it out. | 943 # Write it out. |
| 944 p.WriteIfChanged() | 944 p.WriteIfChanged() |
| 945 | 945 |
| 946 return missing_sources | 946 return missing_sources |
| 947 | 947 |
| 948 | 948 |
| 949 def _GetUniquePlatforms(spec): | 949 def _GetUniquePlatforms(spec): |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 | 1018 |
| 1019 Arguments: | 1019 Arguments: |
| 1020 p: The target project being generated. | 1020 p: The target project being generated. |
| 1021 spec: The target dictionary containing the properties of the target. | 1021 spec: The target dictionary containing the properties of the target. |
| 1022 config_type: The configuration type, a number as defined by Microsoft. | 1022 config_type: The configuration type, a number as defined by Microsoft. |
| 1023 config_name: The name of the configuration. | 1023 config_name: The name of the configuration. |
| 1024 config: The dictionnary that defines the special processing to be done | 1024 config: The dictionnary that defines the special processing to be done |
| 1025 for this configuration. | 1025 for this configuration. |
| 1026 """ | 1026 """ |
| 1027 # Get the information for this configuration | 1027 # Get the information for this configuration |
| 1028 include_dirs, resource_include_dirs = _GetIncludeDirs(config) | 1028 include_dirs, resource_include_dirs, _ = _GetIncludeDirs(config) |
| 1029 libraries = _GetLibraries(spec) | 1029 libraries = _GetLibraries(spec) |
| 1030 out_file, vc_tool, _ = _GetOutputFilePathAndTool(spec, msbuild=False) | 1030 out_file, vc_tool, _ = _GetOutputFilePathAndTool(spec, msbuild=False) |
| 1031 defines = _GetDefines(config) | 1031 defines = _GetDefines(config) |
| 1032 defines = [_EscapeCppDefineForMSVS(d) for d in defines] | 1032 defines = [_EscapeCppDefineForMSVS(d) for d in defines] |
| 1033 disabled_warnings = _GetDisabledWarnings(config) | 1033 disabled_warnings = _GetDisabledWarnings(config) |
| 1034 prebuild = config.get('msvs_prebuild') | 1034 prebuild = config.get('msvs_prebuild') |
| 1035 postbuild = config.get('msvs_postbuild') | 1035 postbuild = config.get('msvs_postbuild') |
| 1036 def_file = _GetModuleDefinition(spec) | 1036 def_file = _GetModuleDefinition(spec) |
| 1037 precompiled_header = config.get('msvs_precompiled_header') | 1037 precompiled_header = config.get('msvs_precompiled_header') |
| 1038 | 1038 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 _AddConfigurationToMSVS(p, spec, tools, config, config_type, config_name) | 1087 _AddConfigurationToMSVS(p, spec, tools, config, config_type, config_name) |
| 1088 | 1088 |
| 1089 | 1089 |
| 1090 def _GetIncludeDirs(config): | 1090 def _GetIncludeDirs(config): |
| 1091 """Returns the list of directories to be used for #include directives. | 1091 """Returns the list of directories to be used for #include directives. |
| 1092 | 1092 |
| 1093 Arguments: | 1093 Arguments: |
| 1094 config: The dictionnary that defines the special processing to be done | 1094 config: The dictionnary that defines the special processing to be done |
| 1095 for this configuration. | 1095 for this configuration. |
| 1096 Returns: | 1096 Returns: |
| 1097 The list of directory paths. | 1097 A triple of (C++ include directory paths, Resource Compiler include |
| 1098 directory paths, MASM include directory paths) |
| 1098 """ | 1099 """ |
| 1099 # TODO(bradnelson): include_dirs should really be flexible enough not to | 1100 # TODO(bradnelson): include_dirs should really be flexible enough not to |
| 1100 # require this sort of thing. | 1101 # require this sort of thing. |
| 1101 include_dirs = ( | 1102 include_dirs = ( |
| 1102 config.get('include_dirs', []) + | 1103 config.get('include_dirs', []) + |
| 1103 config.get('msvs_system_include_dirs', [])) | 1104 config.get('msvs_system_include_dirs', [])) |
| 1104 resource_include_dirs = config.get('resource_include_dirs', include_dirs) | 1105 resource_include_dirs = config.get('resource_include_dirs', include_dirs) |
| 1106 masm_include_dirs = config.get('masm_include_dirs', include_dirs) |
| 1105 include_dirs = _FixPaths(include_dirs) | 1107 include_dirs = _FixPaths(include_dirs) |
| 1106 resource_include_dirs = _FixPaths(resource_include_dirs) | 1108 resource_include_dirs = _FixPaths(resource_include_dirs) |
| 1107 return include_dirs, resource_include_dirs | 1109 masm_include_dirs = _FixPaths(masm_include_dirs) |
| 1110 return include_dirs, resource_include_dirs, masm_include_dirs |
| 1108 | 1111 |
| 1109 | 1112 |
| 1110 def _GetLibraries(spec): | 1113 def _GetLibraries(spec): |
| 1111 """Returns the list of libraries for this configuration. | 1114 """Returns the list of libraries for this configuration. |
| 1112 | 1115 |
| 1113 Arguments: | 1116 Arguments: |
| 1114 spec: The target dictionary containing the properties of the target. | 1117 spec: The target dictionary containing the properties of the target. |
| 1115 Returns: | 1118 Returns: |
| 1116 The list of directory paths. | 1119 The list of directory paths. |
| 1117 """ | 1120 """ |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 Also converts the sets to lists. | 1333 Also converts the sets to lists. |
| 1331 | 1334 |
| 1332 Arguments: | 1335 Arguments: |
| 1333 spec: The target dictionary containing the properties of the target. | 1336 spec: The target dictionary containing the properties of the target. |
| 1334 options: Global generator options. | 1337 options: Global generator options. |
| 1335 gyp_dir: The path to the gyp file being processed. | 1338 gyp_dir: The path to the gyp file being processed. |
| 1336 sources: A set of sources to be included for this project. | 1339 sources: A set of sources to be included for this project. |
| 1337 excluded_sources: A set of sources to be excluded for this project. | 1340 excluded_sources: A set of sources to be excluded for this project. |
| 1338 Returns: | 1341 Returns: |
| 1339 A trio of (list of sources, list of excluded sources, | 1342 A trio of (list of sources, list of excluded sources, |
| 1340 path of excluded IDL file) | 1343 path of excluded files being handled by non-MSVS-native rules) |
| 1341 """ | 1344 """ |
| 1342 # Exclude excluded sources coming into the generator. | 1345 # Exclude excluded sources coming into the generator. |
| 1343 excluded_sources.update(set(spec.get('sources_excluded', []))) | 1346 excluded_sources.update(set(spec.get('sources_excluded', []))) |
| 1344 # Add excluded sources into sources for good measure. | 1347 # Add excluded sources into sources for good measure. |
| 1345 sources.update(excluded_sources) | 1348 sources.update(excluded_sources) |
| 1346 # Convert to proper windows form. | 1349 # Convert to proper windows form. |
| 1347 # NOTE: sources goes from being a set to a list here. | 1350 # NOTE: sources goes from being a set to a list here. |
| 1348 # NOTE: excluded_sources goes from being a set to a list here. | 1351 # NOTE: excluded_sources goes from being a set to a list here. |
| 1349 sources = _FixPaths(sources) | 1352 sources = _FixPaths(sources) |
| 1350 # Convert to proper windows form. | 1353 # Convert to proper windows form. |
| 1351 excluded_sources = _FixPaths(excluded_sources) | 1354 excluded_sources = _FixPaths(excluded_sources) |
| 1352 | 1355 |
| 1353 excluded_idl = _IdlFilesHandledNonNatively(spec, sources) | 1356 excluded_custom_files = _FilesHandledNonNatively(spec, sources) |
| 1354 | 1357 |
| 1355 precompiled_related = _GetPrecompileRelatedFiles(spec) | 1358 precompiled_related = _GetPrecompileRelatedFiles(spec) |
| 1356 # Find the excluded ones, minus the precompiled header related ones. | 1359 # Find the excluded ones, minus the precompiled header related ones. |
| 1357 fully_excluded = [i for i in excluded_sources if i not in precompiled_related] | 1360 fully_excluded = [i for i in excluded_sources if i not in precompiled_related] |
| 1358 | 1361 |
| 1359 # Convert to folders and the right slashes. | 1362 # Convert to folders and the right slashes. |
| 1360 sources = [i.split('\\') for i in sources] | 1363 sources = [i.split('\\') for i in sources] |
| 1361 sources = _ConvertSourcesToFilterHierarchy(sources, excluded=fully_excluded, | 1364 sources = _ConvertSourcesToFilterHierarchy(sources, excluded=fully_excluded, |
| 1362 list_excluded=list_excluded) | 1365 list_excluded=list_excluded) |
| 1363 | 1366 |
| 1364 return sources, excluded_sources, excluded_idl | 1367 return sources, excluded_sources, excluded_custom_files |
| 1365 | 1368 |
| 1366 | 1369 |
| 1367 def _IdlFilesHandledNonNatively(spec, sources): | 1370 def _FilesHandledNonNatively(spec, sources): |
| 1368 # If any non-native rules use 'idl' as an extension exclude idl files. | 1371 # If any non-native rules exist for extensions normally handled by MSVS, such |
| 1372 # as .idl or .asm, then exclude files with those extensions. |
| 1369 # Gather a list here to use later. | 1373 # Gather a list here to use later. |
| 1370 using_idl = False | 1374 excluded_files = [] |
| 1371 for rule in spec.get('rules', []): | 1375 for extension in ['idl', 'asm']: |
| 1372 if rule['extension'] == 'idl' and int(rule.get('msvs_external_rule', 0)): | 1376 using_custom_rule = False |
| 1373 using_idl = True | 1377 for rule in spec.get('rules', []): |
| 1374 break | 1378 if (rule['extension'] == extension and |
| 1375 if using_idl: | 1379 int(rule.get('msvs_external_rule', 0))): |
| 1376 excluded_idl = [i for i in sources if i.endswith('.idl')] | 1380 using_custom_rule = True |
| 1377 else: | 1381 break |
| 1378 excluded_idl = [] | 1382 if using_custom_rule: |
| 1379 return excluded_idl | 1383 excluded_files.extend([i for i in sources if i.endswith('.' + extension)]) |
| 1384 return excluded_files |
| 1380 | 1385 |
| 1381 | 1386 |
| 1382 def _GetPrecompileRelatedFiles(spec): | 1387 def _GetPrecompileRelatedFiles(spec): |
| 1383 # Gather a list of precompiled header related sources. | 1388 # Gather a list of precompiled header related sources. |
| 1384 precompiled_related = [] | 1389 precompiled_related = [] |
| 1385 for _, config in spec['configurations'].iteritems(): | 1390 for _, config in spec['configurations'].iteritems(): |
| 1386 for k in precomp_keys: | 1391 for k in precomp_keys: |
| 1387 f = config.get(k) | 1392 f = config.get(k) |
| 1388 if f: | 1393 if f: |
| 1389 precompiled_related.append(_FixPath(f)) | 1394 precompiled_related.append(_FixPath(f)) |
| 1390 return precompiled_related | 1395 return precompiled_related |
| 1391 | 1396 |
| 1392 | 1397 |
| 1393 def _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl, | 1398 def _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, |
| 1394 list_excluded): | 1399 excluded_custom_files, list_excluded): |
| 1395 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) | 1400 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, |
| 1401 excluded_custom_files) |
| 1396 for file_name, excluded_configs in exclusions.iteritems(): | 1402 for file_name, excluded_configs in exclusions.iteritems(): |
| 1397 if (not list_excluded and | 1403 if (not list_excluded and |
| 1398 len(excluded_configs) == len(spec['configurations'])): | 1404 len(excluded_configs) == len(spec['configurations'])): |
| 1399 # If we're not listing excluded files, then they won't appear in the | 1405 # If we're not listing excluded files, then they won't appear in the |
| 1400 # project, so don't try to configure them to be excluded. | 1406 # project, so don't try to configure them to be excluded. |
| 1401 pass | 1407 pass |
| 1402 else: | 1408 else: |
| 1403 for config_name, config in excluded_configs: | 1409 for config_name, config in excluded_configs: |
| 1404 p.AddFileConfig(file_name, _ConfigFullName(config_name, config), | 1410 p.AddFileConfig(file_name, _ConfigFullName(config_name, config), |
| 1405 {'ExcludedFromBuild': 'true'}) | 1411 {'ExcludedFromBuild': 'true'}) |
| 1406 | 1412 |
| 1407 | 1413 |
| 1408 def _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl): | 1414 def _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_custom_files): |
| 1409 exclusions = {} | 1415 exclusions = {} |
| 1410 # Exclude excluded sources from being built. | 1416 # Exclude excluded sources from being built. |
| 1411 for f in excluded_sources: | 1417 for f in excluded_sources: |
| 1412 excluded_configs = [] | 1418 excluded_configs = [] |
| 1413 for config_name, config in spec['configurations'].iteritems(): | 1419 for config_name, config in spec['configurations'].iteritems(): |
| 1414 precomped = [_FixPath(config.get(i, '')) for i in precomp_keys] | 1420 precomped = [_FixPath(config.get(i, '')) for i in precomp_keys] |
| 1415 # Don't do this for ones that are precompiled header related. | 1421 # Don't do this for ones that are precompiled header related. |
| 1416 if f not in precomped: | 1422 if f not in precomped: |
| 1417 excluded_configs.append((config_name, config)) | 1423 excluded_configs.append((config_name, config)) |
| 1418 exclusions[f] = excluded_configs | 1424 exclusions[f] = excluded_configs |
| 1419 # If any non-native rules use 'idl' as an extension exclude idl files. | 1425 # If any non-native rules use 'idl' as an extension exclude idl files. |
| 1420 # Exclude them now. | 1426 # Exclude them now. |
| 1421 for f in excluded_idl: | 1427 for f in excluded_custom_files: |
| 1422 excluded_configs = [] | 1428 excluded_configs = [] |
| 1423 for config_name, config in spec['configurations'].iteritems(): | 1429 for config_name, config in spec['configurations'].iteritems(): |
| 1424 excluded_configs.append((config_name, config)) | 1430 excluded_configs.append((config_name, config)) |
| 1425 exclusions[f] = excluded_configs | 1431 exclusions[f] = excluded_configs |
| 1426 return exclusions | 1432 return exclusions |
| 1427 | 1433 |
| 1428 | 1434 |
| 1429 def _AddToolFilesToMSVS(p, spec): | 1435 def _AddToolFilesToMSVS(p, spec): |
| 1430 # Add in tool files (rules). | 1436 # Add in tool files (rules). |
| 1431 tool_files = set() | 1437 tool_files = set() |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 element = 'ClCompile' | 1970 element = 'ClCompile' |
| 1965 elif ext in ['.h', '.hxx']: | 1971 elif ext in ['.h', '.hxx']: |
| 1966 group = 'include' | 1972 group = 'include' |
| 1967 element = 'ClInclude' | 1973 element = 'ClInclude' |
| 1968 elif ext == '.rc': | 1974 elif ext == '.rc': |
| 1969 group = 'resource' | 1975 group = 'resource' |
| 1970 element = 'ResourceCompile' | 1976 element = 'ResourceCompile' |
| 1971 elif ext == '.idl': | 1977 elif ext == '.idl': |
| 1972 group = 'midl' | 1978 group = 'midl' |
| 1973 element = 'Midl' | 1979 element = 'Midl' |
| 1980 elif ext == '.asm': |
| 1981 group = 'masm' |
| 1982 element = 'MASM' |
| 1974 else: | 1983 else: |
| 1975 group = 'none' | 1984 group = 'none' |
| 1976 element = 'None' | 1985 element = 'None' |
| 1977 return (group, element) | 1986 return (group, element) |
| 1978 | 1987 |
| 1979 | 1988 |
| 1980 def _GenerateRulesForMSBuild(output_dir, options, spec, | 1989 def _GenerateRulesForMSBuild(output_dir, options, spec, |
| 1981 sources, excluded_sources, | 1990 sources, excluded_sources, |
| 1982 props_files_of_rules, targets_files_of_rules, | 1991 props_files_of_rules, targets_files_of_rules, |
| 1983 actions_to_add, extension_to_rule_name): | 1992 actions_to_add, extension_to_rule_name): |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2771 | 2780 |
| 2772 def _FinalizeMSBuildSettings(spec, configuration): | 2781 def _FinalizeMSBuildSettings(spec, configuration): |
| 2773 if 'msbuild_settings' in configuration: | 2782 if 'msbuild_settings' in configuration: |
| 2774 converted = False | 2783 converted = False |
| 2775 msbuild_settings = configuration['msbuild_settings'] | 2784 msbuild_settings = configuration['msbuild_settings'] |
| 2776 MSVSSettings.ValidateMSBuildSettings(msbuild_settings) | 2785 MSVSSettings.ValidateMSBuildSettings(msbuild_settings) |
| 2777 else: | 2786 else: |
| 2778 converted = True | 2787 converted = True |
| 2779 msvs_settings = configuration.get('msvs_settings', {}) | 2788 msvs_settings = configuration.get('msvs_settings', {}) |
| 2780 msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings) | 2789 msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings) |
| 2781 include_dirs, resource_include_dirs = _GetIncludeDirs(configuration) | 2790 include_dirs, resource_include_dirs, masm_include_dirs = \ |
| 2791 _GetIncludeDirs(configuration) |
| 2782 libraries = _GetLibraries(spec) | 2792 libraries = _GetLibraries(spec) |
| 2783 out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec, msbuild=True) | 2793 out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec, msbuild=True) |
| 2784 defines = _GetDefines(configuration) | 2794 defines = _GetDefines(configuration) |
| 2785 if converted: | 2795 if converted: |
| 2786 # Visual Studio 2010 has TR1 | 2796 # Visual Studio 2010 has TR1 |
| 2787 defines = [d for d in defines if d != '_HAS_TR1=0'] | 2797 defines = [d for d in defines if d != '_HAS_TR1=0'] |
| 2788 # Warn of ignored settings | 2798 # Warn of ignored settings |
| 2789 ignored_settings = ['msvs_prebuild', 'msvs_postbuild', 'msvs_tool_files'] | 2799 ignored_settings = ['msvs_prebuild', 'msvs_postbuild', 'msvs_tool_files'] |
| 2790 for ignored_setting in ignored_settings: | 2800 for ignored_setting in ignored_settings: |
| 2791 value = configuration.get(ignored_setting) | 2801 value = configuration.get(ignored_setting) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2802 precompiled_header = configuration.get('msvs_precompiled_header') | 2812 precompiled_header = configuration.get('msvs_precompiled_header') |
| 2803 | 2813 |
| 2804 # Add the information to the appropriate tool | 2814 # Add the information to the appropriate tool |
| 2805 # TODO(jeanluc) We could optimize and generate these settings only if | 2815 # TODO(jeanluc) We could optimize and generate these settings only if |
| 2806 # the corresponding files are found, e.g. don't generate ResourceCompile | 2816 # the corresponding files are found, e.g. don't generate ResourceCompile |
| 2807 # if you don't have any resources. | 2817 # if you don't have any resources. |
| 2808 _ToolAppend(msbuild_settings, 'ClCompile', | 2818 _ToolAppend(msbuild_settings, 'ClCompile', |
| 2809 'AdditionalIncludeDirectories', include_dirs) | 2819 'AdditionalIncludeDirectories', include_dirs) |
| 2810 _ToolAppend(msbuild_settings, 'ResourceCompile', | 2820 _ToolAppend(msbuild_settings, 'ResourceCompile', |
| 2811 'AdditionalIncludeDirectories', resource_include_dirs) | 2821 'AdditionalIncludeDirectories', resource_include_dirs) |
| 2822 _ToolAppend(msbuild_settings, 'MASM', |
| 2823 'AdditionalIncludeDirectories', masm_include_dirs) |
| 2812 # Add in libraries. | 2824 # Add in libraries. |
| 2813 _ToolAppend(msbuild_settings, 'Link', 'AdditionalDependencies', libraries) | 2825 _ToolAppend(msbuild_settings, 'Link', 'AdditionalDependencies', libraries) |
| 2814 if out_file: | 2826 if out_file: |
| 2815 _ToolAppend(msbuild_settings, msbuild_tool, 'OutputFile', out_file, | 2827 _ToolAppend(msbuild_settings, msbuild_tool, 'OutputFile', out_file, |
| 2816 only_if_unset=True) | 2828 only_if_unset=True) |
| 2817 # Add defines. | 2829 # Add defines. |
| 2818 _ToolAppend(msbuild_settings, 'ClCompile', | 2830 _ToolAppend(msbuild_settings, 'ClCompile', |
| 2819 'PreprocessorDefinitions', defines) | 2831 'PreprocessorDefinitions', defines) |
| 2820 _ToolAppend(msbuild_settings, 'ResourceCompile', | 2832 _ToolAppend(msbuild_settings, 'ResourceCompile', |
| 2821 'PreprocessorDefinitions', defines) | 2833 'PreprocessorDefinitions', defines) |
| 2834 _ToolAppend(msbuild_settings, 'MASM', |
| 2835 'PreprocessorDefinitions', defines) |
| 2822 # Add disabled warnings. | 2836 # Add disabled warnings. |
| 2823 _ToolAppend(msbuild_settings, 'ClCompile', | 2837 _ToolAppend(msbuild_settings, 'ClCompile', |
| 2824 'DisableSpecificWarnings', disabled_warnings) | 2838 'DisableSpecificWarnings', disabled_warnings) |
| 2825 # Turn on precompiled headers if appropriate. | 2839 # Turn on precompiled headers if appropriate. |
| 2826 if precompiled_header: | 2840 if precompiled_header: |
| 2827 precompiled_header = os.path.split(precompiled_header)[1] | 2841 precompiled_header = os.path.split(precompiled_header)[1] |
| 2828 _ToolAppend(msbuild_settings, 'ClCompile', 'PrecompiledHeader', 'Use') | 2842 _ToolAppend(msbuild_settings, 'ClCompile', 'PrecompiledHeader', 'Use') |
| 2829 _ToolAppend(msbuild_settings, 'ClCompile', | 2843 _ToolAppend(msbuild_settings, 'ClCompile', |
| 2830 'PrecompiledHeaderFile', precompiled_header) | 2844 'PrecompiledHeaderFile', precompiled_header) |
| 2831 _ToolAppend(msbuild_settings, 'ClCompile', | 2845 _ToolAppend(msbuild_settings, 'ClCompile', |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2889 else: | 2903 else: |
| 2890 if '$' not in source: | 2904 if '$' not in source: |
| 2891 full_path = os.path.join(root_dir, source) | 2905 full_path = os.path.join(root_dir, source) |
| 2892 if not os.path.exists(full_path): | 2906 if not os.path.exists(full_path): |
| 2893 missing_sources.append(full_path) | 2907 missing_sources.append(full_path) |
| 2894 return missing_sources | 2908 return missing_sources |
| 2895 | 2909 |
| 2896 | 2910 |
| 2897 def _GetMSBuildSources(spec, sources, exclusions, extension_to_rule_name, | 2911 def _GetMSBuildSources(spec, sources, exclusions, extension_to_rule_name, |
| 2898 actions_spec, sources_handled_by_action, list_excluded): | 2912 actions_spec, sources_handled_by_action, list_excluded): |
| 2899 groups = ['none', 'midl', 'include', 'compile', 'resource', 'rule'] | 2913 groups = ['none', 'midl', 'masm', 'include', 'compile', 'resource', 'rule'] |
| 2900 grouped_sources = {} | 2914 grouped_sources = {} |
| 2901 for g in groups: | 2915 for g in groups: |
| 2902 grouped_sources[g] = [] | 2916 grouped_sources[g] = [] |
| 2903 | 2917 |
| 2904 _AddSources2(spec, sources, exclusions, grouped_sources, | 2918 _AddSources2(spec, sources, exclusions, grouped_sources, |
| 2905 extension_to_rule_name, sources_handled_by_action, list_excluded) | 2919 extension_to_rule_name, sources_handled_by_action, list_excluded) |
| 2906 sources = [] | 2920 sources = [] |
| 2907 for g in groups: | 2921 for g in groups: |
| 2908 if grouped_sources[g]: | 2922 if grouped_sources[g]: |
| 2909 sources.append(['ItemGroup'] + grouped_sources[g]) | 2923 sources.append(['ItemGroup'] + grouped_sources[g]) |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3007 # Add rules. | 3021 # Add rules. |
| 3008 actions_to_add = {} | 3022 actions_to_add = {} |
| 3009 props_files_of_rules = set() | 3023 props_files_of_rules = set() |
| 3010 targets_files_of_rules = set() | 3024 targets_files_of_rules = set() |
| 3011 extension_to_rule_name = {} | 3025 extension_to_rule_name = {} |
| 3012 list_excluded = generator_flags.get('msvs_list_excluded_files', True) | 3026 list_excluded = generator_flags.get('msvs_list_excluded_files', True) |
| 3013 _GenerateRulesForMSBuild(project_dir, options, spec, | 3027 _GenerateRulesForMSBuild(project_dir, options, spec, |
| 3014 sources, excluded_sources, | 3028 sources, excluded_sources, |
| 3015 props_files_of_rules, targets_files_of_rules, | 3029 props_files_of_rules, targets_files_of_rules, |
| 3016 actions_to_add, extension_to_rule_name) | 3030 actions_to_add, extension_to_rule_name) |
| 3017 sources, excluded_sources, excluded_idl = ( | 3031 sources, excluded_sources, excluded_custom_files = ( |
| 3018 _AdjustSourcesAndConvertToFilterHierarchy(spec, options, | 3032 _AdjustSourcesAndConvertToFilterHierarchy(spec, options, |
| 3019 project_dir, sources, | 3033 project_dir, sources, |
| 3020 excluded_sources, | 3034 excluded_sources, |
| 3021 list_excluded)) | 3035 list_excluded)) |
| 3022 _AddActions(actions_to_add, spec, project.build_file) | 3036 _AddActions(actions_to_add, spec, project.build_file) |
| 3023 _AddCopies(actions_to_add, spec) | 3037 _AddCopies(actions_to_add, spec) |
| 3024 | 3038 |
| 3025 # NOTE: this stanza must appear after all actions have been decided. | 3039 # NOTE: this stanza must appear after all actions have been decided. |
| 3026 # Don't excluded sources with actions attached, or they won't run. | 3040 # Don't excluded sources with actions attached, or they won't run. |
| 3027 excluded_sources = _FilterActionsFromExcluded( | 3041 excluded_sources = _FilterActionsFromExcluded( |
| 3028 excluded_sources, actions_to_add) | 3042 excluded_sources, actions_to_add) |
| 3029 | 3043 |
| 3030 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) | 3044 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, |
| 3045 excluded_custom_files) |
| 3031 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( | 3046 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( |
| 3032 spec, actions_to_add) | 3047 spec, actions_to_add) |
| 3033 | 3048 |
| 3034 _GenerateMSBuildFiltersFile(project.path + '.filters', sources, | 3049 _GenerateMSBuildFiltersFile(project.path + '.filters', sources, |
| 3035 extension_to_rule_name) | 3050 extension_to_rule_name) |
| 3036 missing_sources = _VerifySourcesExist(sources, project_dir) | 3051 missing_sources = _VerifySourcesExist(sources, project_dir) |
| 3037 | 3052 |
| 3038 for configuration in configurations.itervalues(): | 3053 for configuration in configurations.itervalues(): |
| 3039 _FinalizeMSBuildSettings(spec, configuration) | 3054 _FinalizeMSBuildSettings(spec, configuration) |
| 3040 | 3055 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3079 | 3094 |
| 3080 easy_xml.WriteXmlIfChanged(content, project.path, pretty=True, win32=True) | 3095 easy_xml.WriteXmlIfChanged(content, project.path, pretty=True, win32=True) |
| 3081 | 3096 |
| 3082 return missing_sources | 3097 return missing_sources |
| 3083 | 3098 |
| 3084 | 3099 |
| 3085 def _GetMSBuildExtensions(props_files_of_rules): | 3100 def _GetMSBuildExtensions(props_files_of_rules): |
| 3086 extensions = ['ImportGroup', {'Label': 'ExtensionSettings'}] | 3101 extensions = ['ImportGroup', {'Label': 'ExtensionSettings'}] |
| 3087 for props_file in props_files_of_rules: | 3102 for props_file in props_files_of_rules: |
| 3088 extensions.append(['Import', {'Project': props_file}]) | 3103 extensions.append(['Import', {'Project': props_file}]) |
| 3104 extensions.append( |
| 3105 ['Import', {'Project': |
| 3106 r'$(VCTargetsPath)\BuildCustomizations\masm.props'}]) |
| 3089 return [extensions] | 3107 return [extensions] |
| 3090 | 3108 |
| 3091 | 3109 |
| 3092 def _GetMSBuildExtensionTargets(targets_files_of_rules): | 3110 def _GetMSBuildExtensionTargets(targets_files_of_rules): |
| 3093 targets_node = ['ImportGroup', {'Label': 'ExtensionTargets'}] | 3111 targets_node = ['ImportGroup', {'Label': 'ExtensionTargets'}] |
| 3094 for targets_file in sorted(targets_files_of_rules): | 3112 for targets_file in sorted(targets_files_of_rules): |
| 3095 targets_node.append(['Import', {'Project': targets_file}]) | 3113 targets_node.append(['Import', {'Project': targets_file}]) |
| 3114 targets_node.append( |
| 3115 ['Import', {'Project': |
| 3116 r'$(VCTargetsPath)\BuildCustomizations\masm.targets'}]) |
| 3096 return [targets_node] | 3117 return [targets_node] |
| 3097 | 3118 |
| 3098 | 3119 |
| 3099 def _GenerateActionsForMSBuild(spec, actions_to_add): | 3120 def _GenerateActionsForMSBuild(spec, actions_to_add): |
| 3100 """Add actions accumulated into an actions_to_add, merging as needed. | 3121 """Add actions accumulated into an actions_to_add, merging as needed. |
| 3101 | 3122 |
| 3102 Arguments: | 3123 Arguments: |
| 3103 spec: the target project dict | 3124 spec: the target project dict |
| 3104 actions_to_add: dictionary keyed on input name, which maps to a list of | 3125 actions_to_add: dictionary keyed on input name, which maps to a list of |
| 3105 dicts describing the actions attached to that input file. | 3126 dicts describing the actions attached to that input file. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3160 action_spec.extend( | 3181 action_spec.extend( |
| 3161 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3182 # TODO(jeanluc) 'Document' for all or just if as_sources? |
| 3162 [['FileType', 'Document'], | 3183 [['FileType', 'Document'], |
| 3163 ['Command', command], | 3184 ['Command', command], |
| 3164 ['Message', description], | 3185 ['Message', description], |
| 3165 ['Outputs', outputs] | 3186 ['Outputs', outputs] |
| 3166 ]) | 3187 ]) |
| 3167 if additional_inputs: | 3188 if additional_inputs: |
| 3168 action_spec.append(['AdditionalInputs', additional_inputs]) | 3189 action_spec.append(['AdditionalInputs', additional_inputs]) |
| 3169 actions_spec.append(action_spec) | 3190 actions_spec.append(action_spec) |
| OLD | NEW |