Commit Graph

33 Commits

Author SHA1 Message Date
Daniel Wagner-Hall 4ea03d6fd0
rust-analyzer: Factor aliases into the project (#2709)
Fixes #2707
2024-06-20 15:47:56 +00:00
Matthieu MOREL 7f2b47cb3e
use bazel_ci_rules bazel_dep instead of http_archive (#2678)
bazel_ci_rules@1.0.0 module has been published to the BCR, see
https://github.com/bazelbuild/bazel-central-registry/pull/2058

This use it has a bazel_dep instead of a http_archive

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-06-06 10:28:40 +00:00
UebelAndre 5b0a6a9721
Update cross to fix crate_universe builds in releases (#2645)
Fix is demonstrated by
https://github.com/UebelAndre/rules_rust/actions/runs/9018414504
2024-05-09 14:33:10 +00:00
Vinh Tran e7f55168ac
Implement support for dylib linkage (#2414)
This PR implements dylib linkage against the standard library behind a
feature flag
`--@rules_rust//rust/settings:experimental_use_dylib_linkage`.


The main part of this feature is
[here](https://github.com/bazelbuild/rules_rust/pull/2414/files#diff-2a806da393e47c07ffe67c78ace69eb488b4ac44b029a46d8237b8e2a05637beR258)
where we skip exporting static rust stdlibs and export only `libstd.so`
instead.

This feature is useful when the subset of libstd being statically linked
to downstream shared libraries and binaries is **larger** than the
entire dylib version of libstd. The following diagram is the high level
of what dylib linkage is trying to achieve.


![Untitled Diagram
drawio](https://github.com/bazelbuild/rules_rust/assets/13268391/d19f18f5-c2d1-4ddc-b170-773a6004f732)

Running the feature against `android_binary` yields a size reduction on
the shared library produced by `android_binary` because it doesn't
statically link the rust stdlibs anymore.

```
> bazel build //:android_app --config=android_x86_64 
> unzip -l bazel-bin/android_app.apk
Archive:  bazel-bin/android_app.apk
  Length      Date    Time    Name
---------  ---------- -----   ----
  1381968  2010-01-01 00:00   lib/x86_64/libandroid_app.so <--- static link with rust stdlibs
---------                     -------
  1390294                     9 files
```

```
> bazel build //:android_app --config=android_x86_64 --config=dylib_linkage
> unzip -l bazel-bin/android_app.apk
Archive:  bazel-bin/android_app.apk
  Length      Date    Time    Name
---------  ---------- -----   ----
     8080  2010-01-01 00:00   lib/x86_64/libandroid_app.so <--- reduced size because of dynamic linking
 13055776  2010-01-01 00:00   lib/x86_64/libstd-8d416d49cf02ecea.so
---------                     -------
 13072400                     10 files
 ```

Here, the benefit comes when there are enough shared libraries statically linking against the rust stdlibs. "Enough" here means that the total up size of those libraries being more than just the entire `libstd.so`.

TODO: I'm leaving this PR without unit tests until I get some feedback or suggestions on my approach.

---------

Co-authored-by: scentini <rosica@google.com>
2024-02-23 15:58:54 +00:00
Vinh Tran 184da7d4ec
Introduce @rules_testing for Starlark tests (#2480)
This is a follow-up PR of
https://github.com/bazelbuild/rules_rust/pull/2422.

I'm scoping it to a separate PR to introduce
[@rules_testing](https://github.com/bazelbuild/rules_testing) (a new
Starlark testing framework). The framework removes a lot of boilerplate
code (unncessarily) required when writing analysis tests.
2024-02-19 17:08:36 +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
Chi Wang bd8c36af84
Migrade rbe_ubuntu1604 to rbe_ubuntu2004 (#2208)
To fix BazelCI errors for the presubmit.
2023-10-19 15:12:21 +02:00
UebelAndre c080d7bfa1
Moved legacy protobuf rules to `proto/protobuf` (#2043)
* Moved legacy protobuf rules to `proto/protobuf`

* Regenerate documentation
2023-07-05 15:27:50 +00:00
freeformstu 7f751cdddf
Consolidate rust_prost_library and fix extension-only proto generation. (#2047)
This PR consolidates rust_prost_library and rust_tonic_library into one rule; `rust_prost_library`. `rust_prost_library` will generate tonic services if you provide a `tonic_plugin` in the toolchain definition. If you do not provide that plugin and you try to build a proto with services, it will print a warning that you should add a `tonic_plugin`.

This PR also handles extension-only proto files. Prost does not generate a file if there are no messages, enums, or services and it appears that Prost doesn't even support proto2 extensions. So to work around this issue, protoc_wrapper will generate an empty `.rs` file in the case that there are only extensions defined in a file.

Closes: #2046
2023-07-05 15:20:52 +01:00
freeformstu a6f29fd07f
Add Prost and Tonic rules. (#2033)
* Setup Prost and Tonic rules.

* Regenerate documentation

* Add more tests.

* Add more tests and address feedback.

* Regenerate documentation

* Add to proto docs page.

* Bump min supported bazel version.

* buildifier

* Always enable backtracing.

* Add more info to failing rename.

* Set min rust version to 1.62.0

* Handle rust keywords as package names.

* exclude windows from prost toolchain support.

* buildifier

* redundant

* Use prost-types to parse the file descriptor set.

* Cleanup and more tests.

* Move prost-types to toolchain definition.

* fix rustfmt

* Add example of building protos with complex imports

* impl Display

* Fix all tests

* Add rust checks for the complex import protos.

* Address feedback

* Fix buildifier

* Depend on remote-apis repo.

* Remove bazel remote apis due to file length and transitive dependency issues.

* Update patch and docs.

* Regenerate documentation

* Regenerate documentation

* Update docs.

---------

Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com>
2023-06-30 19:16:49 +00:00
UebelAndre 3e2ee941ae
Update bindgen rules to build clang from source. (#1998)
* Update bindgen rules to build clang from source.

* Regenerate documentation
2023-06-13 11:52:39 +00:00
UebelAndre 76360dd354
Implement rules archive release artifact in github action. (#1501)
* Implement rules archive release artifact in github action.

* Remove distro package and dependencies
2022-08-08 13:17:53 +01:00
UebelAndre 0e86b9dd30
Added `rust_analyzer_toolchain` and repository rules for creating one (#1455)
* Added `rust_analyzer_toolchain` and repository rules for creating one

* Regenerate documentation

* Update rust/repositories.bzl

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

* Updated rust_analyzer_toolchain export

* Fixed rust_analyzer_toolchain_repository rule

Co-authored-by: Daniel Wagner-Hall <dawagner@gmail.com>
2022-07-21 16:58:55 +00:00
UebelAndre 67c97d44ff
Updated `tools/rust_analyzer` to use `crate_universe`. (#1448)
* Updated `tools/rust_analyzer` to use `crate_universe`.

* Regenerate documentation

* Updated generated files.

* Deleted tools/rust_analyzer/raze

* Add missing bzl_lib target
2022-07-18 15:39:40 +00:00
UebelAndre 120f911d2f
Updated rust_bindgen dependencies API (#1354)
* Moved `rust_bindgen` docs into generated stardoc

* Regenerate documentation
2022-05-23 07:33:51 -07:00
UebelAndre 628e85e70f
Restrucutred `crate_universe` dependency macros (#1208)
* Restrucutred `crate_universe` dependency macros

* Regenerate documentation

* Fixed load issue in crate_universe dependencies
2022-03-21 16:48:20 -07:00
UebelAndre cd44b3670a
Added support for producing distribution archives (#1194) 2022-03-15 10:12:58 -07:00
UebelAndre 59fab4e79f
Replaced `crates_universe` rule with `crates_repository` (#1158)
* Added unmodified `cargo-bazel` source code

* Applied `rules_rust` specific updates to `cargo-bazel` impl

* Updated lockfiles

* Replaced `crate_universe` examples with `crates_repository` examples

* Applied `rules_rust` specific updates to `cargo-bazel` examples

* Updated examples lockfiles

* Updated `crate_universe` docs to represent `crates_repository`

* Regenerate documentation
2022-03-03 06:49:27 -08:00
Chris Fredrickson 2f5253fbae
Add new `import` macro prototype. (#1142)
Co-authored-by: cfredric <cfredric@chromium.org>
Co-authored-by: Marcel Hlopko <hlopko@google.com>
2022-02-18 14:35:40 +01:00
UebelAndre 1cb3c446b2
Added `rules_rust_dependencies` and `rust_register_toolchains` macros (#1105) 2022-01-27 09:55:48 -08:00
Chi Wang e83c39d1d1
Use rbe_preconfig for RBE toolchain config (#958) 2021-09-29 10:04:09 +02:00
UebelAndre af2f908a2d
Updated CI structure to increase coverage (#865) 2021-08-16 13:07:54 -07:00
UebelAndre fe657ed7ac
Update `//proto` rules to provide all required dependencies. (#868) 2021-08-10 05:33:50 -07:00
UebelAndre 998529b9ef
Minor cleanup of various tests and examples (#869) 2021-08-03 06:10:04 -07:00
UebelAndre d0a8586c6f
Fixed legacy repository name (#788) 2021-06-24 08:34:12 -07:00
UebelAndre 7bf61a8673
Fixed RBE by using a newly release of bazel-toolchain (#752) 2021-05-21 12:57:11 -07:00
Marcel Hlopko 714a4d444d
Rename rustc_src to rustc_srcs for bazel consistency (#736) 2021-05-13 06:33:27 -07:00
Marcel Hlopko 96d5118f03
Ask rust_toolchain for rustc_srcs in rust_analyzer.bzl (#733)
In this PR we remove hardcoded assumption about where rust-analyzer support code looks for rustc sources, and instead read that information from the `rust_toolchain.rustc_src`. We also handle the case when rustc sources are actually in the main repository, so there is no need to use the `__EXEC_ROOT__/` prefix for its path.
2021-05-12 08:28:45 +02: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
Daniel Wagner-Hall ce294858db
Avoid downloading multiple resolvers (#694)
Instead, download just the one that's needed for the host platform.
2021-04-19 09:07:36 -07:00
UebelAndre 4ea9bfe136
`crate_universe` now renders json formatted lockfiles (#692)
Notable changes in this PR:
- `crate_universe` `lockfile` attributes are now rendered as json files instead of starlark dumps
- The `cargo-raze` dependenciy has been updated to a pin which implements the required sorting and de-serialization.
- Formatted `use` declarations
- Updated dependencies
- `CARGO` and `RUSTC` environment variables are now ignored in determining the digest. This should be safe given that `cargo version` is an input to generating the lockfile hash.
- `repository_template` has been renamed to `crate_registry_template`, which is more correct.
- The [json](https://docs.bazel.build/versions/master/skylark/lib/json.html) module is now used to handle generating the config `.json` file
2021-04-19 15:55:47 +01: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 a02931d741
Renamed BUILD and WORKSPACE files to BUILD.bazel and WORKSPACE.bazel (#665)
The use of `BUILD`/`WORKSPACE` vs `BUILD.bazel`/`WORKSPACE.bazel` was inconsistent across the repo. This PR updates all files without the `.bazel` extension to use it (which has the higher priority over the two styles. see [here](https://docs.bazel.build/versions/master/build-ref.html#packages)).

Additionally, this PR contains buildifier fixes
2021-03-30 21:51:05 +01:00
Renamed from WORKSPACE (Browse further)