Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: pylib/gyp/generator/analyzer.py

Issue 1142323006: Makes analyzer always output static_libraries that have changed (Closed) Base URL: http://gyp.googlecode.com/svn/trunk
Patch Set: comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/analyzer/gyptest-analyzer.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 config_path) the path of a json file that dictates the files 7 the generator flag config_path) the path of a json file that dictates the files
8 and targets to search for. The following keys are supported: 8 and targets to search for. The following keys are supported:
9 files: list of paths (relative) of the files to search for. 9 files: list of paths (relative) of the files to search for.
10 targets: list of targets to search for. The target names are unqualified. 10 targets: list of targets to search for. The target names are unqualified.
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 back_deps: set of Targets that have a dependency on this Target. 176 back_deps: set of Targets that have a dependency on this Target.
177 visited: used during iteration to indicate whether we've visited this target. 177 visited: used during iteration to indicate whether we've visited this target.
178 This is used for two iterations, once in building the set of Targets and 178 This is used for two iterations, once in building the set of Targets and
179 again in _GetBuildTargets(). 179 again in _GetBuildTargets().
180 name: fully qualified name of the target. 180 name: fully qualified name of the target.
181 requires_build: True if the target type is such that it needs to be built. 181 requires_build: True if the target type is such that it needs to be built.
182 See _DoesTargetTypeRequireBuild for details. 182 See _DoesTargetTypeRequireBuild for details.
183 added_to_compile_targets: used when determining if the target was added to the 183 added_to_compile_targets: used when determining if the target was added to the
184 set of targets that needs to be built. 184 set of targets that needs to be built.
185 in_roots: true if this target is a descendant of one of the root nodes. 185 in_roots: true if this target is a descendant of one of the root nodes.
186 is_executable: true if the type of target is executable.""" 186 is_executable: true if the type of target is executable.
187 is_static_library: true if the type of target is static_library.
188 is_or_has_linked_ancestor: true if the target does a link (eg executable), or
189 if there is a target in back_deps that does a link."""
187 def __init__(self, name): 190 def __init__(self, name):
188 self.deps = set() 191 self.deps = set()
189 self.match_status = MATCH_STATUS_TBD 192 self.match_status = MATCH_STATUS_TBD
190 self.back_deps = set() 193 self.back_deps = set()
191 self.name = name 194 self.name = name
192 # TODO(sky): I don't like hanging this off Target. This state is specific 195 # TODO(sky): I don't like hanging this off Target. This state is specific
193 # to certain functions and should be isolated there. 196 # to certain functions and should be isolated there.
194 self.visited = False 197 self.visited = False
195 self.requires_build = False 198 self.requires_build = False
196 self.added_to_compile_targets = False 199 self.added_to_compile_targets = False
197 self.in_roots = False 200 self.in_roots = False
198 self.is_executable = False 201 self.is_executable = False
202 self.is_static_library = False
203 self.is_or_has_linked_ancestor = False
199 204
200 205
201 class Config(object): 206 class Config(object):
202 """Details what we're looking for 207 """Details what we're looking for
203 files: set of files to search for 208 files: set of files to search for
204 targets: see file description for details.""" 209 targets: see file description for details."""
205 def __init__(self): 210 def __init__(self):
206 self.files = [] 211 self.files = []
207 self.targets = set() 212 self.targets = set()
208 213
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 target_name = targets_to_visit.pop() 307 target_name = targets_to_visit.pop()
303 created_target, target = _GetOrCreateTargetByName(targets, target_name) 308 created_target, target = _GetOrCreateTargetByName(targets, target_name)
304 if created_target: 309 if created_target:
305 roots.add(target) 310 roots.add(target)
306 elif target.visited: 311 elif target.visited:
307 continue 312 continue
308 313
309 target.visited = True 314 target.visited = True
310 target.requires_build = _DoesTargetTypeRequireBuild( 315 target.requires_build = _DoesTargetTypeRequireBuild(
311 target_dicts[target_name]) 316 target_dicts[target_name])
312 target.is_executable = target_dicts[target_name]['type'] == 'executable' 317 target_type = target_dicts[target_name]['type']
318 target.is_executable = target_type == 'executable'
319 target.is_static_library = target_type == 'static_library'
320 target.is_or_has_linked_ancestor = (target_type == 'executable' or
321 target_type == 'shared_library')
313 322
314 build_file = gyp.common.ParseQualifiedTarget(target_name)[0] 323 build_file = gyp.common.ParseQualifiedTarget(target_name)[0]
315 if not build_file in build_file_in_files: 324 if not build_file in build_file_in_files:
316 build_file_in_files[build_file] = \ 325 build_file_in_files[build_file] = \
317 _WasBuildFileModified(build_file, data, files, toplevel_dir) 326 _WasBuildFileModified(build_file, data, files, toplevel_dir)
318 327
319 if build_file in build_files: 328 if build_file in build_files:
320 build_file_targets.add(target) 329 build_file_targets.add(target)
321 330
322 # If a build file (or any of its included files) is modified we assume all 331 # If a build file (or any of its included files) is modified we assume all
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 if target.visited: 413 if target.visited:
405 return 414 return
406 415
407 target.visited = True 416 target.visited = True
408 target.in_roots = not target.back_deps and target in roots 417 target.in_roots = not target.back_deps and target in roots
409 418
410 for back_dep_target in target.back_deps: 419 for back_dep_target in target.back_deps:
411 _AddBuildTargets(back_dep_target, roots, False, result) 420 _AddBuildTargets(back_dep_target, roots, False, result)
412 target.added_to_compile_targets |= back_dep_target.added_to_compile_targets 421 target.added_to_compile_targets |= back_dep_target.added_to_compile_targets
413 target.in_roots |= back_dep_target.in_roots 422 target.in_roots |= back_dep_target.in_roots
423 target.is_or_has_linked_ancestor |= (
424 back_dep_target.is_or_has_linked_ancestor)
414 425
415 # Always add 'executable' targets. Even though they may be built by other 426 # Always add 'executable' targets. Even though they may be built by other
416 # targets that depend upon them it makes detection of what is going to be 427 # targets that depend upon them it makes detection of what is going to be
417 # built easier. 428 # built easier.
429 # And always add static_libraries that have no dependencies on them from
430 # linkables. This is necessary as the other dependencies on them may be
431 # static libraries themselves, which are not compile time dependencies.
418 if target.in_roots and \ 432 if target.in_roots and \
419 (target.is_executable or 433 (target.is_executable or
420 (not target.added_to_compile_targets and 434 (not target.added_to_compile_targets and
421 (add_if_no_ancestor or target.requires_build))): 435 (add_if_no_ancestor or target.requires_build)) or
436 (target.is_static_library and add_if_no_ancestor and
437 not target.is_or_has_linked_ancestor)):
422 result.add(target) 438 result.add(target)
423 target.added_to_compile_targets = True 439 target.added_to_compile_targets = True
424 440
425 441
426 def _GetBuildTargets(matching_targets, roots): 442 def _GetBuildTargets(matching_targets, roots):
427 """Returns the set of Targets that require a build. 443 """Returns the set of Targets that require a build.
428 matching_targets: targets that changed and need to be built. 444 matching_targets: targets that changed and need to be built.
429 roots: set of root targets in the build files to search from.""" 445 roots: set of root targets in the build files to search from."""
430 result = set() 446 result = set()
431 for target in matching_targets: 447 for target in matching_targets:
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 result_dict = { 'targets': matched_search_targets, 576 result_dict = { 'targets': matched_search_targets,
561 'status': found_dependency_string if matching_targets else 577 'status': found_dependency_string if matching_targets else
562 no_dependency_string, 578 no_dependency_string,
563 'build_targets': build_targets} 579 'build_targets': build_targets}
564 if invalid_targets: 580 if invalid_targets:
565 result_dict['invalid_targets'] = invalid_targets 581 result_dict['invalid_targets'] = invalid_targets
566 _WriteOutput(params, **result_dict) 582 _WriteOutput(params, **result_dict)
567 583
568 except Exception as e: 584 except Exception as e:
569 _WriteOutput(params, error=str(e)) 585 _WriteOutput(params, error=str(e))
OLDNEW
« no previous file with comments | « no previous file | test/analyzer/gyptest-analyzer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698