Skip to content

Commit

Permalink
Merge branch 'main' into revert
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre authored Dec 16, 2024
2 parents 16e12e1 + c263575 commit fe2f534
Show file tree
Hide file tree
Showing 365 changed files with 34,706 additions and 352 deletions.
44 changes: 44 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ tasks:
- //...
run_targets:
- "//:test_docs"
- "//:publish_book"
clippy_failure:
name: Negative Clippy Tests
platform: ubuntu2004
Expand Down Expand Up @@ -923,6 +924,49 @@ tasks:
# test_targets:
# - "--"
# - "//..."
extensions_mdbook_linux:
platform: ubuntu2004
name: Extensions MdBook
working_directory: extensions/mdbook
build_flags: *aspects_flags
test_flags: *aspects_flags
build_targets:
- "//..."
test_targets:
- "//..."
extensions_mdbook_linux_rbe:
platform: rbe_ubuntu2004
name: Extensions MdBook
working_directory: extensions/mdbook
shell_commands:
- sed -i 's/^# load("@bazel_ci_rules/load("@bazel_ci_rules/' WORKSPACE.bazel
- sed -i 's/^# rbe_preconfig/rbe_preconfig/' WORKSPACE.bazel
build_flags: *aspects_flags
test_flags: *aspects_flags
build_targets:
- "//..."
test_targets:
- "//..."
extensions_mdbook_macos:
platform: macos_arm64
name: Extensions MdBook
working_directory: extensions/mdbook
build_flags: *aspects_flags
test_flags: *aspects_flags
build_targets:
- "//..."
test_targets:
- "//..."
extensions_mdbook_windows:
platform: windows
name: Extensions MdBook
working_directory: extensions/mdbook
build_flags: *aspects_flags
test_flags: *aspects_flags
build_targets:
- "//..."
test_targets:
- "//..."
extensions_prost_linux:
platform: ubuntu2004
name: Extensions Prost
Expand Down
1 change: 1 addition & 0 deletions .bcr/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ fixedReleaser:
moduleRoots:
- "."
- "extensions/bindgen"
- "extensions/mdbook"
- "extensions/prost"
- "extensions/protobuf"
- "extensions/wasm_bindgen"
23 changes: 23 additions & 0 deletions .bcr/extensions/mdbook/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"homepage": "https://github.com/bazelbuild/rules_rust",
"maintainers": [
{
"email": "[email protected]",
"github": "UebelAndre",
"name": "UebelAndre"
},
{
"email": "[email protected]",
"github": "illicitonion",
"name": "Daniel Wagner-Hall"
},
{
"email": "[email protected]",
"github": "scentini",
"name": "Rosica Dejanovska"
}
],
"repository": ["github:bazelbuild/rules_rust"],
"versions": [],
"yanked_versions": {}
}
12 changes: 12 additions & 0 deletions .bcr/extensions/mdbook/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
bcr_test_module:
module_path: ""
matrix:
platform: ["macos_arm64", "ubuntu2004", "windows"]
bazel: ["7.x"]
tasks:
run_tests:
name: "Run test module"
platform: ${{ platform }}
bazel: ${{ bazel }}
test_targets:
- "//..."
5 changes: 5 additions & 0 deletions .bcr/extensions/mdbook/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "**leave this alone**",
"strip_prefix": "extensions/mdbook",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{VERSION}.tar.gz"
}
24 changes: 24 additions & 0 deletions .github/release_notes.template
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ http_archive(

</details>

### MdBook

<details>

#### Bzlmod

```python
bazel_dep(name = "rules_rust_mdbook", version = "{version}")
```

#### WORKSPACE

```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_rust_mdbook",
integrity = "sha256-{sha256_base64}",
strip_prefix = "extensions/mdbook",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/{version}/rules_rust-{version}.tar.gz"],
)
```

</details>

### Prost

<details>
Expand Down
19 changes: 1 addition & 18 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,17 @@ on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize

jobs:
docs:
name: Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install stable
rustup default stable
- name: Install latest mdbook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir bin
curl -sSL $url | tar -xz --directory=bin
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: Run tests
run: mdbook build
run: bazel run --compilation_mode=opt --stamp //:publish_book
working-directory: docs
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
Expand Down
21 changes: 15 additions & 6 deletions cargo/private/cargo_build_script.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,16 @@ def _cargo_build_script_impl(ctx):

env = dict({})

if ctx.attr.use_default_shell_env == -1:
use_default_shell_env = ctx.attr._default_use_default_shell_env[BuildSettingInfo].value
elif ctx.attr.use_default_shell_env == 0:
use_default_shell_env = False
else:
use_default_shell_env = True

# If enabled, start with the default shell env, which contains any --action_env
# settings passed in on the command line and defaults like $PATH.
if ctx.attr.use_default_shell_env:
if use_default_shell_env:
env.update(ctx.configuration.default_shell_env)

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

return [
Expand Down Expand Up @@ -628,13 +633,14 @@ cargo_build_script = rule(
allow_files = True,
cfg = "exec",
),
"use_default_shell_env": attr.bool(
"use_default_shell_env": attr.int(
doc = dedent("""\
Whether or not to include the default shell environment for the build
script action. By default Bazel's `default_shell_env` is set for build
script actions so crates like `cmake` can probe $PATH to find tools.
"""),
default = True,
default = -1,
values = [-1, 0, 1],
),
"version": attr.string(
doc = "The semantic version (semver) of the crate",
Expand All @@ -654,6 +660,9 @@ cargo_build_script = rule(
"_debug_std_streams_output_group": attr.label(
default = Label("//cargo/settings:debug_std_streams_output_group"),
),
"_default_use_default_shell_env": attr.label(
default = Label("//cargo/settings:use_default_shell_env"),
),
"_experimental_symlink_execroot": attr.label(
default = Label("//cargo/settings:experimental_symlink_execroot"),
),
Expand Down
12 changes: 12 additions & 0 deletions cargo/private/cargo_build_script_wrapper.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ load(
load("//rust:defs.bzl", "rust_binary")

def cargo_build_script(
*,
name,
edition = None,
crate_name = None,
Expand All @@ -21,6 +22,7 @@ def cargo_build_script(
link_deps = [],
proc_macro_deps = [],
build_script_env = {},
use_default_shell_env = None,
data = [],
compile_data = [],
tools = [],
Expand Down Expand Up @@ -107,6 +109,8 @@ def cargo_build_script(
links attribute and therefore provide environment variables to this build script.
proc_macro_deps (list of label, optional): List of rust_proc_macro targets used to build the script.
build_script_env (dict, optional): Environment variables for build scripts.
use_default_shell_env (bool, optional): Whether or not to include the default shell environment for the build script action. If unset the global
setting `@rules_rust//cargo/settings:use_default_shell_env` will be used to determine this value.
data (list, optional): Files needed by the build script.
compile_data (list, optional): Files needed for the compilation of the build script.
tools (list, optional): Tools (executables) needed by the build script.
Expand Down Expand Up @@ -191,13 +195,21 @@ def cargo_build_script(
**wrapper_kwargs
)

if use_default_shell_env == None:
sanitized_use_default_shell_env = -1
elif type(use_default_shell_env) == "bool":
sanitized_use_default_shell_env = 1 if use_default_shell_env else 0
else:
sanitized_use_default_shell_env = use_default_shell_env

# This target executes the build script.
_build_script_run(
name = name,
script = ":{}-".format(name),
crate_features = crate_features,
version = version,
build_script_env = build_script_env,
use_default_shell_env = sanitized_use_default_shell_env,
links = links,
deps = deps,
link_deps = link_deps,
Expand Down
14 changes: 14 additions & 0 deletions cargo/private/cargo_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

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

# TODO: remove after dropping support for Bazel < 7 when `abs` is a global
def abs(value):
"""Returns the absolute value of a number.
Args:
value (int): A number.
Returns:
int: The absolute value of the number.
"""
if value < 0:
return -value
return value

def _resolve_repository_template(
*,
template,
Expand Down
7 changes: 7 additions & 0 deletions cargo/settings/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ bool_flag(
name = "debug_std_streams_output_group",
build_setting_default = False,
)

# A flag which controls the global default of `ctx.actions.run.use_default_shell_env`
# for `cargo_build_script` targets.
bool_flag(
name = "use_default_shell_env",
build_setting_default = True,
)
Loading

0 comments on commit fe2f534

Please sign in to comment.