cargo rssc - Rust scripts for crates building
Inside your main rust project directory (the one with Cargo.toml) run:
bash
cargo install cargo-rssc
cargo rssc new
Open in new editor the new directory scripts_rssc
in your main rust project and view/edit the rust code of the helper rust project.
Then try in the main rust project:
bash
cargo rssc build
cargo rssc release
cargo rssc docs
Cargo is a great tool for building rust projects. It has all the basics: cargo build
, cargo build --release
, cargo fmt
, cargo test
, cargo doc
,...
But sometimes we need to do more things like copying some files, publish to ftp or enter long commands. These are tasks that must be automated.
There are many different build systems and task runners there: make, cmake, shell scripts, cargo-make, cargo-script, cargo-run-script, runner, python scripts, powershell scripts, cmd prompt scripts, ...
Sadly there is no standard in the rust community for now. I wanted something similar to build.rs, so I can write my "scripts" in pure rust. I don't want to learn another meta language with weird syntax and difficult to debug. So I will make something really simple, easy, rusty and extensible.
Rust is a compiled language. It is not really a scripting or interpreted language. But the compilation of small projects is really fast and can be ignored. Subsequent calls will use the already built binary and so the speed will be even faster.
In the root of the main rust project
it will create a new directory scripts_rssc
with a new helper rust project. It should not interfere with the main rust project. This folder will then go into git commits and pushed to remote repositories as part of the main project. It has its own .gitignore
to avoid committing its target directory.
The scripts_rssc helper project contains user defined tasks in rust code. This helper project should be opened in a new editor starting from the scripts_rssc
folder. It does not share dependencies with the main project. It is completely separate.
The binary crate cargo-rssc
is added to cargo as a new subcommand cargo rssc
.
rust
cargo install cargo-rssc
Examples:
bash
cargo rssc new
cargo rssc build
cargo rssc release
cargo rssc docs
It reads the CLI arguments and runs the scripts_rssc
binary with them. If needed it will compile scripts_rssc
first.
The code-flow of the source code of cargo-rssc is simple, fully commented and straightforward to audit in this open-source crate.
The command
rust
cargo rssc new
will copy the template_basic into scripts_rssc
folder.
This has no dependencies and is really simple to understand how it works.
Explore it and add your own tasks or rust code.
Then in the main project run your task like:
rust
cargo rssc build
Your code will be compiled and executed.
This is a work in progress.
The goal is to create a cargorssclib with many functions that are commonly used when building rust projects.
It is recommended to always use cargo-crev
to verify the trustworthiness of each of your dependencies.
Please, spread this info.
On the web use this url to read crate reviews. Example:
https://web.crev.dev/rust-reviews/crate/num-traits/