@@ -183,7 +183,10 @@ class Target(object):
183
183
added_to_compile_targets: used when determining if the target was added to the
184
184
set of targets that needs to be built.
185
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
190
def __init__ (self , name ):
188
191
self .deps = set ()
189
192
self .match_status = MATCH_STATUS_TBD
@@ -196,6 +199,8 @@ def __init__(self, name):
196
199
self .added_to_compile_targets = False
197
200
self .in_roots = False
198
201
self .is_executable = False
202
+ self .is_static_library = False
203
+ self .is_or_has_linked_ancestor = False
199
204
200
205
201
206
class Config (object ):
@@ -266,8 +271,8 @@ def _GetOrCreateTargetByName(targets, target_name):
266
271
def _DoesTargetTypeRequireBuild (target_dict ):
267
272
"""Returns true if the target type is such that it needs to be built."""
268
273
# If a 'none' target has rules or actions we assume it requires a build.
269
- return target_dict ['type' ] != 'none' or \
270
- target_dict .get ('actions' ) or target_dict .get ('rules' )
274
+ return bool ( target_dict ['type' ] != 'none' or
275
+ target_dict .get ('actions' ) or target_dict .get ('rules' ) )
271
276
272
277
273
278
def _GenerateTargets (data , target_list , target_dicts , toplevel_dir , files ,
@@ -309,7 +314,11 @@ def _GenerateTargets(data, target_list, target_dicts, toplevel_dir, files,
309
314
target .visited = True
310
315
target .requires_build = _DoesTargetTypeRequireBuild (
311
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
323
build_file = gyp .common .ParseQualifiedTarget (target_name )[0 ]
315
324
if not build_file in build_file_in_files :
@@ -378,6 +387,7 @@ def _DoesTargetDependOn(target):
378
387
for dep in target .deps :
379
388
if _DoesTargetDependOn (dep ):
380
389
target .match_status = MATCH_STATUS_MATCHES_BY_DEPENDENCY
390
+ print '\t ' , target .name , 'matches by dep' , dep .name
381
391
return True
382
392
target .match_status = MATCH_STATUS_DOESNT_MATCH
383
393
return False
@@ -388,6 +398,7 @@ def _GetTargetsDependingOn(possible_targets):
388
398
directly on indirectly) on the matched targets.
389
399
possible_targets: targets to search from."""
390
400
found = []
401
+ print 'Targets that matched by dependency:'
391
402
for target in possible_targets :
392
403
if _DoesTargetDependOn (target ):
393
404
found .append (target )
@@ -411,14 +422,27 @@ def _AddBuildTargets(target, roots, add_if_no_ancestor, result):
411
422
_AddBuildTargets (back_dep_target , roots , False , result )
412
423
target .added_to_compile_targets |= back_dep_target .added_to_compile_targets
413
424
target .in_roots |= back_dep_target .in_roots
425
+ target .is_or_has_linked_ancestor |= (
426
+ back_dep_target .is_or_has_linked_ancestor )
414
427
415
428
# Always add 'executable' targets. Even though they may be built by other
416
429
# targets that depend upon them it makes detection of what is going to be
417
430
# built easier.
431
+ # And always add static_libraries that have no dependencies on them from
432
+ # linkables. This is necessary as the other dependencies on them may be
433
+ # static libraries themselves, which are not compile time dependencies.
418
434
if target .in_roots and \
419
435
(target .is_executable or
420
436
(not target .added_to_compile_targets and
421
- (add_if_no_ancestor or target .requires_build ))):
437
+ (add_if_no_ancestor or target .requires_build )) or
438
+ (target .is_static_library and add_if_no_ancestor and
439
+ not target .is_or_has_linked_ancestor )):
440
+ print '\t \t adding to build targets' , target .name , 'executable' , \
441
+ target .is_executable , 'added_to_compile_targets' , \
442
+ target .added_to_compile_targets , 'add_if_no_ancestor' , \
443
+ add_if_no_ancestor , 'requires_build' , target .requires_build , \
444
+ 'is_static_library' , target .is_static_library , \
445
+ 'is_or_has_linked_ancestor' , target .is_or_has_linked_ancestor
422
446
result .add (target )
423
447
target .added_to_compile_targets = True
424
448
@@ -429,6 +453,7 @@ def _GetBuildTargets(matching_targets, roots):
429
453
roots: set of root targets in the build files to search from."""
430
454
result = set ()
431
455
for target in matching_targets :
456
+ print '\t finding build targets for match' , target .name
432
457
_AddBuildTargets (target , roots , True , result )
433
458
return result
434
459
@@ -536,6 +561,10 @@ def GenerateOutput(target_list, target_dicts, data, params):
536
561
data , target_list , target_dicts , toplevel_dir , frozenset (config .files ),
537
562
params ['build_files' ])
538
563
564
+ print 'roots:'
565
+ for root in roots :
566
+ print '\t ' , root .name
567
+
539
568
unqualified_mapping = _GetUnqualifiedToTargetMapping (all_targets ,
540
569
config .targets )
541
570
invalid_targets = None
@@ -544,10 +573,20 @@ def GenerateOutput(target_list, target_dicts, data, params):
544
573
545
574
if matching_targets :
546
575
search_targets = _LookupTargets (config .targets , unqualified_mapping )
576
+ print 'supplied targets'
577
+ for target in config .targets :
578
+ print '\t ' , target
579
+ print 'expanded supplied targets'
580
+ for target in search_targets :
581
+ print '\t ' , target .name
547
582
matched_search_targets = _GetTargetsDependingOn (search_targets )
583
+ print 'raw matched search targets:'
584
+ for target in matched_search_targets :
585
+ print '\t ' , target .name
548
586
# Reset the visited status for _GetBuildTargets.
549
587
for target in all_targets .itervalues ():
550
588
target .visited = False
589
+ print 'Finding build targets'
551
590
build_targets = _GetBuildTargets (matching_targets , roots )
552
591
matched_search_targets = [gyp .common .ParseQualifiedTarget (target .name )[1 ]
553
592
for target in matched_search_targets ]
0 commit comments