Commit Graph

19 Commits

Author SHA1 Message Date
Daniel Wagner-Hall 840ec13304
Get rolling releases CI green (#2916)
The default value for this flag changed, but we require it.
2024-10-04 00:34:54 +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
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
Cameron Martin 95e5d44050
Advertise CcInfo provider on rules (#2126)
The aspect used in the `cc_shared_library` implementation in bazel 6.3
and 7 only traverses attributes that advertise the `CcInfo` provider via
the `provides` attribute. This means in these versions of bazel, rust
libraries are currently omitted from libraries built with
`cc_shared_library`.

Fixes #2101.
2024-01-05 08:31:08 -08:00
UebelAndre 828c8071f3
Added `rust_unpretty_aspect` and `rust_unpretty` rules (#2356)
Proposal for https://github.com/bazelbuild/rules_rust/issues/1642
Duplicates https://github.com/bazelbuild/rules_rust/pull/1643 (special
thanks to @freeformstu)

### Summary

Rustc can be used to expand all macros so that you can inspect the
generated source files easier.

This feature is enabled via `-Zunpretty={mode}`. The `-Z` flag is only
available in the nightly
version of `rustc` (https://github.com/rust-lang/rust/issues/43364).


### Unprettying

Build and test your targets normally.

```
bazel build //:ok_binary   
INFO: Analyzed target //:ok_binary (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:ok_binary up-to-date:
  bazel-bin/ok_binary
INFO: Elapsed time: 0.081s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
```

Use the aspect to generate the expanded files in as a one-off build.

(`.bazelrc`)
```
# Enable unpretty for all targets in the workspace
build:unpretty --aspects=@rules_rust//rust:defs.bzl%rust_unpretty_aspect
build:unpretty --output_groups=+rust_unpretty

# `unpretty` requires the nightly toolchain. See tracking issue:
# https://github.com/rust-lang/rust/issues/43364
build:unpretty --@rules_rust//rust/toolchain/channel=nightly
```

```
bazel build --config=unpretty //:ok_binary
INFO: Analyzed target //:ok_binary (1 packages loaded, 2 targets configured).
INFO: Found 1 target...
Aspect @rules_rust//rust/private:unpretty.bzl%rust_unpretty_aspect of //:ok_binary up-to-date:
  bazel-bin/ok_binary.expand.rs
INFO: Elapsed time: 0.149s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
```

Targeting tests is valid as well.

```
bazel build --config=unpretty //:ok_test  
INFO: Analyzed target //:ok_test (0 packages loaded, 2 targets configured).
INFO: Found 1 target...
Aspect @rules_rust//rust/private:unpretty.bzl%rust_expand_aspect of //:ok_test up-to-date:
  bazel-bin/test-397521499/ok_test.expand.rs
INFO: Elapsed time: 0.113s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
```

Finally, manually wire up a `rust_unpretty` target explicitly if you
want a target to build. This rule is unique compared to the aspect in
that it forces a transition to a nightly toolchain so that `-Zunpretty`
can be used.

```starlark
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_unpretty")

rust_binary(
    name = "ok_binary",
    srcs = ["src/main.rs"],
    edition = "2021",
)

rust_unpretty(
    name = "ok_binary_expand",
    deps = [":ok_binary"],
)
```

```
bazel build //:ok_binary_expand
INFO: Analyzed target //:ok_binary_expand (0 packages loaded, 1 target configured).
INFO: Found 1 target...
Target //:ok_binary_expand up-to-date:
  bazel-bin/ok_binary.expand.rs
INFO: Elapsed time: 0.090s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
```
2023-12-27 17:02:43 +00:00
UebelAndre ab545e0479
Minor cleanup of `.bazelrc` (#2341) 2023-12-19 15:25:18 +00:00
Yun Peng a458757181
Disable Bzlmod explicitly in .bazelrc (#2182)
This will help make sure [Bazel Downstream
Pipeline](https://github.com/bazelbuild/continuous-integration/blob/master/docs/downstream-testing.md)
is green after enabling Bzlmod at Bazel@HEAD

See
https://github.com/bazelbuild/bazel/issues/18958#issuecomment-1749058780

Related issue: https://github.com/bazelbuild/rules_rust/issues/2181
2023-10-06 17:01:55 +01:00
UebelAndre 2ded0c2f50
Fix flaky coverage test in CI (#2028) 2023-06-23 13:45:35 +02: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
Daniel Wagner-Hall f5813fa08e
Set windows flags in platform-specific bazelrc (#1988)
Rather than writing them in .bazelci yaml blocks.

This makes running the examples on Windows more likely to work out of
the box.
2023-06-02 12:34:55 +01:00
UebelAndre ba0fb5956c
Added support for `--nolegacy_external_runfiles` to `rust_doc_test` (#1790) 2023-01-20 12:08:30 +00:00
UebelAndre 52231ef9f8
Added compatibility flags to `.bazelrc` to prevent regressions (#1789) 2023-01-19 16:48:50 +00:00
UebelAndre acca6f4000
Add `user.bazelrc` support to each workspace (#1161) 2022-03-01 06:59:47 -08:00
OJ Kwon 8ae83f07c2
fix(test_env): export canonical CARGO_BIN_EXE env variable (#842)
* fix(test_env): export canonical CARGO_BIN_EXE env variable

* test(test_env): update test cases

* build(bazelrc): enable symlink for windows platform

Co-authored-by: UebelAndre <github@uebelandre.com>
2021-08-20 14:44:39 -07:00
UebelAndre ed64716a87
Added support for `noclippy` tag (#824)
* Added support for `noclippy` tag

* Regenerate documentation

* Added regression tests for `noclippy` tag.

* Fixed typo

* Fixed bad cherry-pick
2021-07-10 09:22:07 -07:00
UebelAndre 52c87aad42
Added rustfmt config for running rustfmt in CI (#747)
* Added rustfmt_aspect to enforce formatting in the workspace

* Added config

* Added alias and updated docs

* Fixed formatting

* Regenerate documentation

* Addressed PR feedback

* Revert "Added alias and updated docs"

This reverts commit 191fb68741.

* Updated formatting

* Revert "Regenerate documentation"

This reverts commit 4af576e881.
2021-06-01 14:18:58 -07:00
UebelAndre a04ff4182c
Added crate_universe examples to CI (#707)
* Added crate_universe examples to CI

* Update crate_universe/bootstrap.bzl

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>

* Updated docs

* Remove crate_universe.bazelrc

* Updated attribute names

* Deleted example lockfile

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
2021-04-27 10:15:18 -07:00
UebelAndre a3c2741207
Added bootstrapping for crate_universe (#663)
* Added bootstrap script for crate_universe and github action for auto-releasing new binaries

* Addressed PR feedback

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>

* Updated local dev documentation

* Add announce_rc to crate_universe.bazelrc

* Addressed buildifier defect

* Addressed additional user feedback

* Apply suggestions from code review

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>

* Fixed missing extension for windows.

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
2021-04-07 10:11:43 -07:00