Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Rust toolchain example #314

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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