The Basics
This guide will walk you through writing a basic build script for a Rust project.
Start by creating a file in the same directory as your Cargo.toml
called main.august
and add the following.
Writing your first Task
A task is a high level execution unit that can be used by the CLI and can be dependent on the completing of other tasks.
This task prints the contents of Cargo.toml
and runs cargo build
:
Now lets make another task to run some tests!
We have now run into a problem, test
will not run when build
is called, and test
needs to be run before build
.
To fix this we introduce the dependency modifier, which does this exact thing.
Update the top line of the build
task with this:
Adding the dependency modifier is optional for tasks no dependencies. Both of these are valid syntax:
Writing your first Command Definition
Command defintions allow for extracting commands into a single call, which assists with reusability and modularisation. Our current script doesn't really need it, but it doesn't hurt to learn.
Let's take some of the commands in test
and move them into a definition:
Exposing tasks to the CLI
Currently, the August CLI is completely unaware about the semantics of the tasks we made. To assign a task to a CLI command, we use a pragma.
Full Script
@main
#pragma test test
#pragma build build
Task build {
print_file("Cargo.toml");
exec("cargo build");
}
Task test {
lints;
exec("cargo test");
}
cmddef lints {
exec("cargo fmt");
exec("cargo clippy");
}
Runtime!
To run your build script, open the terminal of your choice and run:
To run just the test suite:If your create a task that isn't assigned to a pragma you can use the more general command below: