Commit 6d6b24a
committed
starlark_repository: add .local() tag class for on-disk repos
Lets MODULE.bazel point starlark_repository at a workspace-local path
instead of an http_archive. Useful when the source already lives on
disk — e.g. a git submodule — and we want to skip the network fetch
entirely. The bcr-frontend project hits this with ~449 overlay-bzl
modules that all derive from the same bazel-central-registry archive;
emitting one `.archive(urls=...)` per module trips GitHub's 429 rate
limit on cold caches.
Changes
- extensions/starlark_repository.bzl: new `local` tag class with attrs
{name, path, build_directives, build_file_generation, languages,
cfgs, imports, imports_out (default "imports.csv"), deleted_files,
reresolve_known_proto_imports, importpath}. The extension impl maps
user-facing `path` to the underlying `local_path` attr and dispatches
to the same starlark_repository repo rule used by `.archive`.
- rules/proto/proto_repository.bzl: in `_proto_repository_impl`'s
local_path branch, resolve workspace-relative paths against the main
workspace root (via Label("@@//:MODULE.bazel").dirname) before
passing them to ctx.watch_tree() and fetch_repo's --path arg. Bare
strings were otherwise interpreted relative to the external repo's
own dir, where the directory doesn't exist.
- rules/proto/proto_repository.bzl: in _generate_proto_repository_info,
return empty string when imports_out is unset, so a future caller
with no imports_out can't trip `exports_files([""])`.
Usage:
starlark_repository = use_extension(
"@build_stack_rules_proto//extensions:starlark_repository.bzl",
"starlark_repository",
)
starlark_repository.local(
name = "bzl.colordiff---1.0.22",
path = "data/bazel-central-registry/modules/colordiff/1.0.22/overlay",
build_directives = ["gazelle:starlarkrepository_root"],
build_file_generation = "clean",
languages = ["starlarkrepository"],
)
use_repo(starlark_repository, "bzl.colordiff---1.0.22")1 parent 66bf261 commit 6d6b24a
2 files changed
Lines changed: 62 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
64 | 75 | | |
65 | 76 | | |
66 | 77 | | |
67 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
68 | 84 | | |
69 | 85 | | |
70 | 86 | | |
| |||
79 | 95 | | |
80 | 96 | | |
81 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
82 | 122 | | |
83 | 123 | | |
84 | 124 | | |
85 | 125 | | |
86 | 126 | | |
87 | 127 | | |
88 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
89 | 133 | | |
90 | 134 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
87 | 96 | | |
88 | 97 | | |
89 | | - | |
| 98 | + | |
90 | 99 | | |
91 | 100 | | |
92 | 101 | | |
93 | 102 | | |
94 | | - | |
| 103 | + | |
95 | 104 | | |
96 | | - | |
| 105 | + | |
97 | 106 | | |
98 | 107 | | |
99 | 108 | | |
| |||
461 | 470 | | |
462 | 471 | | |
463 | 472 | | |
| 473 | + | |
| 474 | + | |
464 | 475 | | |
465 | 476 | | |
466 | 477 | | |
| |||
0 commit comments