| Crates.io | compi |
| lib.rs | compi |
| version | 0.4.0 |
| created_at | 2025-06-02 21:31:21.263349+00 |
| updated_at | 2025-06-08 20:26:56.239204+00 |
| description | A build system written in Rust. |
| homepage | https://github.com/Allyedge/compi |
| repository | https://github.com/allyedge/compi |
| max_upload_size | |
| id | 1698398 |
| size | 72,993 |
A build system written in Rust.
cargo install compi
cargo install --git https://github.com/allyedge/compi
git clone https://github.com/allyedge/compi
cd compi
cargo install --path .
Download the latest binary for your platform from the GitHub Releases page.
wget https://github.com/allyedge/compi/releases/latest/download/compi-linux
chmod +x compi-linux
sudo mv compi-linux /usr/local/bin/compi
wget https://github.com/allyedge/compi/releases/latest/download/compi-macos
chmod +x compi-macos
sudo mv compi-macos /usr/local/bin/compi
Download the executable from the releases page and add it to your PATH.
# Run default task
compi
# Run specific task
compi build
# Use a different config file
compi -f my-config.toml
# Verbose output
compi -v build
# Remove outputs after successful execution
compi --rm build
# Run with specific number of workers
compi -j 8 build
# Set task timeout and dry run
compi -t 30s --dry-run test
# Continue on failure with verbose output
compi --continue-on-failure -v all
# Combine flags
compi --rm -v -j 2 test
# Show help
compi --help
-f, --file <FILE>: Configuration file (default: compi.toml)-v, --verbose: Enable verbose output--rm: Remove outputs after successful task execution-j, --workers <N>: Number of parallel workers (default: CPU cores)-t, --timeout <DURATION>: Default timeout for tasks (e.g., "30s", "5m")--dry-run: Show what would be executed without running tasks--continue-on-failure: Continue running independent tasks when others failTASK: Task to runCreate a compi.toml file in your project root:
[config]
default = "build" # Default task to run
cache_dir = "cache" # Cache directory
workers = 4 # Number of parallel workers (default: CPU cores)
default_timeout = "5m" # Default timeout for tasks
[task.task_name]
command = "shell command" # Command to execute
dependencies = ["dep1"] # Tasks that must run before this one
inputs = ["src/*.rs"] # Input files
outputs = ["target/app"] # Output files
auto_remove = false # Automatically remove outputs after successful execution
timeout = "10m" # Task-specific timeout (overrides default)
[config]
default = "build"
cache_dir = ".build-cache"
[variables]
TARGET_DIR = "target"
APP_NAME = "myapp"
SOURCE_PATTERN = "src/**/*.rs"
TEST_PATTERN = "tests/**/*.rs"
[task.prepare]
id = "prep"
command = "mkdir -p ${TARGET_DIR}"
outputs = ["${TARGET_DIR}/"]
[task.build]
command = "cargo build"
dependencies = ["prep"]
inputs = [
"${SOURCE_PATTERN}",
"Cargo.toml"
]
outputs = ["${TARGET_DIR}/debug/${APP_NAME}"]
[task.test]
command = "cargo test"
dependencies = ["build"]
inputs = ["${SOURCE_PATTERN}", "${TEST_PATTERN}"]
[task.clean]
command = "rm -rf ${TARGET_DIR}/"
Compi supports variables for reducing duplication and making configurations more maintainable.
Define variables in the [variables] section:
[variables]
TARGET_DIR = "target"
BUILD_TYPE = "debug"
BINARY_NAME = "myapp"
SOURCE_PATTERN = "src/**/*.rs"
COMPILE_FLAGS = "--release --target x86_64-unknown-linux-gnu"
Use variables anywhere in your configuration with ${VAR_NAME} or $VAR_NAME syntax:
[task.build]
command = "cargo build ${COMPILE_FLAGS}"
inputs = ["${SOURCE_PATTERN}", "Cargo.toml"]
outputs = ["${TARGET_DIR}/${BUILD_TYPE}/${BINARY_NAME}"]
Compi provides several built-in variables:
$PWD: Current working directory$ENV_*: All environment variables prefixed with ENV_ (e.g., $ENV_HOME, $ENV_USER)Access environment variables using the ENV_ prefix:
[variables]
HOME_DIR = "${ENV_HOME}"
USER_NAME = "${ENV_USER}"
[task.deploy]
command = "scp app ${ENV_USER}@server:/home/${ENV_USER}/bin/"
command: Shell command to executeid: Override the task name (defaults to [task.name])dependencies: Array of task names that must run firstinputs: Array of input files/patterns (supports globs)outputs: Array of output files this task producesauto_remove: Automatically remove outputs after successful execution (default: false)timeout: Task timeout duration (e.g., "30s", "5m", "1h") - overrides defaultCompi uses a 4-tier system to determine if a task should run:
Input files support standard glob patterns:
*.rs: All Rust files in current directorysrc/**/*.rs: All Rust files in src and subdirectoriestest/*.{rs,toml}: Rust and TOML files in test directoryCompi provides two ways to automatically clean up outputs after successful task execution:
Use the --rm flag to remove outputs after running a task:
# Remove outputs after building
compi --rm build
# Remove outputs with verbose logging
compi --rm -v test
Set auto_remove = true in task configuration for automatic cleanup:
[task.temp_build]
command = "gcc -o temp_app *.c"
outputs = ["temp_app", "*.o"]
auto_remove = true # Always clean up after successful execution
[task.generate_docs]
command = "doxygen"
outputs = ["docs/"]
# Only removed if --rm flag is used
*.o are expanded to actual files before removalcache_dir in config[config]
default = "deploy"
[task.compile]
command = "gcc *.c -o app"
inputs = ["*.c", "*.h"]
outputs = ["app"]
[task.test]
command = "./app --test"
dependencies = ["compile"]
inputs = ["app"]
[task.deploy]
command = "scp app server:/"
dependencies = ["test"]
inputs = ["app"]
[config]
default = "all"
[task.js]
command = "npm run build"
inputs = ["src/**/*.js", "package.json"]
outputs = ["dist/app.js"]
[task.css]
command = "sass src/style.scss dist/style.css"
inputs = ["src/**/*.scss"]
outputs = ["dist/style.css"]
[task.all]
dependencies = ["js", "css"]
command = "echo 'Build complete'"
[config]
default = "package"
[task.compile]
command = "gcc *.c -o app"
inputs = ["*.c", "*.h"]
outputs = ["app", "*.o"]
[task.test]
command = "./app --test > test.log"
dependencies = ["compile"]
inputs = ["app"]
outputs = ["test.log"]
auto_remove = true # Always clean up test logs
[task.package]
command = "tar -czf app.tar.gz app"
dependencies = ["test"]
inputs = ["app"]
outputs = ["app.tar.gz"]
# Usage:
# compi --rm compile # Removes app and *.o files after compilation
# compi test # Automatically removes test.log (auto_remove = true)
# compi package # Keeps app.tar.gz (no cleanup)