DCR is a utility for managing C/C++ projects in a Cargo-like style.
The current implementation is written in Rust.
- Unified project structure without manual setup
- Simple commands for common tasks
- Transparent compilation and predictable build profiles
- Create a new project or initialize the current directory
- Build a project with
debugandreleaseprofiles - Run the compiled binary
- Clean build artifacts
- Generate IDE integration files (VS Code, CLion) and compilation databases
- Generate a minimal C project template
- Build static and shared libraries
- ASM projects with NASM/GAS or via GCC/Clang
- Mixed language projects (
language = ["c", "asm"]and similar) - Cross-compilation with
--target(short names:linux,macos,windows) - Target-specific configurations and inheritance
- Update the binary via
dcr --update(GitHub Releases, not for pacman/AUR installs)
- Linux:
x86_64-unknown-linux-gnu - macOS Intel:
x86_64-apple-darwin - macOS Apple Silicon:
aarch64-apple-darwin - Windows:
x86_64-pc-windows-msvc
Arch Linux
yay -S dcr # or paru and other AUR package managersgit clone https://github.com/dexoron/dcr.git
cd dcr
cargo build --release
mkdir -p ~/.local/bin
ln -sf "$PWD/target/release/dcr" ~/.local/bin/dcrcurl -fsSL https://dcr.dexoron.su/install.sh | bashirm https://dcr.dexoron.su/install.ps1 | iexWhen executed, both scripts ask whether to:
- download a prebuilt binary from GitHub Releases
- or build the project from
git
Release assets:
dcr-x86_64-unknown-linux-gnudcr-x86_64-apple-darwindcr-aarch64-apple-darwindcr-x86_64-pc-windows-msvc.exe
- If DCR was installed from GitHub release assets,
install.sh,install.ps1, or built manually:- use
dcr --update
- use
- If DCR is installed via
pacman/AUR:- update with your package manager:
paru/yay -Syu dcrorsudo pacman -Syu dcr dcr --updatedetects package-managed installs and asks you to update via package manager
- update with your package manager:
Create a new project:
dcr new hello
Or initialize the current directory (the directory must be empty):
dcr init
Project structure:
hello/
- src/
- - main.c
- dcr.tomlBuild and run the project:
dcr run or dcr run --release
Creates a project with the specified name in the current directory.
Creates a project in the current directory. The project name is taken from the directory name. The directory must be empty.
Builds the project. If no profile is specified, --debug is used.
Use --force to rebuild without cache, --clean to clean before build.
Builds the project and runs the binary. If no profile is specified, --debug is used.
Use --force to rebuild without cache, --clean to clean before build.
Run manually:
./target/<profile>/<name>
Removes the target directory in the project root.
Use dcr clean --all in a workspace root to clean all member projects.
Generates IDE integration files and build tools.
dcr gen vscode: VS Code workspace configdcr gen clion: CLion project filesdcr gen compile-commands:compile_commands.jsonfor clang tools
Runs the test suite.
Use dcr test --init to create test files.
Two profiles are supported:
--debug(default) - built-in flags per compiler--release- built-in flags per compiler
Custom flags can be added in dcr.toml via build.cflags and build.ldflags.
Profile-specific flags can be added via [build.debug] and [build.release].
You can also set build.target to override the output directory (profile-independent).
You can set build.platform to pass -march=<platform> (GCC/Clang) or /arch:* (MSVC) where supported.
Use build.kind = "staticlib" to build a static library instead of a binary.
Use build.kind = "sharedlib" to build a shared library (.so/.dylib/.dll).
dcr run is only for build.kind = "bin" and will fail for libraries.
Use build.exclude/build.include to control source/header collection.
Use build.roots and build.src_disable to replace the default src/ root.
Use build.steps and build.post_steps to run custom commands.
Use build.clean for extra cleanup paths and [run].cmd to override run command.
DCR supports cross-compilation via --target <triple> or short names:
dcr build --target linux --release # x86_64-unknown-linux-gnu
dcr build --target macos --release # x86_64-apple-darwin
dcr build --target windows --release # x86_64-pc-windows-msvc
dcr run --target aarch64-linux-gnuConfigure multiple targets and target-specific settings in dcr.toml:
[build.targets]
targets = ["linux", "windows"]
[build.linux]
compiler = "gcc"
cflags = ["-O2"]
[build.windows]
compiler = "x86_64-w64-mingw32-gcc"See Cross-compilation guide for details.
The main project file is dcr.toml.
Example dcr.toml:
[package]
name = "hello"
version = "0.1.0"
[build]
language = "c"
standard = "c11"
compiler = "clang"
# Optional platform hint
# platform = "x86_64"
# Optional custom flags
cflags = ["-Wall", "-Wextra"]
ldflags = ["-lm"]
#
# Optional include/exclude:
# exclude = ["src/vendor", "src/legacy/**"]
# include = ["src/boot/arch/**"]
[toolchain]
# Optional tool overrides:
# cc = "clang"
# cxx = "clang++"
# as = "as"
# ar = "ar"
# ld = "ld"
# uic = "uic"
# moc = "moc"
# rcc = "rcc"
[dependencies]Workspace example:
[workspace]
kernel = { path = "src/kernel", deps = ["core", "userspace"] }
core = { path = "src/core", deps = ["userspace"] }
userspace = { path = "src/userspace" }Path dependencies are supported. DCR will resolve them on build and generate dcr.lock.
Incremental build note: object files are rebuilt when source .c/.cpp files change. Header dependency tracking is not implemented yet.
- Rust toolchain (
rustc,cargo) - for building DCR from source - C compiler (
clang,gcc, or 'cl'(msvc))
Releases are built automatically via GitHub Actions (.github/workflows/release.yml) when a tag matching v* is pushed.
See LICENSE.