Skip to content

Commit 398ee0e

Browse files
committed
Update README, minor protoc toolchain cleanups
Fixes a broken `single_version_override` link in the README. Added info explicitly indicating that `repo_mapping` and other mechanisms used to translate `@rules_scala_config` also apply to translating `@rules_scala`. Slightly touches up `protoc_toolchain.bzl` and `update_protoc_integrity.py.
1 parent 0c0fb6d commit 398ee0e

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

README.md

+18-8
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@ v6.x:
166166

167167
- __`rules_scala` no longer requires the `io_bazel_rules_scala` repository
168168
name__ unless your `BUILD` files or those of your dependencies require it
169-
(bazelbuild/rules_scala#1696).
169+
(bazelbuild/rules_scala#1696). You can use the `repo_mapping` attribute of
170+
`http_archive`, or equivalent Bzlmod mechanisms, to translate `@rules_scala`
171+
to `@io_bazel_rules_scala` for dependencies. The
172+
['@io_bazel_rules_scala_config' is now '@rules_scala_config'](#map) section
173+
below describes these options in detail. (That section is about
174+
`@rules_scala_config`, but the same mechanisms apply.)
170175

171176
- __`rules_scala` v7.0.0 introduces a new `scala_toolchains()` API that is
172177
very different from `rules_scala` 6__. For details on what's changed, see
@@ -237,6 +242,7 @@ which also requires that the patch be a regular file in your own repo. In other
237242
words, neither `@rules_scala//protoc:0001-protobuf-19679-rm-protoc-dep.patch`
238243
nor an [`alias`][] to it will work.
239244

245+
[`single_version_override`]: https://bazel.build/rules/lib/globals/module#single_version_override
240246
[`alias`]: https://bazel.build/reference/be/general#alias
241247

242248
Assuming you've copied the patch to a file called `protobuf.patch` in the root
@@ -667,7 +673,7 @@ register_toolchains(
667673
)
668674
```
669675

670-
### `@io_bazel_rules_scala_config` is now `@rules_scala_config`
676+
### <a id="map"></a>`@io_bazel_rules_scala_config` is now `@rules_scala_config`
671677

672678
Since `@io_bazel_rules_scala` is no longer hardcoded in `rules_scala` internals,
673679
we've shortened `@io_bazel_rules_scala_config` to `@rules_scala_config`. This
@@ -676,7 +682,16 @@ shouldn't affect most users, but it may break some builds using
676682
./docs/cross-compilation.md).
677683

678684
If you can't fix uses of `@io_bazel_rules_scala_config` in your own project
679-
immediately, you can remap `@rules_scala_config` via [`use_repo()`]:
685+
immediately, or have dependencies that need it, there are options.
686+
Use one of the following mechanisms to override it with `@rules_scala_config`.
687+
688+
The same mechanisms also apply if you need to translate `@rules_scala` to
689+
`@io_bazel_rules_scala` for your dependencies.
690+
691+
#### Bzlmod
692+
693+
You can remap `@rules_scala_config` via [`use_repo()`] if you need it in your
694+
own project:
680695

681696
[`use_repo()`]: https://bazel.build/rules/lib/globals/module#use_repo
682697

@@ -689,11 +704,6 @@ scala_config = use_extension(
689704
use_repo(scala_config, io_bazel_rules_scala_config = "rules_scala_config")
690705
```
691706

692-
If any of your dependencies still require `@io_bazel_rules_scala_config`, use
693-
one of the following mechanisms to override it with `@rules_scala_config`:
694-
695-
#### Bzlmod
696-
697707
For [`bazel_dep()`][] dependencies, use [`override_repo()`][] to
698708
override `@io_bazel_rules_scala_config` with `@rules_scala_config`:
699709

protoc/private/protoc_toolchain.bzl

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ def _platform_build(platform):
2828
)
2929
return protoc_build
3030

31-
_PROTOC_BUILD_ENTRY_TEMPLATE = """ "{platform}": [\n{specs}\n ],"""
32-
3331
def _download_build(repository_ctx, package, platform, protoc_build):
3432
repository_ctx.download_and_extract(
3533
url = PROTOC_DOWNLOAD_URL.format(
@@ -41,7 +39,7 @@ def _download_build(repository_ctx, package, platform, protoc_build):
4139
)
4240

4341
def _emit_platform_entry(platform, protoc_build):
44-
return _PROTOC_BUILD_ENTRY_TEMPLATE.format(
42+
return ' "{platform}": [\n{specs}\n ],'.format(
4543
platform = platform,
4644
specs = "\n".join([
4745
' "%s",' % s

scripts/update_protoc_integrity.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,10 @@ def get_protoc_integrity(platform, version):
116116
Raises:
117117
`UpdateProtocIntegrityError` if downloading or checksumming fails
118118
"""
119-
try:
120-
url = PROTOC_DOWNLOAD_URL.format(
121-
version = version,
122-
platform = platform
123-
)
124-
print(f'Updating protoc {version} for {platform}:')
125-
print(f' {url}')
119+
url = PROTOC_DOWNLOAD_URL.format(version = version, platform = platform)
120+
print(f'Updating protoc {version} for {platform}:\n {url}')
126121

122+
try:
127123
with urllib.request.urlopen(url) as data:
128124
body = data.read()
129125

0 commit comments

Comments
 (0)