![]() INFO: Analyzed target //:rg (156 packages loaded, 2780 targets configured). We will handle the rest of the crates the same way. Let’s look at the matcher crate for example, Now it’s time to build some crates in our workspace. Writing BUILD files and Cargo-Bazel parity $ bazel query we can see that the repository consists of targets for dependencies explicitly mentioned Let’s create an empty lock file for crate_universe and the empty BUILD.bazel file for a so far empty manifests: the list of Cargo.toml files in the workspace.Initially it should be created empty, then it will be automatically updated and maintained by lockfile: this is the file used by crate_universe to store metadata gathered from Cargo files.cargo_lockfile: the actual Cargo.lock of the Cargo workspace.Manifests =, )Ĭrates_repository creates a repository_rule containing targets for all external dependencies explicitly mentioned in the Cargo.toml files as dependencies. One could reason this behavior is closer to what is done by ripgrep’s CI configuration, but I would rather suggest being more explicit for the sake of reproducibility and clarity: In this case, we will end up using the stable and nightly versions pinned by the version of rules_rust. rust_register_toolchains allows us to omit the versions attribute. Regarding the rustc version, if we look at the ripgrep CI configuration, we notice it uses the nightly toolchain pinned by the dtolnay/rust-toolchain Github action. rust_register_toolchains allows us to set the Rust toolchain version for all three channels (stable, beta and nightly) we want to use for our workspace. ![]() There is also a standard mechanism of distributing and updating the Rust toolchain through channels. ripgrep is using “2018”, and we are doing the same. Editions are used by the Rust team to perform changes which are backwards incompatible, you can leave it unspecified and just use the latest one. Load (, "rules_rust_dependencies", "rust_register_toolchains" ) ![]() The project is organized as a Cargo workspace consisting of several crates: I chose ripgrep, since it is well-known in the Rust community. That’s all great, but how am I going to make my Cargo workspace use Bazel? To show this, I’m going to take an open source Rust project and guide you through the steps to migrate it to Bazel. Be it building Python packages from Rust code with PyO3, connecting JavaScript code with WASM compiled from Rust, or managing Rust crates incorporating FFI calls from a C-library with Bazel you have a solid solution. The polyglot nature of Bazel allows expressing connections between Rust code and targets written in other languages in a much more simple and straightforward manner.Remote caching and execution can significantly reduce the amount of Rust compilation done locally on developers’ machines.Bazel’s focus on hermeticity and aggressive caching allows us to improve median build and test times, especially for a single Pull Request against a relatively large codebase.But there are a handful of reasons to consider Bazel: Here is a nice article elaborating on why Cargo should not be considered as a such a build system. Cargo is great when you are developing and packaging a single Rust library or application, but when it comes toĪ fast-growing and complex workspace, one could be attracted to the idea of using a more flexible and scalable build system. const MaxConcurrentCrawls = Math.min( Math.max(os.cpus().The vast majority of the Rust projects are using Cargo as a build tool. const realRgPath = rgPath.replace( /\bapp\.asar\b/, '') // Define the maximum number of concurrent crawling processes based on the number of CPUs // with a maximum value of 8 and minimum of 1. * global emit */ const async = require( 'async')Ĭonst = require( 'vscode-ripgrep')Ĭonst PathsChunkSize = 100 // Use the unpacked path if the ripgrep binary is in asar archive.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |