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 from compiler.ast import Const | 5 from compiler.ast import Const |
6 from compiler.ast import Dict | 6 from compiler.ast import Dict |
7 from compiler.ast import Discard | 7 from compiler.ast import Discard |
8 from compiler.ast import List | 8 from compiler.ast import List |
9 from compiler.ast import Module | 9 from compiler.ast import Module |
10 from compiler.ast import Node | 10 from compiler.ast import Node |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 # is to be expecting a list in return, and not all callers do | 774 # is to be expecting a list in return, and not all callers do |
775 # because not all are working in list context. Also, for list | 775 # because not all are working in list context. Also, for list |
776 # expansions, there can be no other text besides the variable | 776 # expansions, there can be no other text besides the variable |
777 # expansion in the input string. | 777 # expansion in the input string. |
778 expand_to_list = '@' in match['type'] and input_str == replacement | 778 expand_to_list = '@' in match['type'] and input_str == replacement |
779 | 779 |
780 if run_command or file_list: | 780 if run_command or file_list: |
781 # Find the build file's directory, so commands can be run or file lists | 781 # Find the build file's directory, so commands can be run or file lists |
782 # generated relative to it. | 782 # generated relative to it. |
783 build_file_dir = os.path.dirname(build_file) | 783 build_file_dir = os.path.dirname(build_file) |
784 if build_file_dir == '': | 784 if build_file_dir == '' and not file_list: |
785 # If build_file is just a leaf filename indicating a file in the | 785 # If build_file is just a leaf filename indicating a file in the |
786 # current directory, build_file_dir might be an empty string. Set | 786 # current directory, build_file_dir might be an empty string. Set |
787 # it to None to signal to subprocess.Popen that it should run the | 787 # it to None to signal to subprocess.Popen that it should run the |
788 # command in the current directory. | 788 # command in the current directory. |
789 build_file_dir = None | 789 build_file_dir = None |
790 | 790 |
791 # Support <|(listfile.txt ...) which generates a file | 791 # Support <|(listfile.txt ...) which generates a file |
792 # containing items from a gyp list, generated at gyp time. | 792 # containing items from a gyp list, generated at gyp time. |
793 # This works around actions/rules which have more inputs than will | 793 # This works around actions/rules which have more inputs than will |
794 # fit on the command line. | 794 # fit on the command line. |
795 if file_list: | 795 if file_list: |
796 if type(contents) == list: | 796 if type(contents) == list: |
797 contents_list = contents | 797 contents_list = contents |
798 else: | 798 else: |
799 contents_list = contents.split(' ') | 799 contents_list = contents.split(' ') |
800 replacement = contents_list[0] | 800 replacement = contents_list[0] |
801 path = replacement | 801 if os.path.isabs(replacement): |
802 if build_file_dir and not os.path.isabs(path): | 802 raise GypError('| cannot handle absolute paths, got "%s"' % path) |
803 path = os.path.join(build_file_dir, path) | 803 |
| 804 path = generator_filelist_path(build_file_dir, replacement) |
| 805 replacement = gyp.common.RelativePath(path, build_file_dir) |
804 f = gyp.common.WriteOnDiff(path) | 806 f = gyp.common.WriteOnDiff(path) |
805 for i in contents_list[1:]: | 807 for i in contents_list[1:]: |
806 f.write('%s\n' % i) | 808 f.write('%s\n' % i) |
807 f.close() | 809 f.close() |
808 | 810 |
809 elif run_command: | 811 elif run_command: |
810 use_shell = True | 812 use_shell = True |
811 if match['is_array']: | 813 if match['is_array']: |
812 contents = eval(contents) | 814 contents = eval(contents) |
813 use_shell = False | 815 use_shell = False |
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2592 path_sections.extend(generator_input_info['path_sections']) | 2594 path_sections.extend(generator_input_info['path_sections']) |
2593 | 2595 |
2594 global non_configuration_keys | 2596 global non_configuration_keys |
2595 non_configuration_keys = base_non_configuration_keys[:] | 2597 non_configuration_keys = base_non_configuration_keys[:] |
2596 non_configuration_keys.extend(generator_input_info['non_configuration_keys']) | 2598 non_configuration_keys.extend(generator_input_info['non_configuration_keys']) |
2597 | 2599 |
2598 global multiple_toolsets | 2600 global multiple_toolsets |
2599 multiple_toolsets = generator_input_info[ | 2601 multiple_toolsets = generator_input_info[ |
2600 'generator_supports_multiple_toolsets'] | 2602 'generator_supports_multiple_toolsets'] |
2601 | 2603 |
| 2604 global generator_filelist_path |
| 2605 generator_filelist_path = generator_input_info['generator_filelist_path'] |
| 2606 if not generator_filelist_path: |
| 2607 generator_filelist_path = lambda a, b: os.path.join(a, b) |
| 2608 |
2602 # A generator can have other lists (in addition to sources) be processed | 2609 # A generator can have other lists (in addition to sources) be processed |
2603 # for rules. | 2610 # for rules. |
2604 extra_sources_for_rules = generator_input_info['extra_sources_for_rules'] | 2611 extra_sources_for_rules = generator_input_info['extra_sources_for_rules'] |
2605 | 2612 |
2606 # Load build files. This loads every target-containing build file into | 2613 # Load build files. This loads every target-containing build file into |
2607 # the |data| dictionary such that the keys to |data| are build file names, | 2614 # the |data| dictionary such that the keys to |data| are build file names, |
2608 # and the values are the entire build file contents after "early" or "pre" | 2615 # and the values are the entire build file contents after "early" or "pre" |
2609 # processing has been done and includes have been resolved. | 2616 # processing has been done and includes have been resolved. |
2610 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as | 2617 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as |
2611 # well as meta-data (e.g. 'included_files' key). 'target_build_files' keeps | 2618 # well as meta-data (e.g. 'included_files' key). 'target_build_files' keeps |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2727 ValidateRunAsInTarget(target, target_dict, build_file) | 2734 ValidateRunAsInTarget(target, target_dict, build_file) |
2728 ValidateActionsInTarget(target, target_dict, build_file) | 2735 ValidateActionsInTarget(target, target_dict, build_file) |
2729 | 2736 |
2730 # Generators might not expect ints. Turn them into strs. | 2737 # Generators might not expect ints. Turn them into strs. |
2731 TurnIntIntoStrInDict(data) | 2738 TurnIntIntoStrInDict(data) |
2732 | 2739 |
2733 # TODO(mark): Return |data| for now because the generator needs a list of | 2740 # TODO(mark): Return |data| for now because the generator needs a list of |
2734 # build files that came in. In the future, maybe it should just accept | 2741 # build files that came in. In the future, maybe it should just accept |
2735 # a list, and not the whole data dict. | 2742 # a list, and not the whole data dict. |
2736 return [flat_list, targets, data] | 2743 return [flat_list, targets, data] |
OLD | NEW |