rules_rust/WORKSPACE.bazel

94 lines
2.9 KiB
Plaintext
Raw Normal View History

workspace(name = "rules_rust")
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
rules_rust_dependencies()
rust_register_toolchains()
load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
crate_universe_dependencies(bootstrap = True)
load("//crate_universe/tools/cross_installer:cross_installer_deps.bzl", "cross_installer_deps")
cross_installer_deps()
# buildifier: disable=bzl-visibility
load("@rules_rust//proto/prost/private:repositories.bzl", "rust_prost_dependencies", "rust_prost_register_toolchains")
rust_prost_dependencies()
rust_prost_register_toolchains()
Protobuf support (#92) * Also add the dependencies in /examples/WORKSPACE This allow to runs the tests in examples as a remote repository and as a local repository. * Add a dummy Cargo craze to use cargo raze on it. With this craze, and cargo raze, we can simply use raze generated repositories to add the necessary dependencies. * Add generated files for the raze package of protobuf * Add rust_(proto|grpc)_library Those library add protobuf / gRPC support to Rust language in Bazel using the native proto_library. It generates one crate per proto_library which is efficient for incrementality but can lead to naming collisions. We expose a bit of rust_library internal to re-use it in rust_proto_library and create a new provider "rust_libs" that will declare a group of rust libraries. * Add a gRPC client/server example And a test with it. * Add documentation for the rust_(proto|grpc)_library * Use the new runfiles library in the test rather than a custom algorithm * Add the missing dependencies to examples/WORKSPACE This new dependency is quite unfortunate, it make using rules_rust more complex since it needs to import a bzl file from skylib to be able to use rules_rust, that adds 10 lines in the WORKSPACE without much improvement. I guess this cannot be better until recursive workspace are a thing. * Generates cargo raze files compatible with macOS and Linux Also to keep the same lockfile, check in the Cargo.lock and have a lever to not re-run cargo generate-lockfile. * Compile all proto stubs in one library This a workaround a bug in Bazel that prevent the toolchain from being loaded with the target transition (see https://github.com/bazelbuild/bazel/pull/5650). This is not ideal because it recompiles several time the same proto if you depends on it from several dependency path and can lead to seeing two compilation of the same proto as different type. This is also terrible for incremental build and contrary to the (protobuf blog entry)[https://blog.bazel.build/2017/02/27/protocol-buffers.html]. * Force set the lazy_static implementation configuration. The lazy_static crates now set a configuration from the build.rs, ideally we would be able to handle that but that is not the case with the current cargo raze method. * Final touch: documenting and simplifying toolchain creation - Documents how to create your custom toolchain when you need to import your own crates (or to use a different protobuf/grpc stubs compiler). - Add extra_aliased_targets to simply the cargo-raze generation - Use skylark http_archive to import protobuf. - Regenerate crates with google/cargo-raze#77 so that we don't need to have custom rewriting policy. Hence, deleted the wrapper around cargo raze, an update to the build file should simply be `cargo genrate-lockfiles && cargo raze` now. * Fix nits suggested by @mfarrugi * Remove usage of CrateInfos This was a leftover from compiling the crates in the proto aspect. * Use python for the optional_output_wrapper Also move the optional_output_wrapper from the toolchain to the library itself. For some reason the runfiles where not shipped to the actions with the old way which wasn't important for Bash that did not had any runfiles but it is important for python. * fix: README format * Second pass of nits from @mfarrugi * fix: add back the list of grpc stubs to create if not created
2018-11-13 18:27:19 +00:00
load("@rules_rust//proto/prost:transitive_repositories.bzl", "rust_prost_transitive_repositories")
rust_prost_transitive_repositories()
load("@rules_rust//proto/protobuf:repositories.bzl", "rust_proto_protobuf_dependencies", "rust_proto_protobuf_register_toolchains")
rust_proto_protobuf_dependencies()
rust_proto_protobuf_register_toolchains()
load("@rules_rust//proto/protobuf:transitive_repositories.bzl", "rust_proto_protobuf_transitive_repositories")
rust_proto_protobuf_transitive_repositories()
load("@rules_rust//bindgen:repositories.bzl", "rust_bindgen_dependencies", "rust_bindgen_register_toolchains")
rust_bindgen_dependencies()
rust_bindgen_register_toolchains()
2019-02-06 01:59:45 +00:00
load("@rules_rust//bindgen:transitive_repositories.bzl", "rust_bindgen_transitive_dependencies")
rust_bindgen_transitive_dependencies()
load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies")
rust_analyzer_dependencies()
load("@rules_rust//wasm_bindgen:repositories.bzl", "rust_wasm_bindgen_repositories")
rust_wasm_bindgen_repositories()
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
2021-06-24 15:34:12 +00:00
load("//test:deps.bzl", "rules_rust_test_deps")
2021-06-24 15:34:12 +00:00
rules_rust_test_deps()
load("//test:deps_transitive.bzl", "rules_rust_test_deps_transitive")
rules_rust_test_deps_transitive()
# --- end stardoc
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "bazel_ci_rules",
sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e",
strip_prefix = "bazelci_rules-1.0.0",
url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz",
)
# To run with RBE on Bazel CI, uncomment the following lines.
#
# load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig")
# rbe_preconfig(name = "buildkite_config", toolchain = "ubuntu2004-bazel-java11")
http_archive(
name = "rules_testing",
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
sha256 = "02c62574631876a4e3b02a1820cb51167bb9cdcdea2381b2fa9d9b8b11c407c4",
strip_prefix = "rules_testing-0.6.0",
url = "https://github.com/bazelbuild/rules_testing/releases/download/v0.6.0/rules_testing-v0.6.0.tar.gz",
)
load("//test/3rdparty/crates:crates.bzl", test_crate_repositories = "crate_repositories")
test_crate_repositories()