112 Commits

Author SHA1 Message Date
2f2c4aa208 New translations test-framework.mdx (Ukrainian)
[ci skip]
2026-07-07 11:22:40 +08:00
87bad94848 New translations test-framework.mdx (Russian)
[ci skip]
2026-07-07 11:22:39 +08:00
39bba3cea8 New translations test-framework.mdx (Polish)
[ci skip]
2026-07-07 11:22:38 +08:00
d498e67782 New translations test-framework.mdx (German)
[ci skip]
2026-07-07 11:22:36 +08:00
82de72ce8d New translations running-tests.mdx (Ukrainian)
[ci skip]
2026-07-07 11:22:35 +08:00
ffaf1f1dd1 New translations running-tests.mdx (Russian)
[ci skip]
2026-07-07 11:22:34 +08:00
c050ffb8c4 New translations running-tests.mdx (Polish)
[ci skip]
2026-07-07 11:22:33 +08:00
e9908f359d New translations running-tests.mdx (German)
[ci skip]
2026-07-07 11:22:32 +08:00
024bbfcaa9 New translations self-update.mdx (Ukrainian)
[ci skip]
2026-07-07 11:22:31 +08:00
4b8d78dac7 New translations self-update.mdx (Russian)
[ci skip]
2026-07-07 11:22:29 +08:00
50a2c59fed New translations self-update.mdx (Polish)
[ci skip]
2026-07-07 11:22:28 +08:00
184c44902c New translations self-update.mdx (German)
[ci skip]
2026-07-07 11:22:27 +08:00
44cb4f3665 New translations workspaces.mdx (Ukrainian)
[ci skip]
2026-07-07 11:22:26 +08:00
98fc25c40d New translations workspaces.mdx (Russian)
[ci skip]
2026-07-07 11:22:25 +08:00
fc968d07bd New translations workspaces.mdx (Polish)
[ci skip]
2026-07-07 11:22:24 +08:00
ba20bf7d3d New translations workspaces.mdx (German)
[ci skip]
2026-07-07 11:22:23 +08:00
787e89f779 New translations platform-support.mdx (Ukrainian)
[ci skip]
2026-07-07 11:22:21 +08:00
a67729a673 New translations platform-support.mdx (Russian)
[ci skip]
2026-07-07 11:22:20 +08:00
25cc7b8f3b New translations platform-support.mdx (Polish)
[ci skip]
2026-07-07 11:22:19 +08:00
bddbc3603a New translations platform-support.mdx (German)
[ci skip]
2026-07-07 11:22:18 +08:00
666794d33d New translations environment-variables.mdx (Ukrainian)
[ci skip]
2026-07-07 11:22:17 +08:00
e35f5e0ad1 New translations environment-variables.mdx (Russian)
[ci skip]
2026-07-07 11:22:16 +08:00
4ce4632a92 New translations environment-variables.mdx (Polish)
[ci skip]
2026-07-07 11:22:14 +08:00
aaa6c99795 New translations environment-variables.mdx (German)
[ci skip]
2026-07-07 11:22:13 +08:00
fe6ac220e6 New translations dependencies.mdx (Ukrainian)
[ci skip]
2026-07-07 11:22:12 +08:00
6622353ff8 New translations dependencies.mdx (Russian)
[ci skip]
2026-07-07 11:22:11 +08:00
b3f14d1e68 New translations dependencies.mdx (Polish)
[ci skip]
2026-07-07 11:22:09 +08:00
4cb8985bfb New translations dependencies.mdx (German)
[ci skip]
2026-07-07 11:22:08 +08:00
95bb204884 New translations dcr-toml.mdx (Ukrainian)
[ci skip]
2026-07-07 11:22:07 +08:00
bebda1fe8a New translations dcr-toml.mdx (Russian)
[ci skip]
2026-07-07 11:22:06 +08:00
f0e587b12b New translations dcr-toml.mdx (Polish)
[ci skip]
2026-07-07 11:22:02 +08:00
476f13676a New translations dcr-toml.mdx (German)
[ci skip]
2026-07-07 11:22:01 +08:00
fcf21b2b2e New translations cross-compilation.mdx (Ukrainian)
[ci skip]
2026-07-07 11:22:00 +08:00
cb519cc4fd New translations cross-compilation.mdx (Russian)
[ci skip]
2026-07-07 11:21:56 +08:00
32911212e8 New translations cross-compilation.mdx (Polish)
[ci skip]
2026-07-07 11:21:52 +08:00
3f506e79af New translations cross-compilation.mdx (German)
[ci skip]
2026-07-07 11:21:48 +08:00
fc657b8a99 New translations build-system.mdx (Ukrainian)
[ci skip]
2026-07-07 11:21:46 +08:00
462c53d93f New translations build-system.mdx (Russian)
[ci skip]
2026-07-07 11:21:45 +08:00
c9ff114b25 New translations build-system.mdx (Polish)
[ci skip]
2026-07-07 11:21:44 +08:00
746a26bae9 New translations build-system.mdx (German)
[ci skip]
2026-07-07 11:21:42 +08:00
b6b171b2a9 New translations build-profiles.mdx (Ukrainian)
[ci skip]
2026-07-07 11:21:41 +08:00
a1ccaebfd3 New translations build-profiles.mdx (Russian)
[ci skip]
2026-07-07 11:21:40 +08:00
a15470e669 New translations build-profiles.mdx (Polish)
[ci skip]
2026-07-07 11:21:39 +08:00
901ea9ebaa New translations build-profiles.mdx (German)
[ci skip]
2026-07-07 11:21:38 +08:00
75cf0af9b4 New translations multi-package-workspace.mdx (Ukrainian)
[ci skip]
2026-07-07 11:21:37 +08:00
54f5f78e2c New translations multi-package-workspace.mdx (Russian)
[ci skip]
2026-07-07 11:21:36 +08:00
bb27b4e2e6 New translations multi-package-workspace.mdx (Polish)
[ci skip]
2026-07-07 11:21:35 +08:00
9d9422b45b New translations multi-package-workspace.mdx (German)
[ci skip]
2026-07-07 11:21:33 +08:00
b37aa2a380 New translations library-project.mdx (Ukrainian)
[ci skip]
2026-07-07 11:21:32 +08:00
af96ba2ac2 New translations library-project.mdx (Russian)
[ci skip]
2026-07-07 11:21:31 +08:00
2d73d07923 New translations library-project.mdx (Polish)
[ci skip]
2026-07-07 11:21:30 +08:00
d193dc1314 New translations library-project.mdx (German)
[ci skip]
2026-07-07 11:21:29 +08:00
8ddf4c3fb9 New translations cross-to-windows.mdx (Ukrainian)
[ci skip]
2026-07-07 11:21:28 +08:00
f7c0a50e0e New translations cross-to-windows.mdx (Russian)
[ci skip]
2026-07-07 11:21:27 +08:00
f4748173f9 New translations cross-to-windows.mdx (Polish)
[ci skip]
2026-07-07 11:21:26 +08:00
1ed2cd9a71 New translations cross-to-windows.mdx (German)
[ci skip]
2026-07-07 11:21:25 +08:00
d77fcf6b29 New translations license.mdx (Ukrainian)
[ci skip]
2026-07-07 11:21:23 +08:00
458cda2da2 New translations license.mdx (Russian)
[ci skip]
2026-07-07 11:21:22 +08:00
af9b67edec New translations license.mdx (Polish)
[ci skip]
2026-07-07 11:21:21 +08:00
72654896c0 New translations license.mdx (German)
[ci skip]
2026-07-07 11:21:20 +08:00
82a2b38132 New translations ide-integration.mdx (Ukrainian)
[ci skip]
2026-07-07 11:21:19 +08:00
c936c03fbf New translations ide-integration.mdx (Russian)
[ci skip]
2026-07-07 11:21:17 +08:00
0fecd4c2b7 New translations ide-integration.mdx (Polish)
[ci skip]
2026-07-07 11:21:16 +08:00
1e6a1ae9c1 New translations ide-integration.mdx (German)
[ci skip]
2026-07-07 11:21:15 +08:00
813354c5da New translations installation.mdx (Ukrainian)
[ci skip]
2026-07-07 11:21:14 +08:00
a02f302c48 New translations installation.mdx (Russian)
[ci skip]
2026-07-07 11:21:13 +08:00
a1d2d41fb0 New translations installation.mdx (Polish)
[ci skip]
2026-07-07 11:21:12 +08:00
c11c1a83df New translations installation.mdx (German)
[ci skip]
2026-07-07 11:21:10 +08:00
98db98d353 New translations first-steps.mdx (Ukrainian)
[ci skip]
2026-07-07 11:21:09 +08:00
6c326c21d4 New translations first-steps.mdx (Russian)
[ci skip]
2026-07-07 11:21:08 +08:00
2e895619bf New translations first-steps.mdx (Polish)
[ci skip]
2026-07-07 11:21:07 +08:00
03146c2857 New translations first-steps.mdx (German)
[ci skip]
2026-07-07 11:21:06 +08:00
6c1e041037 New translations faq.mdx (Ukrainian)
[ci skip]
2026-07-07 11:21:05 +08:00
fc545c6af9 New translations faq.mdx (Russian)
[ci skip]
2026-07-07 11:21:04 +08:00
4e2688d66f New translations faq.mdx (Polish)
[ci skip]
2026-07-07 11:21:02 +08:00
1eca47feb5 New translations faq.mdx (German)
[ci skip]
2026-07-07 11:21:01 +08:00
12f4177a91 New translations contributing.mdx (Ukrainian)
[ci skip]
2026-07-07 11:21:00 +08:00
84eb7c0c52 New translations contributing.mdx (Russian)
[ci skip]
2026-07-07 11:20:59 +08:00
ce643077b3 New translations contributing.mdx (Polish)
[ci skip]
2026-07-07 11:20:58 +08:00
bc71ee7202 New translations contributing.mdx (German)
[ci skip]
2026-07-07 11:20:57 +08:00
42312e10bb New translations system-commands.mdx (Ukrainian)
[ci skip]
2026-07-07 11:20:56 +08:00
7e54cb7155 New translations system-commands.mdx (Russian)
[ci skip]
2026-07-07 11:20:55 +08:00
4c40e74dbb New translations system-commands.mdx (Polish)
[ci skip]
2026-07-07 11:20:54 +08:00
8aa350629c New translations system-commands.mdx (German)
[ci skip]
2026-07-07 11:20:52 +08:00
49d63a1ea1 New translations quality-commands.mdx (Ukrainian)
[ci skip]
2026-07-07 11:20:51 +08:00
f87112faf0 New translations quality-commands.mdx (Russian)
[ci skip]
2026-07-07 11:20:50 +08:00
ab0ad58925 New translations quality-commands.mdx (Polish)
[ci skip]
2026-07-07 11:20:49 +08:00
f5b465446c New translations quality-commands.mdx (German)
[ci skip]
2026-07-07 11:20:48 +08:00
f4124ea268 New translations project-commands.mdx (Ukrainian)
[ci skip]
2026-07-07 11:20:46 +08:00
d10358bdab New translations project-commands.mdx (Russian)
[ci skip]
2026-07-07 11:20:45 +08:00
fd5150f3db New translations project-commands.mdx (Polish)
[ci skip]
2026-07-07 11:20:44 +08:00
82e10cc75d New translations project-commands.mdx (German)
[ci skip]
2026-07-07 11:20:43 +08:00
b7c9edb35e New translations gen-commands.mdx (Ukrainian)
[ci skip]
2026-07-07 11:20:42 +08:00
04fcedc428 New translations gen-commands.mdx (Russian)
[ci skip]
2026-07-07 11:20:41 +08:00
548808a8d8 New translations gen-commands.mdx (Polish)
[ci skip]
2026-07-07 11:20:40 +08:00
dcb8e676f1 New translations gen-commands.mdx (German)
[ci skip]
2026-07-07 11:20:38 +08:00
1b0ee1402a New translations dependency-commands.mdx (Ukrainian)
[ci skip]
2026-07-07 11:20:37 +08:00
6c6fa8d5d4 New translations dependency-commands.mdx (Russian)
[ci skip]
2026-07-07 11:20:36 +08:00
c2c3a7bd7a New translations dependency-commands.mdx (Polish)
[ci skip]
2026-07-07 11:20:35 +08:00
23149d8149 New translations dependency-commands.mdx (German)
[ci skip]
2026-07-07 11:20:34 +08:00
801a164da9 New translations build-commands.mdx (Ukrainian)
[ci skip]
2026-07-07 11:20:33 +08:00
e3ec2c198d New translations build-commands.mdx (Russian)
[ci skip]
2026-07-07 11:20:32 +08:00
312af43702 New translations build-commands.mdx (Polish)
[ci skip]
2026-07-07 11:20:30 +08:00
3ca1db4f7c New translations build-commands.mdx (German)
[ci skip]
2026-07-07 11:20:29 +08:00
0af619907a New translations changelog.mdx (Ukrainian)
[ci skip]
2026-07-07 11:20:28 +08:00
e257afde70 New translations changelog.mdx (Russian)
[ci skip]
2026-07-07 11:20:27 +08:00
cd3ef3a7f5 New translations changelog.mdx (Polish)
[ci skip]
2026-07-07 11:20:26 +08:00
966018c1e0 New translations changelog.mdx (German)
[ci skip]
2026-07-07 11:20:25 +08:00
180f927e85 New translations readme.mdx (Ukrainian)
[ci skip]
2026-07-07 11:20:23 +08:00
7ba9d296a1 New translations readme.mdx (Russian)
[ci skip]
2026-07-07 11:20:22 +08:00
93a894e66a New translations readme.mdx (Polish)
[ci skip]
2026-07-07 11:20:21 +08:00
c7dd8fecaa New translations readme.mdx (German)
[ci skip]
2026-07-07 11:20:20 +08:00
112 changed files with 7808 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
---
sidebar_label: Introduction
---
# DCR — C/C++ Build Tool & Package Manager
<details>
<summary>Quick reference</summary>
```bash
# Installation
curl -fsSL https://dcr.dexoron.su/install.sh | sh
# Create a project
dcr new my-app
cd my-app
# Build and run
dcr build
dcr run
# Run tests
dcr test
# Add a dependency
dcr add fmt
# Generate IDE files
dcr gen vscode
```
</details>
## Contents
| Section | Description |
| ----------------------------------------------------- | --------------------------------------------- |
| [Getting Started](/docs/getting-started/installation) | Installation and first steps |
| [Commands](/docs/commands/project-commands) | All CLI commands |
| [Reference](/docs/reference/dcr-toml) | Configuration, build, dependencies, platforms |
| [Testing](/docs/testing/test-framework) | Built-in test framework |
| [Recipes](/docs/recipes/cross-to-windows) | Common scenarios |
| [IDE Integration](/docs/ide-integration) | VS Code, CLion, compile_commands.json |
| [Self Update](/docs/self-update) | Auto-update |
| [FAQ](/docs/faq) | Frequently asked questions |
| [Changelog](/docs/changelog) | Version history |
| [License](/docs/license) | DCR and vendored library licenses |
| [Contributing](/docs/contributing) | DCR development |
## Features
* **Incremental builds** — mtime + `.d` headers + SHA256 fingerprint
* **Parallel compilation** — thread::scope, atomic task queue
* **4 backends** — gcc/clang, MSVC/clang-cl, GAS (ARM), NASM (x86)
* **7 project kinds** — bin, staticlib, sharedlib, efi, elf, none, custom
* **Cross-compilation** — short names and full triples
* **Profiles** — debug / release with field overrides
* **Workspaces** — multi-package projects with topological sort
* **Registry + Git + Path** — three dependency mechanisms
* **IDE generation** — VS Code, CLion, compile_commands.json, JSON metadata
* **pkg-config** — automatic system library discovery
* **Per-command `--help`** — `dcr build --help`, `dcr new --help`, etc.
* **Man pages** — `man dcr`, `man dcr-build`, `man dcr-new`

View File

@@ -0,0 +1,91 @@
---
sidebar_label: Changelog
---
# Changelog
## 0.7.1 (2026-06-02)
### Added
* **`--help` for all commands** — `dcr build --help`, `dcr run --help`, `dcr new --help`,
`dcr init --help`, `dcr clean --help`, `dcr add --help`, `dcr fmt --help`,
`dcr setup --help`, `dcr tree --help`, `dcr gen --help`, `dcr --update --help`,
`dcr test --help`. All output uses styled headers (green) and usage lines (cyan).
* **Man pages** — 12 troff pages in `man/man1/`: `dcr.1`, `dcr-build.1`,
`dcr-run.1`, `dcr-new.1`, `dcr-init.1`, `dcr-clean.1`, `dcr-add.1`, `dcr-test.1`,
`dcr-gen.1`, `dcr-fmt.1`, `dcr-tree.1`, `dcr-setup.1`.
* **Man pages in all packaging** — install.sh, install_bsd.sh, AUR PKGBUILD,
Debian (cargo-deb), RPM (cargo-generate-rpm), Nix (postInstall), Homebrew
(resource), Snap, GitHub Release assets.
* **Project name validation** — `dcr init` and `dcr new` now validate names before
creating files. Only ASCII letters, digits, `_` and `-` are allowed.
* **`documentation` and `homepage` fields** — added to `Cargo.toml`.
* **Release profile optimizations** — `opt-level = "z"`, LTO, `codegen-units = 1`,
`panic = "abort"`, `strip = true` for smaller binaries.
* **Linux i686, armv7, riscv64 targets** — added to release workflow and install scripts.
* **Linux musl i686, armv7 targets** — cross-compiled via zigbuild in CI.
* **AUR packages** — `dcr-dev`, `dcr-dev-bin` publishing workflow.
* **Snap publishing** — automated Snapcraft publishing in CI.
* **Snap badge** — in README.
### Changed
* **`validate_package_name` made public** — callable from CLI commands.
* **README platform table** — reorganized: libc variants as separate OS rows,
removed extra columns. Linux architecture list updated.
* **`gen.rs` no-args output** — now uses styled output instead of raw `eprintln!`.
* **`tree.rs`, `fmt.rs`, and `setup.rs`** — now accept arguments for `--help`.
* **README install commands** — `| bash` → `| sh` for POSIX compatibility.
### Fixed
* **`dcr new \<invalid-name>` creates directory then fails** — validation now
happens before any file operations.
* **`dcr init` on invalid directory name** — same fix.
* **Man pages missing in installed packages** — now shipped in all formats.
* **Windows drive letter false positive** — in dependency file parser.
* **CRLF (`\r\n`) breaks dependency parser** — now handles mixed line endings.
* **Newline after backslash not consumed** — in `parse_d_file` escape handling.
## 0.7.0 (2026-06-01)
### Added
* **OpenBSD and NetBSD target support** — full platform routing with dynamic target triples using `std::env::consts::ARCH` and `std::env::consts::OS`. Affects `build`, `run`, `clean` commands and the platform module.
* **`src/platform/bsd.rs`** — new BSD platform module (shared by FreeBSD, OpenBSD, NetBSD) providing `bin_path`, `lib_path`, `elf_path`, `efi_path`, `shared_lib_path`.
* **`build.out_dir` config option** — custom output directory that overrides the default `target/\<triple>/\<profile>` path for final artifacts. Supported in `build`, `run`, and config validation.
* **`dcr fmt` command** — new CLI command that formats all C/C++ source files (`*.c`, `*.cpp`, `*.h`, `*.hpp`) in `src/` and `tests/` using `clang-format`.
* **Incremental linking** — `needs_link()` in `common.rs` checks if any object file is newer than the linked output, skipping unnecessary relinking. Implemented for all backends (`unix_cc`, `msvc`, `gas`, `nasm`).
* **`build.kind = "none"` and `"custom"`** — two new project kinds for special build scenarios that don't produce standard artifacts.
* **`install_bsd.sh`** — POSIX-compliant installation script for BSD systems (FreeBSD, OpenBSD, NetBSD) with binary download and source build modes.
* **Linux ARM64 support in `install.sh`** — added `Linux:aarch64|Linux:arm64` target detection for pre-built binary downloads.
* **BSD OS detection in `install.sh`** — detects FreeBSD, OpenBSD, NetBSD and determines target triple.
* **`rust-toolchain.toml`** — explicit toolchain pinning to `stable` channel.
* **Integration tests** — `build_with_target_config` (verifies `build.target = "linux"`) and `build_with_out_dir` (validates custom output directory).
* **`get_build_string_with_profile` made `pub`** — so `run.rs` can determine custom output directory configuration.
### Changed
* **`build.target` semantics changed** — now strictly contains a target triple (e.g., `x86_64-unknown-linux-gnu`) or short name (`linux`, `macos`, `windows`). No longer used as custom output directory — this functionality moved to `build.out_dir`.
* **`build.standard` made optional** — changed from `String` to `Option\<String>`. Validation only enforces non-empty for non-ASM languages. Skipped in `dcr.toml` output if empty.
* **`dcr run` with `out_dir`** — now determines target directory respecting `build.out_dir` via `get_build_string_with_profile()` from `build.rs`.
* **`collect_sources()` returns empty vector** instead of error when no sources are found, allowing `kind = "none"` or `kind = "custom"` projects with no source files.
* **CI/CD release workflow refactored** — `git2` made target-specific (no vendored-openssl on Windows), Zig-based cross-compilation for non-x86_64 Linux targets, Arch Linux package version cleanup (dashes → dots), `gmake` symlink for NetBSD.
* **README compatibility table** — FreeBSD, OpenBSD, NetBSD build/run status upgraded from "community/best-effort" to "officially supported".
* **Documentation updated** — `build-section.md` describes new `build.target` and `build.out_dir` fields. `target-directory.md` rewritten to clarify the distinction.
### Fixed
* **stdout/stderr not inherited in `dcr run`** — child process output was captured and manually printed, breaking interactive programs. Fixed by switching to `Command::status()`.
* **Race condition in release CI** — matrix build jobs could upload assets to a release that didn't exist yet. Fixed by adding a dedicated `create-release` job.
* **Release GHA — stable toolchain override** — fixed Rust toolchain override issues in CI.
* **Arch Linux package version sanitization** — version strings with dashes (e.g., `0.7.0-dev`) are invalid for `pkgver`. Fixed by replacing dashes with dots.
* **GPG permissions after Docker** — Docker operations changed GPG directory ownership. Fixed by running `chown` after Docker commands.
* **RPM artifact paths** — RPM artifacts were placed in `rpm/x86_64/` instead of `fedora/x86_64/`. Fixed in Dexoron Packages Index workflow.
* **JSON parsing reliability in `install.sh`** — added `jq` as primary parser with `python3` fallback for dev channel release lookup.
### Removed
* **`format_roots()` helper function** — removed from `common.rs`. Was only used by the old error handling path in `collect_sources()`.
* **Per-distribution artifact download steps** — three separate `actions/download-artifact` steps replaced with unified `gh release download --clobber`.

View File

@@ -0,0 +1,42 @@
---
sidebar_label: Build commands (build, run, clean)
---
# Build Commands
## `dcr build`
Builds the project according to `dcr.toml`.
```bash
dcr build # debug profile
dcr build --release # release build
dcr build --debug # explicit debug
dcr build --target aarch64-unknown-linux-gnu
dcr build --force # full rebuild
dcr build --clean # clean + build
dcr build --verbose # show compilation commands
dcr build --workspace pkg-a # build specific workspace package
```
Artifacts: `target/\<triple>/\<profile>/\<binary-name>` (Linux with explicit target).
## `dcr run`
Builds (if sources are newer than artifacts) and runs the binary.
```bash
dcr run
dcr run --release
```
## `dcr clean`
Removes `target/` directory (or `target/\<target>/\<profile>`).
```bash
dcr clean
dcr clean --release # target/release/ only
dcr clean --target windows # target/x86_64-pc-windows-msvc/
dcr clean --all # clean all workspace packages
```

View File

@@ -0,0 +1,53 @@
---
sidebar_label: Dependency commands (add, tree)
---
# Dependency Commands
## `dcr add \<name> [source]`
Adds a dependency to `dcr.toml`.
```bash
dcr add fmt # registry lookup
dcr add mylib ../path/to/lib # path as source
dcr add mylib path:./lib # explicit path prefix
dcr add mylib git:https://github.com/user/repo # explicit git prefix
dcr add mylib github:user/repo # GitHub shorthand
dcr add mylib gitlab:user/repo # GitLab shorthand
```
Source prefixes:
* `path:` — local path
* `git:` — generic git URL
* `github:` — expands to `https://github.com/\<user>/\<repo>`
* `gitlab:` — expands to `https://gitlab.com/\<user>/\<repo>`
* `http://` / `https://` / `git@` — full URL
Flags:
* `--branch \<name>` — git branch
* `--tag \<name>` — git tag
* `--rev \<hash>` — git commit
If source is omitted — DCR searches connected registries.
## `dcr tree`
Displays the project dependency tree.
```bash
dcr tree
```
Example output:
```
my-app v0.1.0
├── fmt (registry)
│ └── spdlog (registry)
└── catch2 (registry)
```
For path dependencies, recursively shows their own dependencies (from their `dcr.toml`).

View File

@@ -0,0 +1,73 @@
---
sidebar_label: Gen commands (vscode, clion, ...)
---
# Gen Commands
## `dcr gen \<target>`
Generates IDE integration files.
### vscode
```bash
dcr gen vscode
```
Creates:
* `.vscode/tasks.json` — `build` task (dcr build)
* `.vscode/launch.json` — debug launch configuration
* `.vscode/settings.json` — C/C++ settings (clangd paths, includes)
* `.vscode/extensions.json` — recommended extensions (vscode-clangd, vscode-lldb)
### clion
```bash
dcr gen clion
```
Creates:
* `.idea/externalTools.xml` — external tools (build, run, clean, test)
* `.idea/customTargets.xml` — custom build targets
* `.idea/misc.xml` — C/C++ project settings
* `.idea/runConfigurations/\<name>.xml` — per-binary run configurations
### compile-commands
```bash
dcr gen compile-commands
```
Generates `compile_commands.json` — standard format for clangd, cpptools, static analyzers.
### project-info
```bash
dcr gen project-info
```
Outputs JSON array with project metadata:
```json
[
{
"name": "my-app",
"version": "0.1.0",
"root": "/path/to/project",
"profile": "debug",
"language": "c",
"standard": "c17",
"cxx_standard": null,
"compiler": "/usr/bin/clang",
"kind": "bin",
"sources": ["src/main.c"],
"include_dirs": ["src"],
"lib_dirs": [],
"libs": [],
"cflags": ["-std=c17", "-O0", "-g"],
"ldflags": []
}
]
```

View File

@@ -0,0 +1,31 @@
---
sidebar_label: Project commands (new, init)
---
# Project Commands
## `dcr new \<name>`
Creates a new project with a standard structure and `dcr.toml`. The `name` argument is required.
Only ASCII letters, digits, underscores `_` and hyphens `-` are allowed in the project name.
```bash
dcr new my-app
```
Generates:
* `dcr.toml` with basic fields
* `src/main.c` with a `main` template
## `dcr init`
Initializes a DCR project in the current (empty) directory.
```bash
mkdir app && cd app
dcr init
```
The project name is taken from the current directory name. The directory name must follow the same naming rules as `dcr new`.

View File

@@ -0,0 +1,60 @@
---
sidebar_label: Quality commands (test, fmt)
---
# Quality Commands
## `dcr test`
Runs tests.
```bash
dcr test # debug profile
dcr test --release # release profile
dcr test --debug # explicit debug
dcr test --help # detailed help
```
Before first use, initialize tests:
```bash
dcr test --init
```
This creates `tests/dcr_test.h` (framework) and `tests/test.c` (template).
What `dcr test` does:
1. Builds the project
2. Collects `tests/*.c` files (`.c` only, not `.cpp`)
3. Compiles and links each test file
4. Runs each test binary
5. Prints summary: TOTAL, PASS, SKIP, FAIL
6. Returns non-zero exit code on any FAIL
## `dcr fmt`
Formats C/C++ source files using `clang-format`.
```bash
dcr fmt
```
Processes: `src/**/*.{c,cpp,cxx,cc,h,hpp,hxx,hh}` and `tests/**/*.{c,cpp,cxx,cc,h,hpp,hxx,hh}`.
Uses `.clang-format` at the project root (if present), otherwise default clang-format style.
## `dcr lint`
Runs `clang-tidy` on C/C++ source files for static analysis.
```bash
dcr lint # show diagnostics
dcr lint --fix # apply fixes automatically
dcr lint --help # detailed help
```
Processes: `src/**/*.{c,cpp,cxx,cc}` and `tests/**/*.{c,cpp,cxx,cc}`.
Without `--fix`, clang-tidy reports warnings and errors without modifying files.
With `--fix`, clang-tidy applies automatic suggestions in place.

View File

@@ -0,0 +1,51 @@
---
sidebar_label: System commands (setup, --help, ...)
---
# System Commands
## `dcr setup`
Shows configured registries from `~/.dcr/config.toml`.
```bash
dcr setup
```
If `~/.dcr/config.toml` is not found, DCR returns an error. Create it manually:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```
## `dcr --help`
Shows help for all commands.
```bash
dcr --help
```
## `dcr --version`
Shows version and target triple.
```bash
dcr --version # dcr 0.7.0 (x86_64-unknown-linux-gnu)
```
## `dcr --update`
Self-update. Downloads the latest release binary from GitHub Releases and replaces the current one.
```bash
dcr --update
```
Features:
* Auto-detects platform and architecture
* Warns if installed via AUR (use package manager instead)
* Works on Linux, macOS, Windows

View File

@@ -0,0 +1,51 @@
---
sidebar_label: Contributing
---
# Contributing
## Setup
```bash
git clone https://github.com/dexoron/dcr
cd dcr
cargo build
```
## Code style
All code must be formatted with `cargo fmt`:
```bash
cargo fmt
```
## Linting
```bash
cargo clippy --all-targets -- -D warnings
```
## Tests
```bash
cargo test --all-targets
```
## PR process
1. Fork the repository
2. Create a branch: `git checkout -b feature/description`
3. Make changes
4. Run `cargo fmt && cargo clippy && cargo test`
5. Open a Pull Request
## CI
CI runs:
* `cargo fmt --check`
* `cargo clippy --all-targets -- -D warnings`
* `cargo test --all-targets`
* Build on Linux, macOS, Windows
* Integration tests

View File

@@ -0,0 +1,81 @@
---
sidebar_label: FAQ
---
# FAQ
## Registry not found
```
error: registry not found
```
**Solution:** Make sure `~/.dcr/config.toml` exists:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```
And check `DCR_INDEX_PATH`:
```bash
echo $DCR_INDEX_PATH
```
## Compiler not found
```
error: compiler not found
```
**Solution:** Ensure a compiler is installed and available in PATH.
```bash
which gcc
which clang
```
Or specify explicitly via `[toolchain]` in `dcr.toml`.
## openssl-sys build failed
When building DCR from source:
```
error: failed to run custom build command for openssl-sys
```
**Solution:** Install OpenSSL development headers:
```bash
# Ubuntu/Debian
sudo apt install libssl-dev
# Fedora
sudo dnf install openssl-devel
# macOS
brew install openssl
```
## Ctrl+C during build
DCR handles SIGINT: interrupts the current compilation and exits with non-zero code.
## How to create a library?
See [Library Recipe](/docs/recipes/library-project).
## How to cross-compile to Windows?
See [Cross-Compile Recipe](/docs/recipes/cross-to-windows).
## How to create a multi-package project?
See [Workspace Recipe](/docs/recipes/multi-package-workspace).
## Lock file
`dcr.lock` is created during builds (`dcr build`) when registry dependencies are present. To force an update — delete `dcr.lock` and run `dcr build`.

View File

@@ -0,0 +1,72 @@
---
sidebar_label: First steps
---
# First Steps
## Create a project
```bash
dcr new my-app
cd my-app
```
Structure:
```
my-app/
├── dcr.toml
└── src/
└── main.c
```
`dcr.toml`:
```toml
[package]
name = "my-app"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
compiler = "clang"
kind = "bin"
```
## Build
```bash
dcr build
```
Output — `target/\<triple>/debug/my-app` (Linux) or `target/debug/my-app.exe` (Windows).
Build profiles:
```bash
dcr build --release # release build
dcr build --debug # debug (default)
```
## Run
```bash
dcr run
```
Builds (if needed) and runs the binary.
## First test
```bash
dcr test --init # create test template
dcr test # run tests
```
## Formatting
```bash
dcr fmt # clang-format with .clang-format
```

View File

@@ -0,0 +1,109 @@
---
sidebar_label: Installation
---
# Installation
## Linux (Dexoron Packages)
Configure your package manager at https://pkg.dexoron.su and install:
**Arch Linux**
```sh
sudo pacman -Sy dcr
```
**Debian/Ubuntu**
```sh
sudo apt update && sudo apt install dcr
```
**Fedora/RHEL**
```sh
sudo dnf install dcr
```
## Arch Linux (AUR)
```sh
yay -S dcr
```
## macOS / Linux (Homebrew)
```sh
brew tap dexoron/dexoron
brew install dcr
```
## Snap (Linux)
```sh
sudo snap install dcrup
```
## Nix (flake)
```sh
nix run github:dexoron/dcr
# or install to profile:
nix profile install github:dexoron/dcr
```
## Cargo (crates.io)
```sh
cargo install dcr
```
## Linux / macOS (script)
```sh
curl -fsSL https://dcr.dexoron.su/install.sh | sh
```
## BSD (script)
```sh
curl -fsSL https://dcr.dexoron.su/install_bsd.sh | sh
```
## Windows (PowerShell)
```powershell
irm https://dcr.dexoron.su/install.ps1 | iex
```
## From source
```sh
git clone https://github.com/dexoron/dcr.git
cd dcr && cargo build --release
ln -sf "$PWD/target/release/dcr" ~/.local/bin/dcr
```
## Post-install
Verify the installation:
```bash
dcr --version
```
Man pages are available after installation:
```bash
man dcr
man dcr-build
```
To use the registry, create `~/.dcr/config.toml`:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```

View File

@@ -0,0 +1,51 @@
---
sidebar_label: IDE Integration
---
# IDE Integration
## VS Code
```bash
dcr gen vscode
```
Generates in `.vscode/`:
| File | Purpose |
| ----------------- | -------------------------------------------- |
| `tasks.json` | `build` task (dcr build) |
| `launch.json` | Debug launch configuration |
| `settings.json` | clangd/IntelliSense: include paths, standard |
| `extensions.json` | Recommends vscode-clangd, vscode-lldb |
## CLion
```bash
dcr gen clion
```
Generates in `.idea/`:
| File | Purpose |
| ------------------------------------------------ | ----------------------------------------- |
| `externalTools.xml` | Build, Run, Clean, Test as external tools |
| `customTargets.xml` | Custom build targets |
| `misc.xml` | C/C++ project settings |
| `runConfigurations/\<name>.xml` | Per-binary run configurations |
## compile_commands.json
```bash
dcr gen compile-commands
```
Generates `compile_commands.json` at project root. Standard format for clangd, C/C++ IntelliSense, static analyzers.
## project-info
```bash
dcr gen project-info
```
Outputs JSON array with project metadata (see [gen-commands](/docs/commands/gen-commands)).

View File

@@ -0,0 +1,46 @@
---
sidebar_label: License
---
# License
## DCR
DCR itself is [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later.html) licensed.
> **Note:** DCR is a build tool, not a library. The GPL applies only to DCR's own source code. Projects built with DCR are not subject to DCR's license — their licensing is determined solely by their own code and dependencies.
## Vendored libraries
DCR statically links the following C libraries through its vendored Rust dependencies:
| Library | License | Bundled by |
| ------------------------------------------ | ------------------ | ----------------------------- |
| [libgit2](https://libgit2.org) | MIT OR Apache-2.0 | `git2` / `libgit2-sys` |
| [libssh2](https://libssh2.org) | MIT OR Apache-2.0 | `libgit2-sys` |
| [zlib](https://zlib.net) | MIT OR Apache-2.0 | `libgit2-sys` |
| [OpenSSL](https://openssl.org) | Apache-2.0 | `openssl-sys` / `openssl-src` |
| [ring](https://github.com/briansmith/ring) | Apache-2.0 AND ISC | `rustls` |
## Rust dependencies
DCR is written in Rust. The following notable Rust crates are statically linked:
| Crate | License |
| --------------------------------------------- | ------------------------ |
| [`reqwest`](https://crates.io/crates/reqwest) | MIT OR Apache-2.0 |
| [`rustls`](https://crates.io/crates/rustls) | Apache-2.0 OR ISC OR MIT |
| [`serde`](https://crates.io/crates/serde) | MIT OR Apache-2.0 |
| [`toml`](https://crates.io/crates/toml) | MIT OR Apache-2.0 |
| [`sha2`](https://crates.io/crates/sha2) | MIT OR Apache-2.0 |
| [`git2`](https://crates.io/crates/git2) | MIT OR Apache-2.0 |
| [`openssl`](https://crates.io/crates/openssl) | Apache-2.0 |
| [`tokio`](https://crates.io/crates/tokio) | MIT |
| [`hyper`](https://crates.io/crates/hyper) | MIT |
| [`ctrlc`](https://crates.io/crates/ctrlc) | MIT OR Apache-2.0 |
Full dependency tree (143 packages) is available in [`Cargo.lock`](https://github.com/dexoron/dcr/blob/main/Cargo.lock). The overwhelming majority are dual-licensed under MIT OR Apache-2.0.
## Additional credits
* DCR's CLI design and project model are inspired by [Cargo](https://doc.rust-lang.org/cargo/).

View File

@@ -0,0 +1,49 @@
---
sidebar_label: Cross-compile to Windows
---
# Cross-Compile to Windows from Linux
Building a Windows binary on Linux using mingw-w64.
## Install toolchain
```bash
# Ubuntu/Debian
sudo apt install mingw-w64
# Fedora
sudo dnf install mingw64-gcc mingw64-binutils
```
## Configuration
```toml
[package]
name = "my-app"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
compiler = "clang"
kind = "bin"
target = "x86_64-pc-windows-gnu" # explicit mingw, not msvc
```
## Build
```bash
dcr build --target x86_64-pc-windows-gnu --release
```
Artifact: `target/x86_64-pc-windows-gnu/release/my-app.exe`.
## Custom toolchain
```toml
[toolchain]
cc = "x86_64-w64-mingw32-gcc"
cxx = "x86_64-w64-mingw32-g++"
```

View File

@@ -0,0 +1,70 @@
---
sidebar_label: Library project
---
# Library Project
Creating a static library and using it in another project.
## Step 1: Create the library
```bash
dcr new my-lib
cd my-lib
```
`dcr.toml`:
```toml
[package]
name = "my-lib"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
kind = "staticlib"
```
`src/my_lib.h`:
```c
#ifndef MY_LIB_H
#define MY_LIB_H
int add(int a, int b);
#endif
```
`src/my_lib.c`:
```c
#include "my_lib.h"
int add(int a, int b) { return a + b; }
```
## Step 2: Build
```bash
dcr build --release
```
Artifacts:
* `target/\<triple>/release/libmy-lib.a` (Linux)
* `target/release/my-lib.lib` (Windows)
* `target/include/` — header files
## Step 3: Use in another project
```bash
dcr new my-app
cd my-app
dcr add my-lib ../my-lib
```
Automatically:
* Adds include path to `target/include/` of the library
* Adds lib path to `target/\<triple>/release/`
* Links `libmy-lib.a` / `my-lib.lib`

View File

@@ -0,0 +1,102 @@
---
sidebar_label: Multi-package workspace
---
# Multi-Package Workspace
A project with three packages: two libraries and a binary.
## Structure
```
workspace/
├── dcr.toml # root workspace
├── lib-core/
│ ├── dcr.toml
│ └── src/core.c
├── lib-utils/
│ ├── dcr.toml
│ └── src/utils.c
└── app/
├── dcr.toml
└── src/main.c
```
## Root dcr.toml
```toml
[package]
name = "my-workspace"
version = "0.1.0"
type = "none"
[build]
inherit = true
language = "c"
standard = "c11"
[workspace.lib-core]
path = "lib-core"
[workspace.lib-utils]
path = "lib-utils"
deps = ["lib-core"]
[workspace.app]
path = "app"
deps = ["lib-core", "lib-utils"]
main = true
```
## Packages
`lib-core/dcr.toml`:
```toml
[package]
name = "lib-core"
version = "0.1.0"
type = "none"
[build]
kind = "staticlib"
```
`lib-utils/dcr.toml`:
```toml
[package]
name = "lib-utils"
version = "0.1.0"
type = "none"
[build]
kind = "staticlib"
```
`app/dcr.toml`:
```toml
[package]
name = "app"
version = "0.1.0"
type = "none"
[build]
kind = "bin"
```
## Build
```bash
cd workspace
dcr build # builds everything in correct order
dcr build --workspace app # only app (lib-core and lib-utils built as deps)
dcr run # builds and runs main package
```
Build order (topological sort):
1. `lib-core`
2. `lib-utils` (depends on lib-core)
3. `app` (depends on lib-core, lib-utils)

View File

@@ -0,0 +1,82 @@
---
sidebar_label: Build profiles
---
# Build Profiles
Profiles allow overriding `[build]` fields for specific build modes.
## Configuration
```toml
[build]
language = "c"
standard = "c17"
cflags = ["-Wall"]
[build.debug]
cflags = ["-O0", "-g"]
[build.release]
cflags = ["-O3", "-DNDEBUG"]
```
## Merge rules
Fields from `[build.\<profile>]` are merged on top of `[build]`:
* **Scalar fields** (strings, numbers, bools) — replaced
* **Arrays** (`cflags`, `ldflags`, ...) — **appended** (extend the `[build]` array)
Set `inherit = false` to disable array inheritance (only profile's own arrays are used).
## Built-in profiles
The default flags for each profile are composed from three config fields:
| Field | debug default | release default |
| ----------- | ------------------ | --------------- |
| `opt_level` | `"0"` | `"3"` |
| `debug` | `true` | `false` |
| `warnings` | `["all", "extra"]` | `[]` |
Which produce the equivalent compiler flags:
| Profile | Effective flags |
| --------- | ---------------------------------------------------------- |
| `debug` | `-O0 -g -Wall -Wextra -fno-omit-frame-pointer -DDCR_DEBUG` |
| `release` | `-O3 -DNDEBUG` |
Additional build options can be toggled per-profile:
```toml
[build.release]
opt_level = "z"
lto = true
strip = true
panic = "abort"
codegen-units = "1"
[build.debug]
opt_level = "1"
debug = false
warnings = ["all", "error"]
```
## Target-specific profiles
```toml
[build.linux]
cflags = ["-DLINUX"]
[build.windows.debug]
cflags = ["-DWIN32", "-O0", "-g"]
```
Application order (highest priority first):
1. `[build.\<target>.\<profile>]`
2. `[build.\<profile>.\<target>]`
3. `[build.\<target>]`
4. `[build.\<profile>]`
5. `[build]`

View File

@@ -0,0 +1,131 @@
---
sidebar_label: Build system
---
# Build System
## Compiler Backends
DCR supports 7 compilation backends. Selection is automatic based on file extension and `build.compiler` value.
| Backend | Files | When used |
| --------- | --------------------------------- | ------------------------------------- |
| `unix_cc` | `.c`, `.cpp`, `.cxx`, `.cc`, `.S` | gcc/clang on Linux/macOS/BSD |
| `msvc` | `.c`, `.cpp`, `.cxx`, `.cc` | Windows (cl, clang-cl) |
| `gas` | `.s` | ARM/ARM64 assembler (no preprocessor) |
| `nasm` | `.asm`, `.s` | x86/x86_64 NASM assembler |
| `masm` | `.asm` | MASM (ml/ml64) on Windows |
| `fasm` | `.asm`, `.fasm` | Flat Assembler |
| `llvm_ir` | `.ll` | LLVM IR via `llc -filetype=obj` |
## Qt Support
DCR provides native Qt support for automatic meta-object handling (MOC, UIC, RCC).
Enable it by setting `build.qt = true` in `dcr.toml`. DCR will automatically detect Qt-related files (`.ui`, `.qrc`, `.h` with `Q_OBJECT`) and process them.
```toml
[build]
qt = true
```
*Note: Requires `qt6` modules (Core, Widgets, Gui, Svg) installed via `pkg-config`.*
Advanced customization is still possible via `build.steps` if special handling is needed:
```toml
[build.steps]
moc = "moc {in} -o {out}"
```
### Unix CC
* Compiler resolved via `resolve_compiler()`: `DCR_COMPILER` > `DCR_CC` > `[toolchain]` > `build.compiler` > `PATH`
* Supports `.d` files for header dependency tracking
* Flags: `-std=`, `-MMD -MF`, `-c -o`, `-I`, `-L`, `-l`
* Conditional flags based on config:
* `freestanding` or bare-metal target: `-ffreestanding` (compile), `-nostdlib -static` (link)
* `lto`: `-flto` (compile + link)
* `panic = "abort"`: `-fno-exceptions` (C++ only), `-fno-unwind-tables`, `-fno-asynchronous-unwind-tables`
### MSVC
* Supports cl.exe and clang-cl.exe
* Flags: `/std:`, `/Fo:`, `/Fe:`, `/I`, `/link`
### GAS / NASM / MASM / FASM / LLVM-IR
* GAS: `-I`, `-c -o`, `--defsym`
* NASM: `-I`, `-o`, `-D`, `-f` (format: win64/elf64/macho64/macho32/elf32)
* MASM: `/nologo /c /Fo\<obj> <source>`
* FASM: `<source> \<output>` (output path is the object file)
* LLVM IR: `-filetype=obj <source> -o \<output>`
## Incremental Builds
Three levels of incrementality:
1. **mtime** — if output is newer than all inputs, skip
2. **`.d` files** — header change tracking (including transitive)
3. **SHA256 fingerprint** — recompile if compiler flags changed (stored in `.dcr_fingerprint`)
## Parallel Compilation
* `thread::scope` for thread pool
* Atomic task queue (`AtomicU64`)
* Mutex on stdout (`OUTPUT_MUTEX`)
* Thread count = `available_parallelism()`, capped by `build.codegen-units` if set
## Build Kinds
| Kind | Type | Path (Linux example) |
| ----------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `bin` | Executable | `target/\<triple>/\<profile>/\<name>` (.exe on Windows) |
| `staticlib` | Static library | `target/\<triple>/\<profile>/lib\<name>.a` (.lib) |
| `sharedlib` | Dynamic library | `target/\<triple>/\<profile>/lib\<name>.so` (.dll/.dylib) |
| `efi` | UEFI application | `target/\<triple>/\<profile>/\<name>.efi` |
| `elf` | ELF without stdlib | `target/\<triple>/\<profile>/\<name>` |
| `none` | Compile only, no link | — |
| `custom` | Full filename+extension control | `target/\<triple>/\<profile>/\<filename>.\<extension>` |
## Build Steps
DCR supports pre-build and post-build steps:
* `build.steps` — commands before compilation
* `build.post_steps` — commands after compilation
Substitutions: `{stem}`, `{in}`, `{out}`, `{profile}`, `{version}`, `{name}`.
Example Qt codegen via build steps:
```toml
[build.steps]
moc = "moc {in} -o {out}"
```
## pkg-config
Automatic lookup (read from raw config):
```toml
[build]
pkg_config = ["sdl2", "gl"]
```
DCR runs `pkg-config --cflags sdl2 gl` and `pkg-config --libs sdl2 gl` and adds results to compiler/linker flags.
## Variable Substitution
Supported variables:
| Variable | Description |
| ----------------------- | ---------------------------- |
| `{version}` | Package version |
| `{version_major}` | Major version part |
| `{version_minor}` | Minor version part |
| `{version_patch}` | Patch version |
| `{version_suffix}` | Suffix (e.g., `-rc1`) |
| `{version_suffix_dash}` | Suffix with dash |
| `{profile}` | Profile name (debug/release) |
| `{name}` | Package name |

View File

@@ -0,0 +1,70 @@
---
sidebar_label: Cross-compilation
---
# Cross-Compilation
## Short Names
DCR supports short platform names:
| Short Name | Full Triple |
| ---------- | -------------------------- |
| `linux` | `x86_64-unknown-linux-gnu` |
| `macos` | `x86_64-apple-darwin` |
| `windows` | `x86_64-pc-windows-msvc` |
```bash
dcr build --target windows
```
## Full Triples
```bash
dcr build --target aarch64-unknown-linux-gnu
dcr build --target x86_64-pc-windows-gnu # mingw
dcr build --target armv7-unknown-linux-gnueabihf
```
## clang --target
When using clang, DCR injects `--target=\<triple>` into CFLAGS.
```toml
[build]
compiler = "clang"
target = "aarch64-unknown-linux-gnu"
# Auto: cflags += ["--target=aarch64-unknown-linux-gnu"]
```
## Bare-Metal / Freestanding
For targets containing `none`, `-elf`, `eabi`, or `baremetal`, DCR automatically:
1. **Disables default flags** — no system include paths, no `-l` libc
2. **Injects `-ffreestanding`** at compile time and `-nostdlib -static` at link time
You can also enable freestanding mode explicitly:
```toml
[build]
freestanding = true
```
```bash
dcr build --target aarch64-none-elf
```
## Target Directory
On Linux with explicit target:
```
target/<triple>/<profile>/
```
On macOS/Windows or without target:
```
target/<profile>/
```

View File

@@ -0,0 +1,152 @@
---
sidebar_label: dcr.toml overview
---
# dcr.toml
Main project configuration file. Located at the project root.
## Structure
```toml
[package]
# required fields
[build]
# build settings
[build.debug] # optional: debug override
[build.release] # optional: release override
[build.linux] # optional: Linux override
[build.windows] # optional: Windows override
[build.windows.debug] # target + profile combination
[toolchain]
# compiler/linker paths
[dependencies]
# project dependencies
[workspace]
# multi-package configuration
[run]
# run settings
```
## [package]
| Field | Required | Description |
| --------- | -------- | ----------------------- |
| `name` | yes | Project name |
| `version` | yes | Semantic version |
| `type` | yes | `app`, `lib`, `none` |
| `license` | no | SPDX license identifier |
| `author` | no | Author |
```toml
[package]
name = "my-app"
version = "0.1.0"
type = "app"
license = "MIT"
author = "John Doe"
```
## [build]
...
* `build.qt` — (bool) Enable automatic Qt meta-object handling (MOC, UIC, RCC). Requires `qt6` modules installed via `pkg-config`.
| Field | Default | Description |
| ---------------- | ------------------------------------------- | --------------------------------------------------------------------- |
| `language` | `"c"` | `"c"`, `"c++"`, `"cpp"`, `"cxx"`, `"asm"` |
| `standard` | `"c11"` | C standard (`c11`, `c17`, `c23`) |
| `cxx_standard` | `"c++20"` | C++ standard (`c++17`, `c++20`, `c++23`) |
| `compiler` | `"clang"` | Preferred compiler |
| `kind` | `"bin"` | `bin`, `staticlib`, `sharedlib`, `efi`, `elf`, `none`, `custom` |
| `target` | host | Target triple for cross-compilation |
| `platform` | `"native"` | `native`, `efi` |
| `cflags` | `[]` | Additional C/C++/ASM flags |
| `ldflags` | `[]` | Additional linker flags |
| `filename` | `""` | Custom output file name |
| `extension` | `""` | Custom file extension |
| `roots` | `["src"]` | Source root directories |
| `exclude` | `[]` | Exclude patterns |
| `include` | `[]` | Additional include directories |
| `src_disable` | `false` | Disable auto source discovery |
| `inherit` | `false` | Inherit build from workspace root |
| `clean` | `[]` | Glob patterns for custom clean paths |
| `out_dir` | `""` | Custom output directory |
| `workspace_only` | `false` | Workspace-only, not built standalone |
| `freestanding` | `false` | Compile in freestanding mode (`-ffreestanding` + `-nostdlib -static`) |
| `opt_level` | `"0"` (debug) / `"3"` (release) | Optimization level: `0`-`3`, `"s"`, `"z"` |
| `debug` | `true` (debug) / `false` (release) | Emit debug symbols (`-g`) |
| `lto` | `false` | Link-time optimization (`-flto` for both compiler and linker) |
| `strip` | `false` | Strip symbols from output (`-s` in ldflags) |
| `warnings` | `["all", "extra"]` (debug) / `[]` (release) | Warning flags (e.g. `"all"`, `"extra"`, `"pedantic"`) |
| `panic` | `""` | Panic strategy: `"abort"` disables exceptions and unwind tables |
| `codegen-units` | `""` | Max parallel compilation jobs (`"0"` = auto) |
| `qt` | `false` | Enable automatic Qt meta-object handling (MOC, UIC, RCC) |
Settings from raw config (not in typed struct):
* `pkg_config` — list of pkg-config packages
* `ldscript` — linker script path
* `build.steps` / `build.post_steps` — codegen steps
Example:
```toml
[build]
language = "c++"
standard = "c23"
cxx_standard = "c++23"
compiler = "clang"
kind = "sharedlib"
cflags = ["-Wall", "-Wextra"]
opt_level = "z"
lto = true
strip = true
panic = "abort"
codegen-units = "2"
```
## [toolchain]
```toml
[toolchain]
cc = "/usr/bin/clang"
cxx = "/usr/bin/clang++"
as = "/usr/bin/as"
ar = "/usr/bin/ar"
ld = "/usr/bin/ld.lld"
```
Raw config also supports `uic`, `moc`, `rcc` for Qt codegen.
## [dependencies]
See [dependencies](/docs/reference/dependencies).
## [run]
```toml
[run]
cmd = "./target/{profile}/{name}"
```
Substitutions:
* `{version}` — package version
* `{version_major}`, `{version_minor}`, `{version_patch}`, `{version_suffix}`, `{version_suffix_dash}` — version parts
* `{profile}` — debug / release
* `{name}` — package name
Default `cmd` = `./target/{profile}/{name}` (macOS/Windows) or `./target/\<triple>/\<profile>/\<name>` (Linux).
## [workspace]
See [workspaces](/docs/reference/workspaces).

View File

@@ -0,0 +1,84 @@
---
sidebar_label: Dependencies
---
# Dependencies
## Formats
The `[dependencies]` section supports three formats:
### String (registry)
```toml
[dependencies]
fmt = "10.1.1"
spdlog = "1.12"
catch2 = "3.4.0"
```
The version string is used as-is for registry lookup.
### Table (git)
```toml
[dependencies]
fmt = { git = "https://github.com/fmtlib/fmt", tag = "10.1.1" }
```
Fields: `git`, `branch`, `tag`, `rev`.
### Table (path)
```toml
[dependencies]
mylib = { path = "../mylib" }
```
## Registry
DCR uses a package registry for dependency lookup by name.
```toml
# ~/.dcr/config.toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```
Registry priority: order in `config.toml`. The `DCR_INDEX_PATH` variable overrides the path to `index.json`.
## Git dependencies
DCR clones git repositories via `git2`:
* `branch` — switch to a branch
* `tag` — switch to a tag
* `rev` — switch to a specific commit
* `features` — feature flags (parsed, but does not affect build)
Cache path: `~/.dcr/git/\<hash>/`.
## Path dependencies
Local paths. DCR automatically discovers include and lib directories from the neighbor's `dcr.toml`.
```toml
[dependencies]
mylib = { path = "/abs/path/to/lib" }
mylib = { path = "../relative/path" }
```
## dcr.lock
Dependency lock file. Contains package names and sources.
Created during `dcr build` when registry dependencies are present. Not updated during `dcr add` — only on the next `dcr build`.
## Resolution process
1. Load all dependencies (registry → git → path)
2. For path deps: recursively read their `dcr.toml`
3. For registry deps: search `index.json`
4. For git deps: clone to cache
5. Collect `include_dirs`, `lib_dirs`, `libs` for the compiler

View File

@@ -0,0 +1,60 @@
---
sidebar_label: Environment variables
---
# Environment Variables
## DCR_COMPILER
Overrides the compiler for all languages. **Highest priority.**
```bash
export DCR_COMPILER=clang
dcr build
```
Compiler resolution priority:
1. `DCR_COMPILER` (env)
2. `DCR_CC` / `DCR_CXX` / `DCR_AS` (env)
3. `[toolchain]` (dcr.toml)
4. `build.compiler` (dcr.toml)
5. `PATH`
## DCR_CC / DCR_CXX / DCR_AS
Per-language override (lower priority than `DCR_COMPILER`, higher than `[toolchain]`).
```bash
export DCR_CC=gcc-14
export DCR_CXX=g++-14
export DCR_AS=arm-linux-gnueabihf-as
```
## DCR_LD / DCR_AR
Override linker and archiver.
```bash
export DCR_LD=ld.lld
export DCR_AR=llvm-ar
```
## DCR_DEBUG
Enables debug mode — prints all compilation commands to stderr before execution.
```bash
export DCR_DEBUG=1
dcr build
```
## DCR_INDEX_PATH
Overrides the path to the registry `index.json`.
```bash
export DCR_INDEX_PATH=/custom/path/index.json
```
Default: `~/.dcr/index.json`.

View File

@@ -0,0 +1,51 @@
---
sidebar_label: Platform support
---
# Platform Support
## Target Triples
DCR normalizes target triples. Short platform names are expanded to full triples.
### Linux
```
target/<arch>-unknown-linux-gnu/<profile>/
```
Architectures: `x86_64`, `aarch64` (host-detected).
Artifact type: ELF. Extensions: `.so` (sharedlib), `.a` (staticlib).
### macOS
```
target/<profile>/
```
Architectures: `x86_64`, `aarch64` (host-detected).
Extensions: `.dylib` (sharedlib), `.a` (staticlib).
### Windows
```
target/<profile>/
```
Architectures: `x86_64`, `aarch64`.
Extensions: `.exe` (bin), `.lib` (staticlib), `.dll` (sharedlib), `.efi` (UEFI).
### BSD
```
target/<arch>-unknown-<os>/<profile>/
```
Supported systems: `freebsd`, `openbsd`, `netbsd`, `dragonfly`.
## Host Detection
DCR uses `std::env::consts::ARCH` and `std::env::consts::OS` for host platform detection. Used as fallback when `target` is not specified.

View File

@@ -0,0 +1,67 @@
---
sidebar_label: Workspaces
---
# Workspaces
Workspaces allow managing multiple packages in a single repository.
## Configuration
```toml
[workspace.lib-core]
path = "lib-core"
[workspace.lib-utils]
path = "lib-utils"
deps = ["lib-core"]
[workspace.app]
path = "app"
deps = ["lib-core", "lib-utils"]
main = true
```
### Member fields
| Field | Description |
| ------ | ------------------------------------------------ |
| `path` | Path to the package (relative to workspace root) |
| `deps` | Dependencies on other members |
| `main` | Mark as the main package |
## Topological sort
DCR automatically sorts packages by dependencies: package A is built before B if B depends on A.
Cyclic dependencies are detected and cause an error.
## Build
```bash
dcr build # build all packages in dependency order
dcr build --workspace app # build only app (dependencies built automatically)
```
When building a workspace, member outputs (libraries) are automatically added to include/lib paths of dependent packages.
## Clean
```bash
dcr clean # clean only root target/
dcr clean --all # clean target/ of all packages
```
## Inheritance
If a member has `inherit = true` in its `[build]` section, fields from the root `[build]` are merged into the member:
```toml
# root dcr.toml
[build]
inherit = true
language = "c"
standard = "c17"
# member inherits language and standard
```

View File

@@ -0,0 +1,46 @@
---
sidebar_label: Self Update
---
# Self Update
## dcr --update
Automatic update to the latest version. Downloads a binary (not an archive) from GitHub Releases and replaces the current executable.
```bash
dcr --update
```
## How it works
1. DCR detects the current platform and architecture
2. Fetches the latest release from `api.github.com/repos/dexoron/dcr/releases/latest`
3. Compares versions
4. Downloads the matching asset (direct binary URL, not archive)
5. Replaces the current executable via `self_replace`
## Asset naming
Pattern: `dcr-\<triple>` or `dcr-\<triple>.exe`
| Platform | Asset name |
| -------------- | -------------------------------- |
| Linux x86_64 | `dcr-x86_64-unknown-linux-gnu` |
| macOS x86_64 | `dcr-x86_64-apple-darwin` |
| macOS ARM64 | `dcr-aarch64-apple-darwin` |
| Windows x86_64 | `dcr-x86_64-pc-windows-msvc.exe` |
## AUR
If DCR was installed via AUR, `--update` shows a warning:
```
Update via package manager: yay/paru -Syu {package_name} or sudo pacman -Syu {package_name}
```
## Errors
* Cannot detect platform — error
* Cannot fetch release — error with URL
* No write permission — error (use `sudo` or manual install)

View File

@@ -0,0 +1,45 @@
---
sidebar_label: Running tests
---
# Running Tests
## Execution
```bash
dcr test
```
Builds the project, then compiles and runs test files from `tests/`.
## Profiles
```bash
dcr test # debug (default)
dcr test --release # release
dcr test --debug # explicit debug
```
## Output
```
=====================
Testsuite summary
=====================
TOTAL: 5
PASS: 3
SKIP: 1
FAIL: 1
=====================
```
## Exit code
* 0 — all tests passed (FAIL = 0)
* 1 — test failures or build error
## What gets built
* All `.c` files from `tests/` (`.cpp` not supported)
* Include path: `tests/` (for `dcr_test.h`)
* Linked with project if `package.type = "lib"` or `kind = "staticlib"`/`"sharedlib"`

View File

@@ -0,0 +1,69 @@
---
sidebar_label: Test framework (EXPECT, TEST, ...)
---
# Test Framework
DCR has a built-in minimal test framework for C.
## Macros
### `EXPECT(expr)`
Asserts that an expression is true.
```c
EXPECT(1 + 1 == 2);
EXPECT(ptr != NULL);
```
### `SKIP(reason)`
Skips a test with a message.
```c
SKIP("not implemented on Windows");
```
### `TEST(name)`
Defines a test.
```c
TEST(addition) {
EXPECT(1 + 1 == 2);
EXPECT(2 + 2 == 4);
}
```
### `TEST_CASE(name)`
Registers a test case.
```c
TEST_CASE(math) {
EXPECT(1 + 1 == 2);
}
```
## Initialization
```bash
dcr test --init
```
Creates:
* `tests/dcr_test.h` — framework header (do not edit)
* `tests/test.c` — template with example test
## Structure
```
tests/
├── dcr_test.h # framework (do not edit)
├── test.c # main tests
└── ... # additional .c test files
```
Only `.c` files are compiled (`.cpp` is not supported).

View File

@@ -0,0 +1,63 @@
---
sidebar_label: Introduction
---
# DCR — C/C++ Build Tool & Package Manager
<details>
<summary>Quick reference</summary>
```bash
# Installation
curl -fsSL https://dcr.dexoron.su/install.sh | sh
# Create a project
dcr new my-app
cd my-app
# Build and run
dcr build
dcr run
# Run tests
dcr test
# Add a dependency
dcr add fmt
# Generate IDE files
dcr gen vscode
```
</details>
## Contents
| Section | Description |
| ----------------------------------------------------- | --------------------------------------------- |
| [Getting Started](/docs/getting-started/installation) | Installation and first steps |
| [Commands](/docs/commands/project-commands) | All CLI commands |
| [Reference](/docs/reference/dcr-toml) | Configuration, build, dependencies, platforms |
| [Testing](/docs/testing/test-framework) | Built-in test framework |
| [Recipes](/docs/recipes/cross-to-windows) | Common scenarios |
| [IDE Integration](/docs/ide-integration) | VS Code, CLion, compile_commands.json |
| [Self Update](/docs/self-update) | Auto-update |
| [FAQ](/docs/faq) | Frequently asked questions |
| [Changelog](/docs/changelog) | Version history |
| [License](/docs/license) | DCR and vendored library licenses |
| [Contributing](/docs/contributing) | DCR development |
## Features
* **Incremental builds** — mtime + `.d` headers + SHA256 fingerprint
* **Parallel compilation** — thread::scope, atomic task queue
* **4 backends** — gcc/clang, MSVC/clang-cl, GAS (ARM), NASM (x86)
* **7 project kinds** — bin, staticlib, sharedlib, efi, elf, none, custom
* **Cross-compilation** — short names and full triples
* **Profiles** — debug / release with field overrides
* **Workspaces** — multi-package projects with topological sort
* **Registry + Git + Path** — three dependency mechanisms
* **IDE generation** — VS Code, CLion, compile_commands.json, JSON metadata
* **pkg-config** — automatic system library discovery
* **Per-command `--help`** — `dcr build --help`, `dcr new --help`, etc.
* **Man pages** — `man dcr`, `man dcr-build`, `man dcr-new`

View File

@@ -0,0 +1,91 @@
---
sidebar_label: Changelog
---
# Changelog
## 0.7.1 (2026-06-02)
### Added
* **`--help` for all commands** — `dcr build --help`, `dcr run --help`, `dcr new --help`,
`dcr init --help`, `dcr clean --help`, `dcr add --help`, `dcr fmt --help`,
`dcr setup --help`, `dcr tree --help`, `dcr gen --help`, `dcr --update --help`,
`dcr test --help`. All output uses styled headers (green) and usage lines (cyan).
* **Man pages** — 12 troff pages in `man/man1/`: `dcr.1`, `dcr-build.1`,
`dcr-run.1`, `dcr-new.1`, `dcr-init.1`, `dcr-clean.1`, `dcr-add.1`, `dcr-test.1`,
`dcr-gen.1`, `dcr-fmt.1`, `dcr-tree.1`, `dcr-setup.1`.
* **Man pages in all packaging** — install.sh, install_bsd.sh, AUR PKGBUILD,
Debian (cargo-deb), RPM (cargo-generate-rpm), Nix (postInstall), Homebrew
(resource), Snap, GitHub Release assets.
* **Project name validation** — `dcr init` and `dcr new` now validate names before
creating files. Only ASCII letters, digits, `_` and `-` are allowed.
* **`documentation` and `homepage` fields** — added to `Cargo.toml`.
* **Release profile optimizations** — `opt-level = "z"`, LTO, `codegen-units = 1`,
`panic = "abort"`, `strip = true` for smaller binaries.
* **Linux i686, armv7, riscv64 targets** — added to release workflow and install scripts.
* **Linux musl i686, armv7 targets** — cross-compiled via zigbuild in CI.
* **AUR packages** — `dcr-dev`, `dcr-dev-bin` publishing workflow.
* **Snap publishing** — automated Snapcraft publishing in CI.
* **Snap badge** — in README.
### Changed
* **`validate_package_name` made public** — callable from CLI commands.
* **README platform table** — reorganized: libc variants as separate OS rows,
removed extra columns. Linux architecture list updated.
* **`gen.rs` no-args output** — now uses styled output instead of raw `eprintln!`.
* **`tree.rs`, `fmt.rs`, and `setup.rs`** — now accept arguments for `--help`.
* **README install commands** — `| bash` → `| sh` for POSIX compatibility.
### Fixed
* **`dcr new \<invalid-name>` creates directory then fails** — validation now
happens before any file operations.
* **`dcr init` on invalid directory name** — same fix.
* **Man pages missing in installed packages** — now shipped in all formats.
* **Windows drive letter false positive** — in dependency file parser.
* **CRLF (`\r\n`) breaks dependency parser** — now handles mixed line endings.
* **Newline after backslash not consumed** — in `parse_d_file` escape handling.
## 0.7.0 (2026-06-01)
### Added
* **OpenBSD and NetBSD target support** — full platform routing with dynamic target triples using `std::env::consts::ARCH` and `std::env::consts::OS`. Affects `build`, `run`, `clean` commands and the platform module.
* **`src/platform/bsd.rs`** — new BSD platform module (shared by FreeBSD, OpenBSD, NetBSD) providing `bin_path`, `lib_path`, `elf_path`, `efi_path`, `shared_lib_path`.
* **`build.out_dir` config option** — custom output directory that overrides the default `target/\<triple>/\<profile>` path for final artifacts. Supported in `build`, `run`, and config validation.
* **`dcr fmt` command** — new CLI command that formats all C/C++ source files (`*.c`, `*.cpp`, `*.h`, `*.hpp`) in `src/` and `tests/` using `clang-format`.
* **Incremental linking** — `needs_link()` in `common.rs` checks if any object file is newer than the linked output, skipping unnecessary relinking. Implemented for all backends (`unix_cc`, `msvc`, `gas`, `nasm`).
* **`build.kind = "none"` and `"custom"`** — two new project kinds for special build scenarios that don't produce standard artifacts.
* **`install_bsd.sh`** — POSIX-compliant installation script for BSD systems (FreeBSD, OpenBSD, NetBSD) with binary download and source build modes.
* **Linux ARM64 support in `install.sh`** — added `Linux:aarch64|Linux:arm64` target detection for pre-built binary downloads.
* **BSD OS detection in `install.sh`** — detects FreeBSD, OpenBSD, NetBSD and determines target triple.
* **`rust-toolchain.toml`** — explicit toolchain pinning to `stable` channel.
* **Integration tests** — `build_with_target_config` (verifies `build.target = "linux"`) and `build_with_out_dir` (validates custom output directory).
* **`get_build_string_with_profile` made `pub`** — so `run.rs` can determine custom output directory configuration.
### Changed
* **`build.target` semantics changed** — now strictly contains a target triple (e.g., `x86_64-unknown-linux-gnu`) or short name (`linux`, `macos`, `windows`). No longer used as custom output directory — this functionality moved to `build.out_dir`.
* **`build.standard` made optional** — changed from `String` to `Option\<String>`. Validation only enforces non-empty for non-ASM languages. Skipped in `dcr.toml` output if empty.
* **`dcr run` with `out_dir`** — now determines target directory respecting `build.out_dir` via `get_build_string_with_profile()` from `build.rs`.
* **`collect_sources()` returns empty vector** instead of error when no sources are found, allowing `kind = "none"` or `kind = "custom"` projects with no source files.
* **CI/CD release workflow refactored** — `git2` made target-specific (no vendored-openssl on Windows), Zig-based cross-compilation for non-x86_64 Linux targets, Arch Linux package version cleanup (dashes → dots), `gmake` symlink for NetBSD.
* **README compatibility table** — FreeBSD, OpenBSD, NetBSD build/run status upgraded from "community/best-effort" to "officially supported".
* **Documentation updated** — `build-section.md` describes new `build.target` and `build.out_dir` fields. `target-directory.md` rewritten to clarify the distinction.
### Fixed
* **stdout/stderr not inherited in `dcr run`** — child process output was captured and manually printed, breaking interactive programs. Fixed by switching to `Command::status()`.
* **Race condition in release CI** — matrix build jobs could upload assets to a release that didn't exist yet. Fixed by adding a dedicated `create-release` job.
* **Release GHA — stable toolchain override** — fixed Rust toolchain override issues in CI.
* **Arch Linux package version sanitization** — version strings with dashes (e.g., `0.7.0-dev`) are invalid for `pkgver`. Fixed by replacing dashes with dots.
* **GPG permissions after Docker** — Docker operations changed GPG directory ownership. Fixed by running `chown` after Docker commands.
* **RPM artifact paths** — RPM artifacts were placed in `rpm/x86_64/` instead of `fedora/x86_64/`. Fixed in Dexoron Packages Index workflow.
* **JSON parsing reliability in `install.sh`** — added `jq` as primary parser with `python3` fallback for dev channel release lookup.
### Removed
* **`format_roots()` helper function** — removed from `common.rs`. Was only used by the old error handling path in `collect_sources()`.
* **Per-distribution artifact download steps** — three separate `actions/download-artifact` steps replaced with unified `gh release download --clobber`.

View File

@@ -0,0 +1,42 @@
---
sidebar_label: Build commands (build, run, clean)
---
# Build Commands
## `dcr build`
Builds the project according to `dcr.toml`.
```bash
dcr build # debug profile
dcr build --release # release build
dcr build --debug # explicit debug
dcr build --target aarch64-unknown-linux-gnu
dcr build --force # full rebuild
dcr build --clean # clean + build
dcr build --verbose # show compilation commands
dcr build --workspace pkg-a # build specific workspace package
```
Artifacts: `target/\<triple>/\<profile>/\<binary-name>` (Linux with explicit target).
## `dcr run`
Builds (if sources are newer than artifacts) and runs the binary.
```bash
dcr run
dcr run --release
```
## `dcr clean`
Removes `target/` directory (or `target/\<target>/\<profile>`).
```bash
dcr clean
dcr clean --release # target/release/ only
dcr clean --target windows # target/x86_64-pc-windows-msvc/
dcr clean --all # clean all workspace packages
```

View File

@@ -0,0 +1,53 @@
---
sidebar_label: Dependency commands (add, tree)
---
# Dependency Commands
## `dcr add \<name> [source]`
Adds a dependency to `dcr.toml`.
```bash
dcr add fmt # registry lookup
dcr add mylib ../path/to/lib # path as source
dcr add mylib path:./lib # explicit path prefix
dcr add mylib git:https://github.com/user/repo # explicit git prefix
dcr add mylib github:user/repo # GitHub shorthand
dcr add mylib gitlab:user/repo # GitLab shorthand
```
Source prefixes:
* `path:` — local path
* `git:` — generic git URL
* `github:` — expands to `https://github.com/\<user>/\<repo>`
* `gitlab:` — expands to `https://gitlab.com/\<user>/\<repo>`
* `http://` / `https://` / `git@` — full URL
Flags:
* `--branch \<name>` — git branch
* `--tag \<name>` — git tag
* `--rev \<hash>` — git commit
If source is omitted — DCR searches connected registries.
## `dcr tree`
Displays the project dependency tree.
```bash
dcr tree
```
Example output:
```
my-app v0.1.0
├── fmt (registry)
│ └── spdlog (registry)
└── catch2 (registry)
```
For path dependencies, recursively shows their own dependencies (from their `dcr.toml`).

View File

@@ -0,0 +1,73 @@
---
sidebar_label: Gen commands (vscode, clion, ...)
---
# Gen Commands
## `dcr gen \<target>`
Generates IDE integration files.
### vscode
```bash
dcr gen vscode
```
Creates:
* `.vscode/tasks.json` — `build` task (dcr build)
* `.vscode/launch.json` — debug launch configuration
* `.vscode/settings.json` — C/C++ settings (clangd paths, includes)
* `.vscode/extensions.json` — recommended extensions (vscode-clangd, vscode-lldb)
### clion
```bash
dcr gen clion
```
Creates:
* `.idea/externalTools.xml` — external tools (build, run, clean, test)
* `.idea/customTargets.xml` — custom build targets
* `.idea/misc.xml` — C/C++ project settings
* `.idea/runConfigurations/\<name>.xml` — per-binary run configurations
### compile-commands
```bash
dcr gen compile-commands
```
Generates `compile_commands.json` — standard format for clangd, cpptools, static analyzers.
### project-info
```bash
dcr gen project-info
```
Outputs JSON array with project metadata:
```json
[
{
"name": "my-app",
"version": "0.1.0",
"root": "/path/to/project",
"profile": "debug",
"language": "c",
"standard": "c17",
"cxx_standard": null,
"compiler": "/usr/bin/clang",
"kind": "bin",
"sources": ["src/main.c"],
"include_dirs": ["src"],
"lib_dirs": [],
"libs": [],
"cflags": ["-std=c17", "-O0", "-g"],
"ldflags": []
}
]
```

View File

@@ -0,0 +1,31 @@
---
sidebar_label: Project commands (new, init)
---
# Project Commands
## `dcr new \<name>`
Creates a new project with a standard structure and `dcr.toml`. The `name` argument is required.
Only ASCII letters, digits, underscores `_` and hyphens `-` are allowed in the project name.
```bash
dcr new my-app
```
Generates:
* `dcr.toml` with basic fields
* `src/main.c` with a `main` template
## `dcr init`
Initializes a DCR project in the current (empty) directory.
```bash
mkdir app && cd app
dcr init
```
The project name is taken from the current directory name. The directory name must follow the same naming rules as `dcr new`.

View File

@@ -0,0 +1,60 @@
---
sidebar_label: Quality commands (test, fmt)
---
# Quality Commands
## `dcr test`
Runs tests.
```bash
dcr test # debug profile
dcr test --release # release profile
dcr test --debug # explicit debug
dcr test --help # detailed help
```
Before first use, initialize tests:
```bash
dcr test --init
```
This creates `tests/dcr_test.h` (framework) and `tests/test.c` (template).
What `dcr test` does:
1. Builds the project
2. Collects `tests/*.c` files (`.c` only, not `.cpp`)
3. Compiles and links each test file
4. Runs each test binary
5. Prints summary: TOTAL, PASS, SKIP, FAIL
6. Returns non-zero exit code on any FAIL
## `dcr fmt`
Formats C/C++ source files using `clang-format`.
```bash
dcr fmt
```
Processes: `src/**/*.{c,cpp,cxx,cc,h,hpp,hxx,hh}` and `tests/**/*.{c,cpp,cxx,cc,h,hpp,hxx,hh}`.
Uses `.clang-format` at the project root (if present), otherwise default clang-format style.
## `dcr lint`
Runs `clang-tidy` on C/C++ source files for static analysis.
```bash
dcr lint # show diagnostics
dcr lint --fix # apply fixes automatically
dcr lint --help # detailed help
```
Processes: `src/**/*.{c,cpp,cxx,cc}` and `tests/**/*.{c,cpp,cxx,cc}`.
Without `--fix`, clang-tidy reports warnings and errors without modifying files.
With `--fix`, clang-tidy applies automatic suggestions in place.

View File

@@ -0,0 +1,51 @@
---
sidebar_label: System commands (setup, --help, ...)
---
# System Commands
## `dcr setup`
Shows configured registries from `~/.dcr/config.toml`.
```bash
dcr setup
```
If `~/.dcr/config.toml` is not found, DCR returns an error. Create it manually:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```
## `dcr --help`
Shows help for all commands.
```bash
dcr --help
```
## `dcr --version`
Shows version and target triple.
```bash
dcr --version # dcr 0.7.0 (x86_64-unknown-linux-gnu)
```
## `dcr --update`
Self-update. Downloads the latest release binary from GitHub Releases and replaces the current one.
```bash
dcr --update
```
Features:
* Auto-detects platform and architecture
* Warns if installed via AUR (use package manager instead)
* Works on Linux, macOS, Windows

View File

@@ -0,0 +1,51 @@
---
sidebar_label: Contributing
---
# Contributing
## Setup
```bash
git clone https://github.com/dexoron/dcr
cd dcr
cargo build
```
## Code style
All code must be formatted with `cargo fmt`:
```bash
cargo fmt
```
## Linting
```bash
cargo clippy --all-targets -- -D warnings
```
## Tests
```bash
cargo test --all-targets
```
## PR process
1. Fork the repository
2. Create a branch: `git checkout -b feature/description`
3. Make changes
4. Run `cargo fmt && cargo clippy && cargo test`
5. Open a Pull Request
## CI
CI runs:
* `cargo fmt --check`
* `cargo clippy --all-targets -- -D warnings`
* `cargo test --all-targets`
* Build on Linux, macOS, Windows
* Integration tests

View File

@@ -0,0 +1,81 @@
---
sidebar_label: FAQ
---
# FAQ
## Registry not found
```
error: registry not found
```
**Solution:** Make sure `~/.dcr/config.toml` exists:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```
And check `DCR_INDEX_PATH`:
```bash
echo $DCR_INDEX_PATH
```
## Compiler not found
```
error: compiler not found
```
**Solution:** Ensure a compiler is installed and available in PATH.
```bash
which gcc
which clang
```
Or specify explicitly via `[toolchain]` in `dcr.toml`.
## openssl-sys build failed
When building DCR from source:
```
error: failed to run custom build command for openssl-sys
```
**Solution:** Install OpenSSL development headers:
```bash
# Ubuntu/Debian
sudo apt install libssl-dev
# Fedora
sudo dnf install openssl-devel
# macOS
brew install openssl
```
## Ctrl+C during build
DCR handles SIGINT: interrupts the current compilation and exits with non-zero code.
## How to create a library?
See [Library Recipe](/docs/recipes/library-project).
## How to cross-compile to Windows?
See [Cross-Compile Recipe](/docs/recipes/cross-to-windows).
## How to create a multi-package project?
See [Workspace Recipe](/docs/recipes/multi-package-workspace).
## Lock file
`dcr.lock` is created during builds (`dcr build`) when registry dependencies are present. To force an update — delete `dcr.lock` and run `dcr build`.

View File

@@ -0,0 +1,72 @@
---
sidebar_label: First steps
---
# First Steps
## Create a project
```bash
dcr new my-app
cd my-app
```
Structure:
```
my-app/
├── dcr.toml
└── src/
└── main.c
```
`dcr.toml`:
```toml
[package]
name = "my-app"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
compiler = "clang"
kind = "bin"
```
## Build
```bash
dcr build
```
Output — `target/\<triple>/debug/my-app` (Linux) or `target/debug/my-app.exe` (Windows).
Build profiles:
```bash
dcr build --release # release build
dcr build --debug # debug (default)
```
## Run
```bash
dcr run
```
Builds (if needed) and runs the binary.
## First test
```bash
dcr test --init # create test template
dcr test # run tests
```
## Formatting
```bash
dcr fmt # clang-format with .clang-format
```

View File

@@ -0,0 +1,109 @@
---
sidebar_label: Installation
---
# Installation
## Linux (Dexoron Packages)
Configure your package manager at https://pkg.dexoron.su and install:
**Arch Linux**
```sh
sudo pacman -Sy dcr
```
**Debian/Ubuntu**
```sh
sudo apt update && sudo apt install dcr
```
**Fedora/RHEL**
```sh
sudo dnf install dcr
```
## Arch Linux (AUR)
```sh
yay -S dcr
```
## macOS / Linux (Homebrew)
```sh
brew tap dexoron/dexoron
brew install dcr
```
## Snap (Linux)
```sh
sudo snap install dcrup
```
## Nix (flake)
```sh
nix run github:dexoron/dcr
# or install to profile:
nix profile install github:dexoron/dcr
```
## Cargo (crates.io)
```sh
cargo install dcr
```
## Linux / macOS (script)
```sh
curl -fsSL https://dcr.dexoron.su/install.sh | sh
```
## BSD (script)
```sh
curl -fsSL https://dcr.dexoron.su/install_bsd.sh | sh
```
## Windows (PowerShell)
```powershell
irm https://dcr.dexoron.su/install.ps1 | iex
```
## From source
```sh
git clone https://github.com/dexoron/dcr.git
cd dcr && cargo build --release
ln -sf "$PWD/target/release/dcr" ~/.local/bin/dcr
```
## Post-install
Verify the installation:
```bash
dcr --version
```
Man pages are available after installation:
```bash
man dcr
man dcr-build
```
To use the registry, create `~/.dcr/config.toml`:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```

View File

@@ -0,0 +1,51 @@
---
sidebar_label: IDE Integration
---
# IDE Integration
## VS Code
```bash
dcr gen vscode
```
Generates in `.vscode/`:
| File | Purpose |
| ----------------- | -------------------------------------------- |
| `tasks.json` | `build` task (dcr build) |
| `launch.json` | Debug launch configuration |
| `settings.json` | clangd/IntelliSense: include paths, standard |
| `extensions.json` | Recommends vscode-clangd, vscode-lldb |
## CLion
```bash
dcr gen clion
```
Generates in `.idea/`:
| File | Purpose |
| ------------------------------------------------ | ----------------------------------------- |
| `externalTools.xml` | Build, Run, Clean, Test as external tools |
| `customTargets.xml` | Custom build targets |
| `misc.xml` | C/C++ project settings |
| `runConfigurations/\<name>.xml` | Per-binary run configurations |
## compile_commands.json
```bash
dcr gen compile-commands
```
Generates `compile_commands.json` at project root. Standard format for clangd, C/C++ IntelliSense, static analyzers.
## project-info
```bash
dcr gen project-info
```
Outputs JSON array with project metadata (see [gen-commands](/docs/commands/gen-commands)).

View File

@@ -0,0 +1,46 @@
---
sidebar_label: License
---
# License
## DCR
DCR itself is [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later.html) licensed.
> **Note:** DCR is a build tool, not a library. The GPL applies only to DCR's own source code. Projects built with DCR are not subject to DCR's license — their licensing is determined solely by their own code and dependencies.
## Vendored libraries
DCR statically links the following C libraries through its vendored Rust dependencies:
| Library | License | Bundled by |
| ------------------------------------------ | ------------------ | ----------------------------- |
| [libgit2](https://libgit2.org) | MIT OR Apache-2.0 | `git2` / `libgit2-sys` |
| [libssh2](https://libssh2.org) | MIT OR Apache-2.0 | `libgit2-sys` |
| [zlib](https://zlib.net) | MIT OR Apache-2.0 | `libgit2-sys` |
| [OpenSSL](https://openssl.org) | Apache-2.0 | `openssl-sys` / `openssl-src` |
| [ring](https://github.com/briansmith/ring) | Apache-2.0 AND ISC | `rustls` |
## Rust dependencies
DCR is written in Rust. The following notable Rust crates are statically linked:
| Crate | License |
| --------------------------------------------- | ------------------------ |
| [`reqwest`](https://crates.io/crates/reqwest) | MIT OR Apache-2.0 |
| [`rustls`](https://crates.io/crates/rustls) | Apache-2.0 OR ISC OR MIT |
| [`serde`](https://crates.io/crates/serde) | MIT OR Apache-2.0 |
| [`toml`](https://crates.io/crates/toml) | MIT OR Apache-2.0 |
| [`sha2`](https://crates.io/crates/sha2) | MIT OR Apache-2.0 |
| [`git2`](https://crates.io/crates/git2) | MIT OR Apache-2.0 |
| [`openssl`](https://crates.io/crates/openssl) | Apache-2.0 |
| [`tokio`](https://crates.io/crates/tokio) | MIT |
| [`hyper`](https://crates.io/crates/hyper) | MIT |
| [`ctrlc`](https://crates.io/crates/ctrlc) | MIT OR Apache-2.0 |
Full dependency tree (143 packages) is available in [`Cargo.lock`](https://github.com/dexoron/dcr/blob/main/Cargo.lock). The overwhelming majority are dual-licensed under MIT OR Apache-2.0.
## Additional credits
* DCR's CLI design and project model are inspired by [Cargo](https://doc.rust-lang.org/cargo/).

View File

@@ -0,0 +1,49 @@
---
sidebar_label: Cross-compile to Windows
---
# Cross-Compile to Windows from Linux
Building a Windows binary on Linux using mingw-w64.
## Install toolchain
```bash
# Ubuntu/Debian
sudo apt install mingw-w64
# Fedora
sudo dnf install mingw64-gcc mingw64-binutils
```
## Configuration
```toml
[package]
name = "my-app"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
compiler = "clang"
kind = "bin"
target = "x86_64-pc-windows-gnu" # explicit mingw, not msvc
```
## Build
```bash
dcr build --target x86_64-pc-windows-gnu --release
```
Artifact: `target/x86_64-pc-windows-gnu/release/my-app.exe`.
## Custom toolchain
```toml
[toolchain]
cc = "x86_64-w64-mingw32-gcc"
cxx = "x86_64-w64-mingw32-g++"
```

View File

@@ -0,0 +1,70 @@
---
sidebar_label: Library project
---
# Library Project
Creating a static library and using it in another project.
## Step 1: Create the library
```bash
dcr new my-lib
cd my-lib
```
`dcr.toml`:
```toml
[package]
name = "my-lib"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
kind = "staticlib"
```
`src/my_lib.h`:
```c
#ifndef MY_LIB_H
#define MY_LIB_H
int add(int a, int b);
#endif
```
`src/my_lib.c`:
```c
#include "my_lib.h"
int add(int a, int b) { return a + b; }
```
## Step 2: Build
```bash
dcr build --release
```
Artifacts:
* `target/\<triple>/release/libmy-lib.a` (Linux)
* `target/release/my-lib.lib` (Windows)
* `target/include/` — header files
## Step 3: Use in another project
```bash
dcr new my-app
cd my-app
dcr add my-lib ../my-lib
```
Automatically:
* Adds include path to `target/include/` of the library
* Adds lib path to `target/\<triple>/release/`
* Links `libmy-lib.a` / `my-lib.lib`

View File

@@ -0,0 +1,102 @@
---
sidebar_label: Multi-package workspace
---
# Multi-Package Workspace
A project with three packages: two libraries and a binary.
## Structure
```
workspace/
├── dcr.toml # root workspace
├── lib-core/
│ ├── dcr.toml
│ └── src/core.c
├── lib-utils/
│ ├── dcr.toml
│ └── src/utils.c
└── app/
├── dcr.toml
└── src/main.c
```
## Root dcr.toml
```toml
[package]
name = "my-workspace"
version = "0.1.0"
type = "none"
[build]
inherit = true
language = "c"
standard = "c11"
[workspace.lib-core]
path = "lib-core"
[workspace.lib-utils]
path = "lib-utils"
deps = ["lib-core"]
[workspace.app]
path = "app"
deps = ["lib-core", "lib-utils"]
main = true
```
## Packages
`lib-core/dcr.toml`:
```toml
[package]
name = "lib-core"
version = "0.1.0"
type = "none"
[build]
kind = "staticlib"
```
`lib-utils/dcr.toml`:
```toml
[package]
name = "lib-utils"
version = "0.1.0"
type = "none"
[build]
kind = "staticlib"
```
`app/dcr.toml`:
```toml
[package]
name = "app"
version = "0.1.0"
type = "none"
[build]
kind = "bin"
```
## Build
```bash
cd workspace
dcr build # builds everything in correct order
dcr build --workspace app # only app (lib-core and lib-utils built as deps)
dcr run # builds and runs main package
```
Build order (topological sort):
1. `lib-core`
2. `lib-utils` (depends on lib-core)
3. `app` (depends on lib-core, lib-utils)

View File

@@ -0,0 +1,82 @@
---
sidebar_label: Build profiles
---
# Build Profiles
Profiles allow overriding `[build]` fields for specific build modes.
## Configuration
```toml
[build]
language = "c"
standard = "c17"
cflags = ["-Wall"]
[build.debug]
cflags = ["-O0", "-g"]
[build.release]
cflags = ["-O3", "-DNDEBUG"]
```
## Merge rules
Fields from `[build.\<profile>]` are merged on top of `[build]`:
* **Scalar fields** (strings, numbers, bools) — replaced
* **Arrays** (`cflags`, `ldflags`, ...) — **appended** (extend the `[build]` array)
Set `inherit = false` to disable array inheritance (only profile's own arrays are used).
## Built-in profiles
The default flags for each profile are composed from three config fields:
| Field | debug default | release default |
| ----------- | ------------------ | --------------- |
| `opt_level` | `"0"` | `"3"` |
| `debug` | `true` | `false` |
| `warnings` | `["all", "extra"]` | `[]` |
Which produce the equivalent compiler flags:
| Profile | Effective flags |
| --------- | ---------------------------------------------------------- |
| `debug` | `-O0 -g -Wall -Wextra -fno-omit-frame-pointer -DDCR_DEBUG` |
| `release` | `-O3 -DNDEBUG` |
Additional build options can be toggled per-profile:
```toml
[build.release]
opt_level = "z"
lto = true
strip = true
panic = "abort"
codegen-units = "1"
[build.debug]
opt_level = "1"
debug = false
warnings = ["all", "error"]
```
## Target-specific profiles
```toml
[build.linux]
cflags = ["-DLINUX"]
[build.windows.debug]
cflags = ["-DWIN32", "-O0", "-g"]
```
Application order (highest priority first):
1. `[build.\<target>.\<profile>]`
2. `[build.\<profile>.\<target>]`
3. `[build.\<target>]`
4. `[build.\<profile>]`
5. `[build]`

View File

@@ -0,0 +1,131 @@
---
sidebar_label: Build system
---
# Build System
## Compiler Backends
DCR supports 7 compilation backends. Selection is automatic based on file extension and `build.compiler` value.
| Backend | Files | When used |
| --------- | --------------------------------- | ------------------------------------- |
| `unix_cc` | `.c`, `.cpp`, `.cxx`, `.cc`, `.S` | gcc/clang on Linux/macOS/BSD |
| `msvc` | `.c`, `.cpp`, `.cxx`, `.cc` | Windows (cl, clang-cl) |
| `gas` | `.s` | ARM/ARM64 assembler (no preprocessor) |
| `nasm` | `.asm`, `.s` | x86/x86_64 NASM assembler |
| `masm` | `.asm` | MASM (ml/ml64) on Windows |
| `fasm` | `.asm`, `.fasm` | Flat Assembler |
| `llvm_ir` | `.ll` | LLVM IR via `llc -filetype=obj` |
## Qt Support
DCR provides native Qt support for automatic meta-object handling (MOC, UIC, RCC).
Enable it by setting `build.qt = true` in `dcr.toml`. DCR will automatically detect Qt-related files (`.ui`, `.qrc`, `.h` with `Q_OBJECT`) and process them.
```toml
[build]
qt = true
```
*Note: Requires `qt6` modules (Core, Widgets, Gui, Svg) installed via `pkg-config`.*
Advanced customization is still possible via `build.steps` if special handling is needed:
```toml
[build.steps]
moc = "moc {in} -o {out}"
```
### Unix CC
* Compiler resolved via `resolve_compiler()`: `DCR_COMPILER` > `DCR_CC` > `[toolchain]` > `build.compiler` > `PATH`
* Supports `.d` files for header dependency tracking
* Flags: `-std=`, `-MMD -MF`, `-c -o`, `-I`, `-L`, `-l`
* Conditional flags based on config:
* `freestanding` or bare-metal target: `-ffreestanding` (compile), `-nostdlib -static` (link)
* `lto`: `-flto` (compile + link)
* `panic = "abort"`: `-fno-exceptions` (C++ only), `-fno-unwind-tables`, `-fno-asynchronous-unwind-tables`
### MSVC
* Supports cl.exe and clang-cl.exe
* Flags: `/std:`, `/Fo:`, `/Fe:`, `/I`, `/link`
### GAS / NASM / MASM / FASM / LLVM-IR
* GAS: `-I`, `-c -o`, `--defsym`
* NASM: `-I`, `-o`, `-D`, `-f` (format: win64/elf64/macho64/macho32/elf32)
* MASM: `/nologo /c /Fo\<obj> <source>`
* FASM: `<source> \<output>` (output path is the object file)
* LLVM IR: `-filetype=obj <source> -o \<output>`
## Incremental Builds
Three levels of incrementality:
1. **mtime** — if output is newer than all inputs, skip
2. **`.d` files** — header change tracking (including transitive)
3. **SHA256 fingerprint** — recompile if compiler flags changed (stored in `.dcr_fingerprint`)
## Parallel Compilation
* `thread::scope` for thread pool
* Atomic task queue (`AtomicU64`)
* Mutex on stdout (`OUTPUT_MUTEX`)
* Thread count = `available_parallelism()`, capped by `build.codegen-units` if set
## Build Kinds
| Kind | Type | Path (Linux example) |
| ----------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `bin` | Executable | `target/\<triple>/\<profile>/\<name>` (.exe on Windows) |
| `staticlib` | Static library | `target/\<triple>/\<profile>/lib\<name>.a` (.lib) |
| `sharedlib` | Dynamic library | `target/\<triple>/\<profile>/lib\<name>.so` (.dll/.dylib) |
| `efi` | UEFI application | `target/\<triple>/\<profile>/\<name>.efi` |
| `elf` | ELF without stdlib | `target/\<triple>/\<profile>/\<name>` |
| `none` | Compile only, no link | — |
| `custom` | Full filename+extension control | `target/\<triple>/\<profile>/\<filename>.\<extension>` |
## Build Steps
DCR supports pre-build and post-build steps:
* `build.steps` — commands before compilation
* `build.post_steps` — commands after compilation
Substitutions: `{stem}`, `{in}`, `{out}`, `{profile}`, `{version}`, `{name}`.
Example Qt codegen via build steps:
```toml
[build.steps]
moc = "moc {in} -o {out}"
```
## pkg-config
Automatic lookup (read from raw config):
```toml
[build]
pkg_config = ["sdl2", "gl"]
```
DCR runs `pkg-config --cflags sdl2 gl` and `pkg-config --libs sdl2 gl` and adds results to compiler/linker flags.
## Variable Substitution
Supported variables:
| Variable | Description |
| ----------------------- | ---------------------------- |
| `{version}` | Package version |
| `{version_major}` | Major version part |
| `{version_minor}` | Minor version part |
| `{version_patch}` | Patch version |
| `{version_suffix}` | Suffix (e.g., `-rc1`) |
| `{version_suffix_dash}` | Suffix with dash |
| `{profile}` | Profile name (debug/release) |
| `{name}` | Package name |

View File

@@ -0,0 +1,70 @@
---
sidebar_label: Cross-compilation
---
# Cross-Compilation
## Short Names
DCR supports short platform names:
| Short Name | Full Triple |
| ---------- | -------------------------- |
| `linux` | `x86_64-unknown-linux-gnu` |
| `macos` | `x86_64-apple-darwin` |
| `windows` | `x86_64-pc-windows-msvc` |
```bash
dcr build --target windows
```
## Full Triples
```bash
dcr build --target aarch64-unknown-linux-gnu
dcr build --target x86_64-pc-windows-gnu # mingw
dcr build --target armv7-unknown-linux-gnueabihf
```
## clang --target
When using clang, DCR injects `--target=\<triple>` into CFLAGS.
```toml
[build]
compiler = "clang"
target = "aarch64-unknown-linux-gnu"
# Auto: cflags += ["--target=aarch64-unknown-linux-gnu"]
```
## Bare-Metal / Freestanding
For targets containing `none`, `-elf`, `eabi`, or `baremetal`, DCR automatically:
1. **Disables default flags** — no system include paths, no `-l` libc
2. **Injects `-ffreestanding`** at compile time and `-nostdlib -static` at link time
You can also enable freestanding mode explicitly:
```toml
[build]
freestanding = true
```
```bash
dcr build --target aarch64-none-elf
```
## Target Directory
On Linux with explicit target:
```
target/<triple>/<profile>/
```
On macOS/Windows or without target:
```
target/<profile>/
```

View File

@@ -0,0 +1,152 @@
---
sidebar_label: dcr.toml overview
---
# dcr.toml
Main project configuration file. Located at the project root.
## Structure
```toml
[package]
# required fields
[build]
# build settings
[build.debug] # optional: debug override
[build.release] # optional: release override
[build.linux] # optional: Linux override
[build.windows] # optional: Windows override
[build.windows.debug] # target + profile combination
[toolchain]
# compiler/linker paths
[dependencies]
# project dependencies
[workspace]
# multi-package configuration
[run]
# run settings
```
## [package]
| Field | Required | Description |
| --------- | -------- | ----------------------- |
| `name` | yes | Project name |
| `version` | yes | Semantic version |
| `type` | yes | `app`, `lib`, `none` |
| `license` | no | SPDX license identifier |
| `author` | no | Author |
```toml
[package]
name = "my-app"
version = "0.1.0"
type = "app"
license = "MIT"
author = "John Doe"
```
## [build]
...
* `build.qt` — (bool) Enable automatic Qt meta-object handling (MOC, UIC, RCC). Requires `qt6` modules installed via `pkg-config`.
| Field | Default | Description |
| ---------------- | ------------------------------------------- | --------------------------------------------------------------------- |
| `language` | `"c"` | `"c"`, `"c++"`, `"cpp"`, `"cxx"`, `"asm"` |
| `standard` | `"c11"` | C standard (`c11`, `c17`, `c23`) |
| `cxx_standard` | `"c++20"` | C++ standard (`c++17`, `c++20`, `c++23`) |
| `compiler` | `"clang"` | Preferred compiler |
| `kind` | `"bin"` | `bin`, `staticlib`, `sharedlib`, `efi`, `elf`, `none`, `custom` |
| `target` | host | Target triple for cross-compilation |
| `platform` | `"native"` | `native`, `efi` |
| `cflags` | `[]` | Additional C/C++/ASM flags |
| `ldflags` | `[]` | Additional linker flags |
| `filename` | `""` | Custom output file name |
| `extension` | `""` | Custom file extension |
| `roots` | `["src"]` | Source root directories |
| `exclude` | `[]` | Exclude patterns |
| `include` | `[]` | Additional include directories |
| `src_disable` | `false` | Disable auto source discovery |
| `inherit` | `false` | Inherit build from workspace root |
| `clean` | `[]` | Glob patterns for custom clean paths |
| `out_dir` | `""` | Custom output directory |
| `workspace_only` | `false` | Workspace-only, not built standalone |
| `freestanding` | `false` | Compile in freestanding mode (`-ffreestanding` + `-nostdlib -static`) |
| `opt_level` | `"0"` (debug) / `"3"` (release) | Optimization level: `0`-`3`, `"s"`, `"z"` |
| `debug` | `true` (debug) / `false` (release) | Emit debug symbols (`-g`) |
| `lto` | `false` | Link-time optimization (`-flto` for both compiler and linker) |
| `strip` | `false` | Strip symbols from output (`-s` in ldflags) |
| `warnings` | `["all", "extra"]` (debug) / `[]` (release) | Warning flags (e.g. `"all"`, `"extra"`, `"pedantic"`) |
| `panic` | `""` | Panic strategy: `"abort"` disables exceptions and unwind tables |
| `codegen-units` | `""` | Max parallel compilation jobs (`"0"` = auto) |
| `qt` | `false` | Enable automatic Qt meta-object handling (MOC, UIC, RCC) |
Settings from raw config (not in typed struct):
* `pkg_config` — list of pkg-config packages
* `ldscript` — linker script path
* `build.steps` / `build.post_steps` — codegen steps
Example:
```toml
[build]
language = "c++"
standard = "c23"
cxx_standard = "c++23"
compiler = "clang"
kind = "sharedlib"
cflags = ["-Wall", "-Wextra"]
opt_level = "z"
lto = true
strip = true
panic = "abort"
codegen-units = "2"
```
## [toolchain]
```toml
[toolchain]
cc = "/usr/bin/clang"
cxx = "/usr/bin/clang++"
as = "/usr/bin/as"
ar = "/usr/bin/ar"
ld = "/usr/bin/ld.lld"
```
Raw config also supports `uic`, `moc`, `rcc` for Qt codegen.
## [dependencies]
See [dependencies](/docs/reference/dependencies).
## [run]
```toml
[run]
cmd = "./target/{profile}/{name}"
```
Substitutions:
* `{version}` — package version
* `{version_major}`, `{version_minor}`, `{version_patch}`, `{version_suffix}`, `{version_suffix_dash}` — version parts
* `{profile}` — debug / release
* `{name}` — package name
Default `cmd` = `./target/{profile}/{name}` (macOS/Windows) or `./target/\<triple>/\<profile>/\<name>` (Linux).
## [workspace]
See [workspaces](/docs/reference/workspaces).

View File

@@ -0,0 +1,84 @@
---
sidebar_label: Dependencies
---
# Dependencies
## Formats
The `[dependencies]` section supports three formats:
### String (registry)
```toml
[dependencies]
fmt = "10.1.1"
spdlog = "1.12"
catch2 = "3.4.0"
```
The version string is used as-is for registry lookup.
### Table (git)
```toml
[dependencies]
fmt = { git = "https://github.com/fmtlib/fmt", tag = "10.1.1" }
```
Fields: `git`, `branch`, `tag`, `rev`.
### Table (path)
```toml
[dependencies]
mylib = { path = "../mylib" }
```
## Registry
DCR uses a package registry for dependency lookup by name.
```toml
# ~/.dcr/config.toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```
Registry priority: order in `config.toml`. The `DCR_INDEX_PATH` variable overrides the path to `index.json`.
## Git dependencies
DCR clones git repositories via `git2`:
* `branch` — switch to a branch
* `tag` — switch to a tag
* `rev` — switch to a specific commit
* `features` — feature flags (parsed, but does not affect build)
Cache path: `~/.dcr/git/\<hash>/`.
## Path dependencies
Local paths. DCR automatically discovers include and lib directories from the neighbor's `dcr.toml`.
```toml
[dependencies]
mylib = { path = "/abs/path/to/lib" }
mylib = { path = "../relative/path" }
```
## dcr.lock
Dependency lock file. Contains package names and sources.
Created during `dcr build` when registry dependencies are present. Not updated during `dcr add` — only on the next `dcr build`.
## Resolution process
1. Load all dependencies (registry → git → path)
2. For path deps: recursively read their `dcr.toml`
3. For registry deps: search `index.json`
4. For git deps: clone to cache
5. Collect `include_dirs`, `lib_dirs`, `libs` for the compiler

View File

@@ -0,0 +1,60 @@
---
sidebar_label: Environment variables
---
# Environment Variables
## DCR_COMPILER
Overrides the compiler for all languages. **Highest priority.**
```bash
export DCR_COMPILER=clang
dcr build
```
Compiler resolution priority:
1. `DCR_COMPILER` (env)
2. `DCR_CC` / `DCR_CXX` / `DCR_AS` (env)
3. `[toolchain]` (dcr.toml)
4. `build.compiler` (dcr.toml)
5. `PATH`
## DCR_CC / DCR_CXX / DCR_AS
Per-language override (lower priority than `DCR_COMPILER`, higher than `[toolchain]`).
```bash
export DCR_CC=gcc-14
export DCR_CXX=g++-14
export DCR_AS=arm-linux-gnueabihf-as
```
## DCR_LD / DCR_AR
Override linker and archiver.
```bash
export DCR_LD=ld.lld
export DCR_AR=llvm-ar
```
## DCR_DEBUG
Enables debug mode — prints all compilation commands to stderr before execution.
```bash
export DCR_DEBUG=1
dcr build
```
## DCR_INDEX_PATH
Overrides the path to the registry `index.json`.
```bash
export DCR_INDEX_PATH=/custom/path/index.json
```
Default: `~/.dcr/index.json`.

View File

@@ -0,0 +1,51 @@
---
sidebar_label: Platform support
---
# Platform Support
## Target Triples
DCR normalizes target triples. Short platform names are expanded to full triples.
### Linux
```
target/<arch>-unknown-linux-gnu/<profile>/
```
Architectures: `x86_64`, `aarch64` (host-detected).
Artifact type: ELF. Extensions: `.so` (sharedlib), `.a` (staticlib).
### macOS
```
target/<profile>/
```
Architectures: `x86_64`, `aarch64` (host-detected).
Extensions: `.dylib` (sharedlib), `.a` (staticlib).
### Windows
```
target/<profile>/
```
Architectures: `x86_64`, `aarch64`.
Extensions: `.exe` (bin), `.lib` (staticlib), `.dll` (sharedlib), `.efi` (UEFI).
### BSD
```
target/<arch>-unknown-<os>/<profile>/
```
Supported systems: `freebsd`, `openbsd`, `netbsd`, `dragonfly`.
## Host Detection
DCR uses `std::env::consts::ARCH` and `std::env::consts::OS` for host platform detection. Used as fallback when `target` is not specified.

View File

@@ -0,0 +1,67 @@
---
sidebar_label: Workspaces
---
# Workspaces
Workspaces allow managing multiple packages in a single repository.
## Configuration
```toml
[workspace.lib-core]
path = "lib-core"
[workspace.lib-utils]
path = "lib-utils"
deps = ["lib-core"]
[workspace.app]
path = "app"
deps = ["lib-core", "lib-utils"]
main = true
```
### Member fields
| Field | Description |
| ------ | ------------------------------------------------ |
| `path` | Path to the package (relative to workspace root) |
| `deps` | Dependencies on other members |
| `main` | Mark as the main package |
## Topological sort
DCR automatically sorts packages by dependencies: package A is built before B if B depends on A.
Cyclic dependencies are detected and cause an error.
## Build
```bash
dcr build # build all packages in dependency order
dcr build --workspace app # build only app (dependencies built automatically)
```
When building a workspace, member outputs (libraries) are automatically added to include/lib paths of dependent packages.
## Clean
```bash
dcr clean # clean only root target/
dcr clean --all # clean target/ of all packages
```
## Inheritance
If a member has `inherit = true` in its `[build]` section, fields from the root `[build]` are merged into the member:
```toml
# root dcr.toml
[build]
inherit = true
language = "c"
standard = "c17"
# member inherits language and standard
```

View File

@@ -0,0 +1,46 @@
---
sidebar_label: Self Update
---
# Self Update
## dcr --update
Automatic update to the latest version. Downloads a binary (not an archive) from GitHub Releases and replaces the current executable.
```bash
dcr --update
```
## How it works
1. DCR detects the current platform and architecture
2. Fetches the latest release from `api.github.com/repos/dexoron/dcr/releases/latest`
3. Compares versions
4. Downloads the matching asset (direct binary URL, not archive)
5. Replaces the current executable via `self_replace`
## Asset naming
Pattern: `dcr-\<triple>` or `dcr-\<triple>.exe`
| Platform | Asset name |
| -------------- | -------------------------------- |
| Linux x86_64 | `dcr-x86_64-unknown-linux-gnu` |
| macOS x86_64 | `dcr-x86_64-apple-darwin` |
| macOS ARM64 | `dcr-aarch64-apple-darwin` |
| Windows x86_64 | `dcr-x86_64-pc-windows-msvc.exe` |
## AUR
If DCR was installed via AUR, `--update` shows a warning:
```
Update via package manager: yay/paru -Syu {package_name} or sudo pacman -Syu {package_name}
```
## Errors
* Cannot detect platform — error
* Cannot fetch release — error with URL
* No write permission — error (use `sudo` or manual install)

View File

@@ -0,0 +1,45 @@
---
sidebar_label: Running tests
---
# Running Tests
## Execution
```bash
dcr test
```
Builds the project, then compiles and runs test files from `tests/`.
## Profiles
```bash
dcr test # debug (default)
dcr test --release # release
dcr test --debug # explicit debug
```
## Output
```
=====================
Testsuite summary
=====================
TOTAL: 5
PASS: 3
SKIP: 1
FAIL: 1
=====================
```
## Exit code
* 0 — all tests passed (FAIL = 0)
* 1 — test failures or build error
## What gets built
* All `.c` files from `tests/` (`.cpp` not supported)
* Include path: `tests/` (for `dcr_test.h`)
* Linked with project if `package.type = "lib"` or `kind = "staticlib"`/`"sharedlib"`

View File

@@ -0,0 +1,69 @@
---
sidebar_label: Test framework (EXPECT, TEST, ...)
---
# Test Framework
DCR has a built-in minimal test framework for C.
## Macros
### `EXPECT(expr)`
Asserts that an expression is true.
```c
EXPECT(1 + 1 == 2);
EXPECT(ptr != NULL);
```
### `SKIP(reason)`
Skips a test with a message.
```c
SKIP("not implemented on Windows");
```
### `TEST(name)`
Defines a test.
```c
TEST(addition) {
EXPECT(1 + 1 == 2);
EXPECT(2 + 2 == 4);
}
```
### `TEST_CASE(name)`
Registers a test case.
```c
TEST_CASE(math) {
EXPECT(1 + 1 == 2);
}
```
## Initialization
```bash
dcr test --init
```
Creates:
* `tests/dcr_test.h` — framework header (do not edit)
* `tests/test.c` — template with example test
## Structure
```
tests/
├── dcr_test.h # framework (do not edit)
├── test.c # main tests
└── ... # additional .c test files
```
Only `.c` files are compiled (`.cpp` is not supported).

View File

@@ -0,0 +1,63 @@
---
sidebar_label: Introduction
---
# DCR — C/C++ Build Tool & Package Manager
<details>
<summary>Quick reference</summary>
```bash
# Installation
curl -fsSL https://dcr.dexoron.su/install.sh | sh
# Create a project
dcr new my-app
cd my-app
# Build and run
dcr build
dcr run
# Run tests
dcr test
# Add a dependency
dcr add fmt
# Generate IDE files
dcr gen vscode
```
</details>
## Contents
| Section | Description |
| ----------------------------------------------------- | --------------------------------------------- |
| [Getting Started](/docs/getting-started/installation) | Installation and first steps |
| [Commands](/docs/commands/project-commands) | All CLI commands |
| [Reference](/docs/reference/dcr-toml) | Configuration, build, dependencies, platforms |
| [Testing](/docs/testing/test-framework) | Built-in test framework |
| [Recipes](/docs/recipes/cross-to-windows) | Common scenarios |
| [IDE Integration](/docs/ide-integration) | VS Code, CLion, compile_commands.json |
| [Self Update](/docs/self-update) | Auto-update |
| [FAQ](/docs/faq) | Frequently asked questions |
| [Changelog](/docs/changelog) | Version history |
| [License](/docs/license) | DCR and vendored library licenses |
| [Contributing](/docs/contributing) | DCR development |
## Features
* **Incremental builds** — mtime + `.d` headers + SHA256 fingerprint
* **Parallel compilation** — thread::scope, atomic task queue
* **4 backends** — gcc/clang, MSVC/clang-cl, GAS (ARM), NASM (x86)
* **7 project kinds** — bin, staticlib, sharedlib, efi, elf, none, custom
* **Cross-compilation** — short names and full triples
* **Profiles** — debug / release with field overrides
* **Workspaces** — multi-package projects with topological sort
* **Registry + Git + Path** — three dependency mechanisms
* **IDE generation** — VS Code, CLion, compile_commands.json, JSON metadata
* **pkg-config** — automatic system library discovery
* **Per-command `--help`** — `dcr build --help`, `dcr new --help`, etc.
* **Man pages** — `man dcr`, `man dcr-build`, `man dcr-new`

View File

@@ -0,0 +1,91 @@
---
sidebar_label: Changelog
---
# Changelog
## 0.7.1 (2026-06-02)
### Added
* **`--help` for all commands** — `dcr build --help`, `dcr run --help`, `dcr new --help`,
`dcr init --help`, `dcr clean --help`, `dcr add --help`, `dcr fmt --help`,
`dcr setup --help`, `dcr tree --help`, `dcr gen --help`, `dcr --update --help`,
`dcr test --help`. All output uses styled headers (green) and usage lines (cyan).
* **Man pages** — 12 troff pages in `man/man1/`: `dcr.1`, `dcr-build.1`,
`dcr-run.1`, `dcr-new.1`, `dcr-init.1`, `dcr-clean.1`, `dcr-add.1`, `dcr-test.1`,
`dcr-gen.1`, `dcr-fmt.1`, `dcr-tree.1`, `dcr-setup.1`.
* **Man pages in all packaging** — install.sh, install_bsd.sh, AUR PKGBUILD,
Debian (cargo-deb), RPM (cargo-generate-rpm), Nix (postInstall), Homebrew
(resource), Snap, GitHub Release assets.
* **Project name validation** — `dcr init` and `dcr new` now validate names before
creating files. Only ASCII letters, digits, `_` and `-` are allowed.
* **`documentation` and `homepage` fields** — added to `Cargo.toml`.
* **Release profile optimizations** — `opt-level = "z"`, LTO, `codegen-units = 1`,
`panic = "abort"`, `strip = true` for smaller binaries.
* **Linux i686, armv7, riscv64 targets** — added to release workflow and install scripts.
* **Linux musl i686, armv7 targets** — cross-compiled via zigbuild in CI.
* **AUR packages** — `dcr-dev`, `dcr-dev-bin` publishing workflow.
* **Snap publishing** — automated Snapcraft publishing in CI.
* **Snap badge** — in README.
### Changed
* **`validate_package_name` made public** — callable from CLI commands.
* **README platform table** — reorganized: libc variants as separate OS rows,
removed extra columns. Linux architecture list updated.
* **`gen.rs` no-args output** — now uses styled output instead of raw `eprintln!`.
* **`tree.rs`, `fmt.rs`, and `setup.rs`** — now accept arguments for `--help`.
* **README install commands** — `| bash` → `| sh` for POSIX compatibility.
### Fixed
* **`dcr new \<invalid-name>` creates directory then fails** — validation now
happens before any file operations.
* **`dcr init` on invalid directory name** — same fix.
* **Man pages missing in installed packages** — now shipped in all formats.
* **Windows drive letter false positive** — in dependency file parser.
* **CRLF (`\r\n`) breaks dependency parser** — now handles mixed line endings.
* **Newline after backslash not consumed** — in `parse_d_file` escape handling.
## 0.7.0 (2026-06-01)
### Added
* **OpenBSD and NetBSD target support** — full platform routing with dynamic target triples using `std::env::consts::ARCH` and `std::env::consts::OS`. Affects `build`, `run`, `clean` commands and the platform module.
* **`src/platform/bsd.rs`** — new BSD platform module (shared by FreeBSD, OpenBSD, NetBSD) providing `bin_path`, `lib_path`, `elf_path`, `efi_path`, `shared_lib_path`.
* **`build.out_dir` config option** — custom output directory that overrides the default `target/\<triple>/\<profile>` path for final artifacts. Supported in `build`, `run`, and config validation.
* **`dcr fmt` command** — new CLI command that formats all C/C++ source files (`*.c`, `*.cpp`, `*.h`, `*.hpp`) in `src/` and `tests/` using `clang-format`.
* **Incremental linking** — `needs_link()` in `common.rs` checks if any object file is newer than the linked output, skipping unnecessary relinking. Implemented for all backends (`unix_cc`, `msvc`, `gas`, `nasm`).
* **`build.kind = "none"` and `"custom"`** — two new project kinds for special build scenarios that don't produce standard artifacts.
* **`install_bsd.sh`** — POSIX-compliant installation script for BSD systems (FreeBSD, OpenBSD, NetBSD) with binary download and source build modes.
* **Linux ARM64 support in `install.sh`** — added `Linux:aarch64|Linux:arm64` target detection for pre-built binary downloads.
* **BSD OS detection in `install.sh`** — detects FreeBSD, OpenBSD, NetBSD and determines target triple.
* **`rust-toolchain.toml`** — explicit toolchain pinning to `stable` channel.
* **Integration tests** — `build_with_target_config` (verifies `build.target = "linux"`) and `build_with_out_dir` (validates custom output directory).
* **`get_build_string_with_profile` made `pub`** — so `run.rs` can determine custom output directory configuration.
### Changed
* **`build.target` semantics changed** — now strictly contains a target triple (e.g., `x86_64-unknown-linux-gnu`) or short name (`linux`, `macos`, `windows`). No longer used as custom output directory — this functionality moved to `build.out_dir`.
* **`build.standard` made optional** — changed from `String` to `Option\<String>`. Validation only enforces non-empty for non-ASM languages. Skipped in `dcr.toml` output if empty.
* **`dcr run` with `out_dir`** — now determines target directory respecting `build.out_dir` via `get_build_string_with_profile()` from `build.rs`.
* **`collect_sources()` returns empty vector** instead of error when no sources are found, allowing `kind = "none"` or `kind = "custom"` projects with no source files.
* **CI/CD release workflow refactored** — `git2` made target-specific (no vendored-openssl on Windows), Zig-based cross-compilation for non-x86_64 Linux targets, Arch Linux package version cleanup (dashes → dots), `gmake` symlink for NetBSD.
* **README compatibility table** — FreeBSD, OpenBSD, NetBSD build/run status upgraded from "community/best-effort" to "officially supported".
* **Documentation updated** — `build-section.md` describes new `build.target` and `build.out_dir` fields. `target-directory.md` rewritten to clarify the distinction.
### Fixed
* **stdout/stderr not inherited in `dcr run`** — child process output was captured and manually printed, breaking interactive programs. Fixed by switching to `Command::status()`.
* **Race condition in release CI** — matrix build jobs could upload assets to a release that didn't exist yet. Fixed by adding a dedicated `create-release` job.
* **Release GHA — stable toolchain override** — fixed Rust toolchain override issues in CI.
* **Arch Linux package version sanitization** — version strings with dashes (e.g., `0.7.0-dev`) are invalid for `pkgver`. Fixed by replacing dashes with dots.
* **GPG permissions after Docker** — Docker operations changed GPG directory ownership. Fixed by running `chown` after Docker commands.
* **RPM artifact paths** — RPM artifacts were placed in `rpm/x86_64/` instead of `fedora/x86_64/`. Fixed in Dexoron Packages Index workflow.
* **JSON parsing reliability in `install.sh`** — added `jq` as primary parser with `python3` fallback for dev channel release lookup.
### Removed
* **`format_roots()` helper function** — removed from `common.rs`. Was only used by the old error handling path in `collect_sources()`.
* **Per-distribution artifact download steps** — three separate `actions/download-artifact` steps replaced with unified `gh release download --clobber`.

View File

@@ -0,0 +1,42 @@
---
sidebar_label: Build commands (build, run, clean)
---
# Build Commands
## `dcr build`
Builds the project according to `dcr.toml`.
```bash
dcr build # debug profile
dcr build --release # release build
dcr build --debug # explicit debug
dcr build --target aarch64-unknown-linux-gnu
dcr build --force # full rebuild
dcr build --clean # clean + build
dcr build --verbose # show compilation commands
dcr build --workspace pkg-a # build specific workspace package
```
Artifacts: `target/\<triple>/\<profile>/\<binary-name>` (Linux with explicit target).
## `dcr run`
Builds (if sources are newer than artifacts) and runs the binary.
```bash
dcr run
dcr run --release
```
## `dcr clean`
Removes `target/` directory (or `target/\<target>/\<profile>`).
```bash
dcr clean
dcr clean --release # target/release/ only
dcr clean --target windows # target/x86_64-pc-windows-msvc/
dcr clean --all # clean all workspace packages
```

View File

@@ -0,0 +1,53 @@
---
sidebar_label: Dependency commands (add, tree)
---
# Dependency Commands
## `dcr add \<name> [source]`
Adds a dependency to `dcr.toml`.
```bash
dcr add fmt # registry lookup
dcr add mylib ../path/to/lib # path as source
dcr add mylib path:./lib # explicit path prefix
dcr add mylib git:https://github.com/user/repo # explicit git prefix
dcr add mylib github:user/repo # GitHub shorthand
dcr add mylib gitlab:user/repo # GitLab shorthand
```
Source prefixes:
* `path:` — local path
* `git:` — generic git URL
* `github:` — expands to `https://github.com/\<user>/\<repo>`
* `gitlab:` — expands to `https://gitlab.com/\<user>/\<repo>`
* `http://` / `https://` / `git@` — full URL
Flags:
* `--branch \<name>` — git branch
* `--tag \<name>` — git tag
* `--rev \<hash>` — git commit
If source is omitted — DCR searches connected registries.
## `dcr tree`
Displays the project dependency tree.
```bash
dcr tree
```
Example output:
```
my-app v0.1.0
├── fmt (registry)
│ └── spdlog (registry)
└── catch2 (registry)
```
For path dependencies, recursively shows their own dependencies (from their `dcr.toml`).

View File

@@ -0,0 +1,73 @@
---
sidebar_label: Gen commands (vscode, clion, ...)
---
# Gen Commands
## `dcr gen \<target>`
Generates IDE integration files.
### vscode
```bash
dcr gen vscode
```
Creates:
* `.vscode/tasks.json` — `build` task (dcr build)
* `.vscode/launch.json` — debug launch configuration
* `.vscode/settings.json` — C/C++ settings (clangd paths, includes)
* `.vscode/extensions.json` — recommended extensions (vscode-clangd, vscode-lldb)
### clion
```bash
dcr gen clion
```
Creates:
* `.idea/externalTools.xml` — external tools (build, run, clean, test)
* `.idea/customTargets.xml` — custom build targets
* `.idea/misc.xml` — C/C++ project settings
* `.idea/runConfigurations/\<name>.xml` — per-binary run configurations
### compile-commands
```bash
dcr gen compile-commands
```
Generates `compile_commands.json` — standard format for clangd, cpptools, static analyzers.
### project-info
```bash
dcr gen project-info
```
Outputs JSON array with project metadata:
```json
[
{
"name": "my-app",
"version": "0.1.0",
"root": "/path/to/project",
"profile": "debug",
"language": "c",
"standard": "c17",
"cxx_standard": null,
"compiler": "/usr/bin/clang",
"kind": "bin",
"sources": ["src/main.c"],
"include_dirs": ["src"],
"lib_dirs": [],
"libs": [],
"cflags": ["-std=c17", "-O0", "-g"],
"ldflags": []
}
]
```

View File

@@ -0,0 +1,31 @@
---
sidebar_label: Project commands (new, init)
---
# Project Commands
## `dcr new \<name>`
Creates a new project with a standard structure and `dcr.toml`. The `name` argument is required.
Only ASCII letters, digits, underscores `_` and hyphens `-` are allowed in the project name.
```bash
dcr new my-app
```
Generates:
* `dcr.toml` with basic fields
* `src/main.c` with a `main` template
## `dcr init`
Initializes a DCR project in the current (empty) directory.
```bash
mkdir app && cd app
dcr init
```
The project name is taken from the current directory name. The directory name must follow the same naming rules as `dcr new`.

View File

@@ -0,0 +1,60 @@
---
sidebar_label: Quality commands (test, fmt)
---
# Quality Commands
## `dcr test`
Runs tests.
```bash
dcr test # debug profile
dcr test --release # release profile
dcr test --debug # explicit debug
dcr test --help # detailed help
```
Before first use, initialize tests:
```bash
dcr test --init
```
This creates `tests/dcr_test.h` (framework) and `tests/test.c` (template).
What `dcr test` does:
1. Builds the project
2. Collects `tests/*.c` files (`.c` only, not `.cpp`)
3. Compiles and links each test file
4. Runs each test binary
5. Prints summary: TOTAL, PASS, SKIP, FAIL
6. Returns non-zero exit code on any FAIL
## `dcr fmt`
Formats C/C++ source files using `clang-format`.
```bash
dcr fmt
```
Processes: `src/**/*.{c,cpp,cxx,cc,h,hpp,hxx,hh}` and `tests/**/*.{c,cpp,cxx,cc,h,hpp,hxx,hh}`.
Uses `.clang-format` at the project root (if present), otherwise default clang-format style.
## `dcr lint`
Runs `clang-tidy` on C/C++ source files for static analysis.
```bash
dcr lint # show diagnostics
dcr lint --fix # apply fixes automatically
dcr lint --help # detailed help
```
Processes: `src/**/*.{c,cpp,cxx,cc}` and `tests/**/*.{c,cpp,cxx,cc}`.
Without `--fix`, clang-tidy reports warnings and errors without modifying files.
With `--fix`, clang-tidy applies automatic suggestions in place.

View File

@@ -0,0 +1,51 @@
---
sidebar_label: System commands (setup, --help, ...)
---
# System Commands
## `dcr setup`
Shows configured registries from `~/.dcr/config.toml`.
```bash
dcr setup
```
If `~/.dcr/config.toml` is not found, DCR returns an error. Create it manually:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```
## `dcr --help`
Shows help for all commands.
```bash
dcr --help
```
## `dcr --version`
Shows version and target triple.
```bash
dcr --version # dcr 0.7.0 (x86_64-unknown-linux-gnu)
```
## `dcr --update`
Self-update. Downloads the latest release binary from GitHub Releases and replaces the current one.
```bash
dcr --update
```
Features:
* Auto-detects platform and architecture
* Warns if installed via AUR (use package manager instead)
* Works on Linux, macOS, Windows

View File

@@ -0,0 +1,51 @@
---
sidebar_label: Contributing
---
# Contributing
## Setup
```bash
git clone https://github.com/dexoron/dcr
cd dcr
cargo build
```
## Code style
All code must be formatted with `cargo fmt`:
```bash
cargo fmt
```
## Linting
```bash
cargo clippy --all-targets -- -D warnings
```
## Tests
```bash
cargo test --all-targets
```
## PR process
1. Fork the repository
2. Create a branch: `git checkout -b feature/description`
3. Make changes
4. Run `cargo fmt && cargo clippy && cargo test`
5. Open a Pull Request
## CI
CI runs:
* `cargo fmt --check`
* `cargo clippy --all-targets -- -D warnings`
* `cargo test --all-targets`
* Build on Linux, macOS, Windows
* Integration tests

View File

@@ -0,0 +1,81 @@
---
sidebar_label: FAQ
---
# FAQ
## Registry not found
```
error: registry not found
```
**Solution:** Make sure `~/.dcr/config.toml` exists:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```
And check `DCR_INDEX_PATH`:
```bash
echo $DCR_INDEX_PATH
```
## Compiler not found
```
error: compiler not found
```
**Solution:** Ensure a compiler is installed and available in PATH.
```bash
which gcc
which clang
```
Or specify explicitly via `[toolchain]` in `dcr.toml`.
## openssl-sys build failed
When building DCR from source:
```
error: failed to run custom build command for openssl-sys
```
**Solution:** Install OpenSSL development headers:
```bash
# Ubuntu/Debian
sudo apt install libssl-dev
# Fedora
sudo dnf install openssl-devel
# macOS
brew install openssl
```
## Ctrl+C during build
DCR handles SIGINT: interrupts the current compilation and exits with non-zero code.
## How to create a library?
See [Library Recipe](/docs/recipes/library-project).
## How to cross-compile to Windows?
See [Cross-Compile Recipe](/docs/recipes/cross-to-windows).
## How to create a multi-package project?
See [Workspace Recipe](/docs/recipes/multi-package-workspace).
## Lock file
`dcr.lock` is created during builds (`dcr build`) when registry dependencies are present. To force an update — delete `dcr.lock` and run `dcr build`.

View File

@@ -0,0 +1,72 @@
---
sidebar_label: First steps
---
# First Steps
## Create a project
```bash
dcr new my-app
cd my-app
```
Structure:
```
my-app/
├── dcr.toml
└── src/
└── main.c
```
`dcr.toml`:
```toml
[package]
name = "my-app"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
compiler = "clang"
kind = "bin"
```
## Build
```bash
dcr build
```
Output — `target/\<triple>/debug/my-app` (Linux) or `target/debug/my-app.exe` (Windows).
Build profiles:
```bash
dcr build --release # release build
dcr build --debug # debug (default)
```
## Run
```bash
dcr run
```
Builds (if needed) and runs the binary.
## First test
```bash
dcr test --init # create test template
dcr test # run tests
```
## Formatting
```bash
dcr fmt # clang-format with .clang-format
```

View File

@@ -0,0 +1,109 @@
---
sidebar_label: Installation
---
# Installation
## Linux (Dexoron Packages)
Configure your package manager at https://pkg.dexoron.su and install:
**Arch Linux**
```sh
sudo pacman -Sy dcr
```
**Debian/Ubuntu**
```sh
sudo apt update && sudo apt install dcr
```
**Fedora/RHEL**
```sh
sudo dnf install dcr
```
## Arch Linux (AUR)
```sh
yay -S dcr
```
## macOS / Linux (Homebrew)
```sh
brew tap dexoron/dexoron
brew install dcr
```
## Snap (Linux)
```sh
sudo snap install dcrup
```
## Nix (flake)
```sh
nix run github:dexoron/dcr
# or install to profile:
nix profile install github:dexoron/dcr
```
## Cargo (crates.io)
```sh
cargo install dcr
```
## Linux / macOS (script)
```sh
curl -fsSL https://dcr.dexoron.su/install.sh | sh
```
## BSD (script)
```sh
curl -fsSL https://dcr.dexoron.su/install_bsd.sh | sh
```
## Windows (PowerShell)
```powershell
irm https://dcr.dexoron.su/install.ps1 | iex
```
## From source
```sh
git clone https://github.com/dexoron/dcr.git
cd dcr && cargo build --release
ln -sf "$PWD/target/release/dcr" ~/.local/bin/dcr
```
## Post-install
Verify the installation:
```bash
dcr --version
```
Man pages are available after installation:
```bash
man dcr
man dcr-build
```
To use the registry, create `~/.dcr/config.toml`:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```

View File

@@ -0,0 +1,51 @@
---
sidebar_label: IDE Integration
---
# IDE Integration
## VS Code
```bash
dcr gen vscode
```
Generates in `.vscode/`:
| File | Purpose |
| ----------------- | -------------------------------------------- |
| `tasks.json` | `build` task (dcr build) |
| `launch.json` | Debug launch configuration |
| `settings.json` | clangd/IntelliSense: include paths, standard |
| `extensions.json` | Recommends vscode-clangd, vscode-lldb |
## CLion
```bash
dcr gen clion
```
Generates in `.idea/`:
| File | Purpose |
| ------------------------------------------------ | ----------------------------------------- |
| `externalTools.xml` | Build, Run, Clean, Test as external tools |
| `customTargets.xml` | Custom build targets |
| `misc.xml` | C/C++ project settings |
| `runConfigurations/\<name>.xml` | Per-binary run configurations |
## compile_commands.json
```bash
dcr gen compile-commands
```
Generates `compile_commands.json` at project root. Standard format for clangd, C/C++ IntelliSense, static analyzers.
## project-info
```bash
dcr gen project-info
```
Outputs JSON array with project metadata (see [gen-commands](/docs/commands/gen-commands)).

View File

@@ -0,0 +1,46 @@
---
sidebar_label: License
---
# License
## DCR
DCR itself is [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later.html) licensed.
> **Note:** DCR is a build tool, not a library. The GPL applies only to DCR's own source code. Projects built with DCR are not subject to DCR's license — their licensing is determined solely by their own code and dependencies.
## Vendored libraries
DCR statically links the following C libraries through its vendored Rust dependencies:
| Library | License | Bundled by |
| ------------------------------------------ | ------------------ | ----------------------------- |
| [libgit2](https://libgit2.org) | MIT OR Apache-2.0 | `git2` / `libgit2-sys` |
| [libssh2](https://libssh2.org) | MIT OR Apache-2.0 | `libgit2-sys` |
| [zlib](https://zlib.net) | MIT OR Apache-2.0 | `libgit2-sys` |
| [OpenSSL](https://openssl.org) | Apache-2.0 | `openssl-sys` / `openssl-src` |
| [ring](https://github.com/briansmith/ring) | Apache-2.0 AND ISC | `rustls` |
## Rust dependencies
DCR is written in Rust. The following notable Rust crates are statically linked:
| Crate | License |
| --------------------------------------------- | ------------------------ |
| [`reqwest`](https://crates.io/crates/reqwest) | MIT OR Apache-2.0 |
| [`rustls`](https://crates.io/crates/rustls) | Apache-2.0 OR ISC OR MIT |
| [`serde`](https://crates.io/crates/serde) | MIT OR Apache-2.0 |
| [`toml`](https://crates.io/crates/toml) | MIT OR Apache-2.0 |
| [`sha2`](https://crates.io/crates/sha2) | MIT OR Apache-2.0 |
| [`git2`](https://crates.io/crates/git2) | MIT OR Apache-2.0 |
| [`openssl`](https://crates.io/crates/openssl) | Apache-2.0 |
| [`tokio`](https://crates.io/crates/tokio) | MIT |
| [`hyper`](https://crates.io/crates/hyper) | MIT |
| [`ctrlc`](https://crates.io/crates/ctrlc) | MIT OR Apache-2.0 |
Full dependency tree (143 packages) is available in [`Cargo.lock`](https://github.com/dexoron/dcr/blob/main/Cargo.lock). The overwhelming majority are dual-licensed under MIT OR Apache-2.0.
## Additional credits
* DCR's CLI design and project model are inspired by [Cargo](https://doc.rust-lang.org/cargo/).

View File

@@ -0,0 +1,49 @@
---
sidebar_label: Cross-compile to Windows
---
# Cross-Compile to Windows from Linux
Building a Windows binary on Linux using mingw-w64.
## Install toolchain
```bash
# Ubuntu/Debian
sudo apt install mingw-w64
# Fedora
sudo dnf install mingw64-gcc mingw64-binutils
```
## Configuration
```toml
[package]
name = "my-app"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
compiler = "clang"
kind = "bin"
target = "x86_64-pc-windows-gnu" # explicit mingw, not msvc
```
## Build
```bash
dcr build --target x86_64-pc-windows-gnu --release
```
Artifact: `target/x86_64-pc-windows-gnu/release/my-app.exe`.
## Custom toolchain
```toml
[toolchain]
cc = "x86_64-w64-mingw32-gcc"
cxx = "x86_64-w64-mingw32-g++"
```

View File

@@ -0,0 +1,70 @@
---
sidebar_label: Library project
---
# Library Project
Creating a static library and using it in another project.
## Step 1: Create the library
```bash
dcr new my-lib
cd my-lib
```
`dcr.toml`:
```toml
[package]
name = "my-lib"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
kind = "staticlib"
```
`src/my_lib.h`:
```c
#ifndef MY_LIB_H
#define MY_LIB_H
int add(int a, int b);
#endif
```
`src/my_lib.c`:
```c
#include "my_lib.h"
int add(int a, int b) { return a + b; }
```
## Step 2: Build
```bash
dcr build --release
```
Artifacts:
* `target/\<triple>/release/libmy-lib.a` (Linux)
* `target/release/my-lib.lib` (Windows)
* `target/include/` — header files
## Step 3: Use in another project
```bash
dcr new my-app
cd my-app
dcr add my-lib ../my-lib
```
Automatically:
* Adds include path to `target/include/` of the library
* Adds lib path to `target/\<triple>/release/`
* Links `libmy-lib.a` / `my-lib.lib`

View File

@@ -0,0 +1,102 @@
---
sidebar_label: Multi-package workspace
---
# Multi-Package Workspace
A project with three packages: two libraries and a binary.
## Structure
```
workspace/
├── dcr.toml # root workspace
├── lib-core/
│ ├── dcr.toml
│ └── src/core.c
├── lib-utils/
│ ├── dcr.toml
│ └── src/utils.c
└── app/
├── dcr.toml
└── src/main.c
```
## Root dcr.toml
```toml
[package]
name = "my-workspace"
version = "0.1.0"
type = "none"
[build]
inherit = true
language = "c"
standard = "c11"
[workspace.lib-core]
path = "lib-core"
[workspace.lib-utils]
path = "lib-utils"
deps = ["lib-core"]
[workspace.app]
path = "app"
deps = ["lib-core", "lib-utils"]
main = true
```
## Packages
`lib-core/dcr.toml`:
```toml
[package]
name = "lib-core"
version = "0.1.0"
type = "none"
[build]
kind = "staticlib"
```
`lib-utils/dcr.toml`:
```toml
[package]
name = "lib-utils"
version = "0.1.0"
type = "none"
[build]
kind = "staticlib"
```
`app/dcr.toml`:
```toml
[package]
name = "app"
version = "0.1.0"
type = "none"
[build]
kind = "bin"
```
## Build
```bash
cd workspace
dcr build # builds everything in correct order
dcr build --workspace app # only app (lib-core and lib-utils built as deps)
dcr run # builds and runs main package
```
Build order (topological sort):
1. `lib-core`
2. `lib-utils` (depends on lib-core)
3. `app` (depends on lib-core, lib-utils)

View File

@@ -0,0 +1,82 @@
---
sidebar_label: Build profiles
---
# Build Profiles
Profiles allow overriding `[build]` fields for specific build modes.
## Configuration
```toml
[build]
language = "c"
standard = "c17"
cflags = ["-Wall"]
[build.debug]
cflags = ["-O0", "-g"]
[build.release]
cflags = ["-O3", "-DNDEBUG"]
```
## Merge rules
Fields from `[build.\<profile>]` are merged on top of `[build]`:
* **Scalar fields** (strings, numbers, bools) — replaced
* **Arrays** (`cflags`, `ldflags`, ...) — **appended** (extend the `[build]` array)
Set `inherit = false` to disable array inheritance (only profile's own arrays are used).
## Built-in profiles
The default flags for each profile are composed from three config fields:
| Field | debug default | release default |
| ----------- | ------------------ | --------------- |
| `opt_level` | `"0"` | `"3"` |
| `debug` | `true` | `false` |
| `warnings` | `["all", "extra"]` | `[]` |
Which produce the equivalent compiler flags:
| Profile | Effective flags |
| --------- | ---------------------------------------------------------- |
| `debug` | `-O0 -g -Wall -Wextra -fno-omit-frame-pointer -DDCR_DEBUG` |
| `release` | `-O3 -DNDEBUG` |
Additional build options can be toggled per-profile:
```toml
[build.release]
opt_level = "z"
lto = true
strip = true
panic = "abort"
codegen-units = "1"
[build.debug]
opt_level = "1"
debug = false
warnings = ["all", "error"]
```
## Target-specific profiles
```toml
[build.linux]
cflags = ["-DLINUX"]
[build.windows.debug]
cflags = ["-DWIN32", "-O0", "-g"]
```
Application order (highest priority first):
1. `[build.\<target>.\<profile>]`
2. `[build.\<profile>.\<target>]`
3. `[build.\<target>]`
4. `[build.\<profile>]`
5. `[build]`

View File

@@ -0,0 +1,131 @@
---
sidebar_label: Build system
---
# Build System
## Compiler Backends
DCR supports 7 compilation backends. Selection is automatic based on file extension and `build.compiler` value.
| Backend | Files | When used |
| --------- | --------------------------------- | ------------------------------------- |
| `unix_cc` | `.c`, `.cpp`, `.cxx`, `.cc`, `.S` | gcc/clang on Linux/macOS/BSD |
| `msvc` | `.c`, `.cpp`, `.cxx`, `.cc` | Windows (cl, clang-cl) |
| `gas` | `.s` | ARM/ARM64 assembler (no preprocessor) |
| `nasm` | `.asm`, `.s` | x86/x86_64 NASM assembler |
| `masm` | `.asm` | MASM (ml/ml64) on Windows |
| `fasm` | `.asm`, `.fasm` | Flat Assembler |
| `llvm_ir` | `.ll` | LLVM IR via `llc -filetype=obj` |
## Qt Support
DCR provides native Qt support for automatic meta-object handling (MOC, UIC, RCC).
Enable it by setting `build.qt = true` in `dcr.toml`. DCR will automatically detect Qt-related files (`.ui`, `.qrc`, `.h` with `Q_OBJECT`) and process them.
```toml
[build]
qt = true
```
*Note: Requires `qt6` modules (Core, Widgets, Gui, Svg) installed via `pkg-config`.*
Advanced customization is still possible via `build.steps` if special handling is needed:
```toml
[build.steps]
moc = "moc {in} -o {out}"
```
### Unix CC
* Compiler resolved via `resolve_compiler()`: `DCR_COMPILER` > `DCR_CC` > `[toolchain]` > `build.compiler` > `PATH`
* Supports `.d` files for header dependency tracking
* Flags: `-std=`, `-MMD -MF`, `-c -o`, `-I`, `-L`, `-l`
* Conditional flags based on config:
* `freestanding` or bare-metal target: `-ffreestanding` (compile), `-nostdlib -static` (link)
* `lto`: `-flto` (compile + link)
* `panic = "abort"`: `-fno-exceptions` (C++ only), `-fno-unwind-tables`, `-fno-asynchronous-unwind-tables`
### MSVC
* Supports cl.exe and clang-cl.exe
* Flags: `/std:`, `/Fo:`, `/Fe:`, `/I`, `/link`
### GAS / NASM / MASM / FASM / LLVM-IR
* GAS: `-I`, `-c -o`, `--defsym`
* NASM: `-I`, `-o`, `-D`, `-f` (format: win64/elf64/macho64/macho32/elf32)
* MASM: `/nologo /c /Fo\<obj> <source>`
* FASM: `<source> \<output>` (output path is the object file)
* LLVM IR: `-filetype=obj <source> -o \<output>`
## Incremental Builds
Three levels of incrementality:
1. **mtime** — if output is newer than all inputs, skip
2. **`.d` files** — header change tracking (including transitive)
3. **SHA256 fingerprint** — recompile if compiler flags changed (stored in `.dcr_fingerprint`)
## Parallel Compilation
* `thread::scope` for thread pool
* Atomic task queue (`AtomicU64`)
* Mutex on stdout (`OUTPUT_MUTEX`)
* Thread count = `available_parallelism()`, capped by `build.codegen-units` if set
## Build Kinds
| Kind | Type | Path (Linux example) |
| ----------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `bin` | Executable | `target/\<triple>/\<profile>/\<name>` (.exe on Windows) |
| `staticlib` | Static library | `target/\<triple>/\<profile>/lib\<name>.a` (.lib) |
| `sharedlib` | Dynamic library | `target/\<triple>/\<profile>/lib\<name>.so` (.dll/.dylib) |
| `efi` | UEFI application | `target/\<triple>/\<profile>/\<name>.efi` |
| `elf` | ELF without stdlib | `target/\<triple>/\<profile>/\<name>` |
| `none` | Compile only, no link | — |
| `custom` | Full filename+extension control | `target/\<triple>/\<profile>/\<filename>.\<extension>` |
## Build Steps
DCR supports pre-build and post-build steps:
* `build.steps` — commands before compilation
* `build.post_steps` — commands after compilation
Substitutions: `{stem}`, `{in}`, `{out}`, `{profile}`, `{version}`, `{name}`.
Example Qt codegen via build steps:
```toml
[build.steps]
moc = "moc {in} -o {out}"
```
## pkg-config
Automatic lookup (read from raw config):
```toml
[build]
pkg_config = ["sdl2", "gl"]
```
DCR runs `pkg-config --cflags sdl2 gl` and `pkg-config --libs sdl2 gl` and adds results to compiler/linker flags.
## Variable Substitution
Supported variables:
| Variable | Description |
| ----------------------- | ---------------------------- |
| `{version}` | Package version |
| `{version_major}` | Major version part |
| `{version_minor}` | Minor version part |
| `{version_patch}` | Patch version |
| `{version_suffix}` | Suffix (e.g., `-rc1`) |
| `{version_suffix_dash}` | Suffix with dash |
| `{profile}` | Profile name (debug/release) |
| `{name}` | Package name |

View File

@@ -0,0 +1,70 @@
---
sidebar_label: Cross-compilation
---
# Cross-Compilation
## Short Names
DCR supports short platform names:
| Short Name | Full Triple |
| ---------- | -------------------------- |
| `linux` | `x86_64-unknown-linux-gnu` |
| `macos` | `x86_64-apple-darwin` |
| `windows` | `x86_64-pc-windows-msvc` |
```bash
dcr build --target windows
```
## Full Triples
```bash
dcr build --target aarch64-unknown-linux-gnu
dcr build --target x86_64-pc-windows-gnu # mingw
dcr build --target armv7-unknown-linux-gnueabihf
```
## clang --target
When using clang, DCR injects `--target=\<triple>` into CFLAGS.
```toml
[build]
compiler = "clang"
target = "aarch64-unknown-linux-gnu"
# Auto: cflags += ["--target=aarch64-unknown-linux-gnu"]
```
## Bare-Metal / Freestanding
For targets containing `none`, `-elf`, `eabi`, or `baremetal`, DCR automatically:
1. **Disables default flags** — no system include paths, no `-l` libc
2. **Injects `-ffreestanding`** at compile time and `-nostdlib -static` at link time
You can also enable freestanding mode explicitly:
```toml
[build]
freestanding = true
```
```bash
dcr build --target aarch64-none-elf
```
## Target Directory
On Linux with explicit target:
```
target/<triple>/<profile>/
```
On macOS/Windows or without target:
```
target/<profile>/
```

View File

@@ -0,0 +1,152 @@
---
sidebar_label: dcr.toml overview
---
# dcr.toml
Main project configuration file. Located at the project root.
## Structure
```toml
[package]
# required fields
[build]
# build settings
[build.debug] # optional: debug override
[build.release] # optional: release override
[build.linux] # optional: Linux override
[build.windows] # optional: Windows override
[build.windows.debug] # target + profile combination
[toolchain]
# compiler/linker paths
[dependencies]
# project dependencies
[workspace]
# multi-package configuration
[run]
# run settings
```
## [package]
| Field | Required | Description |
| --------- | -------- | ----------------------- |
| `name` | yes | Project name |
| `version` | yes | Semantic version |
| `type` | yes | `app`, `lib`, `none` |
| `license` | no | SPDX license identifier |
| `author` | no | Author |
```toml
[package]
name = "my-app"
version = "0.1.0"
type = "app"
license = "MIT"
author = "John Doe"
```
## [build]
...
* `build.qt` — (bool) Enable automatic Qt meta-object handling (MOC, UIC, RCC). Requires `qt6` modules installed via `pkg-config`.
| Field | Default | Description |
| ---------------- | ------------------------------------------- | --------------------------------------------------------------------- |
| `language` | `"c"` | `"c"`, `"c++"`, `"cpp"`, `"cxx"`, `"asm"` |
| `standard` | `"c11"` | C standard (`c11`, `c17`, `c23`) |
| `cxx_standard` | `"c++20"` | C++ standard (`c++17`, `c++20`, `c++23`) |
| `compiler` | `"clang"` | Preferred compiler |
| `kind` | `"bin"` | `bin`, `staticlib`, `sharedlib`, `efi`, `elf`, `none`, `custom` |
| `target` | host | Target triple for cross-compilation |
| `platform` | `"native"` | `native`, `efi` |
| `cflags` | `[]` | Additional C/C++/ASM flags |
| `ldflags` | `[]` | Additional linker flags |
| `filename` | `""` | Custom output file name |
| `extension` | `""` | Custom file extension |
| `roots` | `["src"]` | Source root directories |
| `exclude` | `[]` | Exclude patterns |
| `include` | `[]` | Additional include directories |
| `src_disable` | `false` | Disable auto source discovery |
| `inherit` | `false` | Inherit build from workspace root |
| `clean` | `[]` | Glob patterns for custom clean paths |
| `out_dir` | `""` | Custom output directory |
| `workspace_only` | `false` | Workspace-only, not built standalone |
| `freestanding` | `false` | Compile in freestanding mode (`-ffreestanding` + `-nostdlib -static`) |
| `opt_level` | `"0"` (debug) / `"3"` (release) | Optimization level: `0`-`3`, `"s"`, `"z"` |
| `debug` | `true` (debug) / `false` (release) | Emit debug symbols (`-g`) |
| `lto` | `false` | Link-time optimization (`-flto` for both compiler and linker) |
| `strip` | `false` | Strip symbols from output (`-s` in ldflags) |
| `warnings` | `["all", "extra"]` (debug) / `[]` (release) | Warning flags (e.g. `"all"`, `"extra"`, `"pedantic"`) |
| `panic` | `""` | Panic strategy: `"abort"` disables exceptions and unwind tables |
| `codegen-units` | `""` | Max parallel compilation jobs (`"0"` = auto) |
| `qt` | `false` | Enable automatic Qt meta-object handling (MOC, UIC, RCC) |
Settings from raw config (not in typed struct):
* `pkg_config` — list of pkg-config packages
* `ldscript` — linker script path
* `build.steps` / `build.post_steps` — codegen steps
Example:
```toml
[build]
language = "c++"
standard = "c23"
cxx_standard = "c++23"
compiler = "clang"
kind = "sharedlib"
cflags = ["-Wall", "-Wextra"]
opt_level = "z"
lto = true
strip = true
panic = "abort"
codegen-units = "2"
```
## [toolchain]
```toml
[toolchain]
cc = "/usr/bin/clang"
cxx = "/usr/bin/clang++"
as = "/usr/bin/as"
ar = "/usr/bin/ar"
ld = "/usr/bin/ld.lld"
```
Raw config also supports `uic`, `moc`, `rcc` for Qt codegen.
## [dependencies]
See [dependencies](/docs/reference/dependencies).
## [run]
```toml
[run]
cmd = "./target/{profile}/{name}"
```
Substitutions:
* `{version}` — package version
* `{version_major}`, `{version_minor}`, `{version_patch}`, `{version_suffix}`, `{version_suffix_dash}` — version parts
* `{profile}` — debug / release
* `{name}` — package name
Default `cmd` = `./target/{profile}/{name}` (macOS/Windows) or `./target/\<triple>/\<profile>/\<name>` (Linux).
## [workspace]
See [workspaces](/docs/reference/workspaces).

View File

@@ -0,0 +1,84 @@
---
sidebar_label: Dependencies
---
# Dependencies
## Formats
The `[dependencies]` section supports three formats:
### String (registry)
```toml
[dependencies]
fmt = "10.1.1"
spdlog = "1.12"
catch2 = "3.4.0"
```
The version string is used as-is for registry lookup.
### Table (git)
```toml
[dependencies]
fmt = { git = "https://github.com/fmtlib/fmt", tag = "10.1.1" }
```
Fields: `git`, `branch`, `tag`, `rev`.
### Table (path)
```toml
[dependencies]
mylib = { path = "../mylib" }
```
## Registry
DCR uses a package registry for dependency lookup by name.
```toml
# ~/.dcr/config.toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```
Registry priority: order in `config.toml`. The `DCR_INDEX_PATH` variable overrides the path to `index.json`.
## Git dependencies
DCR clones git repositories via `git2`:
* `branch` — switch to a branch
* `tag` — switch to a tag
* `rev` — switch to a specific commit
* `features` — feature flags (parsed, but does not affect build)
Cache path: `~/.dcr/git/\<hash>/`.
## Path dependencies
Local paths. DCR automatically discovers include and lib directories from the neighbor's `dcr.toml`.
```toml
[dependencies]
mylib = { path = "/abs/path/to/lib" }
mylib = { path = "../relative/path" }
```
## dcr.lock
Dependency lock file. Contains package names and sources.
Created during `dcr build` when registry dependencies are present. Not updated during `dcr add` — only on the next `dcr build`.
## Resolution process
1. Load all dependencies (registry → git → path)
2. For path deps: recursively read their `dcr.toml`
3. For registry deps: search `index.json`
4. For git deps: clone to cache
5. Collect `include_dirs`, `lib_dirs`, `libs` for the compiler

View File

@@ -0,0 +1,60 @@
---
sidebar_label: Environment variables
---
# Environment Variables
## DCR_COMPILER
Overrides the compiler for all languages. **Highest priority.**
```bash
export DCR_COMPILER=clang
dcr build
```
Compiler resolution priority:
1. `DCR_COMPILER` (env)
2. `DCR_CC` / `DCR_CXX` / `DCR_AS` (env)
3. `[toolchain]` (dcr.toml)
4. `build.compiler` (dcr.toml)
5. `PATH`
## DCR_CC / DCR_CXX / DCR_AS
Per-language override (lower priority than `DCR_COMPILER`, higher than `[toolchain]`).
```bash
export DCR_CC=gcc-14
export DCR_CXX=g++-14
export DCR_AS=arm-linux-gnueabihf-as
```
## DCR_LD / DCR_AR
Override linker and archiver.
```bash
export DCR_LD=ld.lld
export DCR_AR=llvm-ar
```
## DCR_DEBUG
Enables debug mode — prints all compilation commands to stderr before execution.
```bash
export DCR_DEBUG=1
dcr build
```
## DCR_INDEX_PATH
Overrides the path to the registry `index.json`.
```bash
export DCR_INDEX_PATH=/custom/path/index.json
```
Default: `~/.dcr/index.json`.

View File

@@ -0,0 +1,51 @@
---
sidebar_label: Platform support
---
# Platform Support
## Target Triples
DCR normalizes target triples. Short platform names are expanded to full triples.
### Linux
```
target/<arch>-unknown-linux-gnu/<profile>/
```
Architectures: `x86_64`, `aarch64` (host-detected).
Artifact type: ELF. Extensions: `.so` (sharedlib), `.a` (staticlib).
### macOS
```
target/<profile>/
```
Architectures: `x86_64`, `aarch64` (host-detected).
Extensions: `.dylib` (sharedlib), `.a` (staticlib).
### Windows
```
target/<profile>/
```
Architectures: `x86_64`, `aarch64`.
Extensions: `.exe` (bin), `.lib` (staticlib), `.dll` (sharedlib), `.efi` (UEFI).
### BSD
```
target/<arch>-unknown-<os>/<profile>/
```
Supported systems: `freebsd`, `openbsd`, `netbsd`, `dragonfly`.
## Host Detection
DCR uses `std::env::consts::ARCH` and `std::env::consts::OS` for host platform detection. Used as fallback when `target` is not specified.

View File

@@ -0,0 +1,67 @@
---
sidebar_label: Workspaces
---
# Workspaces
Workspaces allow managing multiple packages in a single repository.
## Configuration
```toml
[workspace.lib-core]
path = "lib-core"
[workspace.lib-utils]
path = "lib-utils"
deps = ["lib-core"]
[workspace.app]
path = "app"
deps = ["lib-core", "lib-utils"]
main = true
```
### Member fields
| Field | Description |
| ------ | ------------------------------------------------ |
| `path` | Path to the package (relative to workspace root) |
| `deps` | Dependencies on other members |
| `main` | Mark as the main package |
## Topological sort
DCR automatically sorts packages by dependencies: package A is built before B if B depends on A.
Cyclic dependencies are detected and cause an error.
## Build
```bash
dcr build # build all packages in dependency order
dcr build --workspace app # build only app (dependencies built automatically)
```
When building a workspace, member outputs (libraries) are automatically added to include/lib paths of dependent packages.
## Clean
```bash
dcr clean # clean only root target/
dcr clean --all # clean target/ of all packages
```
## Inheritance
If a member has `inherit = true` in its `[build]` section, fields from the root `[build]` are merged into the member:
```toml
# root dcr.toml
[build]
inherit = true
language = "c"
standard = "c17"
# member inherits language and standard
```

View File

@@ -0,0 +1,46 @@
---
sidebar_label: Self Update
---
# Self Update
## dcr --update
Automatic update to the latest version. Downloads a binary (not an archive) from GitHub Releases and replaces the current executable.
```bash
dcr --update
```
## How it works
1. DCR detects the current platform and architecture
2. Fetches the latest release from `api.github.com/repos/dexoron/dcr/releases/latest`
3. Compares versions
4. Downloads the matching asset (direct binary URL, not archive)
5. Replaces the current executable via `self_replace`
## Asset naming
Pattern: `dcr-\<triple>` or `dcr-\<triple>.exe`
| Platform | Asset name |
| -------------- | -------------------------------- |
| Linux x86_64 | `dcr-x86_64-unknown-linux-gnu` |
| macOS x86_64 | `dcr-x86_64-apple-darwin` |
| macOS ARM64 | `dcr-aarch64-apple-darwin` |
| Windows x86_64 | `dcr-x86_64-pc-windows-msvc.exe` |
## AUR
If DCR was installed via AUR, `--update` shows a warning:
```
Update via package manager: yay/paru -Syu {package_name} or sudo pacman -Syu {package_name}
```
## Errors
* Cannot detect platform — error
* Cannot fetch release — error with URL
* No write permission — error (use `sudo` or manual install)

View File

@@ -0,0 +1,45 @@
---
sidebar_label: Running tests
---
# Running Tests
## Execution
```bash
dcr test
```
Builds the project, then compiles and runs test files from `tests/`.
## Profiles
```bash
dcr test # debug (default)
dcr test --release # release
dcr test --debug # explicit debug
```
## Output
```
=====================
Testsuite summary
=====================
TOTAL: 5
PASS: 3
SKIP: 1
FAIL: 1
=====================
```
## Exit code
* 0 — all tests passed (FAIL = 0)
* 1 — test failures or build error
## What gets built
* All `.c` files from `tests/` (`.cpp` not supported)
* Include path: `tests/` (for `dcr_test.h`)
* Linked with project if `package.type = "lib"` or `kind = "staticlib"`/`"sharedlib"`

View File

@@ -0,0 +1,69 @@
---
sidebar_label: Test framework (EXPECT, TEST, ...)
---
# Test Framework
DCR has a built-in minimal test framework for C.
## Macros
### `EXPECT(expr)`
Asserts that an expression is true.
```c
EXPECT(1 + 1 == 2);
EXPECT(ptr != NULL);
```
### `SKIP(reason)`
Skips a test with a message.
```c
SKIP("not implemented on Windows");
```
### `TEST(name)`
Defines a test.
```c
TEST(addition) {
EXPECT(1 + 1 == 2);
EXPECT(2 + 2 == 4);
}
```
### `TEST_CASE(name)`
Registers a test case.
```c
TEST_CASE(math) {
EXPECT(1 + 1 == 2);
}
```
## Initialization
```bash
dcr test --init
```
Creates:
* `tests/dcr_test.h` — framework header (do not edit)
* `tests/test.c` — template with example test
## Structure
```
tests/
├── dcr_test.h # framework (do not edit)
├── test.c # main tests
└── ... # additional .c test files
```
Only `.c` files are compiled (`.cpp` is not supported).

View File

@@ -0,0 +1,63 @@
---
sidebar_label: Introduction
---
# DCR — C/C++ Build Tool & Package Manager
<details>
<summary>Quick reference</summary>
```bash
# Installation
curl -fsSL https://dcr.dexoron.su/install.sh | sh
# Create a project
dcr new my-app
cd my-app
# Build and run
dcr build
dcr run
# Run tests
dcr test
# Add a dependency
dcr add fmt
# Generate IDE files
dcr gen vscode
```
</details>
## Contents
| Section | Description |
| ----------------------------------------------------- | --------------------------------------------- |
| [Getting Started](/docs/getting-started/installation) | Installation and first steps |
| [Commands](/docs/commands/project-commands) | All CLI commands |
| [Reference](/docs/reference/dcr-toml) | Configuration, build, dependencies, platforms |
| [Testing](/docs/testing/test-framework) | Built-in test framework |
| [Recipes](/docs/recipes/cross-to-windows) | Common scenarios |
| [IDE Integration](/docs/ide-integration) | VS Code, CLion, compile_commands.json |
| [Self Update](/docs/self-update) | Auto-update |
| [FAQ](/docs/faq) | Frequently asked questions |
| [Changelog](/docs/changelog) | Version history |
| [License](/docs/license) | DCR and vendored library licenses |
| [Contributing](/docs/contributing) | DCR development |
## Features
* **Incremental builds** — mtime + `.d` headers + SHA256 fingerprint
* **Parallel compilation** — thread::scope, atomic task queue
* **4 backends** — gcc/clang, MSVC/clang-cl, GAS (ARM), NASM (x86)
* **7 project kinds** — bin, staticlib, sharedlib, efi, elf, none, custom
* **Cross-compilation** — short names and full triples
* **Profiles** — debug / release with field overrides
* **Workspaces** — multi-package projects with topological sort
* **Registry + Git + Path** — three dependency mechanisms
* **IDE generation** — VS Code, CLion, compile_commands.json, JSON metadata
* **pkg-config** — automatic system library discovery
* **Per-command `--help`** — `dcr build --help`, `dcr new --help`, etc.
* **Man pages** — `man dcr`, `man dcr-build`, `man dcr-new`

View File

@@ -0,0 +1,91 @@
---
sidebar_label: Changelog
---
# Changelog
## 0.7.1 (2026-06-02)
### Added
* **`--help` for all commands** — `dcr build --help`, `dcr run --help`, `dcr new --help`,
`dcr init --help`, `dcr clean --help`, `dcr add --help`, `dcr fmt --help`,
`dcr setup --help`, `dcr tree --help`, `dcr gen --help`, `dcr --update --help`,
`dcr test --help`. All output uses styled headers (green) and usage lines (cyan).
* **Man pages** — 12 troff pages in `man/man1/`: `dcr.1`, `dcr-build.1`,
`dcr-run.1`, `dcr-new.1`, `dcr-init.1`, `dcr-clean.1`, `dcr-add.1`, `dcr-test.1`,
`dcr-gen.1`, `dcr-fmt.1`, `dcr-tree.1`, `dcr-setup.1`.
* **Man pages in all packaging** — install.sh, install_bsd.sh, AUR PKGBUILD,
Debian (cargo-deb), RPM (cargo-generate-rpm), Nix (postInstall), Homebrew
(resource), Snap, GitHub Release assets.
* **Project name validation** — `dcr init` and `dcr new` now validate names before
creating files. Only ASCII letters, digits, `_` and `-` are allowed.
* **`documentation` and `homepage` fields** — added to `Cargo.toml`.
* **Release profile optimizations** — `opt-level = "z"`, LTO, `codegen-units = 1`,
`panic = "abort"`, `strip = true` for smaller binaries.
* **Linux i686, armv7, riscv64 targets** — added to release workflow and install scripts.
* **Linux musl i686, armv7 targets** — cross-compiled via zigbuild in CI.
* **AUR packages** — `dcr-dev`, `dcr-dev-bin` publishing workflow.
* **Snap publishing** — automated Snapcraft publishing in CI.
* **Snap badge** — in README.
### Changed
* **`validate_package_name` made public** — callable from CLI commands.
* **README platform table** — reorganized: libc variants as separate OS rows,
removed extra columns. Linux architecture list updated.
* **`gen.rs` no-args output** — now uses styled output instead of raw `eprintln!`.
* **`tree.rs`, `fmt.rs`, and `setup.rs`** — now accept arguments for `--help`.
* **README install commands** — `| bash` → `| sh` for POSIX compatibility.
### Fixed
* **`dcr new \<invalid-name>` creates directory then fails** — validation now
happens before any file operations.
* **`dcr init` on invalid directory name** — same fix.
* **Man pages missing in installed packages** — now shipped in all formats.
* **Windows drive letter false positive** — in dependency file parser.
* **CRLF (`\r\n`) breaks dependency parser** — now handles mixed line endings.
* **Newline after backslash not consumed** — in `parse_d_file` escape handling.
## 0.7.0 (2026-06-01)
### Added
* **OpenBSD and NetBSD target support** — full platform routing with dynamic target triples using `std::env::consts::ARCH` and `std::env::consts::OS`. Affects `build`, `run`, `clean` commands and the platform module.
* **`src/platform/bsd.rs`** — new BSD platform module (shared by FreeBSD, OpenBSD, NetBSD) providing `bin_path`, `lib_path`, `elf_path`, `efi_path`, `shared_lib_path`.
* **`build.out_dir` config option** — custom output directory that overrides the default `target/\<triple>/\<profile>` path for final artifacts. Supported in `build`, `run`, and config validation.
* **`dcr fmt` command** — new CLI command that formats all C/C++ source files (`*.c`, `*.cpp`, `*.h`, `*.hpp`) in `src/` and `tests/` using `clang-format`.
* **Incremental linking** — `needs_link()` in `common.rs` checks if any object file is newer than the linked output, skipping unnecessary relinking. Implemented for all backends (`unix_cc`, `msvc`, `gas`, `nasm`).
* **`build.kind = "none"` and `"custom"`** — two new project kinds for special build scenarios that don't produce standard artifacts.
* **`install_bsd.sh`** — POSIX-compliant installation script for BSD systems (FreeBSD, OpenBSD, NetBSD) with binary download and source build modes.
* **Linux ARM64 support in `install.sh`** — added `Linux:aarch64|Linux:arm64` target detection for pre-built binary downloads.
* **BSD OS detection in `install.sh`** — detects FreeBSD, OpenBSD, NetBSD and determines target triple.
* **`rust-toolchain.toml`** — explicit toolchain pinning to `stable` channel.
* **Integration tests** — `build_with_target_config` (verifies `build.target = "linux"`) and `build_with_out_dir` (validates custom output directory).
* **`get_build_string_with_profile` made `pub`** — so `run.rs` can determine custom output directory configuration.
### Changed
* **`build.target` semantics changed** — now strictly contains a target triple (e.g., `x86_64-unknown-linux-gnu`) or short name (`linux`, `macos`, `windows`). No longer used as custom output directory — this functionality moved to `build.out_dir`.
* **`build.standard` made optional** — changed from `String` to `Option\<String>`. Validation only enforces non-empty for non-ASM languages. Skipped in `dcr.toml` output if empty.
* **`dcr run` with `out_dir`** — now determines target directory respecting `build.out_dir` via `get_build_string_with_profile()` from `build.rs`.
* **`collect_sources()` returns empty vector** instead of error when no sources are found, allowing `kind = "none"` or `kind = "custom"` projects with no source files.
* **CI/CD release workflow refactored** — `git2` made target-specific (no vendored-openssl on Windows), Zig-based cross-compilation for non-x86_64 Linux targets, Arch Linux package version cleanup (dashes → dots), `gmake` symlink for NetBSD.
* **README compatibility table** — FreeBSD, OpenBSD, NetBSD build/run status upgraded from "community/best-effort" to "officially supported".
* **Documentation updated** — `build-section.md` describes new `build.target` and `build.out_dir` fields. `target-directory.md` rewritten to clarify the distinction.
### Fixed
* **stdout/stderr not inherited in `dcr run`** — child process output was captured and manually printed, breaking interactive programs. Fixed by switching to `Command::status()`.
* **Race condition in release CI** — matrix build jobs could upload assets to a release that didn't exist yet. Fixed by adding a dedicated `create-release` job.
* **Release GHA — stable toolchain override** — fixed Rust toolchain override issues in CI.
* **Arch Linux package version sanitization** — version strings with dashes (e.g., `0.7.0-dev`) are invalid for `pkgver`. Fixed by replacing dashes with dots.
* **GPG permissions after Docker** — Docker operations changed GPG directory ownership. Fixed by running `chown` after Docker commands.
* **RPM artifact paths** — RPM artifacts were placed in `rpm/x86_64/` instead of `fedora/x86_64/`. Fixed in Dexoron Packages Index workflow.
* **JSON parsing reliability in `install.sh`** — added `jq` as primary parser with `python3` fallback for dev channel release lookup.
### Removed
* **`format_roots()` helper function** — removed from `common.rs`. Was only used by the old error handling path in `collect_sources()`.
* **Per-distribution artifact download steps** — three separate `actions/download-artifact` steps replaced with unified `gh release download --clobber`.

View File

@@ -0,0 +1,42 @@
---
sidebar_label: Build commands (build, run, clean)
---
# Build Commands
## `dcr build`
Builds the project according to `dcr.toml`.
```bash
dcr build # debug profile
dcr build --release # release build
dcr build --debug # explicit debug
dcr build --target aarch64-unknown-linux-gnu
dcr build --force # full rebuild
dcr build --clean # clean + build
dcr build --verbose # show compilation commands
dcr build --workspace pkg-a # build specific workspace package
```
Artifacts: `target/\<triple>/\<profile>/\<binary-name>` (Linux with explicit target).
## `dcr run`
Builds (if sources are newer than artifacts) and runs the binary.
```bash
dcr run
dcr run --release
```
## `dcr clean`
Removes `target/` directory (or `target/\<target>/\<profile>`).
```bash
dcr clean
dcr clean --release # target/release/ only
dcr clean --target windows # target/x86_64-pc-windows-msvc/
dcr clean --all # clean all workspace packages
```

View File

@@ -0,0 +1,53 @@
---
sidebar_label: Dependency commands (add, tree)
---
# Dependency Commands
## `dcr add \<name> [source]`
Adds a dependency to `dcr.toml`.
```bash
dcr add fmt # registry lookup
dcr add mylib ../path/to/lib # path as source
dcr add mylib path:./lib # explicit path prefix
dcr add mylib git:https://github.com/user/repo # explicit git prefix
dcr add mylib github:user/repo # GitHub shorthand
dcr add mylib gitlab:user/repo # GitLab shorthand
```
Source prefixes:
* `path:` — local path
* `git:` — generic git URL
* `github:` — expands to `https://github.com/\<user>/\<repo>`
* `gitlab:` — expands to `https://gitlab.com/\<user>/\<repo>`
* `http://` / `https://` / `git@` — full URL
Flags:
* `--branch \<name>` — git branch
* `--tag \<name>` — git tag
* `--rev \<hash>` — git commit
If source is omitted — DCR searches connected registries.
## `dcr tree`
Displays the project dependency tree.
```bash
dcr tree
```
Example output:
```
my-app v0.1.0
├── fmt (registry)
│ └── spdlog (registry)
└── catch2 (registry)
```
For path dependencies, recursively shows their own dependencies (from their `dcr.toml`).

View File

@@ -0,0 +1,73 @@
---
sidebar_label: Gen commands (vscode, clion, ...)
---
# Gen Commands
## `dcr gen \<target>`
Generates IDE integration files.
### vscode
```bash
dcr gen vscode
```
Creates:
* `.vscode/tasks.json` — `build` task (dcr build)
* `.vscode/launch.json` — debug launch configuration
* `.vscode/settings.json` — C/C++ settings (clangd paths, includes)
* `.vscode/extensions.json` — recommended extensions (vscode-clangd, vscode-lldb)
### clion
```bash
dcr gen clion
```
Creates:
* `.idea/externalTools.xml` — external tools (build, run, clean, test)
* `.idea/customTargets.xml` — custom build targets
* `.idea/misc.xml` — C/C++ project settings
* `.idea/runConfigurations/\<name>.xml` — per-binary run configurations
### compile-commands
```bash
dcr gen compile-commands
```
Generates `compile_commands.json` — standard format for clangd, cpptools, static analyzers.
### project-info
```bash
dcr gen project-info
```
Outputs JSON array with project metadata:
```json
[
{
"name": "my-app",
"version": "0.1.0",
"root": "/path/to/project",
"profile": "debug",
"language": "c",
"standard": "c17",
"cxx_standard": null,
"compiler": "/usr/bin/clang",
"kind": "bin",
"sources": ["src/main.c"],
"include_dirs": ["src"],
"lib_dirs": [],
"libs": [],
"cflags": ["-std=c17", "-O0", "-g"],
"ldflags": []
}
]
```

View File

@@ -0,0 +1,31 @@
---
sidebar_label: Project commands (new, init)
---
# Project Commands
## `dcr new \<name>`
Creates a new project with a standard structure and `dcr.toml`. The `name` argument is required.
Only ASCII letters, digits, underscores `_` and hyphens `-` are allowed in the project name.
```bash
dcr new my-app
```
Generates:
* `dcr.toml` with basic fields
* `src/main.c` with a `main` template
## `dcr init`
Initializes a DCR project in the current (empty) directory.
```bash
mkdir app && cd app
dcr init
```
The project name is taken from the current directory name. The directory name must follow the same naming rules as `dcr new`.

View File

@@ -0,0 +1,60 @@
---
sidebar_label: Quality commands (test, fmt)
---
# Quality Commands
## `dcr test`
Runs tests.
```bash
dcr test # debug profile
dcr test --release # release profile
dcr test --debug # explicit debug
dcr test --help # detailed help
```
Before first use, initialize tests:
```bash
dcr test --init
```
This creates `tests/dcr_test.h` (framework) and `tests/test.c` (template).
What `dcr test` does:
1. Builds the project
2. Collects `tests/*.c` files (`.c` only, not `.cpp`)
3. Compiles and links each test file
4. Runs each test binary
5. Prints summary: TOTAL, PASS, SKIP, FAIL
6. Returns non-zero exit code on any FAIL
## `dcr fmt`
Formats C/C++ source files using `clang-format`.
```bash
dcr fmt
```
Processes: `src/**/*.{c,cpp,cxx,cc,h,hpp,hxx,hh}` and `tests/**/*.{c,cpp,cxx,cc,h,hpp,hxx,hh}`.
Uses `.clang-format` at the project root (if present), otherwise default clang-format style.
## `dcr lint`
Runs `clang-tidy` on C/C++ source files for static analysis.
```bash
dcr lint # show diagnostics
dcr lint --fix # apply fixes automatically
dcr lint --help # detailed help
```
Processes: `src/**/*.{c,cpp,cxx,cc}` and `tests/**/*.{c,cpp,cxx,cc}`.
Without `--fix`, clang-tidy reports warnings and errors without modifying files.
With `--fix`, clang-tidy applies automatic suggestions in place.

View File

@@ -0,0 +1,51 @@
---
sidebar_label: System commands (setup, --help, ...)
---
# System Commands
## `dcr setup`
Shows configured registries from `~/.dcr/config.toml`.
```bash
dcr setup
```
If `~/.dcr/config.toml` is not found, DCR returns an error. Create it manually:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```
## `dcr --help`
Shows help for all commands.
```bash
dcr --help
```
## `dcr --version`
Shows version and target triple.
```bash
dcr --version # dcr 0.7.0 (x86_64-unknown-linux-gnu)
```
## `dcr --update`
Self-update. Downloads the latest release binary from GitHub Releases and replaces the current one.
```bash
dcr --update
```
Features:
* Auto-detects platform and architecture
* Warns if installed via AUR (use package manager instead)
* Works on Linux, macOS, Windows

View File

@@ -0,0 +1,51 @@
---
sidebar_label: Contributing
---
# Contributing
## Setup
```bash
git clone https://github.com/dexoron/dcr
cd dcr
cargo build
```
## Code style
All code must be formatted with `cargo fmt`:
```bash
cargo fmt
```
## Linting
```bash
cargo clippy --all-targets -- -D warnings
```
## Tests
```bash
cargo test --all-targets
```
## PR process
1. Fork the repository
2. Create a branch: `git checkout -b feature/description`
3. Make changes
4. Run `cargo fmt && cargo clippy && cargo test`
5. Open a Pull Request
## CI
CI runs:
* `cargo fmt --check`
* `cargo clippy --all-targets -- -D warnings`
* `cargo test --all-targets`
* Build on Linux, macOS, Windows
* Integration tests

View File

@@ -0,0 +1,81 @@
---
sidebar_label: FAQ
---
# FAQ
## Registry not found
```
error: registry not found
```
**Solution:** Make sure `~/.dcr/config.toml` exists:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```
And check `DCR_INDEX_PATH`:
```bash
echo $DCR_INDEX_PATH
```
## Compiler not found
```
error: compiler not found
```
**Solution:** Ensure a compiler is installed and available in PATH.
```bash
which gcc
which clang
```
Or specify explicitly via `[toolchain]` in `dcr.toml`.
## openssl-sys build failed
When building DCR from source:
```
error: failed to run custom build command for openssl-sys
```
**Solution:** Install OpenSSL development headers:
```bash
# Ubuntu/Debian
sudo apt install libssl-dev
# Fedora
sudo dnf install openssl-devel
# macOS
brew install openssl
```
## Ctrl+C during build
DCR handles SIGINT: interrupts the current compilation and exits with non-zero code.
## How to create a library?
See [Library Recipe](/docs/recipes/library-project).
## How to cross-compile to Windows?
See [Cross-Compile Recipe](/docs/recipes/cross-to-windows).
## How to create a multi-package project?
See [Workspace Recipe](/docs/recipes/multi-package-workspace).
## Lock file
`dcr.lock` is created during builds (`dcr build`) when registry dependencies are present. To force an update — delete `dcr.lock` and run `dcr build`.

View File

@@ -0,0 +1,72 @@
---
sidebar_label: First steps
---
# First Steps
## Create a project
```bash
dcr new my-app
cd my-app
```
Structure:
```
my-app/
├── dcr.toml
└── src/
└── main.c
```
`dcr.toml`:
```toml
[package]
name = "my-app"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
compiler = "clang"
kind = "bin"
```
## Build
```bash
dcr build
```
Output — `target/\<triple>/debug/my-app` (Linux) or `target/debug/my-app.exe` (Windows).
Build profiles:
```bash
dcr build --release # release build
dcr build --debug # debug (default)
```
## Run
```bash
dcr run
```
Builds (if needed) and runs the binary.
## First test
```bash
dcr test --init # create test template
dcr test # run tests
```
## Formatting
```bash
dcr fmt # clang-format with .clang-format
```

View File

@@ -0,0 +1,109 @@
---
sidebar_label: Installation
---
# Installation
## Linux (Dexoron Packages)
Configure your package manager at https://pkg.dexoron.su and install:
**Arch Linux**
```sh
sudo pacman -Sy dcr
```
**Debian/Ubuntu**
```sh
sudo apt update && sudo apt install dcr
```
**Fedora/RHEL**
```sh
sudo dnf install dcr
```
## Arch Linux (AUR)
```sh
yay -S dcr
```
## macOS / Linux (Homebrew)
```sh
brew tap dexoron/dexoron
brew install dcr
```
## Snap (Linux)
```sh
sudo snap install dcrup
```
## Nix (flake)
```sh
nix run github:dexoron/dcr
# or install to profile:
nix profile install github:dexoron/dcr
```
## Cargo (crates.io)
```sh
cargo install dcr
```
## Linux / macOS (script)
```sh
curl -fsSL https://dcr.dexoron.su/install.sh | sh
```
## BSD (script)
```sh
curl -fsSL https://dcr.dexoron.su/install_bsd.sh | sh
```
## Windows (PowerShell)
```powershell
irm https://dcr.dexoron.su/install.ps1 | iex
```
## From source
```sh
git clone https://github.com/dexoron/dcr.git
cd dcr && cargo build --release
ln -sf "$PWD/target/release/dcr" ~/.local/bin/dcr
```
## Post-install
Verify the installation:
```bash
dcr --version
```
Man pages are available after installation:
```bash
man dcr
man dcr-build
```
To use the registry, create `~/.dcr/config.toml`:
```toml
[[registry]]
name = "default"
url = "https://index.dcr.pm"
```

View File

@@ -0,0 +1,51 @@
---
sidebar_label: IDE Integration
---
# IDE Integration
## VS Code
```bash
dcr gen vscode
```
Generates in `.vscode/`:
| File | Purpose |
| ----------------- | -------------------------------------------- |
| `tasks.json` | `build` task (dcr build) |
| `launch.json` | Debug launch configuration |
| `settings.json` | clangd/IntelliSense: include paths, standard |
| `extensions.json` | Recommends vscode-clangd, vscode-lldb |
## CLion
```bash
dcr gen clion
```
Generates in `.idea/`:
| File | Purpose |
| ------------------------------------------------ | ----------------------------------------- |
| `externalTools.xml` | Build, Run, Clean, Test as external tools |
| `customTargets.xml` | Custom build targets |
| `misc.xml` | C/C++ project settings |
| `runConfigurations/\<name>.xml` | Per-binary run configurations |
## compile_commands.json
```bash
dcr gen compile-commands
```
Generates `compile_commands.json` at project root. Standard format for clangd, C/C++ IntelliSense, static analyzers.
## project-info
```bash
dcr gen project-info
```
Outputs JSON array with project metadata (see [gen-commands](/docs/commands/gen-commands)).

View File

@@ -0,0 +1,46 @@
---
sidebar_label: License
---
# License
## DCR
DCR itself is [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later.html) licensed.
> **Note:** DCR is a build tool, not a library. The GPL applies only to DCR's own source code. Projects built with DCR are not subject to DCR's license — their licensing is determined solely by their own code and dependencies.
## Vendored libraries
DCR statically links the following C libraries through its vendored Rust dependencies:
| Library | License | Bundled by |
| ------------------------------------------ | ------------------ | ----------------------------- |
| [libgit2](https://libgit2.org) | MIT OR Apache-2.0 | `git2` / `libgit2-sys` |
| [libssh2](https://libssh2.org) | MIT OR Apache-2.0 | `libgit2-sys` |
| [zlib](https://zlib.net) | MIT OR Apache-2.0 | `libgit2-sys` |
| [OpenSSL](https://openssl.org) | Apache-2.0 | `openssl-sys` / `openssl-src` |
| [ring](https://github.com/briansmith/ring) | Apache-2.0 AND ISC | `rustls` |
## Rust dependencies
DCR is written in Rust. The following notable Rust crates are statically linked:
| Crate | License |
| --------------------------------------------- | ------------------------ |
| [`reqwest`](https://crates.io/crates/reqwest) | MIT OR Apache-2.0 |
| [`rustls`](https://crates.io/crates/rustls) | Apache-2.0 OR ISC OR MIT |
| [`serde`](https://crates.io/crates/serde) | MIT OR Apache-2.0 |
| [`toml`](https://crates.io/crates/toml) | MIT OR Apache-2.0 |
| [`sha2`](https://crates.io/crates/sha2) | MIT OR Apache-2.0 |
| [`git2`](https://crates.io/crates/git2) | MIT OR Apache-2.0 |
| [`openssl`](https://crates.io/crates/openssl) | Apache-2.0 |
| [`tokio`](https://crates.io/crates/tokio) | MIT |
| [`hyper`](https://crates.io/crates/hyper) | MIT |
| [`ctrlc`](https://crates.io/crates/ctrlc) | MIT OR Apache-2.0 |
Full dependency tree (143 packages) is available in [`Cargo.lock`](https://github.com/dexoron/dcr/blob/main/Cargo.lock). The overwhelming majority are dual-licensed under MIT OR Apache-2.0.
## Additional credits
* DCR's CLI design and project model are inspired by [Cargo](https://doc.rust-lang.org/cargo/).

View File

@@ -0,0 +1,49 @@
---
sidebar_label: Cross-compile to Windows
---
# Cross-Compile to Windows from Linux
Building a Windows binary on Linux using mingw-w64.
## Install toolchain
```bash
# Ubuntu/Debian
sudo apt install mingw-w64
# Fedora
sudo dnf install mingw64-gcc mingw64-binutils
```
## Configuration
```toml
[package]
name = "my-app"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
compiler = "clang"
kind = "bin"
target = "x86_64-pc-windows-gnu" # explicit mingw, not msvc
```
## Build
```bash
dcr build --target x86_64-pc-windows-gnu --release
```
Artifact: `target/x86_64-pc-windows-gnu/release/my-app.exe`.
## Custom toolchain
```toml
[toolchain]
cc = "x86_64-w64-mingw32-gcc"
cxx = "x86_64-w64-mingw32-g++"
```

View File

@@ -0,0 +1,70 @@
---
sidebar_label: Library project
---
# Library Project
Creating a static library and using it in another project.
## Step 1: Create the library
```bash
dcr new my-lib
cd my-lib
```
`dcr.toml`:
```toml
[package]
name = "my-lib"
version = "0.1.0"
type = "none"
[build]
language = "c"
standard = "c11"
kind = "staticlib"
```
`src/my_lib.h`:
```c
#ifndef MY_LIB_H
#define MY_LIB_H
int add(int a, int b);
#endif
```
`src/my_lib.c`:
```c
#include "my_lib.h"
int add(int a, int b) { return a + b; }
```
## Step 2: Build
```bash
dcr build --release
```
Artifacts:
* `target/\<triple>/release/libmy-lib.a` (Linux)
* `target/release/my-lib.lib` (Windows)
* `target/include/` — header files
## Step 3: Use in another project
```bash
dcr new my-app
cd my-app
dcr add my-lib ../my-lib
```
Automatically:
* Adds include path to `target/include/` of the library
* Adds lib path to `target/\<triple>/release/`
* Links `libmy-lib.a` / `my-lib.lib`

Some files were not shown because too many files have changed in this diff Show More