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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 cmd = [_RuleExpandPath(c, tf) for c in rule['action']] | 585 cmd = [_RuleExpandPath(c, tf) for c in rule['action']] |
| 586 cmd = ['"%s"' % i for i in cmd] | 586 cmd = ['"%s"' % i for i in cmd] |
| 587 cmd = ' '.join(cmd) | 587 cmd = ' '.join(cmd) |
| 588 # Add it to the makefile. | 588 # Add it to the makefile. |
| 589 mk_file.write('%s: %s\n' % (' '.join(outputs), ' '.join(inputs))) | 589 mk_file.write('%s: %s\n' % (' '.join(outputs), ' '.join(inputs))) |
| 590 mk_file.write('\t%s\n\n' % cmd) | 590 mk_file.write('\t%s\n\n' % cmd) |
| 591 # Close up the file. | 591 # Close up the file. |
| 592 mk_file.close() | 592 mk_file.close() |
| 593 | 593 |
| 594 # Add makefile to list of sources. | 594 # Add makefile to list of sources. |
| 595 sources.add(filename) | 595 sources.add(filename) |
|
Nico
2013/12/06 16:28:29
Will this still work?
| |
| 596 # Add a build action to call makefile. | 596 # Add a build action to call makefile. |
| 597 cmd = ['make', | 597 cmd = ['make', |
| 598 'OutDir=$(OutDir)', | 598 'OutDir=$(OutDir)', |
| 599 'IntDir=$(IntDir)', | 599 'IntDir=$(IntDir)', |
| 600 '-j', '${NUMBER_OF_PROCESSORS_PLUS_1}', | 600 '-j', '${NUMBER_OF_PROCESSORS_PLUS_1}', |
| 601 '-f', filename] | 601 '-f', filename] |
| 602 cmd = _BuildCommandLineForRuleRaw(spec, cmd, True, False, True, True) | 602 cmd = _BuildCommandLineForRuleRaw(spec, cmd, True, False, True, True) |
| 603 # Insert makefile as 0'th input, so it gets the action attached there, | 603 # Insert makefile as 0'th input, so it gets the action attached there, |
| 604 # as this is easier to understand from in the IDE. | 604 # as this is easier to understand from in the IDE. |
| 605 all_inputs = list(all_inputs) | 605 all_inputs = list(all_inputs) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 795 for rule in rules: | 795 for rule in rules: |
| 796 # Done if not processing outputs as sources. | 796 # Done if not processing outputs as sources. |
| 797 if int(rule.get('process_outputs_as_sources', False)): | 797 if int(rule.get('process_outputs_as_sources', False)): |
| 798 # Add in the outputs from this rule. | 798 # Add in the outputs from this rule. |
| 799 trigger_files = _FindRuleTriggerFiles(rule, sources) | 799 trigger_files = _FindRuleTriggerFiles(rule, sources) |
| 800 for trigger_file in trigger_files: | 800 for trigger_file in trigger_files: |
| 801 inputs, outputs = _RuleInputsAndOutputs(rule, trigger_file) | 801 inputs, outputs = _RuleInputsAndOutputs(rule, trigger_file) |
| 802 inputs = set(_FixPaths(inputs)) | 802 inputs = set(_FixPaths(inputs)) |
| 803 outputs = set(_FixPaths(outputs)) | 803 outputs = set(_FixPaths(outputs)) |
| 804 inputs.remove(_FixPath(trigger_file)) | 804 inputs.remove(_FixPath(trigger_file)) |
| 805 sources.update(inputs) | 805 sources.update(inputs) |
|
Nico
2013/12/06 16:28:29
Won't this throw now that sources is a set? (I gue
| |
| 806 if not spec.get('msvs_external_builder'): | 806 if not spec.get('msvs_external_builder'): |
| 807 excluded_sources.update(inputs) | 807 excluded_sources.update(inputs) |
| 808 sources.update(outputs) | 808 sources.update(outputs) |
| 809 | 809 |
| 810 | 810 |
| 811 def _FilterActionsFromExcluded(excluded_sources, actions_to_add): | 811 def _FilterActionsFromExcluded(excluded_sources, actions_to_add): |
| 812 """Take inputs with actions attached out of the list of exclusions. | 812 """Take inputs with actions attached out of the list of exclusions. |
| 813 | 813 |
| 814 Arguments: | 814 Arguments: |
| 815 excluded_sources: list of source files not to be built. | 815 excluded_sources: list of source files not to be built. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 883 # Skip emitting anything if told to with msvs_existing_vcproj option. | 883 # Skip emitting anything if told to with msvs_existing_vcproj option. |
| 884 if default_config.get('msvs_existing_vcproj'): | 884 if default_config.get('msvs_existing_vcproj'): |
| 885 return [] | 885 return [] |
| 886 | 886 |
| 887 if version.UsesVcxproj(): | 887 if version.UsesVcxproj(): |
| 888 return _GenerateMSBuildProject(project, options, version, generator_flags) | 888 return _GenerateMSBuildProject(project, options, version, generator_flags) |
| 889 else: | 889 else: |
| 890 return _GenerateMSVSProject(project, options, version, generator_flags) | 890 return _GenerateMSVSProject(project, options, version, generator_flags) |
| 891 | 891 |
| 892 | 892 |
| 893 def _GenerateMSVSProject(project, options, version, generator_flags): | 893 def _GenerateMSVSProject(project, options, version, generator_flags): |
|
Nico
2013/12/06 16:28:29
Unrelated: This can probably be removed eventually
| |
| 894 """Generates a .vcproj file. It may create .rules and .user files too. | 894 """Generates a .vcproj file. It may create .rules and .user files too. |
| 895 | 895 |
| 896 Arguments: | 896 Arguments: |
| 897 project: The project object we will generate the file for. | 897 project: The project object we will generate the file for. |
| 898 options: Global options passed to the generator. | 898 options: Global options passed to the generator. |
| 899 version: The VisualStudioVersion object. | 899 version: The VisualStudioVersion object. |
| 900 generator_flags: dict of generator-specific flags. | 900 generator_flags: dict of generator-specific flags. |
| 901 """ | 901 """ |
| 902 spec = project.spec | 902 spec = project.spec |
| 903 vcproj_dir = os.path.dirname(project.path) | 903 vcproj_dir = os.path.dirname(project.path) |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1323 if 'IntermediateDirectory' not in prepared_attrs: | 1323 if 'IntermediateDirectory' not in prepared_attrs: |
| 1324 intermediate = '$(ConfigurationName)\\obj\\$(ProjectName)' | 1324 intermediate = '$(ConfigurationName)\\obj\\$(ProjectName)' |
| 1325 prepared_attrs['IntermediateDirectory'] = _FixPath(intermediate) + '\\' | 1325 prepared_attrs['IntermediateDirectory'] = _FixPath(intermediate) + '\\' |
| 1326 else: | 1326 else: |
| 1327 intermediate = _FixPath(prepared_attrs['IntermediateDirectory']) + '\\' | 1327 intermediate = _FixPath(prepared_attrs['IntermediateDirectory']) + '\\' |
| 1328 intermediate = MSVSSettings.FixVCMacroSlashes(intermediate) | 1328 intermediate = MSVSSettings.FixVCMacroSlashes(intermediate) |
| 1329 prepared_attrs['IntermediateDirectory'] = intermediate | 1329 prepared_attrs['IntermediateDirectory'] = intermediate |
| 1330 return prepared_attrs | 1330 return prepared_attrs |
| 1331 | 1331 |
| 1332 | 1332 |
| 1333 def _AddNormalizedSources(sources_set, sources_array): | 1333 def _AddNormalizedSources(sources_list, sources_array): |
|
Nico
2013/12/06 16:28:29
sources_list and sources_array, hm? :-)
| |
| 1334 sources = [_NormalizedSource(s) for s in sources_array] | 1334 sources = [_NormalizedSource(s) for s in sources_array] |
| 1335 sources_set.update(set(sources)) | 1335 sources_list.extend(sources) |
| 1336 | 1336 |
| 1337 | 1337 |
| 1338 def _PrepareListOfSources(spec, generator_flags, gyp_file): | 1338 def _PrepareListOfSources(spec, generator_flags, gyp_file): |
| 1339 """Prepare list of sources and excluded sources. | 1339 """Prepare list of sources and excluded sources. |
| 1340 | 1340 |
| 1341 Besides the sources specified directly in the spec, adds the gyp file so | 1341 Besides the sources specified directly in the spec, adds the gyp file so |
| 1342 that a change to it will cause a re-compile. Also adds appropriate sources | 1342 that a change to it will cause a re-compile. Also adds appropriate sources |
| 1343 for actions and copies. Assumes later stage will un-exclude files which | 1343 for actions and copies. Assumes later stage will un-exclude files which |
| 1344 have custom build steps attached. | 1344 have custom build steps attached. |
| 1345 | 1345 |
| 1346 Arguments: | 1346 Arguments: |
| 1347 spec: The target dictionary containing the properties of the target. | 1347 spec: The target dictionary containing the properties of the target. |
| 1348 gyp_file: The name of the gyp file. | 1348 gyp_file: The name of the gyp file. |
| 1349 Returns: | 1349 Returns: |
| 1350 A pair of (list of sources, list of excluded sources). | 1350 A pair of (list of sources, list of excluded sources). |
| 1351 The sources will be relative to the gyp file. | 1351 The sources will be relative to the gyp file. |
| 1352 """ | 1352 """ |
| 1353 sources = set() | 1353 sources = list() |
| 1354 _AddNormalizedSources(sources, spec.get('sources', [])) | 1354 _AddNormalizedSources(sources, spec.get('sources', [])) |
| 1355 excluded_sources = set() | 1355 excluded_sources = list() |
| 1356 # Add in the gyp file. | 1356 # Add in the gyp file. |
| 1357 if not generator_flags.get('standalone'): | 1357 if not generator_flags.get('standalone'): |
| 1358 sources.add(gyp_file) | 1358 sources.append(gyp_file) |
| 1359 | 1359 |
| 1360 # Add in 'action' inputs and outputs. | 1360 # Add in 'action' inputs and outputs. |
| 1361 for a in spec.get('actions', []): | 1361 for a in spec.get('actions', []): |
| 1362 inputs = a['inputs'] | 1362 inputs = a['inputs'] |
| 1363 inputs = [_NormalizedSource(i) for i in inputs] | 1363 inputs = [_NormalizedSource(i) for i in inputs] |
| 1364 # Add all inputs to sources and excluded sources. | 1364 # Add all inputs to sources and excluded sources. |
| 1365 inputs = set(inputs) | 1365 sources.extend(inputs) |
| 1366 sources.update(inputs) | |
| 1367 if not spec.get('msvs_external_builder'): | 1366 if not spec.get('msvs_external_builder'): |
| 1368 excluded_sources.update(inputs) | 1367 excluded_sources.extend(inputs) |
| 1369 if int(a.get('process_outputs_as_sources', False)): | 1368 if int(a.get('process_outputs_as_sources', False)): |
| 1370 _AddNormalizedSources(sources, a.get('outputs', [])) | 1369 _AddNormalizedSources(sources, a.get('outputs', [])) |
| 1371 # Add in 'copies' inputs and outputs. | 1370 # Add in 'copies' inputs and outputs. |
| 1372 for cpy in spec.get('copies', []): | 1371 for cpy in spec.get('copies', []): |
| 1373 _AddNormalizedSources(sources, cpy.get('files', [])) | 1372 _AddNormalizedSources(sources, cpy.get('files', [])) |
| 1374 return (sources, excluded_sources) | 1373 return (sources, excluded_sources) |
| 1375 | 1374 |
| 1376 | 1375 |
| 1377 def _AdjustSourcesAndConvertToFilterHierarchy( | 1376 def _AdjustSourcesAndConvertToFilterHierarchy( |
| 1378 spec, options, gyp_dir, sources, excluded_sources, list_excluded): | 1377 spec, options, gyp_dir, sources, excluded_sources, list_excluded): |
| 1379 """Adjusts the list of sources and excluded sources. | 1378 """Adjusts the list of sources and excluded sources. |
| 1380 | 1379 |
| 1381 Also converts the sets to lists. | 1380 Also converts the sets to lists. |
|
Nico
2013/12/06 16:28:29
remove?
| |
| 1382 | 1381 |
| 1383 Arguments: | 1382 Arguments: |
| 1384 spec: The target dictionary containing the properties of the target. | 1383 spec: The target dictionary containing the properties of the target. |
| 1385 options: Global generator options. | 1384 options: Global generator options. |
| 1386 gyp_dir: The path to the gyp file being processed. | 1385 gyp_dir: The path to the gyp file being processed. |
| 1387 sources: A set of sources to be included for this project. | 1386 sources: A list of sources to be included for this project. |
| 1388 excluded_sources: A set of sources to be excluded for this project. | 1387 excluded_sources: A list of sources to be excluded for this project. |
|
Nico
2013/12/06 16:28:29
maybe add list_excluded while you're here
| |
| 1389 Returns: | 1388 Returns: |
| 1390 A trio of (list of sources, list of excluded sources, | 1389 A trio of (list of sources, list of excluded sources, |
| 1391 path of excluded IDL file) | 1390 path of excluded IDL file) |
| 1392 """ | 1391 """ |
| 1393 # Exclude excluded sources coming into the generator. | 1392 # Exclude excluded sources coming into the generator. |
| 1394 excluded_sources.update(set(spec.get('sources_excluded', []))) | 1393 excluded_sources.extend(spec.get('sources_excluded', [])) |
| 1395 # Add excluded sources into sources for good measure. | 1394 # Add excluded sources into sources for good measure. |
| 1396 sources.update(excluded_sources) | 1395 sources.extend(excluded_sources) |
| 1397 # Convert to proper windows form. | 1396 # Convert to proper windows form. |
| 1398 # NOTE: sources goes from being a set to a list here. | 1397 # NOTE: sources goes from being a set to a list here. |
| 1399 # NOTE: excluded_sources goes from being a set to a list here. | 1398 # NOTE: excluded_sources goes from being a set to a list here. |
| 1400 sources = _FixPaths(sources) | 1399 sources = _FixPaths(sources) |
| 1401 # Convert to proper windows form. | 1400 # Convert to proper windows form. |
| 1402 excluded_sources = _FixPaths(excluded_sources) | 1401 excluded_sources = _FixPaths(excluded_sources) |
| 1403 | 1402 |
| 1404 excluded_idl = _IdlFilesHandledNonNatively(spec, sources) | 1403 excluded_idl = _IdlFilesHandledNonNatively(spec, sources) |
| 1405 | 1404 |
| 1406 precompiled_related = _GetPrecompileRelatedFiles(spec) | 1405 precompiled_related = _GetPrecompileRelatedFiles(spec) |
| (...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3260 action_spec.extend( | 3259 action_spec.extend( |
| 3261 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3260 # TODO(jeanluc) 'Document' for all or just if as_sources? |
| 3262 [['FileType', 'Document'], | 3261 [['FileType', 'Document'], |
| 3263 ['Command', command], | 3262 ['Command', command], |
| 3264 ['Message', description], | 3263 ['Message', description], |
| 3265 ['Outputs', outputs] | 3264 ['Outputs', outputs] |
| 3266 ]) | 3265 ]) |
| 3267 if additional_inputs: | 3266 if additional_inputs: |
| 3268 action_spec.append(['AdditionalInputs', additional_inputs]) | 3267 action_spec.append(['AdditionalInputs', additional_inputs]) |
| 3269 actions_spec.append(action_spec) | 3268 actions_spec.append(action_spec) |
| OLD | NEW |