Skip to content
  • Matthew Clarkson's avatar
    fix(toolchain_local_select): use `label_keyed_string_dict` for `map` attribute · 1d48d2e4
    Matthew Clarkson authored
    BREAKING CHANGE: `toolchain_local_select#map` is now flipped taking the labels as they keys rather than as the values.
    
    Previous releases had the following setup:
    
    ```py
    download_file(
        name = "abc-arm64-linux-gnu",
        output = "abc",
    )
    
    download_file(
        name = "abc-arm64-linux-musl",
        output = "abc",
    )
    
    toolchain_local_select(
        name = "abc",
        map = {
            "arm64-linux-gnu": "@abc-arm64-linux-gnu",
            "arm64-linux-musl": "@abc-arm64-linux-musl",
        },
    )
    ```
    
    This prevented eagarly overfetching all the repositories that would be
    selected. As of Bazel 7.4.0+[1], it no longer overfetches so the `map`
    attribute has been switched to a `label_keyed_string_dict`:
    
    ```py
    toolchain_local_select(
        name = "abc",
        map = {
            "@abc-arm64-linux-gnu": "arm64-linux-gnu",
            "@abc-arm64-linux-musl": "arm64-linux-musl",
        },
    )
    ```
    
    The repository rule will _only_ fetch the repostory label that has been selected due
    to the triplet value matching.
    
    Whilst this is a breaking change, it will introduce a regression on Bazel 7.3 and below
    which will overfetch the repositories. It is *highly* recommended to use Bazel 7.4 and above.
    
    [1]: https://github.com/bazelbuild/bazel/commit/6fabb1fc6869a204373e5ee0adde696a659415dd
    1d48d2e4
Loading