Commit Graph

163 Commits

Author SHA1 Message Date
UebelAndre f213d28fda
Added Rust 1.82.0 (#2944)
https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html
2024-10-21 05:39:37 +00:00
Fabian Meumertzheim 9390eba52c
Allow `+` in repo names (#2908)
Bazel 8 uses `+` as the separator for segments of canonical repo names,
whereas Bazel 7 uses `~` or `+` depending on the value of
`--incompatible_use_plus_in_repo_names`.

---------

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
2024-10-01 13:36:51 +00:00
Stu Schwartz beebf3b071
Add wasm64 support. (#2866)
This PR adds support for `wasm64-unknown-unknown` although there are no
prebuilt `wasm64-unknown-unknown` rustc toolchains. Compiling for
`wasm64` will be left up to anyone using this target triple until we get
T2 support for wasm64.

---------

Co-authored-by: Andre Brisco <andre.brisco@freeform.co>
2024-09-18 00:34:07 +00:00
UebelAndre 1ade1876f2
Added Rust 1.81.0 (#2841)
https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html

---------

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
2024-09-10 21:02:49 +00:00
Daniel Wagner-Hall 20503514db
Use fake.rs not /dev/null as fake source file (#2851)
We store in the lockfile the path of this source file relative to the
package, and if we use an absolute path we end up encoding the depth of
your local git clone into the lockfile, which is non-determinstic across
machines.

Elsewhere we use fake.rs, let's use it here as well.
2024-09-10 16:14:04 +00:00
UebelAndre 05d54a46b1
Prune `known_shas.bzl` to only include versions used in BazelCI (#2850) 2024-09-10 15:35:23 +00:00
UebelAndre ab3a6886ad
Support emitting debug logs in rules_rust process wrapper. (#2845)
When debugging an action it can be incredibly helpful to have the exact
command used to invoke `rustc`. This PR updates the rustc process
wrapper to emit debug logs when the `RULES_RUST_PROCESS_WRAPPER_DEBUG`
environment variable is enabled.

Example:
```bash
bazel build //test/... --action_env=RULES_RUST_PROCESS_WRAPPER_DEBUG=1
```
```
INFO: From Generating Rustdoc for @//test/unit/rustdoc:lib_with_proc_macro:
Command: Command {
    program: "bazel-out/darwin_arm64-fastbuild/bin/external/rust_darwin_aarch64__aarch64-apple-darwin__stable_tools/rust_toolchain/bin/rustdoc",
    args: [
        "bazel-out/darwin_arm64-fastbuild/bin/external/rust_darwin_aarch64__aarch64-apple-darwin__stable_tools/rust_toolchain/bin/rustdoc",
        "test/unit/rustdoc/rustdoc_lib.rs",
        "--crate-name=lib_with_proc_macro",
        "--crate-type=rlib",
        "--error-format=human",
        "--codegen=opt-level=0",
        "--codegen=debuginfo=0",
        "--codegen=strip=none",
        "--color=always",
        "--target=aarch64-apple-darwin",
        "-L",
        "bazel-out/darwin_arm64-fastbuild/bin/external/rust_darwin_aarch64__aarch64-apple-darwin__stable_tools/rust_toolchain/lib/rustlib/aarch64-apple-darwin/lib",
        "--output",
        "bazel-out/darwin_arm64-fastbuild/bin/test/unit/rustdoc/lib_with_proc_macro_doc.rustdoc",
        "--extern",
        "lib_with_proc_macro=bazel-out/darwin_arm64-fastbuild/bin/test/unit/rustdoc/liblib_with_proc_macro-78138021.rlib",
        "--edition=2018",
        "--codegen=linker=external/local_config_cc/cc_wrapper.sh",
        "--codegen=link-arg=-mmacosx-version-min=14.5",
        "--codegen=link-arg=-no-canonical-prefixes",
        "--codegen=link-arg=-fobjc-link-runtime",
        "--codegen=link-arg=-headerpad_max_install_names",
        "--codegen=link-arg=-lc++",
        "--codegen=link-arg=-lm",
        "--extern=rustdoc_proc_macro=bazel-out/darwin_arm64-opt-exec-ST-a828a81199fe/bin/test/unit/rustdoc/librustdoc_proc_macro-2600278351.dylib",
        "-Ldependency=bazel-out/darwin_arm64-opt-exec-ST-a828a81199fe/bin/test/unit/rustdoc",
        "--sysroot=bazel-out/darwin_arm64-fastbuild/bin/external/rust_darwin_aarch64__aarch64-apple-darwin__stable_tools/rust_toolchain",
    ],
    env: CommandEnv {
        clear: true,
        vars: {
            "CARGO_CFG_TARGET_ARCH": Some(
                "aarch64",
            ),
            "CARGO_CFG_TARGET_OS": Some(
                "darwin",
            ),
            "CARGO_CRATE_NAME": Some(
                "lib_with_proc_macro",
            ),
            "CARGO_MANIFEST_DIR": Some(
                "/private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52/sandbox/darwin-sandbox/1151/execroot/rules_rust/test/unit/rustdoc",
            ),
            "CARGO_PKG_AUTHORS": Some(
                "",
            ),
            "CARGO_PKG_DESCRIPTION": Some(
                "",
            ),
            "CARGO_PKG_HOMEPAGE": Some(
                "",
            ),
            "CARGO_PKG_NAME": Some(
                "lib_with_proc_macro",
            ),
            "CARGO_PKG_VERSION": Some(
                "0.0.0",
            ),
            "CARGO_PKG_VERSION_MAJOR": Some(
                "0",
            ),
            "CARGO_PKG_VERSION_MINOR": Some(
                "0",
            ),
            "CARGO_PKG_VERSION_PATCH": Some(
                "0",
            ),
            "CARGO_PKG_VERSION_PRE": Some(
                "",
            ),
            "REPOSITORY_NAME": Some(
                "",
            ),
            "RULES_RUST_PROCESS_WRAPPER_DEBUG": Some(
                "1",
            ),
            "TMPDIR": Some(
                "/var/folders/hf/phjl9q7501gb5wt_qr4ltn3m0000gn/T/",
            ),
            "ZERO_AR_DATE": Some(
                "1",
            ),
            "__CF_USER_TEXT_ENCODING": Some(
                "0x1F5:0x0:0x0",
            ),
        },
    },
    stdout: Some(
        Inherit,
    ),
    stderr: Some(
        MakePipe,
    ),
}
```

---------

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
2024-09-10 15:00:15 +00:00
UebelAndre dca03c94f6
Updated fetch_shas utility to use the channel manifest tomls (#2840)
Updating shas was taking much longer than it used to. I've refactored
the shell script into python so to manage increased complexity. The
script now fetches the `channel-rust-*.toml` files which contains
additional sha256 values. This script still falls back to brute force
fetching of artifacts to account for any that are missing. The runtime
was reduced from ~20 min to ~80s.

```bash
python3.11 ./util/fetch_shas/fetch_shas.py
```
```
2024-09-06 08:57:22 - INFO - Fetching known sha256 data...
2024-09-06 08:57:22 - INFO - Downloading data...
2024-09-06 08:57:29 - INFO - Done.
2024-09-06 08:57:29 - INFO - Deserializing 119 tomls...
2024-09-06 08:57:36 - INFO - Done.
2024-09-06 08:57:36 - INFO - Parsing artifacts...
2024-09-06 08:57:36 - INFO - Done. Identified 52790 artifacts.
2024-09-06 08:57:36 - INFO - Checking for 81514 missing artifacts...
2024-09-06 08:58:26 - INFO - Done.
2024-09-06 08:58:29 - INFO - Downloading 404 missing artifacts...
2024-09-06 08:58:29 - INFO - Done.
2024-09-06 08:58:36 - INFO - Done. Wrote rust/known_shas.bzl
```

Note that `beta` sha256 values have been removed in this change.
2024-09-10 14:55:13 +00:00
Daniel Wagner-Hall 64deada614
Merge repin scripts (#2769)
We have two of these, and they do overlapping but not equal things.

Unify to one, and merge in the missing functionality.
2024-07-31 09:30:54 +00:00
UebelAndre ad615c702c
Added Rust 1.80.0 (#2763)
https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html
2024-07-29 14:45:19 +00:00
Daniel Wagner-Hall 4ea03d6fd0
rust-analyzer: Factor aliases into the project (#2709)
Fixes #2707
2024-06-20 15:47:56 +00:00
UebelAndre 67b3571d7e
Added Rust 1.79.0 (#2695)
https://blog.rust-lang.org/2024/06/13/Rust-1.79.0.html
2024-06-13 17:03:32 +00:00
UebelAndre d83c86581c
Add flag to refer to a `sh_toolchain` for process wrapper bootstrap shebangs (#2694)
This introduces the flag
`--@rules_rust//rust/settings:experimental_use_sh_toolchain_for_bootstrap_process_wrapper`
which can be used to embed the shell path from
`@bazel_tools//tools/sh:toolchain_type` in the rustc bootstrap process
wrapper.
2024-06-13 16:37:40 +00:00
Daniel Wagner-Hall 9c672947a1
Remote vendor doesn't require srcs present (#2688)
Before this, if we re-generate all of the BUILD.bazel files for our
vendored deps, they are invalid because they only have BUILD.bazel files
and the globs present in them expect srcs.

First two commits are real changes, third commit is just a repin.
2024-06-13 16:13:39 +00:00
UebelAndre 3342d6879d
Added Rust 1.78.0 (#2639)
https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html
2024-05-07 10:07:49 +00:00
UebelAndre 768eaf4067
Added Rust 1.77.2 (#2608)
https://blog.rust-lang.org/2024/04/09/Rust-1.77.2.html
2024-04-10 08:58:26 +00:00
UebelAndre 33f2f18a0e
Added Rust 1.77.1 (#2591)
https://blog.rust-lang.org/2024/03/28/Rust-1.77.1.html
2024-04-05 15:07:18 +00:00
UebelAndre 4bda11a16d
Added Rust 1.77.0 (#2568)
https://blog.rust-lang.org/2024/03/21/Rust-1.77.0.html
2024-03-21 16:34:39 +00:00
James Leitch f8ffba5ab2
Rust Analyzer added NixOS supported platforms (#2547) 2024-03-19 04:27:15 +00:00
UebelAndre 998f7d532a
Updated label crate to understand canonical vs apparent repositories (#2507)
Doing my best to adhere to https://bazel.build/concepts/labels. This
change updates the label utility to account for modern changes to Bazel
labels (e.g. from bzlmod).
2024-02-22 14:54:52 +00:00
UebelAndre b1fc85232d
Update crates_universe render script to run from Bazel (#2492) 2024-02-19 17:45:55 +00:00
Cameron Martin 04f1b5d0b0
Add script to revendor all crates (#2459)
It seems that vendored crates commonly get out of sync. Re-vendoring
seems to currently be a quite manual process, and finding everything to
re-vendor is a hassle.

This adds a bash script, `vendor.sh`, that finds all crate vendor rules
in all workspaces in this repository and runs them. This significantly
improves the workflow for updating these.

This also adds `.bazelrc` files to disable bzlmod to non-bzlmod
workspaces, since otherwise bazel 7 create a MODULE.bazel and
MODULE.bazel.lock when re-vendoring.

This also re-vendors all crates (in a separate commit).
2024-02-18 09:35:00 -08:00
UebelAndre 9f68ed24fc
Added Rust 1.76.0 (#2468)
https://blog.rust-lang.org/2024/02/08/Rust-1.76.0.html
2024-02-08 18:22:54 +00:00
scentini caa3959740
Drop import macro (#2411)
As discussed over at
https://github.com/bazelbuild/rules_rust/issues/2383
2024-01-11 10:19:23 +00:00
UebelAndre 86379418f0
Added Rust 1.75.0 (#2380)
https://blog.rust-lang.org/2023/12/28/Rust-1.75.0.html
2024-01-02 11:21:08 +00:00
UebelAndre ea60dc5a4e
Added Rust 1.74.1 (#2354)
https://blog.rust-lang.org/2023/12/07/Rust-1.74.1.html
2023-12-27 11:19:46 +00:00
James Leitch 0e4be00d1e
Platform transition added to Rust binary rules. (#2310)
Without much insight into core Bazel's plans for supporting "flagless"
builds across platforms, this seems like the most direct way to select
the platform for a given Rust binary target (all the terminal rules)
that doesn't need additional work to forward providers.

Currently I'm using `platform_transition_binary`
(https://github.com/aspect-build/bazel-lib/blob/main/docs/transitions.md),
but it doesn't work with Rust Analyzer/Clippy/etc. presumably due to not
forwarding the providers. In the case of this particular rule, it also
doesn't work for something like `rust_shared_library()` which is
explicitly not an `executable = True` target.

@illicitonion brought to my attention `with_cfg`
(https://github.com/fmeum/with_cfg.bzl) which could be used as an
alternative by consumers of `rules_rust` instead of this PR. That feels
reasonable, though certainly more work for individual users and appears
to rely on a lot of Bazel black magic.

Along the same lines, this could wait on rule inheritance as presumably
a more formally supported `with_cfg` approach, which would also be up to
individual users and not `rules_rust`.
2023-12-13 17:39:11 +00:00
James Leitch 3ca92dd44b
Nix example switched to using `crate_universe_dependencies(bootstrap=True)` (#2313)
Seeing as #2279 is merged, this fixes the current Nix built
`cargo-bazel` getting stale because it's not able to watch the source
files. This should make for much better iteration speed as well, as the
Nix built form has to do a clean build every time.
2023-12-12 17:57:07 +00:00
Matt 44ffccb91c
Allow additional targets to compile with bzlmod (#2314)
See #2246 for how we declare dependencies automatically for third party
crates. I'm using the same mechanism for all other repositories.

Note that the MODULE.bazel changes in use_repo are autogenerated, and if
you change the third party crates you depend on, you should get an error
message saying something like "run this command to fix it" on your
bzlmod presubmit environment.
2023-12-12 13:52:58 +00:00
Matt 0bded8073d
Add an option to save the json output from rustc to pass to rust-analyzer (#1942)
@googleson78 originally wrote
https://github.com/bazelbuild/rules_rust/pull/1657 in order to solve
this problem. As discussed in that PR, they're no longer working on
this, so I offered to pick this up. This is the same PR as that one, but
has some bugfixes and refactoring applied.

---------

Co-authored-by: Georgi Lyubenov <georgi.lyubenov@tweag.io>
Co-authored-by: UebelAndre <github@uebelandre.com>
2023-12-04 18:24:29 -08:00
Matt 3fd4987269
Declare dependencies in vendored crates (#2246)
Currently, when you run `bazel build --enable_bzlmod
//crate_universe:bin`, you get the error `undefined repo @cui`.

When you add a dependency on CUI, you get errors like `undefined repo
@cui__<crate>-<version>` (the repo for the third party crate).

This change will allow us to automatically declare dependencies on our
third party crates from bzlmod (see
https://docs.google.com/document/d/1dj8SN5L6nwhNOufNqjBhYkk5f-BJI_FPYWKxlB3GAmA/edit#heading=h.5mcn15i0e1ch).

---------

Co-authored-by: UebelAndre <github@uebelandre.com>
2023-12-04 07:50:52 -08:00
Daniel Wagner-Hall 4aa6550b95
Add repin script (#2282)
Every time I need to update these I incrementally run these commands,
finding out what I missed via CI each time.

Instead, let's write this down.
2023-11-23 15:38:30 +00:00
UebelAndre 40e1a9257a
Added Rust 1.74.0 (#2268)
https://blog.rust-lang.org/2023/11/16/Rust-1.74.0.html
2023-11-16 15:06:27 +00:00
Roberto Bampi 9341d1ff4f
process_wrapper: write all output from rustc if json parsing fails. (#2234)
Previously we were only reporting the first line of any error rustc may
emit when it panic'd or otherwise unexpectedly stopped outputting json.
2023-11-03 13:55:57 +01:00
UebelAndre ec5fd40164
Fix issues causing the `Rustc` process wrapper to be built non-determ… (#2216)
This change aims to ensure the process wrapper is built
determinisitically, thus reducing churn in cases where multiple
developers share a bazel remote cache. The shared cache is notable as
the binaries can be deterministically produced for a single user for a
single checkout as some host information is embedded in the compiled
binaries. The host information is stored in the `debug-info` section of
the executable. This can be resolved by stripping it. The other issue of
determinism is `rust_binary_without_process_wrapper` does not resolve
`${pwd}` like the process wrapper does, thus stripping sandbox paths
from rustc outputs. To solve for this a small bash and batch script was
added to account for this behavior. The intent of these scripts is to
use __no__ host executables and instead rely on pure bash and batch to
accomplish this and keep any actions which use this as hermetic as
possible.


The following tables were produced on macOS. Note that `rules_rust_2` is
simply another checkout of `rules_rust` on the same commit

Before the changes in this PR:

| path | rules_rust sha256 | rules_rust_2 sha256 |
| --- | --- | --- |
|
bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/rules_rust_tinyjson/libtinyjson-4031717389.rlib
| 60db194b3e98b67cc0702c6b6c48c5bc8fcf7d723f3ece6a7a24a53888158c7e |
3eac0b443ba160e3a1bde3b023f4e953bb9fc9722e430b5ded6dbb723bc2b532 |
|
bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/util/process_wrapper/process_wrapper
| 32e7840602c977b76bba0bc39da768d35db3e7a17dbf96e455727be2b2f0151f |
0d248279bbc9b17be5914b41a66759f939ef4da77f8a40a5ce6fa3bf339648ad |

After the changes:

| path | rules_rust sha256 | rules_rust_2 sha256 |
| --- | --- | --- |
|
bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/rules_rust_tinyjson/libtinyjson-4031717389.rlib
| 07432f5d207da854266ccde212243c67c29907f81a7619434ce9f608b1658d96 |
07432f5d207da854266ccde212243c67c29907f81a7619434ce9f608b1658d96 |
|
bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/util/process_wrapper/process_wrapper
| cbf17392338aabfc942d975f95a49a67b731c5e597a7d27e3d9cf4d4a06b8f2c |
cbf17392338aabfc942d975f95a49a67b731c5e597a7d27e3d9cf4d4a06b8f2c |

closes https://github.com/bazelbuild/rules_rust/issues/2092
2023-10-27 05:20:44 -07:00
UebelAndre 699c833c2e
Added Rust 1.73.0 (#2184)
https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html
2023-10-09 10:33:44 +01:00
UebelAndre ca99de8a2e
Added Rust 1.72.1 (#2163)
https://blog.rust-lang.org/2023/09/19/Rust-1.72.1.html
2023-09-21 14:49:44 +00:00
Daniel Wagner-Hall 1f9b63a408
cargo_build_scripts can be run from custom directories (#2152)
While running from CARGO_MANIFEST_DIR is the simplest thing for
compatibility, there are cases where a cargo build script may be easier
to run from the exec root as most bazel actions do (e.g. where a C++
toolchain specifies in-repo include paths).

This mirrors the `rundir` attribute of `go_test`, which has similar
concerns:
https://github.com/bazelbuild/rules_go/blob/master/docs/go/core/rules.md#go_test-rundir
2023-09-06 18:38:35 +02:00
UebelAndre b55575e127
Added Rust 1.72.0 (#2127)
https://blog.rust-lang.org/2023/08/24/Rust-1.72.0.html
2023-08-28 16:42:12 +00:00
UebelAndre ddbce7eb9a
Add support for split_coverage_post_processing (#2000)
This change introduces `experimental_use_coverage_metadata_files`
(https://github.com/bazelbuild/rules_rust/issues/2082) which is required
to support
[--experimental_split_coverage_postprocessing](https://bazel.build/reference/command-line-reference#flag--experimental_split_coverage_postprocessing)'

Changes:
- Implemented coverage collection logic in Rust.
- Added a flag
`--@rules_rust//rust/settings:experimental_use_coverage_metadata_files`
to toggle the changes necessary for supporting
`--experimental_split_coverage_postprocessing`.
- Added regression testing in CI to test
`--experimental_split_coverage_postprocessing`.
2023-07-28 12:59:53 +02:00
UebelAndre 4bd44d03ec
Added Rust 1.71.0 (#2062)
https://blog.rust-lang.org/2023/07/13/Rust-1.71.0.html
2023-07-27 10:19:55 +00:00
Cameron Martin 36f8251f97
Exclude .tmp_git_root from globs (#1948)
* Exclude .tmp_git_root from globs

This directory contains the original git repo when the crate is from git. Including this directory currently makes these rules re-run whenever the repository rule re-runs, although this is fixed by https://github.com/bazelbuild/bazel/pull/18271. Even after this fix, excluding this directory avoids depending on unnecessary files.

Fixes #1927.

* Regenerate vendored crates
2023-06-23 04:27:16 -07:00
UebelAndre 8e848414da
Regenerated crate_universe outputs for all packages (#2011)
* Regenerated crate_universe outputs for all packages

* Regenerated crate_unvierse examples
2023-06-14 15:25:34 +00:00
UebelAndre 93b230bb82
Fix code coverage collection. (#2001)
* Minor CI and test cleanup

* Bump min tested Bazel version to 5.2.0

* Fix code coverage collection.
2023-06-13 17:34:14 +00:00
UebelAndre 73a06f1305
Added Rust 1.70.0 (#1991)
* Added Rust 1.70.0

* Regenerate documentation

* Updated crate_universe examples

* Disable proto targets to avoid ambiguous imports

* Address new clippy defects
2023-06-02 14:25:37 +00:00
David Tolnay 56e7604879
Fix typo in crate_universe-generated defs.bzl comment (#1981) 2023-05-30 10:45:18 +01:00
UebelAndre a86313282f
Added Rust 1.69.0 (#1930)
* Added Rust 1.69.0

* Update crate_universe examples

* Regenerate documentation
2023-04-24 10:18:01 +02:00
Gabriel Féron dab4257606
Add Rust 1.68.2 (#1908)
* Add Rust 1.68.2

* Regenerate documentation
2023-03-30 10:08:11 -07:00
UebelAndre 7a47449dfd
Added Rust 1.68.1 (#1898)
* Added Rust 1.68.1

* Regenerate documentation

* Update crate_universe examples
2023-03-24 11:02:14 +00:00
UebelAndre b3cd5962ea
Added Rust 1.68.0 (#1866)
https://blog.rust-lang.org/2023/03/09/Rust-1.68.0.html
2023-03-14 23:39:44 +00:00