Build Helpers
Functions for extracting archives. For running commands, see the Commands helpers.
Overview
Build helpers extract archives to prepare sources for compilation. Use shell() or shell_in() from the Commands helpers to run build commands.
extract
Extract an archive to a destination directory. Takes the archive path and destination directory as arguments. Format is auto-detected from the file extension.
| Format | Extensions |
|---|---|
| tar.gz / tgz | .tar.gz, .tgz |
| tar.xz / txz | .tar.xz, .txz |
| tar.bz2 / tbz2 | .tar.bz2, .tbz2 |
| tar.zst | .tar.zst |
| zip | .zip |
rust|
let archive = download(url, join_path(BUILD_DIR, "foo-1.0.tar.xz"));
extract(archive, BUILD_DIR);
// Creates BUILD_DIR/foo-1.0/extract_with_format
Extract an archive with an explicit format. Useful when the file extension doesn't match the actual format.
rust|
// Force tar.gz extraction even if extension is wrong
extract_with_format(archive, BUILD_DIR, "tar.gz");Running Build Commands
Use shell_in() to run commands in a specific directory. This is the recommended pattern instead of changing directories:
rust|
fn build(ctx) {
let src = ctx.source_dir;
// Run configure in the source directory
shell_in(src, "./configure --prefix=" + PREFIX);
// Run make in the source directory
shell_in(src, "make -j" + NPROC);
ctx
} See shell(), shell_in(), shell_output() in the Commands helpers for more options.