Commit Graph

12 Commits

Author SHA1 Message Date
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
David Zbarsky 8d074a0b9e
Bzlmod-aware runfiles library (#2566)
This implements the repo_mapping capabilities and provides a new
runfiles API. The new API can be accessed explicitly as
`runfiles::Runfiles::rlocation_from` or with the `runfiles::rlocation!`
macro, which adds compile-time support for correctly embedding the
external repo. This is a purely new API, existing usage continues to
work, although we mark it deprecated because it's not fully correct. We
can remove it at some point in the future.

This PR also transitions in-repo examples/tests to using it, in case
anyone copies them.

---------

Co-authored-by: scentini <rosica@google.com>
2024-04-22 08:27:51 +00:00
Chuck Grindel 6a9359232e
chore: add `//bzlmod:hello_world_test` and use it as BCR presubmit (#2347)
- Create `bzlmod/hello_world` package based upon
`examples/bzlmod/hello_world`.
- Add `rules_bazel_integration_test` so that `//bzlmod:hello_world_test`
can be executed as a test from the parent workspace.
- Add `filegroup` targets named `all_files` to collect files for all of
the packages that are necessary to use `rules_rust`. These are an input
to the `rules_bazel_integration_test` test.
- Replace `.bcr/presubmit.yml` to test `//bzlmod:hello_world_test`.
- Update CI to test `//bzlmod:hello_world_test`.

Related to
https://github.com/bazelbuild/bazel-central-registry/pull/1199#discussion_r1429129814.
2023-12-27 16:46:57 +00:00
scentini 80f0eb488a
Support for `no_std` mode (#1934)
Initial support for `no_std` mode.
This allows us to
1. Don't pass the whole standard library to compile actions that specify `no_std`
2. Conditionally select `crate_features` and `deps` based on whether `no_std` mode is used.
Currently the only supported modes are `off` and `alloc`, with a possibility to expand in the future.

The `no_std` support comes with the following caveats:
1. Targets in `exec` mode are still built with `std`; the logic here being that if a device has enough space to run bazel and rustc, std's presence would not be a problem. This also saves some additional transitions on `proc_macro`s (they need `std`), as they are built in `exec` mode.
2. Tests are still built with `std`, as `libtest` depends on `libstd`

There is quite an ugly hack to make us be able to `select` on the `no_std` flavor taking `exec` into account; I'm looking forward to the day where Bazel will expose better ways to inspect the cfg.

There is also one part I didn't manage to make work - having a `rust_test` that tests the `rust_shared_library` in `cc_common.link` mode; I got a link error for missing `__rg_alloc` & co. symbols, which should be present as we pass `--@rules_rust//rust/settings:experimental_use_global_allocator=True`. Unfortunately I could only spot this error on CI, and could not reproduce locally. I removed the test because the `rust_shared_library` is already tested via a `cc_test`. I will however give another shot at inspecting how my local setup differs from CI.

The `rust_binary` source code in `main.rs` was borrowed from https://github.com/jfarrell468/no_std_examples, big thanks to @jfarrell468 for letting me use it.

Co-authored-by: Krasimir Georgiev <krasimir@google.com>
Co-authored-by: UebelAndre <github@uebelandre.com>
2023-05-03 14:38:47 +02:00
Krasimir Georgiev 078c6908fc
add cc_common.link support for rust_library and rust_test (#1490)
* add cc_common.link support

* Update rust/private/rustc.bzl

Co-authored-by: scentini <rosica@google.com>

* Update rust/private/rustc.bzl

Co-authored-by: scentini <rosica@google.com>

Co-authored-by: scentini <rosica@google.com>
2022-08-12 14:50:57 +02: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
UebelAndre 9f15a01a86
Updated cargo_universe examples (#676)
Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com>
2021-04-07 08:56:54 -07:00
Daniel Wagner-Hall dd7e458de8
crate_universe rule (#598)
This rule dynamically looks up crate dependencies as a repository rule.

See https://github.com/bazelbuild/rules_rust/issues/2 for context.

Note that this rule is currently experimental, and offers absolutely no stability guarantees. Expect significant churn in near future.
2021-03-25 10:38:08 +00:00
UebelAndre d1d04eb0b2
Moved related cargo_manifest_dir examples into the same directory (#473)
Minor reorganization of the examples to try and keep the relevant tests and dependencies together.
2020-11-04 11:56:04 +00:00
Sitaktif 224fe6a81b
Handle external packages using CARGO_MANIFEST_DIR (#464) 2020-10-26 08:46:33 +00:00
UebelAndre 1d2ad1f06d
Small cleanup pass (#446)
* Cleanup .bazelignore file
* Regenerate documentation
2020-10-15 19:43:11 -04:00
UebelAndre 7d9e890c58
Reorganized sub-workspace dependencies (#398)
This pull request contains various cleanup/quality-of-life improvements for the repository by clearly grouping and defining dependencies for the docs and examples workspaces. Ultimately, the files that are created in here can be moved entirely into their neighboring WORKSPACE files once bazelbuild/bazel#1943 has been closed.
2020-09-09 21:15:01 +02:00