mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 08:48:30 +00:00
175 lines
4.7 KiB
Plaintext
175 lines
4.7 KiB
Plaintext
---
|
|
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` | no | `app`, `lib`, `none` (defaults to `"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"` (optional, defaults to `"c"`) |
|
|
| `standard` | `"c11"` | C standard (`c11`, `c17`, `c23`) |
|
|
| `cxx_standard` | — | C++ standard (`c++17`, `c++20`, `c++23`) |
|
|
| `compiler` | `"clang"` | Preferred compiler (optional, defaults to `"clang"`) |
|
|
| `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 (no `language`/`compiler` required) |
|
|
| `freestanding` | `false` | Compile in freestanding mode (`-ffreestanding` + `-nostdlib -static`) |
|
|
| `opt_level` | — | Optimization level: `0`-`3`, `"s"`, `"z"` (derived from profile if omitted) |
|
|
| `debug` | profile-based | Emit debug symbols (`-g`): `true` in debug, `false` in release |
|
|
| `lto` | `false` | Link-time optimization (`-flto` for both compiler and linker) |
|
|
| `strip` | `false` | Strip symbols from output (`-s` in ldflags) |
|
|
| `warnings` | `[]` | Warning flags (e.g. `"all"`, `"extra"`, `"pedantic"`); engine adds `-Wall -Wextra` in debug if empty |
|
|
| `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
|
|
|
|
## Per-language overrides: `[build.c]`, `[build.cxx]`, `[build.asm]`
|
|
|
|
Each language can have its own table that overrides the flat `[build]` settings:
|
|
|
|
```toml
|
|
[build]
|
|
compiler = "clang"
|
|
standard = "c11"
|
|
|
|
[build.c]
|
|
standard = "c23"
|
|
compiler = "gcc"
|
|
|
|
[build.cxx]
|
|
standard = "c++23"
|
|
compiler = "g++"
|
|
|
|
[build.asm]
|
|
compiler = "nasm"
|
|
flags = ["-felf64"]
|
|
```
|
|
|
|
The flat `[build]` acts as fallback; per-language tables take precedence for their language.
|
|
|
|
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).
|