Skip to content

Commit

Permalink
[Rust] Add path option to cargoBuild() (brioche-dev#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylewlacy authored Jul 5, 2024
1 parent 762e715 commit 1d4a8b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/rust/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export default rust;

export interface CargoBuildOptions {
crate: std.AsyncRecipe<std.Directory>;
path?: string;
runnable?: string;
dependencies?: std.AsyncRecipe<std.Directory>[];
}
Expand All @@ -128,6 +129,8 @@ export interface CargoBuildOptions {
* ## Options
*
* - `crate`: The crate to build.
* - `path`: Optionally set a subpath to the crate to build. This is useful
* when building a crate within a workspace.
* - `runnable`: Optionally set a path to the binary to run
* by default (e.g. `bin/foo`).
* - `dependencies`: Optionally add additional dependencies to the build.
Expand Down Expand Up @@ -190,12 +193,13 @@ export function cargoBuild(options: CargoBuildOptions) {

// Use `cargo install` to build and install the project to `$BRIOCHE_OUTPUT`
let buildResult = std.runBash`
cargo install --path . --frozen
cargo install --path "$crate_path" --frozen
`
.dependencies(rust(), std.toolchain(), ...(options.dependencies ?? []))
.env({
CARGO_INSTALL_ROOT: std.outputPath,
PATH: std.tpl`${std.outputPath}/bin`,
crate_path: options.path ?? ".",
})
.workDir(crate)
.toDirectory();
Expand Down

0 comments on commit 1d4a8b9

Please sign in to comment.