tor-browser

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

copy_cached_dep.py (1101B)


      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.transforms.base import TransformSequence
      6 from taskgraph.util.cached_tasks import add_optimization
      7 from taskgraph.util.dependencies import get_primary_dependency
      8 
      9 transforms = TransformSequence()
     10 
     11 
     12 @transforms.add
     13 def copy_cached_dep(config, tasks):
     14    """Ensure this task is replaced anytime the primary dep is."""
     15    # This transform is a bit of a hack to work around the fact that
     16    # the `if-dependencies` feature doesn't work with tasks that get
     17    # optimized by replacement.
     18    for task in tasks:
     19        primary_dep = get_primary_dependency(config, task)
     20 
     21        if primary_dep and "cached_task" in primary_dep.attributes:
     22            add_optimization(
     23                config,
     24                task,
     25                f"{config.kind}.v1",
     26                task["name"],
     27                digest=primary_dep.attributes["cached_task"]["digest"],
     28            )
     29 
     30        yield task