Commit Graph

423 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
UebelAndre 7639ba7c3a
Fix fuchsia platform triple (#2945)
This change aligns with https://github.com/rust-lang/rust/issues/130661
and addresses issues with `crate_universe` in newer versions of Rust.
2024-10-20 15:33:14 +00:00
Stu Schwartz 5d8d989ed2
[Prost] Remove extra generated modules and opt-in to transitively including deps (#2943)
This PR makes two changes:
1. It removes the duplicately generated code in the prost `lib.rs`.
2. It allows opting into transitively including all of the proto deps.

## Duplicately generated code.

Previously there was a bug where we generated the same code at every
proto package level. This created separate Rust types for each module
which made it easy to accidentally import an incompatible type.

Before:
```rust
// @generated

pub mod b_ar {
    pub mod b_az {
        pub mod qaz {
            pub mod qu_x {
                // @generated
                // This file is @generated by prost-build.
                #[allow(clippy::derive_partial_eq_without_eq)]
                #[derive(Clone, PartialEq, ::prost::Message)]
                pub struct Bar {
                    #[prost(string, tag = "1")]
                    pub name: ::prost::alloc::string::String,
                    #[prost(message, optional, tag = "2")]
                    pub foo: ::core::option::Option<
                        ::foo_proto::foo::quu_x::co_rg_e::grault::ga_rply::Foo,
                    >,
                    #[prost(message, optional, tag = "3")]
                    pub nested_foo: ::core::option::Option<
                        ::foo_proto::foo::quu_x::co_rg_e::grault::ga_rply::foo::NestedFoo,
                    >,
                }
                /// Nested message and enum types in `Bar`.
                pub mod bar {
                    #[allow(clippy::derive_partial_eq_without_eq)]
                    #[derive(Clone, PartialEq, ::prost::Message)]
                    pub struct Baz {
                        #[prost(string, tag = "4")]
                        pub name: ::prost::alloc::string::String,
                    }
                }
                // @@protoc_insertion_point(module)
            }
        }
    }
}
pub mod b_az {
    pub mod qaz {
        pub mod qu_x {
            // @generated
            // This file is @generated by prost-build.
            #[allow(clippy::derive_partial_eq_without_eq)]
            #[derive(Clone, PartialEq, ::prost::Message)]
            pub struct Bar {
                #[prost(string, tag = "1")]
                pub name: ::prost::alloc::string::String,
                #[prost(message, optional, tag = "2")]
                pub foo:
                    ::core::option::Option<::foo_proto::foo::quu_x::co_rg_e::grault::ga_rply::Foo>,
                #[prost(message, optional, tag = "3")]
                pub nested_foo: ::core::option::Option<
                    ::foo_proto::foo::quu_x::co_rg_e::grault::ga_rply::foo::NestedFoo,
                >,
            }
            /// Nested message and enum types in `Bar`.
            pub mod bar {
                #[allow(clippy::derive_partial_eq_without_eq)]
                #[derive(Clone, PartialEq, ::prost::Message)]
                pub struct Baz {
                    #[prost(string, tag = "4")]
                    pub name: ::prost::alloc::string::String,
                }
            }
            // @@protoc_insertion_point(module)
        }
    }
}
pub mod qaz {
    pub mod qu_x {
        // @generated
        // This file is @generated by prost-build.
        #[allow(clippy::derive_partial_eq_without_eq)]
        #[derive(Clone, PartialEq, ::prost::Message)]
        pub struct Bar {
            #[prost(string, tag = "1")]
            pub name: ::prost::alloc::string::String,
            #[prost(message, optional, tag = "2")]
            pub foo: ::core::option::Option<::foo_proto::foo::quu_x::co_rg_e::grault::ga_rply::Foo>,
            #[prost(message, optional, tag = "3")]
            pub nested_foo: ::core::option::Option<
                ::foo_proto::foo::quu_x::co_rg_e::grault::ga_rply::foo::NestedFoo,
            >,
        }
        /// Nested message and enum types in `Bar`.
        pub mod bar {
            #[allow(clippy::derive_partial_eq_without_eq)]
            #[derive(Clone, PartialEq, ::prost::Message)]
            pub struct Baz {
                #[prost(string, tag = "4")]
                pub name: ::prost::alloc::string::String,
            }
        }
        // @@protoc_insertion_point(module)
    }
}
pub mod qu_x {
    // @generated
    // This file is @generated by prost-build.
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Clone, PartialEq, ::prost::Message)]
    pub struct Bar {
        #[prost(string, tag = "1")]
        pub name: ::prost::alloc::string::String,
        #[prost(message, optional, tag = "2")]
        pub foo: ::core::option::Option<::foo_proto::foo::quu_x::co_rg_e::grault::ga_rply::Foo>,
        #[prost(message, optional, tag = "3")]
        pub nested_foo: ::core::option::Option<
            ::foo_proto::foo::quu_x::co_rg_e::grault::ga_rply::foo::NestedFoo,
        >,
    }
    /// Nested message and enum types in `Bar`.
    pub mod bar {
        #[allow(clippy::derive_partial_eq_without_eq)]
        #[derive(Clone, PartialEq, ::prost::Message)]
        pub struct Baz {
            #[prost(string, tag = "4")]
            pub name: ::prost::alloc::string::String,
        }
    }
    // @@protoc_insertion_point(module)
}

```

Now:
```rust
// @generated

pub use foo_proto;

pub mod b_ar {
    pub mod b_az {
        pub mod qaz {
            pub mod qu_x {
                // @generated
                // This file is @generated by prost-build.
                #[allow(clippy::derive_partial_eq_without_eq)]
                #[derive(Clone, PartialEq, ::prost::Message)]
                pub struct Bar {
                    #[prost(string, tag = "1")]
                    pub name: ::prost::alloc::string::String,
                    #[prost(message, optional, tag = "2")]
                    pub foo: ::core::option::Option<
                        ::foo_proto::foo::quu_x::co_rg_e::grault::ga_rply::Foo,
                    >,
                    #[prost(message, optional, tag = "3")]
                    pub nested_foo: ::core::option::Option<
                        ::foo_proto::foo::quu_x::co_rg_e::grault::ga_rply::foo::NestedFoo,
                    >,
                }
                /// Nested message and enum types in `Bar`.
                pub mod bar {
                    #[allow(clippy::derive_partial_eq_without_eq)]
                    #[derive(Clone, PartialEq, ::prost::Message)]
                    pub struct Baz {
                        #[prost(string, tag = "4")]
                        pub name: ::prost::alloc::string::String,
                    }
                }
                // @@protoc_insertion_point(module)
            }
        }
    }
}
```

## Including transitive depenencies.

Because the proto rules rely on aspects, we are compiling targets which
may not be directly accessible as a label in Bazel. Out of convenience,
the original implementation automatically included all transitive
dependencies to the `rust_library` or `rust_binary` that depended on the
proto crate.

As an example, let's say we have the following hierarchy:
```
my_crate -> a.proto
a.proto -> b.proto
b.proto -> c.proto
```
The previous setup made it possible for `my_crate` to directly import
`a_proto`, `b_proto`, and `c_proto`.

This is problematic though because it leads to significant crate
dependency bloat. `my_crate` may only use `a_proto` directly but it now
also depends on the unused crates `b_proto` and `c_proto`.


This PR makes every generated crate re-export its direct dependencies.
So, for the same example we now can import via those reexports:
```rust
//! my_crate
use a_proto::A;
use a_proto::b_proto::B;
use a_proto::b_proto::c_proto::C;
```

This means that you can also add the rustc flag
`-Dunused_crate_dependencies` to ensure you're not depending on crates
which are unused. In our monorepo we've had to disable this flag for
crates depending on protos.

If you need to depend on an intermediate crate directly, you can just
add a `rust_prost_library` definition and since it's all generated with
aspects, it will be the identical underlying crate.

Finally, if you really want the extra crates included, you can set the
flag `include_transitive_deps` on the prost toolchain and that will
bring back the previous behavior.
2024-10-18 03:47:00 +00:00
Emmanuel Ferdman 390c998588
Update `BUILD.bazel` location (#2937)
# PR Summary
Commit c080d7bfa1 moved the location of
`BUILD.bazel`. This PR adjusts sources to changes.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2024-10-15 13:46:04 +00:00
Max Heller 5c8f791dee
Fix `override_targets` keys in docs (#2905)
Updates the documentation to match the implementation:
144d34fdaa/crate_universe/src/context/crate_context.rs (L65-L74)

---------

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com>
2024-10-01 20:32:09 +00:00
UebelAndre 57d6cfc174
Updated platform triple mapping to support T3 platforms without `std`. (#2899)
This change allows for the definition of platform constraints without
introducing plumbing in repository rules that would attempt to fetch
artifacts that do not exist.

---------

Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com>
2024-10-01 20:31:32 +00:00
Daniel Wagner-Hall 6e97b2f5b8
Document upstream tooling wrappers (#2890) 2024-09-19 16:41:10 +00:00
UebelAndre b067e5a815
Revert "Update `cargo_build_script` to work without runfiles support (#2871)" (#2885)
This reverts commit c520417e26. (#2871)
2024-09-19 09:25:30 +00:00
UebelAndre c520417e26
Update `cargo_build_script` to work without runfiles support. (#2871)
Partially addresses https://github.com/bazelbuild/rules_rust/issues/1156
2024-09-19 02:44:23 +00:00
UebelAndre 5b7cff3f80
Move all settings flags into `//rust/settings` (#2870)
Aliases are still in place for backward compatibility and intended for
public use.
2024-09-18 15:54:25 +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
Felipe de A. Mello Pereira bad49c4a11
Build `rust_test` targets using a crate name different from the underlying lib (#2828)
This is a rollforward of
https://github.com/bazelbuild/rules_rust/pull/2803, but behind the
`incompatible_change_rust_test_compilation_output_directory`
incompatible flag.

This PR also makes `rust_test` put its compilation outputs in the same
directory as the `rust_library` rule (i.e. not in a `test-{hash}`
subdirectory anymore).

After this change both the `rust_library` and `rust_test` rules will put
all its compilation outputs in the same directory, but there won't be
any name collisions in non-sandboxed environments (see
https://github.com/bazelbuild/rules_rust/pull/1427 for more context).

Issue with context: https://github.com/bazelbuild/rules_rust/issues/2827
2024-09-12 13:16:37 +00:00
UebelAndre 3bae148709
Update crate universe to generate build script targets with compile data (#2855)
https://github.com/bazelbuild/rules_rust/pull/2826 ended up introducing
a regression for crates with build scripts that require extra data at
compile time. This change adds a default glob for all
`cargo_build_script` targets generated by `crate_universe` and also
introduces an `annotation.build_script_compile_data` attribute to add
custom targets to generated outputs.
2024-09-11 13:38:53 +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
UebelAndre 42f327f53c
Minor improvements to documentation. (#2846) 2024-09-10 14:38:11 +00:00
UebelAndre e97988273b
Updated docs to use mdbook (#2834)
This updates docs to be built using
[mdbook](https://rust-lang.github.io/mdBook/) for improved readability
and search-ability. Note that the raw markdown from stardoc is still
committed to the repo and can be easily viewed at any commit to ensure
users are able to get the correct docs for their current version of
rules_rust.
2024-09-05 17:51:48 +00:00
scentini 3601d56c1b
Update min bazel version (#2812)
Bazel `6.4` was released in, Oct 2023, we're well beyond the support
window.

I updated straight to `7.3.1` because according to the
[docs](https://github.com/bazelbuild/bazel/releases/tag/7.3.1) it's
fully compatible with `7.0`:

> Bazel 7.3.1 is a patch LTS release. It is fully backward compatible
with Bazel 7.0 and contains selected changes by the Bazel community and
Google engineers.

Co-authored-by: UebelAndre <github@uebelandre.com>
2024-09-03 17:39:46 +00:00
1_x7 99f421e4bc
Doc: update outdated parameter `output_diagnostics` (#2813)
## Problem
Tracking Issue: https://github.com/bazelbuild/rules_rust/issues/2814
The command in doc looks outdated and I'm getting

```
❯ bazel build --@rules_rust//:output_diagnostics=true --output_groups=+rust_lib_rustc_output,+rust_metadata_rustc_output //hellow_world
WARNING: Target pattern parsing failed.
ERROR: Skipping '@rules_rust//:output_diagnostics': no such target '@@rules_rust~//:output_diagnostics': target 'output_diagnostics' not declared in package '' defined by /private/var/tmp/_bazel_xxx/c947415ff64a19538545e009b2e6df63/external/rules_rust~/BUILD.bazel
ERROR: @rules_rust//:output_diagnostics :: Error loading option @rules_rust//:output_diagnostics: no such target '@@rules_rust~//:output_diagnostics': target 'output_diagnostics' not declared in package '' defined by /private/var/tmp/_bazel_xxx/c947415ff64a19538545e009b2e6df63/external/rules_rust~/BUILD.bazel
```
After checking the code
dff064e21b/BUILD.bazel (L39),
I feel it should be `rustc_output_diagnostics`

## Test

```
bazel build --@rules_rust//:rustc_output_diagnostics=true --output_groups=+rust_lib_rustc_output,+rust_metadata_rustc_output //hello_world
INFO: Analyzed target //hello_world:hello_world (2 packages loaded, 1443 targets configured).
ERROR: /Users/xxx/dev/bazel-rust-example/hello_world/BUILD:3:12: Compiling Rust bin hello_world (1 files) failed: (Exit 1): process_wrapper failed: error executing Rustc command (from target //hello_world:hello_world) bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_rust~/util/process_wrapper/process_wrapper --subst 'pwd=${pwd}' --rustc-output-format rendered --output-file ... (remaining 27 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error[E0423]: expected function, found macro `println`
 --> hello_world/src/main.rs:2:5
  |
2 |     println("Hello, world!");
  |     ^^^^^^^ not a function
  |
help: use `!` to invoke the macro
  |
2 |     println!("Hello, world!");
  |            +

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0423`.
Target //hello_world:hello_world failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.322s, Critical Path: 0.06s
INFO: 4 processes: 4 internal.
ERROR: Build did NOT complete successfully
```
2024-09-03 10:41:34 +00:00
Felipe de A. Mello Pereira ef8ac18bb4
Revert "Build rust_test targets using a crate name different from the underlying lib" (#2815)
This reverts commit b4ccc97bbe.

That commit makes a behavior change, and thus should have been protected
by a feature flag. This will be done in a future PR.
2024-08-28 11:38:52 +00:00
UebelAndre dff064e21b
Added `env_inherit` attribute to `rust_test` (#2809)
This brings Rust into parity with other Bazel rules (e.g. C++, Python,
Java, etc) by introducing the
[env_inherit](https://bazel.build/reference/be/common-definitions#test.env_inherit)
attribute.
2024-08-26 19:01:14 +00:00
Felipe de A. Mello Pereira b4ccc97bbe
Build `rust_test` targets using a crate name different from the underlying lib (#2803)
This PR also makes `rust_test` put its compilation outputs in the same
directory as the `rust_library` rule (i.e. not in a `test-{hash}`
subdirectory anymore).

After this change both the `rust_library` and `rust_test` rules will put
all its compilation outputs in the same directory, but there won't be
any name collisions in non-sandboxed environments (see
https://github.com/bazelbuild/rules_rust/pull/1427 for more context).

This is a partial rollback of
10185339dd
and
26344d4cd7.
2024-08-22 12:40:20 +00:00
Marvin Hansen dec889f0dc
Restored bzlmod documentation. (#2798)
Somehow in PR #2713, the bazelmod docs that I wrote went missing.

This PR restores the bazelmod docs.

Should be easy to review.

---------

Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com>
2024-08-18 17:09:50 +00:00
UebelAndre bef8d2d4e7
Remove deprecated variables from `repositories.bzl` macros (#2795)
Most notably in places where `version` and `iso_date` were used, the
`versions` parameter should be used instead. There have long since
prints guiding folks to use `versions` over the previous two.
2024-08-15 20:56:36 +00:00
Corentin Kerisit 00d1176940
Support alwayslink for linking with clang (#2647)
Simple approach to fix #1271

---------

Co-authored-by: scentini <rosica@google.com>
2024-08-02 09:13:36 +00:00
UebelAndre 1c0de8a98c
Release 0.49.0 (#2773) 2024-08-01 17:15:01 +00:00
Krasimir Georgiev e7fe164839
toolchain: support `$(location)` expansion in `extra_rustc_flags` (#2761)
This is similar to our `$(location)` expansion support for
`stdlib_linkflags`. We found ourselves needing this when defining a
custom rust dfsan-enabled toolchain. There, rustc needs an extra
`-Zsanitizer-dataflow-abilist=/path/to/abilist.txt` flag.

This patch lets us do this by specifying the abilist file in
`rust_stdlib_filegroup.srcs` and passing it as
`rust_toolchain.extra_rustc_flags =
["-Zsanitizer-dataflow-abilist=$(location :dfsan_abilist)"]`.

While looking into this, I noticed and fixed an issue: the sources of
the `rust_stdlib_filegroup` passed to `rust_toolchain.rust_std` weren't
made available downstream to the compile actions. I believe location
expansion was working before for `stdlib_linkflags` just because the
targets used in this location expansion were made available indirectly
e.g., implicitly by the underlying C++ toolchain, or via `rustc_lib`.
2024-07-29 14:51:53 +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
Steve Barrau 4a530aa5d9
feat(crates_repository): customizable repin instructions (#2756)
Add customizable instructions to re-pin the repository if required. Many
people have wrapper scripts for keeping dependencies up to date, and
would like to point users to that instead of the default.

This follows the logic of
https://github.com/bazelbuild/rules_jvm_external/pull/1000

---------

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
2024-07-22 20:43:27 +00:00
Daniel Wagner-Hall ffe8eff049
Support incompatible enable proto toolchain resolution (#2741)
This allows using a shared (generally pre-built) protoc definition,
rather than needing to supply one via a label.

We allow (but deprecate) users to still bring along their own protoc as
a label, but if they want to do so, they will need to ensure they have
the correct repositories registered in order to build/bring their
protoc, rather than us setting them up by default.
2024-07-19 08:10:10 +00:00
Marcel Hlopko 6c2bd67af0
Add support for --wrap-extern-fns to bindgen rules (#2743) 2024-07-16 07:42:40 +00:00
Ivan Carvalho b3fe74cc97
Add support for shared test-only modules (#2734)
Currently, `rust_test_suite` is not capable of supporting integration
tests with shared modules. A very basic example is:
```
[crate]/
    src/
        lib.rs
    tests/
        integration_test_a.rs
        integration_test_b.rs
        util/
            mod.rs
```
With `integration_test_a.rs` and `integration_test_b.rs` importing code
from `util`.

This PR adds a `shared_srcs` argument to `rust_test_suite`. That way, we
can finally compile and run those tests with:
```python
rust_test_suite(
    name = "integrated_tests_suite",
    srcs = glob(["tests/**"]),
    shared_srcs = ["tests/util/mod.rs"],
    deps = [":example_dep"],
)
```
2024-07-10 14:02:35 +00:00
Oliver Graff 2a0698fb65
Clean up downloads that go through the API instead of the CDN (#2718)
This is useful as it seems crates.io is starting to deny some direct
requests, not sure if its based off user agent or remote how IP.
2024-06-29 13:37:23 +00:00
Peter Kolloch c1ab10aaad
upstream wrappers for cargo, rustc, cargo-clippy (#2703)
...and a bazel_env example.

As discussed in
https://bazelbuild.slack.com/archives/CSV56UT0F/p1718207171652029?thread_ts=1718182474.631279&cid=CSV56UT0F
2024-06-25 11:34:39 +00:00
UebelAndre c2014b6e3c
Updated external dependencies docs (#2711) 2024-06-24 19:50:46 +00:00
Daniel Wagner-Hall c014c618f9
crate_universe docs: Split bzlmod from workspace (#2700)
Previously the bzlmod symbols were not documented at all, and in places
they are different from the WORKSPACE versions.

This at least hosts both.

Fixes #2696
2024-06-21 14:51:12 +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
Oliver Graff 33f93ace38
Allow overriding crate universe packages to local packages (#2674)
Allow external crates to be aliased to local targets

In some cases it may be desirable to alias a public crate to a locally
define rust_library target, even for dependencies of crates that are not
being overriden.
Support this use case by swapping out `alias` for `rust_library` when
a user overrides the target using an annotation.

---------

Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com>
2024-06-06 16:55:07 +00:00
Cornelius Riemenschneider e3f6258b1e
crate_universe: Don't include crate name in build script path. (#2663)
This PR shortens the path to the build script (potentially
significantly), which helps with long-path issues on Windows.
This change is motivated by the crate `tree-sitter-embedded-template`,
which has a too long path to the compiled build script otherwise, and
which then fails to build on Windows in a `bzlmod` setting.
Fixes https://github.com/bazelbuild/rules_rust/issues/2520.

The cargo build script name was used to automatically derive the cargo
package name, this now went into a separate override parameter that is
generated by the crate-universe tooling.
There's never two build scripts in a single crate, so I don't see how
having a single build script target with a single name would be a
problem.
2024-06-03 13:09:39 +00:00
Matt Mackay df80ce61e4
fix: default rustfmt version to supplied rust version (#2660)
Modifies the default of `rustfmt_version` so that it uses the first
version in the `versions` list. If there are multiple versions given
then falls back to the original default of `DEFAULT_NIGHTLY_VERSION`.

We tripped over this where supply a single Rust version (non-nightly),
but started using nightly features in `rustfmt.toml` and could no longer
format directly with `cargo fmt`. This helped align the versions of both
toolchains.

---------

Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com>
2024-05-17 16:59:51 +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
Daniel Wagner-Hall d6c57045d9
Add docs and examples of complicated build scripts (#2635)
Fixes https://github.com/bazelbuild/rules_rust/issues/2626
2024-05-03 13:56:44 +00:00
Evgeny Petrov 78d920ba91
Support loading http credentials from netrc (#2623)
Bazel's `http_archive` and `http_file` use `~/.netrc` file to load HTTP
credentials.

Now rules_rust use the same approach if no other authorization
parameters are provided.

NOTE: `http_archive` supports passing a custom `netrc` and
`auth_patterns`. But this parameters are not added to the rust rules at
the moment.

---------

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
2024-04-30 09:58:34 +00:00
UebelAndre 2776987925
Update `cargo_bootstrap_repository` interface to match dependency macros (#2630)
This updates the bootstrap repository rule to use the same interface the
dependency macros and crate_universe does:
-
https://github.com/bazelbuild/rules_rust/blob/0.42.1/rust/repositories.bzl#L157-L158
-
https://github.com/bazelbuild/rules_rust/blob/0.42.1/crate_universe/private/crates_repository.bzl#L302-L305
2024-04-29 10:14:59 +00:00
Grzegorz Lukasik a2d13448a6
Nit: Fix link to example in rust_bindgen.md (#2628)
Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com>
2024-04-24 10:24:11 +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
Matt 5f06994f1a
Support building more things with bzlmod (#2601)
This allows us to build more things with bzlmod with `WORKSPACE.bazel`
disabled. This is required because when you use it as a module, it can't
load dependencies from `WORKSPACE.bazel`.

`bazel build --enable_bzlmod --noenable_workspace --lockfile_mode=off
//... --keep_going`

Before: Analysis succeeded for 937 of 978 top-level targets
After: Analysis succeeded for 978 of 982 top-level targets

Once we get those remaining targets working, we can then change our CI
to add `--noenable_workspace` to our bzlmod configuration.
2024-04-03 15:38:38 +00:00
Matt Epperson b078bbd840
feat: Strip debug info from opt builds (#2513)
Attempts to follow the cargo proposal linked below to remove debug info
for release builds. Furthermore this should uphold the expected behavior
of bazel for cc builds which automatically strips debug symbols for
optimized builds.

https://github.com/rust-lang/cargo/issues/4122#issuecomment-1868318860
2024-04-02 17:27:51 +00:00
UebelAndre f9626f930f
Updated repository rules to notify users about non-reproducible repos. (#2593)
This change updates rules_rust repository rules to report when the rules
are not guaranteed to be reproducible due to missing sha256 values when
fetching Rust artifacts. A common case for this is when users request
newer versions of Rust than the ones referenced in
[@rules_rust//rust:known_shas.bzl](https://github.com/bazelbuild/rules_rust/blob/0.41.0/rust/known_shas.bzl),
thus leading to unnecessary downloads or potential security issues.
After this PR, users will see warnings similar to when `integrity` is
omitted from `http_archive` definitions

```
DEBUG: Rule 'rust_analyzer_1.77.1_tools' indicated that a canonical reproducible form can be obtained by modifying arguments sha256s = {"rust-src-1.77.1.tar.xz": "ad2064aa4a444ae35d55b8b57bec837b90c4f10fe6d721f8fce86d7a1992f607", "rustc-1.77.1-aarch64-apple-darwin.tar.xz": "8da1814eb8358236e88ceb155e32f0f34bbe71cb19cd9700c7eb40e675738d77"}
DEBUG: Repository rust_analyzer_1.77.1_tools instantiated at:
  /Users/user/rules_rust/WORKSPACE.bazel:7:25: in <toplevel>
  /Users/user/rules_rust/rust/repositories.bzl:202:10: in rust_register_toolchains
  /private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52/external/bazel_tools/tools/build_defs/repo/utils.bzl:240:18: in maybe
  /Users/user/rules_rust/rust/repositories.bzl:737:45: in rust_analyzer_toolchain_repository
Repository rule rust_analyzer_toolchain_tools_repository defined at:
  /Users/user/rules_rust/rust/repositories.bzl:705:59: in <toplevel>
DEBUG: Rule 'rust_darwin_aarch64__aarch64-apple-darwin__stable_tools' indicated that a canonical reproducible form can be obtained by modifying arguments sha256s = {"rustc-1.77.1-aarch64-apple-darwin.tar.xz": "8da1814eb8358236e88ceb155e32f0f34bbe71cb19cd9700c7eb40e675738d77", "clippy-1.77.1-aarch64-apple-darwin.tar.xz": "343f125b0c05dd756e71992c04fb5a4a29ce705c50a739d76eb7f38b088103ac", "cargo-1.77.1-aarch64-apple-darwin.tar.xz": "c0249b6c247953cbe3b01e276988b6ca600aeba4e91332cd2ddaa0b7eee4dfb7", "llvm-tools-1.77.1-aarch64-apple-darwin.tar.xz": "dfee0aaed6b24d34362f229f2926e6b1805f2a8ec4a090c7c28837b82a9bdfd1", "rust-std-1.77.1-aarch64-apple-darwin.tar.xz": "3b5b71e40d934de25dcb553b9df28289d38640e6fa2654b42410f4cc8d9bed2a"}
DEBUG: Repository rust_darwin_aarch64__aarch64-apple-darwin__stable_tools instantiated at:
  /Users/user/rules_rust/WORKSPACE.bazel:7:25: in <toplevel>
  /Users/user/rules_rust/rust/repositories.bzl:230:14: in rust_register_toolchains
  /private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52/external/bazel_tools/tools/build_defs/repo/utils.bzl:240:18: in maybe
  /Users/user/rules_rust/rust/repositories.bzl:1043:61: in rust_repository_set
  /Users/user/rules_rust/rust/repositories.bzl:601:36: in rust_toolchain_repository
Repository rule rust_toolchain_tools_repository defined at:
  /Users/user/rules_rust/rust/repositories.bzl:475:50: in <toplevel>
```
The above was produced by running `bazel test //...` after applying the
following diff:
```diff
diff --git a/rust/private/common.bzl b/rust/private/common.bzl
index 52728fe7..c035ad5a 100644
--- a/rust/private/common.bzl
+++ b/rust/private/common.bzl
@@ -31,7 +31,7 @@ load(":providers.bzl", "CrateGroupInfo", "CrateInfo", "DepInfo", "DepVariantInfo
 #
 # Note: Code in `.github/workflows/crate_universe.yaml` looks for this line, if
 # you remove it or change its format, you will also need to update that code.
-DEFAULT_RUST_VERSION = "1.77.0"
+DEFAULT_RUST_VERSION = "1.77.1"

 DEFAULT_NIGHTLY_ISO_DATE = "2024-03-21"

```

closes https://github.com/bazelbuild/rules_rust/issues/1825
2024-04-02 16:36:11 +00:00
UebelAndre 0cb20f516f
Deprecated `rust_bindgen.leak_symbols` (#2590)
This also plumbs `target_compatible_with` and `exec_compatible_with`
into the `rust_bindgen` target from `rust_bindgen_library` to account
for cases where the `"manual"` tag is not sufficient in disabling the
target (e.g. `cquery`).
2024-04-02 14:37:07 +00:00