• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2024 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14"""
15pw_rust_crates_extension allows the pigweed modules "rust_crates" repo to
16be overridden using https://bazel.build/rules/lib/globals/module#override_repo
17
18Downstream projects needing to provide a local `rust_crates` repo can
19do so by adding the following to their root MODULE.bazel
20
21
22local_repository(name = "rust_crates", path = "build/crates_io")
23
24pw_rust_crates = use_extension("@pigweed//pw_build:pw_rust_crates_extension.bzl", "pw_rust_crates_extension")
25override_repo(pw_rust_crates, rust_crates = "rust_crates")
26"""
27
28load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
29
30def _pw_rust_crates_extension_impl(_ctx):
31    local_repository(name = "rust_crates", path = "third_party/crates_io/rust_crates")
32
33pw_rust_crates_extension = module_extension(
34    implementation = _pw_rust_crates_extension_impl,
35)
36