... |
... |
@@ -386,6 +386,7 @@ class Loader(): |
386
|
386
|
|
387
|
387
|
# Cache it now, make sure it's already there before recursing
|
388
|
388
|
self._meta_elements[element.name] = meta_element
|
|
389
|
+ # print("Created", meta_element.name, meta_element.first_pass, "on", id(self), "with kind", element_kind)
|
389
|
390
|
|
390
|
391
|
return meta_element
|
391
|
392
|
|
... |
... |
@@ -393,6 +394,8 @@ class Loader(): |
393
|
394
|
all_elements = set()
|
394
|
395
|
elements_to_process = set(elements)
|
395
|
396
|
|
|
397
|
+ # print([e.name for e in elements_to_process])
|
|
398
|
+
|
396
|
399
|
while elements_to_process:
|
397
|
400
|
element = elements_to_process.pop()
|
398
|
401
|
all_elements.add(element)
|
... |
... |
@@ -425,28 +428,7 @@ class Loader(): |
425
|
428
|
if dep_b.dep_type == Symbol.RUNTIME:
|
426
|
429
|
return -1
|
427
|
430
|
|
428
|
|
- element_a = dep_a.element
|
429
|
|
- element_b = dep_b.element
|
430
|
|
-
|
431
|
|
- # All things being equal, string comparison.
|
432
|
|
- if element_a.name > element_b.name:
|
433
|
|
- return 1
|
434
|
|
- elif element_a.name < element_b.name:
|
435
|
|
- return -1
|
436
|
|
-
|
437
|
|
- # Sort local elements before junction elements
|
438
|
|
- # and use string comparison between junction elements
|
439
|
|
- if element_a.junction and element_b.junction:
|
440
|
|
- if element_a.junction > element_b.junction:
|
441
|
|
- return 1
|
442
|
|
- elif element_a.junction < element_b.junction:
|
443
|
|
- return -1
|
444
|
|
- elif element_a.junction:
|
445
|
|
- return -1
|
446
|
|
- elif element_b.junction:
|
447
|
|
- return 1
|
448
|
|
-
|
449
|
|
- return 0
|
|
431
|
+ return sorter(dep_a.element, dep_b.element)
|
450
|
432
|
|
451
|
433
|
def not_visited(dep):
|
452
|
434
|
return not dep.element.visited
|
... |
... |
@@ -455,16 +437,32 @@ class Loader(): |
455
|
437
|
|
456
|
438
|
# print([e.full_name for e in all_elements])
|
457
|
439
|
|
458
|
|
- for _ in range(len(all_elements)):
|
|
440
|
+ treated_elements = []
|
|
441
|
+
|
|
442
|
+ while all_elements:
|
459
|
443
|
current = all_elements.popleft()
|
|
444
|
+ # print("Visiting", current.full_name)
|
|
445
|
+
|
|
446
|
+ if current.visited:
|
|
447
|
+ continue
|
|
448
|
+
|
|
449
|
+ missing_deps = [
|
|
450
|
+ dep.element
|
|
451
|
+ for dep in sorted(filter(not_visited, current.dependencies), key=cmp_to_key(compare_unprocessed))
|
|
452
|
+ ]
|
460
|
453
|
|
461
|
|
- for dep in sorted(filter(not_visited, current.dependencies)):
|
462
|
|
- dep.element.visited = True
|
463
|
|
- all_elements.append(dep.element)
|
|
454
|
+ if missing_deps:
|
|
455
|
+ all_elements.appendleft(current)
|
|
456
|
+ all_elements.extendleft(missing_deps)
|
|
457
|
+ continue
|
464
|
458
|
|
465
|
459
|
current.visited = True
|
466
|
|
- all_elements.append(current)
|
|
460
|
+ treated_elements.append(current)
|
467
|
461
|
|
|
462
|
+ all_elements = deque(treated_elements)
|
|
463
|
+ # print([e.full_name for e in all_elements])
|
|
464
|
+
|
|
465
|
+ # Filter out duplicated elements
|
468
|
466
|
for _ in range(len(all_elements)):
|
469
|
467
|
current = all_elements.popleft()
|
470
|
468
|
if not current.visited:
|
... |
... |
@@ -609,7 +607,12 @@ class Loader(): |
609
|
607
|
# element.build_dependencies.sort(key=attrgetter("index"), reverse=True)
|
610
|
608
|
# element.dependencies.sort(key=attrgetter("index"), reverse=True)
|
611
|
609
|
|
612
|
|
- ret = [self._collect_element(e) for e in elements]
|
|
610
|
+ ret = [e._loader._collect_element(e) for e in elements]
|
|
611
|
+
|
|
612
|
+ # for e in ret:
|
|
613
|
+ # print(e.name, e.first_pass)
|
|
614
|
+ # for d in e.dependencies:
|
|
615
|
+ # print("\t", d.name)
|
613
|
616
|
|
614
|
617
|
return ret
|
615
|
618
|
|