tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

group_by.py (1625B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 from taskgraph.util.dependencies import group_by
      6 
      7 
      8 @group_by("component")
      9 def component_grouping(config, tasks):
     10    groups = {}
     11    for task in tasks:
     12        component = task.attributes.get("component")
     13        if component == "all":
     14            continue
     15 
     16        build_type = task.attributes.get("build-type")
     17        groups.setdefault((component, build_type), []).append(task)
     18 
     19    tasks_for_all_components = [
     20        task
     21        for task in tasks
     22        if task.attributes.get("component") == "all"
     23        # We just want to depend on the task that waits on all chunks. This way
     24        # we have a single dependency for that kind
     25        and task.attributes.get("is_final_chunked_task", True)
     26    ]
     27    for (_, build_type), group_tasks in groups.items():
     28        group_tasks.extend([
     29            task
     30            for task in tasks_for_all_components
     31            if task.attributes.get("build-type") == build_type
     32        ])
     33 
     34    return groups.values()
     35 
     36 
     37 @group_by("build-type")
     38 def build_type_grouping(config, tasks):
     39    groups = {}
     40    for task in tasks:
     41        # We just want to depend on the task that waits on all chunks. This way
     42        # we have a single dependency for that kind
     43        if not task.attributes.get("is_final_chunked_task", True):
     44            continue
     45 
     46        build_type = task.attributes.get("build-type")
     47        groups.setdefault(build_type, []).append(task)
     48 
     49    return groups.values()