... |
... |
@@ -150,7 +150,7 @@ class Loader(): |
150
|
150
|
#
|
151
|
151
|
key = "-".join([e.name for e in target_elements])
|
152
|
152
|
profile_start(Topics.COLLECT_ELEMENTS, key)
|
153
|
|
- ret = loader._collect_elements(target_elements)
|
|
153
|
+ loader._collect_elements(target_elements)
|
154
|
154
|
profile_end(Topics.COLLECT_ELEMENTS, key)
|
155
|
155
|
|
156
|
156
|
# print("#" * 60)
|
... |
... |
@@ -165,7 +165,7 @@ class Loader(): |
165
|
165
|
# print("#" * 60)
|
166
|
166
|
|
167
|
167
|
|
168
|
|
- return ret
|
|
168
|
+ return [element._loader._meta_elements[element.name] for element in target_elements]
|
169
|
169
|
|
170
|
170
|
# cleanup():
|
171
|
171
|
#
|
... |
... |
@@ -390,13 +390,13 @@ class Loader(): |
390
|
390
|
return meta_element
|
391
|
391
|
|
392
|
392
|
def _collect_elements(self, elements):
|
393
|
|
- all_elements = set()
|
394
|
|
- elements_to_process = set(elements)
|
|
393
|
+ # all_elements = set()
|
|
394
|
+ # elements_to_process = set(elements)
|
395
|
395
|
|
396
|
|
- while elements_to_process:
|
397
|
|
- element = elements_to_process.pop()
|
398
|
|
- all_elements.add(element)
|
399
|
|
- elements_to_process.update([d.element for d in element.dependencies])
|
|
396
|
+ # while elements_to_process:
|
|
397
|
+ # element = elements_to_process.pop()
|
|
398
|
+ # all_elements.add(element)
|
|
399
|
+ # elements_to_process.update([d.element for d in element.dependencies])
|
400
|
400
|
|
401
|
401
|
def sorter(element_a, element_b):
|
402
|
402
|
if element_a.name > element_b.name:
|
... |
... |
@@ -427,53 +427,38 @@ class Loader(): |
427
|
427
|
|
428
|
428
|
return sorter(dep_a.element, dep_b.element)
|
429
|
429
|
|
430
|
|
- def not_visited(dep):
|
431
|
|
- return not dep.element.visited
|
|
430
|
+ # def not_visited(dep):
|
|
431
|
+ # return not dep.element.visited
|
432
|
432
|
|
433
|
|
- all_elements = deque(sorted(all_elements, key=cmp_to_key(sorter)))
|
|
433
|
+ # all_elements = deque(sorted(all_elements, key=cmp_to_key(sorter), reverse=True))
|
434
|
434
|
|
435
|
|
- treated_elements = []
|
|
435
|
+ # while all_elements:
|
436
|
436
|
|
437
|
|
- # print("-" * 60)
|
438
|
|
- while all_elements:
|
439
|
|
- # print([e.name for e in all_elements])
|
440
|
|
- current = all_elements.popleft()
|
|
437
|
+ # elements_to_process = deque(sorted(all_elements, key=cmp_to_key(sorter), reverse=True)
|
|
438
|
+ next_iteration = list(elements)
|
441
|
439
|
|
442
|
|
- if current.visited:
|
443
|
|
- continue
|
444
|
|
-
|
445
|
|
- missing_deps = [
|
446
|
|
- dep.element
|
447
|
|
- for dep in sorted(filter(not_visited, current.dependencies), key=cmp_to_key(compare_unprocessed), reverse=True)
|
|
440
|
+ while next_iteration:
|
|
441
|
+ current_iteration = [
|
|
442
|
+ element
|
|
443
|
+ for element in next_iteration
|
|
444
|
+ if all(dep.element.visited for dep in element.reverse_dependencies)
|
448
|
445
|
]
|
|
446
|
+ next_iteration = []
|
449
|
447
|
|
450
|
|
- if missing_deps:
|
451
|
|
- for entry in missing_deps:
|
452
|
|
- all_elements.remove(entry)
|
453
|
|
-
|
454
|
|
- # print(current.name, "bumped")
|
455
|
|
- # print("Adding", [d.name for d in missing_deps])
|
456
|
|
- all_elements.appendleft(current)
|
457
|
|
- all_elements.extendleft(missing_deps)
|
458
|
|
- continue
|
|
448
|
+ for element in current_iteration:
|
|
449
|
+ element.visited = True
|
|
450
|
+ meta_element = self._collect_element(element)
|
459
|
451
|
|
460
|
|
- current.visited = True
|
461
|
|
- treated_elements.append(current)
|
462
|
452
|
|
463
|
|
- all_elements = deque(treated_elements)
|
464
|
|
-
|
465
|
|
- # Filter out duplicated elements
|
466
|
|
- for _ in range(len(all_elements)):
|
467
|
|
- current = all_elements.popleft()
|
468
|
|
- if not current.visited:
|
|
453
|
+ for element in elements:
|
|
454
|
+ if element.visited:
|
|
455
|
+ # print("Skipping...", element.name)
|
469
|
456
|
continue
|
470
|
457
|
|
471
|
|
- current.visited = False
|
472
|
|
- all_elements.append(current)
|
473
|
|
-
|
474
|
|
- for element in all_elements:
|
475
|
|
- meta_element = element._loader._collect_element(element)
|
|
458
|
+ # print(element.name)
|
476
|
459
|
|
|
460
|
+ self._collect_elements(d.element for d in sorted(element.dependencies, key=cmp_to_key(compare_unprocessed)))
|
|
461
|
+ meta_element = self._collect_element(element)
|
477
|
462
|
for dep in element.dependencies:
|
478
|
463
|
dependency = dep.element._loader._meta_elements[dep.element.name]
|
479
|
464
|
if dep.dep_type != Symbol.RUNTIME:
|
... |
... |
@@ -481,10 +466,69 @@ class Loader(): |
481
|
466
|
if dep.dep_type != Symbol.BUILD:
|
482
|
467
|
meta_element.dependencies.append(dependency)
|
483
|
468
|
|
484
|
|
- # print("------------------")
|
485
|
|
- for element in self._meta_elements.values():
|
486
|
|
- element.build_dependencies.sort(key=attrgetter("index"))
|
487
|
|
- element.dependencies.sort(key=attrgetter("index"))
|
|
469
|
+ meta_element.dependencies.sort(key=attrgetter("index"))
|
|
470
|
+ meta_element.build_dependencies.sort(key=attrgetter("index"))
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+ # next_missing_dep = next(filter())
|
|
474
|
+ # missing_deps = [
|
|
475
|
+ # dep.element
|
|
476
|
+ # for dep in sorted(filter(not_visited, current.dependencies))
|
|
477
|
+ # ]
|
|
478
|
+
|
|
479
|
+ # treated_elements = []
|
|
480
|
+
|
|
481
|
+ # # print("-" * 60)
|
|
482
|
+ # while all_elements:
|
|
483
|
+ # # print([e.name for e in all_elements])
|
|
484
|
+ # current = all_elements.popleft()
|
|
485
|
+
|
|
486
|
+ # if current.visited:
|
|
487
|
+ # continue
|
|
488
|
+
|
|
489
|
+ # missing_deps = [
|
|
490
|
+ # dep.element
|
|
491
|
+ # for dep in sorted(filter(not_visited, current.dependencies), key=cmp_to_key(compare_unprocessed), reverse=True)
|
|
492
|
+ # ]
|
|
493
|
+
|
|
494
|
+ # if missing_deps:
|
|
495
|
+ # for entry in missing_deps:
|
|
496
|
+ # all_elements.remove(entry)
|
|
497
|
+
|
|
498
|
+ # # print(current.name, "bumped")
|
|
499
|
+ # # print("Adding", [d.name for d in missing_deps])
|
|
500
|
+ # all_elements.appendleft(current)
|
|
501
|
+ # all_elements.extendleft(missing_deps)
|
|
502
|
+ # continue
|
|
503
|
+
|
|
504
|
+ # current.visited = True
|
|
505
|
+ # treated_elements.append(current)
|
|
506
|
+
|
|
507
|
+ # all_elements = deque(treated_elements)
|
|
508
|
+
|
|
509
|
+ # # Filter out duplicated elements
|
|
510
|
+ # for _ in range(len(all_elements)):
|
|
511
|
+ # current = all_elements.popleft()
|
|
512
|
+ # if not current.visited:
|
|
513
|
+ # continue
|
|
514
|
+
|
|
515
|
+ # current.visited = False
|
|
516
|
+ # all_elements.append(current)
|
|
517
|
+
|
|
518
|
+ # for element in all_elements:
|
|
519
|
+ # meta_element = element._loader._collect_element(element)
|
|
520
|
+
|
|
521
|
+ # for dep in element.dependencies:
|
|
522
|
+ # dependency = dep.element._loader._meta_elements[dep.element.name]
|
|
523
|
+ # if dep.dep_type != Symbol.RUNTIME:
|
|
524
|
+ # meta_element.build_dependencies.append(dependency)
|
|
525
|
+ # if dep.dep_type != Symbol.BUILD:
|
|
526
|
+ # meta_element.dependencies.append(dependency)
|
|
527
|
+
|
|
528
|
+ # # print("------------------")
|
|
529
|
+ # for element in self._meta_elements.values():
|
|
530
|
+ # element.build_dependencies.sort(key=attrgetter("index"))
|
|
531
|
+ # element.dependencies.sort(key=attrgetter("index"))
|
488
|
532
|
# print("element:", element.name, [e.name for e in element.build_dependencies], [e.name for e in element.dependencies])
|
489
|
533
|
# print("####################")
|
490
|
534
|
|
... |
... |
@@ -607,9 +651,9 @@ class Loader(): |
607
|
651
|
# element.build_dependencies.sort(key=attrgetter("index"), reverse=True)
|
608
|
652
|
# element.dependencies.sort(key=attrgetter("index"), reverse=True)
|
609
|
653
|
|
610
|
|
- ret = [e._loader._collect_element(e) for e in elements]
|
|
654
|
+ # ret = [e._loader._collect_element(e) for e in elements]
|
611
|
655
|
|
612
|
|
- return ret
|
|
656
|
+ # return ret
|
613
|
657
|
|
614
|
658
|
# _get_loader():
|
615
|
659
|
#
|