mmusnjak / bazel-rust

Playing around with some Bazel and Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust and Bazel

Tasks

  • Run Hello World: bazel run //hello_world

  • Run Hello World Axum app: bazel run //axum_app

  • Format: bazel run @rules_rust//:rustfmt

  • Check formatting: bazel build --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect --output_groups=rustfmt_checks //...

  • Run the Clippy linter on all targets: bazel build --output_groups=clippy_checks //...

  • Regenerate rust-analyzer config: bazel run @rules_rust//tools/rust_analyzer:gen_rust_project

  • Repin dependencies: CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index

TODOs

  • Figure out how to build multiple profiles. Is the macro used in axum_app how it is supposed to be?

  • Figure out how to run and debug from inside VSCode. Some info is available in a Github issue

  • Figure out how to build for linux-amd64 from MacOS M1

VSCode setup

A Github issue describes a problem with finding build targets in vscode. There are two ways to fix it:

  1. Force sharing of bazel server (comment)
  2. Add a line to .bazelignore, according to another comment on the same issue.

Both worked for me, choosing to stick with vscode option!

About

Playing around with some Bazel and Rust


Languages

Language:Starlark 62.8%Language:Rust 37.2%