Skip to content

Commit

Permalink
Update the Rust toolchain example
Browse files Browse the repository at this point in the history
Update `rules_rust` to 0.17.0.
  • Loading branch information
mrkkrp committed Feb 2, 2023
1 parent c85f4f9 commit 8ef8a07
Show file tree
Hide file tree
Showing 6 changed files with 362 additions and 270 deletions.
147 changes: 147 additions & 0 deletions examples/toolchains/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/toolchains/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Rust Toolchain Example
======================

This is an example Rust project that uses `rules_rust`.
It showcases the integration nix, giving concrete example of how to approach project compilation with dependency on OpenSSL library.
It showcases the integration nix, giving concrete example of how to approach project compilation with dependency on OpenSSL library.

If the Nix package manager is present in the build environment, this example will use Nix to provide the Rust toolchain.
If the Nix package manager is present in the build environment, this example will use Nix to provide the Rust toolchain.
Otherwise, it will fail (it is possible to make the example run without nix, however it greatly obfuscates the core of the matter).

# Usage

To run the example with Nix, issue the following command:
```
nix-shell --command 'bazel run --config=nix :hello'
nix-shell --command 'bazel run --config=nix //:hello'
```
13 changes: 7 additions & 6 deletions examples/toolchains/rust/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# https://bazelbuild.github.io/rules_rust/#setup
http_archive(
name = "rules_rust",
sha256 = "73580f341f251f2fc633b73cdf74910f4da64d06a44c063cbf5c01b1de753ec1",
sha256 = "d125fb75432dc3b20e9b5a19347b45ec607fabe75f98c6c4ba9badaab9c193ce",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_rust/releases/download/0.5.0/rules_rust-v0.5.0.tar.gz",
"https://github.com/bazelbuild/rules_rust/releases/download/0.5.0/rules_rust-v0.5.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_rust/releases/download/0.17.0/rules_rust-v0.17.0.tar.gz",
"https://github.com/bazelbuild/rules_rust/releases/download/0.17.0/rules_rust-v0.17.0.tar.gz",
],
# rules_rust 0.5.0 does not yet support direct
# rules_rust 0.17.0 does not yet support direct
# overriding toolchain used for build of cargo-bazel
# binary.
# On non-standard systems (viz. NixOS), that approach
# results in download of 'broken' rustc which then
# cannot build cargo bazel.
# This patch fixes the issue, allowing for toolchain
# specification.
#
#
# Note: This should be removed as soon as
# issue in rules_rust is resolved.
patches = [
Expand Down Expand Up @@ -118,7 +118,8 @@ crates_repository(
OPENSSL_CRATE_ANNOTATION
],
},
lockfile = "//:Cargo.Bazel.lock",
cargo_lockfile = "//:Cargo.lock",
lockfile = "//:cargo-bazel-lock.json",
packages = {
"openssl": crate.spec(
version = "0.10.40",
Expand Down
Loading

0 comments on commit 8ef8a07

Please sign in to comment.