OLD | NEW |
1 # Copyright (c) 2014 Google Inc. All rights reserved. | 1 # Copyright (c) 2014 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 """ | 5 """ |
6 This script is intended for use as a GYP_GENERATOR. It takes as input (by way of | 6 This script is intended for use as a GYP_GENERATOR. It takes as input (by way of |
7 the generator flag file_path) the list of relative file paths to consider. If | 7 the generator flag file_path) the list of relative file paths to consider. If |
8 any target has at least one of the paths as a source (or input to an action or | 8 any target has at least one of the paths as a source (or input to an action or |
9 rule) then 'Found dependency' is output, otherwise 'No dependencies' is output. | 9 rule) then 'Found dependency' is output, otherwise 'No dependencies' is output. |
10 """ | 10 """ |
(...skipping 22 matching lines...) Expand all Loading... |
33 generator_default_variables[unused] = '' | 33 generator_default_variables[unused] = '' |
34 | 34 |
35 def __MakeRelativeTargetName(path): | 35 def __MakeRelativeTargetName(path): |
36 """Converts a gyp target name into a relative name. For example, the path to a | 36 """Converts a gyp target name into a relative name. For example, the path to a |
37 gyp file may be something like c:\foo\bar.gyp:target, this converts it to | 37 gyp file may be something like c:\foo\bar.gyp:target, this converts it to |
38 bar.gyp. | 38 bar.gyp. |
39 """ | 39 """ |
40 prune_path = os.getcwd() | 40 prune_path = os.getcwd() |
41 if path.startswith(prune_path): | 41 if path.startswith(prune_path): |
42 path = path[len(prune_path):] | 42 path = path[len(prune_path):] |
| 43 if len(path) and path.startswith(os.sep): |
| 44 path = path[len(os.sep):] |
43 # Gyp paths are always posix style. | 45 # Gyp paths are always posix style. |
44 path = path.replace('\\', '/') | 46 path = path.replace('\\', '/') |
45 if path.endswith('#target'): | 47 if path.endswith('#target'): |
46 path = path[0:len(path) - len('#target')] | 48 path = path[0:len(path) - len('#target')] |
47 return path | 49 return path |
48 | 50 |
49 def __ExtractBasePath(target): | 51 def __ExtractBasePath(target): |
50 """Extracts the path components of the specified gyp target path.""" | 52 """Extracts the path components of the specified gyp target path.""" |
51 last_index = target.rfind('/') | 53 last_index = target.rfind('/') |
52 if last_index == -1: | 54 if last_index == -1: |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 print 'Unable to open file', file_path | 161 print 'Unable to open file', file_path |
160 return None | 162 return None |
161 | 163 |
162 def CalculateVariables(default_variables, params): | 164 def CalculateVariables(default_variables, params): |
163 """Calculate additional variables for use in the build (called by gyp).""" | 165 """Calculate additional variables for use in the build (called by gyp).""" |
164 flavor = gyp.common.GetFlavor(params) | 166 flavor = gyp.common.GetFlavor(params) |
165 if flavor == 'mac': | 167 if flavor == 'mac': |
166 default_variables.setdefault('OS', 'mac') | 168 default_variables.setdefault('OS', 'mac') |
167 elif flavor == 'win': | 169 elif flavor == 'win': |
168 default_variables.setdefault('OS', 'win') | 170 default_variables.setdefault('OS', 'win') |
| 171 # Copy additional generator configuration data from VS, which is shared |
| 172 # by the Windows Ninja generator. |
| 173 import gyp.generator.msvs as msvs_generator |
| 174 generator_additional_non_configuration_keys = getattr(msvs_generator, |
| 175 'generator_additional_non_configuration_keys', []) |
| 176 generator_additional_path_sections = getattr(msvs_generator, |
| 177 'generator_additional_path_sections', []) |
| 178 |
| 179 gyp.msvs_emulation.CalculateCommonVariables(default_variables, params) |
169 else: | 180 else: |
170 operating_system = flavor | 181 operating_system = flavor |
171 if flavor == 'android': | 182 if flavor == 'android': |
172 operating_system = 'linux' # Keep this legacy behavior for now. | 183 operating_system = 'linux' # Keep this legacy behavior for now. |
173 default_variables.setdefault('OS', operating_system) | 184 default_variables.setdefault('OS', operating_system) |
174 | 185 |
175 def GenerateOutput(target_list, target_dicts, data, params): | 186 def GenerateOutput(target_list, target_dicts, data, params): |
176 """Called by gyp as the final stage. Outputs results.""" | 187 """Called by gyp as the final stage. Outputs results.""" |
177 files = __GetFiles(params) | 188 files = __GetFiles(params) |
178 if not files: | 189 if not files: |
179 print 'Must specify files to analyze via file_path generator flag' | 190 print 'Must specify files to analyze via file_path generator flag' |
180 return | 191 return |
181 | 192 |
182 targets = __GenerateTargets(target_list, target_dicts) | 193 targets = __GenerateTargets(target_list, target_dicts) |
183 | 194 |
184 files_set = frozenset(files) | 195 files_set = frozenset(files) |
185 found_in_all_sources = 0 | 196 found_in_all_sources = 0 |
186 for target_name, target in targets.iteritems(): | 197 for target_name, target in targets.iteritems(): |
187 sources = files_set.intersection(target.sources) | 198 sources = files_set.intersection(target.sources) |
188 if len(sources): | 199 if len(sources): |
189 print 'Found dependency' | 200 print 'Found dependency' |
190 return | 201 return |
191 | 202 |
192 print 'No dependencies' | 203 print 'No dependencies' |
OLD | NEW |