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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 f.write('%s\n' % i) | 827 f.write('%s\n' % i) |
828 f.close() | 828 f.close() |
829 | 829 |
830 elif run_command: | 830 elif run_command: |
831 use_shell = True | 831 use_shell = True |
832 if match['is_array']: | 832 if match['is_array']: |
833 contents = eval(contents) | 833 contents = eval(contents) |
834 use_shell = False | 834 use_shell = False |
835 | 835 |
836 # Check for a cached value to avoid executing commands, or generating | 836 # Check for a cached value to avoid executing commands, or generating |
837 # file lists more than once. | 837 # file lists more than once. The cache key contains the command to be |
838 # TODO(http://code.google.com/p/gyp/issues/detail?id=112): It is | 838 # run as well as the directory to run it from, to account for commands |
839 # possible that the command being invoked depends on the current | 839 # that depend on their current directory. |
840 # directory. For that case the syntax needs to be extended so that the | |
841 # directory is also used in cache_key (it becomes a tuple). | |
842 # TODO(http://code.google.com/p/gyp/issues/detail?id=111): In theory, | 840 # TODO(http://code.google.com/p/gyp/issues/detail?id=111): In theory, |
843 # someone could author a set of GYP files where each time the command | 841 # someone could author a set of GYP files where each time the command |
844 # is invoked it produces different output by design. When the need | 842 # is invoked it produces different output by design. When the need |
845 # arises, the syntax should be extended to support no caching off a | 843 # arises, the syntax should be extended to support no caching off a |
846 # command's output so it is run every time. | 844 # command's output so it is run every time. |
847 cache_key = str(contents) | 845 cache_key = (str(contents), build_file_dir) |
848 cached_value = cached_command_results.get(cache_key, None) | 846 cached_value = cached_command_results.get(cache_key, None) |
849 if cached_value is None: | 847 if cached_value is None: |
850 gyp.DebugOutput(gyp.DEBUG_VARIABLES, | 848 gyp.DebugOutput(gyp.DEBUG_VARIABLES, |
851 "Executing command '%s' in directory '%s'", | 849 "Executing command '%s' in directory '%s'", |
852 contents, build_file_dir) | 850 contents, build_file_dir) |
853 | 851 |
854 replacement = '' | 852 replacement = '' |
855 | 853 |
856 if command_string == 'pymod_do_main': | 854 if command_string == 'pymod_do_main': |
857 # <!pymod_do_main(modulename param eters) loads |modulename| as a | 855 # <!pymod_do_main(modulename param eters) loads |modulename| as a |
(...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2815 ValidateRunAsInTarget(target, target_dict, build_file) | 2813 ValidateRunAsInTarget(target, target_dict, build_file) |
2816 ValidateActionsInTarget(target, target_dict, build_file) | 2814 ValidateActionsInTarget(target, target_dict, build_file) |
2817 | 2815 |
2818 # Generators might not expect ints. Turn them into strs. | 2816 # Generators might not expect ints. Turn them into strs. |
2819 TurnIntIntoStrInDict(data) | 2817 TurnIntIntoStrInDict(data) |
2820 | 2818 |
2821 # TODO(mark): Return |data| for now because the generator needs a list of | 2819 # TODO(mark): Return |data| for now because the generator needs a list of |
2822 # build files that came in. In the future, maybe it should just accept | 2820 # build files that came in. In the future, maybe it should just accept |
2823 # a list, and not the whole data dict. | 2821 # a list, and not the whole data dict. |
2824 return [flat_list, targets, data] | 2822 return [flat_list, targets, data] |
OLD | NEW |