Skip to content

Commit fe2f534

Browse files
authored
Merge branch 'main' into revert
2 parents 16e12e1 + c263575 commit fe2f534

File tree

365 files changed

+34706
-352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

365 files changed

+34706
-352
lines changed

.bazelci/presubmit.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ tasks:
392392
- //...
393393
run_targets:
394394
- "//:test_docs"
395+
- "//:publish_book"
395396
clippy_failure:
396397
name: Negative Clippy Tests
397398
platform: ubuntu2004
@@ -923,6 +924,49 @@ tasks:
923924
# test_targets:
924925
# - "--"
925926
# - "//..."
927+
extensions_mdbook_linux:
928+
platform: ubuntu2004
929+
name: Extensions MdBook
930+
working_directory: extensions/mdbook
931+
build_flags: *aspects_flags
932+
test_flags: *aspects_flags
933+
build_targets:
934+
- "//..."
935+
test_targets:
936+
- "//..."
937+
extensions_mdbook_linux_rbe:
938+
platform: rbe_ubuntu2004
939+
name: Extensions MdBook
940+
working_directory: extensions/mdbook
941+
shell_commands:
942+
- sed -i 's/^# load("@bazel_ci_rules/load("@bazel_ci_rules/' WORKSPACE.bazel
943+
- sed -i 's/^# rbe_preconfig/rbe_preconfig/' WORKSPACE.bazel
944+
build_flags: *aspects_flags
945+
test_flags: *aspects_flags
946+
build_targets:
947+
- "//..."
948+
test_targets:
949+
- "//..."
950+
extensions_mdbook_macos:
951+
platform: macos_arm64
952+
name: Extensions MdBook
953+
working_directory: extensions/mdbook
954+
build_flags: *aspects_flags
955+
test_flags: *aspects_flags
956+
build_targets:
957+
- "//..."
958+
test_targets:
959+
- "//..."
960+
extensions_mdbook_windows:
961+
platform: windows
962+
name: Extensions MdBook
963+
working_directory: extensions/mdbook
964+
build_flags: *aspects_flags
965+
test_flags: *aspects_flags
966+
build_targets:
967+
- "//..."
968+
test_targets:
969+
- "//..."
926970
extensions_prost_linux:
927971
platform: ubuntu2004
928972
name: Extensions Prost

.bcr/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ fixedReleaser:
44
moduleRoots:
55
- "."
66
- "extensions/bindgen"
7+
- "extensions/mdbook"
78
- "extensions/prost"
89
- "extensions/protobuf"
910
- "extensions/wasm_bindgen"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"homepage": "https://github.com/bazelbuild/rules_rust",
3+
"maintainers": [
4+
{
5+
"email": "[email protected]",
6+
"github": "UebelAndre",
7+
"name": "UebelAndre"
8+
},
9+
{
10+
"email": "[email protected]",
11+
"github": "illicitonion",
12+
"name": "Daniel Wagner-Hall"
13+
},
14+
{
15+
"email": "[email protected]",
16+
"github": "scentini",
17+
"name": "Rosica Dejanovska"
18+
}
19+
],
20+
"repository": ["github:bazelbuild/rules_rust"],
21+
"versions": [],
22+
"yanked_versions": {}
23+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bcr_test_module:
2+
module_path: ""
3+
matrix:
4+
platform: ["macos_arm64", "ubuntu2004", "windows"]
5+
bazel: ["7.x"]
6+
tasks:
7+
run_tests:
8+
name: "Run test module"
9+
platform: ${{ platform }}
10+
bazel: ${{ bazel }}
11+
test_targets:
12+
- "//..."
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"integrity": "**leave this alone**",
3+
"strip_prefix": "extensions/mdbook",
4+
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{VERSION}.tar.gz"
5+
}

.github/release_notes.template

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,30 @@ http_archive(
4545

4646
</details>
4747

48+
### MdBook
49+
50+
<details>
51+
52+
#### Bzlmod
53+
54+
```python
55+
bazel_dep(name = "rules_rust_mdbook", version = "{version}")
56+
```
57+
58+
#### WORKSPACE
59+
60+
```python
61+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
62+
http_archive(
63+
name = "rules_rust_mdbook",
64+
integrity = "sha256-{sha256_base64}",
65+
strip_prefix = "extensions/mdbook",
66+
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/{version}/rules_rust-{version}.tar.gz"],
67+
)
68+
```
69+
70+
</details>
71+
4872
### Prost
4973

5074
<details>

.github/workflows/docs.yaml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,17 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
8-
types:
9-
- opened
10-
- synchronize
117

128
jobs:
139
docs:
1410
name: Docs
1511
runs-on: ubuntu-latest
1612
steps:
1713
- uses: actions/checkout@master
18-
- name: Install Rust
19-
run: |
20-
rustup set profile minimal
21-
rustup toolchain install stable
22-
rustup default stable
23-
- name: Install latest mdbook
24-
run: |
25-
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
26-
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
27-
mkdir bin
28-
curl -sSL $url | tar -xz --directory=bin
29-
echo "$(pwd)/bin" >> $GITHUB_PATH
3014
- name: Run tests
31-
run: mdbook build
15+
run: bazel run --compilation_mode=opt --stamp //:publish_book
3216
working-directory: docs
3317
- name: Deploy to GitHub Pages
34-
if: github.ref == 'refs/heads/main'
3518
uses: JamesIves/[email protected]
3619
with:
3720
branch: gh-pages # The branch the action should deploy to.

cargo/private/cargo_build_script.bzl

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,16 @@ def _cargo_build_script_impl(ctx):
348348

349349
env = dict({})
350350

351+
if ctx.attr.use_default_shell_env == -1:
352+
use_default_shell_env = ctx.attr._default_use_default_shell_env[BuildSettingInfo].value
353+
elif ctx.attr.use_default_shell_env == 0:
354+
use_default_shell_env = False
355+
else:
356+
use_default_shell_env = True
357+
351358
# If enabled, start with the default shell env, which contains any --action_env
352359
# settings passed in on the command line and defaults like $PATH.
353-
if ctx.attr.use_default_shell_env:
360+
if use_default_shell_env:
354361
env.update(ctx.configuration.default_shell_env)
355362

356363
env.update({
@@ -537,9 +544,7 @@ def _cargo_build_script_impl(ctx):
537544
progress_message = "Running Cargo build script {}".format(pkg_name),
538545
env = env,
539546
toolchain = None,
540-
# If enabled, sets the $PATH environment variable so tools like `cmake`
541-
# can probe $PATH for helper tools. Defaults to `True`.
542-
use_default_shell_env = ctx.attr.use_default_shell_env,
547+
use_default_shell_env = use_default_shell_env,
543548
)
544549

545550
return [
@@ -628,13 +633,14 @@ cargo_build_script = rule(
628633
allow_files = True,
629634
cfg = "exec",
630635
),
631-
"use_default_shell_env": attr.bool(
636+
"use_default_shell_env": attr.int(
632637
doc = dedent("""\
633638
Whether or not to include the default shell environment for the build
634639
script action. By default Bazel's `default_shell_env` is set for build
635640
script actions so crates like `cmake` can probe $PATH to find tools.
636641
"""),
637-
default = True,
642+
default = -1,
643+
values = [-1, 0, 1],
638644
),
639645
"version": attr.string(
640646
doc = "The semantic version (semver) of the crate",
@@ -654,6 +660,9 @@ cargo_build_script = rule(
654660
"_debug_std_streams_output_group": attr.label(
655661
default = Label("//cargo/settings:debug_std_streams_output_group"),
656662
),
663+
"_default_use_default_shell_env": attr.label(
664+
default = Label("//cargo/settings:use_default_shell_env"),
665+
),
657666
"_experimental_symlink_execroot": attr.label(
658667
default = Label("//cargo/settings:experimental_symlink_execroot"),
659668
),

cargo/private/cargo_build_script_wrapper.bzl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ load(
1010
load("//rust:defs.bzl", "rust_binary")
1111

1212
def cargo_build_script(
13+
*,
1314
name,
1415
edition = None,
1516
crate_name = None,
@@ -21,6 +22,7 @@ def cargo_build_script(
2122
link_deps = [],
2223
proc_macro_deps = [],
2324
build_script_env = {},
25+
use_default_shell_env = None,
2426
data = [],
2527
compile_data = [],
2628
tools = [],
@@ -107,6 +109,8 @@ def cargo_build_script(
107109
links attribute and therefore provide environment variables to this build script.
108110
proc_macro_deps (list of label, optional): List of rust_proc_macro targets used to build the script.
109111
build_script_env (dict, optional): Environment variables for build scripts.
112+
use_default_shell_env (bool, optional): Whether or not to include the default shell environment for the build script action. If unset the global
113+
setting `@rules_rust//cargo/settings:use_default_shell_env` will be used to determine this value.
110114
data (list, optional): Files needed by the build script.
111115
compile_data (list, optional): Files needed for the compilation of the build script.
112116
tools (list, optional): Tools (executables) needed by the build script.
@@ -191,13 +195,21 @@ def cargo_build_script(
191195
**wrapper_kwargs
192196
)
193197

198+
if use_default_shell_env == None:
199+
sanitized_use_default_shell_env = -1
200+
elif type(use_default_shell_env) == "bool":
201+
sanitized_use_default_shell_env = 1 if use_default_shell_env else 0
202+
else:
203+
sanitized_use_default_shell_env = use_default_shell_env
204+
194205
# This target executes the build script.
195206
_build_script_run(
196207
name = name,
197208
script = ":{}-".format(name),
198209
crate_features = crate_features,
199210
version = version,
200211
build_script_env = build_script_env,
212+
use_default_shell_env = sanitized_use_default_shell_env,
201213
links = links,
202214
deps = deps,
203215
link_deps = link_deps,

cargo/private/cargo_utils.bzl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
load("//rust/platform:triple_mappings.bzl", "system_to_binary_ext")
44

5+
# TODO: remove after dropping support for Bazel < 7 when `abs` is a global
6+
def abs(value):
7+
"""Returns the absolute value of a number.
8+
9+
Args:
10+
value (int): A number.
11+
12+
Returns:
13+
int: The absolute value of the number.
14+
"""
15+
if value < 0:
16+
return -value
17+
return value
18+
519
def _resolve_repository_template(
620
*,
721
template,

0 commit comments

Comments
 (0)