--- sidebar_label: Обзор dcr.toml --- # Обзор dcr.toml Основной конфигурационный файл проекта. Располагается в корне проекта. ## Структура ```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 [archive] # optional: pack FAT disk image after build ``` ## [пакет] | Поле | Обязательное | Описание | | ---------- | ------------ | ------------------------------------------- | | `имя` | да | Имя проекта | | `версия` | да | Семантическая версия | | `тип` | no | `app`, `lib`, `none` (defaults to `"none"`) | | `лицензия` | нет | SPDX-идентификатор лицензии | | `автор` | нет | Автор | ```toml [package] name = "my-app" version = "0.1.0" type = "app" license = "MIT" author = "John Doe" ``` ## [сборка] ... * `build.qt` — (bool) Включить автоматическую обработку метаобъектов Qt (MOC, UIC, RCC). Требуется установка модулей `qt6` с помощью `pkg-config`. | Поле | По умолчанию | Описание | | ------------------------ | ------------- | --------------------------------------------------------------------------------------------------------- | | `язык` | `"c"` | `"c"`, `"c++"`, `"cpp"`, `"cxx"`, `"asm"`, `"llvm_ir"`, `"llvm-ir"`, `"ll"` (optional, defaults to `"c"`) | | `стандартный` | `"c11"` | Стандарт C (`c11`, `c17`, `c23`) | | `cxx_standard` | — | Стандарт C++ (`c++17`, `c++20`, `c++23`) | | `компилятор` | `cxxflags` | Preferred compiler (optional, defaults to `"clang"`) | | `тип` | `"bin"` | `bin`, `staticlib`, `sharedlib`, `efi`, `elf`, `none`, `custom`, `flat-bin` | | `target` | хост | Target triple для кросс-компиляции | | `платформа` | `"нативный"` | `native`, `efi`, `freestanding` | | `cflags` | `[]` | Дополнительные флаги C++ | | `ldflags` | `[]` | Дополнительные флаги линковки | | `имя файла` | `""` | Кастомное имя выходного файла | | `расширение` | `""` | Custom file extension (for `flat-bin`, default is `bin`) | | `корни` | `["src"]` | Source roots: directories and/or individual source/header files | | `exclude` | `[]` | Паттерны исключений | | `include` | `[]` | Дополнительные include-директории | | `src_disable` | `false` | Отключить автоматический поиск источников | | `наследовать` | `false` | Наследовать build от корня workspace | | `clean` | `[]` | Шаблоны Glob для настраиваемых чистых путей | | `out_dir` | `""` | Пользовательский каталог для вывода данных | | `только рабочая область` | `false` | Workspace-only, not built standalone (no `language`/`compiler` required) | | `отдельно стоящий` | `false` | Компилировать в автономном режиме (`-ffreestanding` + `-nostdlib -static`) | | `opt_level` | — | Optimization level: `0`-`3`, `"s"`, `"z"` (derived from profile if omitted) | | `ldscript` | profile-based | Emit debug symbols (`-g`): `true` in debug, `false` in release | | `lto` | `false` | Оптимизация на этапе компоновки (`-flto` как для компилятора, так и для компоновщика) | | `asflags` | `false` | Удалить символы из вывода (опция `-s` в ldflags) | | `true` | `[]` | Warning flags (e.g. `"all"`, `"extra"`, `"pedantic"`); engine adds `-Wall -Wextra` in debug if empty | | `panic` | `""` | Стратегия «Паника»: `"abort"` отключает исключения и таблицы развертки | | `codegen-units` | `""` | Максимальное количество параллельных заданий компиляции (`"0"` = автоматически) | | `qt` | `false` | Включить автоматическую обработку метаобъектов Qt (MOC, UIC, RCC) | Параметры из исходного файла конфигурации (не в виде типизированной структуры): * Пакеты для pkg-config * Путь к linker script * `build.steps` / `build.post_steps` — этапы генерации кода ## Per-language overrides: `[build.c]`, `[build.cxx]`, `[build.asm]`, `[build.llvm_ir]` 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"] [build.llvm_ir] compiler = "llc" ``` The flat `[build]` acts as fallback; per-language tables take precedence for their language. Пример: ```toml [build] language = ["cpp", "c"] standard = "c17" standard = "c23" cxx_standard = "c++23" compiler = "clang" kind = "sharedlib" cflags = ["-Wall", "-Wextra"] pkg_config = ["sdl2", "gl"] ``` ## [набор инструментов] ```toml [toolchain] cc = "/usr/bin/clang" cxx = "/usr/bin/clang++" as = "/usr/bin/as" ar = "/usr/bin/ar" ld = "/usr/bin/ld.lld" uic = "/usr/bin/uic" # Qt moc = "/usr/bin/moc" # Qt rcc = "/usr/bin/rcc" # Qt ``` Raw config также поддерживает `uic`, `moc` и `rcc` для генерации кода Qt. ## [зависимости] См. [dependencies](/docs/reference/dependencies). ## [запустить] ```toml [запустить] cmd = "./target/{profile}/{name}" ``` Подстановки: * `{version}` — версия из [package] * `pkg_config` * `{profile}` — отладочная / релизная версия * `{name}` — имя из [package] По умолчанию `cmd` вычисляется как `./target/{profile}/{name}`. ## [рабочая область] См. [workspaces](/docs/reference/workspaces). ## [archive] Optional post-build step: format a FAT volume and copy built artifacts into a disk image. Runs after a successful package build (and after workspace member builds that define `[archive]`). Requires DCR built with the `archive` Cargo feature (`cargo build --features archive`). Release binaries include this feature. | Field | Required | Description | | ------------ | -------- | ------------------------------------------------------------------------------------------- | | `output` | yes | Image path relative to project root (`{profile}` allowed) | | `format` | yes | `fat12`, `fat16`, or `fat32` | | `size` | no | Image size: bytes or `K`/`KB`/`M`/`MB`/`G`/`GB` (default `1474560` ≈ 1.44 MiB) | | `offset` | no | Byte offset of the FAT volume inside the image (default `0`) | | `label` | no | Volume label (max 11 chars, default `VOLUME`) | | `bootsector` | no | Path to a 512-byte boot sector written at offset 0 when `offset` is 0 (`{profile}` allowed) | | `layout` | no | List of `{ from, to }` entries (files or globs → path inside the volume) | ```toml [archive] output = "target/{profile}/disk.img" format = "fat12" size = "1440K" label = "MYOS" bootsector = "target/{profile}/boot.bin" [[archive.layout]] from = "target/{profile}/kernel.bin" to = "KERNEL.BIN" [[archive.layout]] from = "assets/*" to = "/" ``` Typical pairing with `kind = "flat-bin"` (NASM `-f bin`) for bootloaders and pure-ASM OS images. ## `flat-bin` (kind) Produces a raw binary (default extension `bin`) for boot sectors, kernels, and freestanding payloads. ### Assemblers | Tool | Language / compiler | How flat-bin is produced | | ---- | ------------------------------------------ | -------------------------------------------- | | NASM | `language = "asm"`, `compiler = "nasm"` | `-f bin` → `\.bin` | | FASM | `compiler = "fasm"` | direct write (use `format binary` in source) | | GAS | `compiler = "as"` / `"gas"` | assemble → `objcopy -O binary` | | MASM | `compiler = "ml"` / `"ml64"` | assemble → `objcopy -O binary` | | LLC | `language = "llvm_ir"`, `compiler = "llc"` | `-filetype=obj` → `objcopy -O binary` | ```toml [build] language = "asm" compiler = "nasm" kind = "flat-bin" extension = "bin" roots = ["src/boot.asm"] ``` ### C / C++ Compile all sources, link with `-nostdlib -static` (plus your `ldflags` / `ldscript`), then convert the intermediate ELF/PE with `objcopy -O binary` to `\.bin`. ```toml [build] language = "c" compiler = "clang" kind = "flat-bin" freestanding = true filename = "kernel" extension = "bin" ldscript = "linker.ld" ldflags = ["-T", "linker.ld"] ``` Notes: * Multi-file **ASM** packages emit one `\.bin` per source; **C/C++** emit a single project binary. * `objcopy` tools tried in order: `llvm-objcopy`, `objcopy`, `gobjcopy`. * Incompatible with `build.qt = true`. * `dcr run` rejects `flat-bin` (not a host executable).