mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 09:18:29 +00:00
Compare commits
52 Commits
e72bc4e778
...
47d88d13ff
| Author | SHA1 | Date | |
|---|---|---|---|
| 47d88d13ff | |||
| f56f23b501 | |||
| fc75d6239a | |||
| edf1c6d181 | |||
| f104472a7e | |||
| 39a99e85fd | |||
| 42c5cbe97e | |||
| 9a18dae5fd | |||
| 7287af6a84 | |||
| f1b66c511d | |||
| fd6077ff74 | |||
| 983ca31a0e | |||
| 0fcfc41f1b | |||
| a0da1bc328 | |||
| d334d2bcb3 | |||
| 781081f791 | |||
| 80355ab713 | |||
| 5aee983fd4 | |||
| 1cb585b2b2 | |||
| 638f26c5df | |||
| 054e715b06 | |||
| 1960f354ef | |||
| e41b69f0e2 | |||
| c10fbccfef | |||
| 52dd403065 | |||
| 39f6817481 | |||
| 3caa5e0fc8 | |||
| bb5be69f89 | |||
| 20d7c33440 | |||
| 8579a22127 | |||
| c2e66576d5 | |||
| e011803ad7 | |||
| ea96f279cc | |||
| 5f80e65b4c | |||
| 91bc295f41 | |||
| 6c23a8316a | |||
| d50ae819f8 | |||
| 084059d414 | |||
| 92f02abfd3 | |||
| f9ad515f4c | |||
| 5222038639 | |||
| 5fabc5b432 | |||
| 18736a544a | |||
| fc6edd6a56 | |||
| 493da800bf | |||
| ccc4749eb8 | |||
| 533874a331 | |||
| 87b9828511 | |||
| 4901ad59d6 | |||
| e42fc593c5 | |||
| 3b6aca3560 | |||
| 5b1f774ac6 |
@@ -51,8 +51,9 @@ dcr gen vscode
|
||||
|
||||
* **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
|
||||
* **7 backends** — gcc/clang (unix_cc), MSVC/clang-cl (msvc), GAS, NASM, MASM, FASM, LLVM IR
|
||||
* **8 project kinds** — bin, staticlib, sharedlib, efi, elf, none, custom, flat-bin
|
||||
* **Disk images** — optional `[archive]` packs FAT12/16/32 images after build
|
||||
* **Cross-compilation** — short names and full triples
|
||||
* **Profiles** — debug / release with field overrides
|
||||
* **Workspaces** — multi-package projects with topological sort
|
||||
|
||||
@@ -4,6 +4,108 @@ sidebar_label: Changelog
|
||||
|
||||
# Changelog
|
||||
|
||||
## 0.8.1 (2026-07-20)
|
||||
|
||||
### Added
|
||||
|
||||
* **`build.kind = "flat-bin"`** — raw binary (default `.bin`) for OS-dev payloads:
|
||||
* **NASM** — `-f bin` → `\<stem>.bin`
|
||||
* **FASM** — direct output (`format binary` in source)
|
||||
* **GAS / MASM / LLC** — object → `objcopy -O binary` → `\<stem>.bin`
|
||||
* **C/C++** — objects → freestanding link → `objcopy -O binary` → `\<name>.bin`
|
||||
* Requires `llvm-objcopy` / `objcopy` / `gobjcopy` except for NASM/FASM direct emit
|
||||
* **`[archive]` section** — after a successful build, pack a FAT disk image (`fatfs`): `output`, `format` (`fat12`/`fat16`/`fat32`), optional `size` (default 1.44 MiB), `offset`, `label`, `bootsector`, and `layout` (`from` → `to`, supports globs). `{profile}` works in paths.
|
||||
* **Single-file `build.roots`** — a root may be a single source or header file, not only a directory.
|
||||
|
||||
### Changed
|
||||
|
||||
* **`--force`** also re-runs `build.steps` and `build.post_steps`.
|
||||
* **`dcr run` on workspace-only root** — if `[run].cmd` is set, run that after build; otherwise delegate to a workspace member.
|
||||
|
||||
### Dependencies
|
||||
|
||||
* `fatfs = "0.3"` for FAT image packing.
|
||||
|
||||
## 0.8.0 (2026-07-18)
|
||||
|
||||
### Added
|
||||
|
||||
* **Dedicated Build Engine (`src/core/build/engine.rs`)** — decoupled the build orchestration logic completely from the CLI front-end wrapper in `src/cli/build.rs` to a reusable, decoupled core build engine.
|
||||
* **Polymorphic Language Model (`Language` trait)** — introduced the abstract `Language` trait (`src/core/build/language/mod.rs`). File scanning, compiler resolution, and flags handling are now encapsulated in dedicated language modules for C, C++ (including Qt code generation), LLVM IR, and ASM (GAS, NASM, FASM, MASM).
|
||||
* **Polymorphic Compilation Dispatch (`Builder` trait)** — introduced the `Builder` trait to generalize builder invocations (`src/core/build/builder/mod.rs`). Consolidated GCC/Clang logic into `builder/cc_common.rs` and Microsoft Visual C++ logic into `builder/msvc/`.
|
||||
* **Per-Language Configuration overrides (`[build.\<lang>]`)** — introduced support for configuring language-specific compiler, standard, and flags (e.g. `[build.c]`, `[build.cxx]`, `[build.asm]`) independently in `dcr.toml`.
|
||||
* **Automatic Workspace Dependency Injection** — during workspace builds, include/lib paths of dependent workspace members (including their source headers, local `include/` folders, and build target `target/include` / `target/lib` folders) are automatically resolved and injected.
|
||||
* **`BuildReporter` Event System** — decoupled build orchestration output into a structured event-driven reporter model (`src/core/build/report.rs`), making DCR suitable for library embedding and IDE integrations without stderr capturing.
|
||||
* **Build Cancellation Support** — introduced thread-safe cancellation tokens (`Arc\<AtomicBool>`) allowing clients to safely abort compile runs mid-execution.
|
||||
* **TOML Formatting & Custom Keys Preservation** — migrated the config editor to `toml_edit`, preserving all unknown/user-defined TOML keys, structures, and comments during file write operations (e.g., in `dcr add`).
|
||||
* **Path Dependencies Target Include Resolution** — local path dependencies configured via tables now correctly expose headers built and packaged into their `target/include` folder to consumer packages.
|
||||
* **Modular Integration Test Suite** — refactored the monolith `tests/cli_basic.rs` file into clean, specialized integration tests: `cli_build.rs`, `cli_deps.rs`, `cli_lint.rs`, `cli_new.rs`, `cli_qt.rs`, `cli_test.rs`, `cli_workspace.rs`.
|
||||
|
||||
### Changed
|
||||
|
||||
* **Consolidated Linking and Archiving** — artifact generation (linking executables/shared libraries and archiving static libraries) consolidated into a single `src/core/build/builder/artifact.rs` module.
|
||||
* **Workspace-Aware member execution** — `dcr run` executed at the workspace root of a `workspace_only` project now triggers the member build inside the workspace context using the `--workspace` parameter, preventing standalone build issues.
|
||||
* **Elimination of Global State** — removed global variables and states from the build core, encapsulating build logic inside isolated `BuildContext` structs for thread safety.
|
||||
* **Build Cache Separation** — relocated mtime tracking, incremental caching, and header-dependency checking logic to `src/core/build/cache.rs`.
|
||||
* **Modularized Pre-build Steps** — decoupled generator scripts and pre-build commands parsing into `src/core/build/steps.rs`.
|
||||
|
||||
## 0.7.4 (2026-06-17)
|
||||
|
||||
### Added
|
||||
|
||||
* **Native Qt support** — automatic meta-object handling (MOC, UIC, RCC) added when `build.qt = true` is set in `dcr.toml`.
|
||||
* **`dcr lint` command** — C/C++ static analysis via `clang-tidy`. Supports `--fix` for automatic fixes. Respects `build.roots` and `build.src_disable` from config.
|
||||
* **Three new assembler backends**:
|
||||
* **MASM** (`compiler = "ml"` / `"ml64"`) — Microsoft Macro Assembler.
|
||||
* **FASM** (`compiler = "fasm"`) — Flat Assembler.
|
||||
* **LLVM IR** (`compiler = "llc"`) — compiles `.ll` files via `llc -filetype=obj`.
|
||||
* **Shared ASM pipeline** — linking and archiving logic consolidated into `core/builder/asm.rs`. Adding a new assembler backend now takes ~30 lines.
|
||||
* **Filesystem utilities** — `to_hex()` and `home_dir()` extracted to `utils/fs.rs`.
|
||||
* **Build utilities** — `normalize_target()`, `normalize_kind()`, `normalize_platform()`, `default_profile_flags()` extracted to `utils/build.rs`.
|
||||
* **Backend helpers** — `asm_lang_flag()`, `source_extensions()`, `elapsed_secs()` added to `core/builder/common.rs`.
|
||||
* **Full Bare-Metal / Freestanding Automation** — introduced the `build.freestanding = true` configuration option. When enabled (or when a bare-metal target is detected), DCR automatically injects `-ffreestanding` during compilation and both `-nostdlib` and `-static` during linking.
|
||||
* **Artifact Optimization (LTO & Strip)** — added `build.lto` (auto-injects `-flto` for compiler and linker) and `build.strip` (automatically strips debug symbols via linker `-s` flag) options to `dcr.toml`.
|
||||
* **Compilation Thread Control** — added the `build.codegen-units` option to strictly limit the maximum number of parallel jobs utilized by the custom `parallel_build` worker pool.
|
||||
* **Panic Behavior Management** — added `build.panic = "abort"` support. For C++ targets, it automatically strips exception handling and unwind tables via `-fno-exceptions`, `-fno-unwind-tables`, and `-fno-asynchronous-unwind-tables`.
|
||||
|
||||
### Changed
|
||||
|
||||
* **Intelligent Default Flags Generation** — automated injection of fallback optimization (`-O3`/`-O0`), debug (`-g`), and warning (`-Wall -Wextra`) flags is now suppressed for bare-metal and freestanding builds if `build.cflags` are overridden.
|
||||
* **Centralized Bare-Metal Detection** — relocated the `is_bare_metal_target` helper to common build utilities (`src/utils/build.rs`) for unified access across the building core.
|
||||
* **Architectural Refactoring**:
|
||||
* Renamed `src/config.rs` to `src/templates.rs`.
|
||||
* Started consolidation of configuration and build orchestration logic.
|
||||
|
||||
## 0.7.3 (2026-06-13)
|
||||
|
||||
### Added
|
||||
|
||||
* **`--vcs` option for `new` and `init` commands** — introduced explicit version control system selection via `--vcs \<git|none>`.
|
||||
* **Git metadata integration in `--version`** — the CLI now appends the current short commit hash and a `-dirty` suffix if there are uncommitted changes in the DCR repository.
|
||||
* **Automatic `.gitignore` generation** — Git repository initialization now automatically writes a `.gitignore` file excluding the `/target` directory.
|
||||
* **Nested repository prevention** — automatic Git initialization is now skipped if `dcr new` or `dcr init` is executed inside an already existing Git repository.
|
||||
* **VCS verification tests** — added `new_vcs_options_work` and `init_vcs_options_work` integration tests to ensure reliable repository behavior.
|
||||
|
||||
### Changed
|
||||
|
||||
* **Complete removal of `git2` dependency** — all Git actions (dependency fetching, VCS setup, status checks) are now delegated to the system `git` executable via `Command`. This simplifies compilation and drops the need for `vendored` and `openssl` features.
|
||||
* **Migrated from `reqwest` to `ureq`** — replaced the heavy `reqwest` crate in `flag_update.rs` with the lightweight synchronous `ureq 2.10` client, reducing overhead and the final binary size.
|
||||
|
||||
## 0.7.2 (2026-06-07)
|
||||
|
||||
### Added
|
||||
|
||||
* `default_target_triple()` now respects `target_env` — Linux (gnu/musl) and Windows (msvc/gnu) use the correct environment instead of hardcoded values.
|
||||
|
||||
### Fixed
|
||||
|
||||
* **macOS Apple Silicon builds failed with `_main` undefined** — `--target=` is now passed to ldflags, not just cflags. `default_target_triple()` uses `std::env::consts::ARCH` on macOS instead of hardcoded `x86_64`.
|
||||
* **GitHub Stars and GPL-3.0 badges not rendering in README** — badge block converted to pure HTML.
|
||||
|
||||
### Changed
|
||||
|
||||
* Default target resolution extracted into shared `default_target_triple()` — removed duplication across build, run, clean.
|
||||
|
||||
## 0.7.1 (2026-06-02)
|
||||
|
||||
### Added
|
||||
|
||||
@@ -13,7 +13,7 @@ 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 --force # full rebuild (also re-runs build.steps / post_steps)
|
||||
dcr build --clean # clean + build
|
||||
dcr build --verbose # show compilation commands
|
||||
dcr build --workspace pkg-a # build specific workspace package
|
||||
@@ -21,6 +21,8 @@ dcr build --workspace pkg-a # build specific workspace package
|
||||
|
||||
Artifacts: `target/\<triple>/\<profile>/\<binary-name>` (Linux with explicit target).
|
||||
|
||||
With `[archive]` in `dcr.toml`, a FAT disk image is packed after a successful build.
|
||||
|
||||
## `dcr run`
|
||||
|
||||
Builds (if sources are newer than artifacts) and runs the binary.
|
||||
@@ -28,8 +30,11 @@ Builds (if sources are newer than artifacts) and runs the binary.
|
||||
```bash
|
||||
dcr run
|
||||
dcr run --release
|
||||
dcr run --force # force rebuild then run
|
||||
```
|
||||
|
||||
On a **workspace-only** root: if `[run].cmd` is set, that command is used after build; otherwise DCR delegates to a workspace member.
|
||||
|
||||
## `dcr clean`
|
||||
|
||||
Removes `target/` directory (or `target/\<target>/\<profile>`).
|
||||
|
||||
@@ -46,6 +46,6 @@ CI runs:
|
||||
|
||||
* `cargo fmt --check`
|
||||
* `cargo clippy --all-targets -- -D warnings`
|
||||
* `cargo test --all-targets`
|
||||
* `cargo check --all-targets --all-features`
|
||||
* Build on Linux, macOS, Windows
|
||||
* Integration tests
|
||||
* Integration tests (compilation check)
|
||||
|
||||
@@ -39,27 +39,6 @@ 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.
|
||||
@@ -76,6 +55,12 @@ See [Cross-Compile Recipe](/docs/recipes/cross-to-windows).
|
||||
|
||||
See [Workspace Recipe](/docs/recipes/multi-package-workspace).
|
||||
|
||||
## Bootloader / pure NASM OS image
|
||||
|
||||
Use `kind = "flat-bin"` (NASM `-f bin`) and optional `[archive]` for a FAT disk image.
|
||||
|
||||
See [OS-dev recipe](/docs/recipes/os-flat-bin-archive).
|
||||
|
||||
## 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`.
|
||||
|
||||
@@ -70,3 +70,10 @@ dcr test # run tests
|
||||
```bash
|
||||
dcr fmt # clang-format with .clang-format
|
||||
```
|
||||
|
||||
## Linting
|
||||
|
||||
```bash
|
||||
dcr lint # clang-tidy checks
|
||||
dcr lint --fix # apply fixes automatically
|
||||
```
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
---
|
||||
sidebar_label: OS-dev (flat-bin + archive)
|
||||
---
|
||||
|
||||
# Pure ASM / boot image (flat-bin + archive)
|
||||
|
||||
Minimal OS-dev style pipeline: assemble raw binaries with NASM, then pack a FAT floppy/image with an optional boot sector.
|
||||
|
||||
## Project layout
|
||||
|
||||
```
|
||||
myos/
|
||||
dcr.toml
|
||||
src/
|
||||
boot.asm # boot sector (512 bytes)
|
||||
kernel.asm # payload
|
||||
```
|
||||
|
||||
For multiple flat artifacts, use a **workspace** (one member per binary) or separate packages; a single `flat-bin` package produces one binary per source stem.
|
||||
|
||||
## Boot package (`flat-bin`)
|
||||
|
||||
```toml
|
||||
[package]
|
||||
name = "boot"
|
||||
version = "0.1.0"
|
||||
|
||||
[build]
|
||||
language = "asm"
|
||||
compiler = "nasm"
|
||||
kind = "flat-bin"
|
||||
extension = "bin"
|
||||
roots = ["src/boot.asm"]
|
||||
```
|
||||
|
||||
```bash
|
||||
dcr build
|
||||
# → target/<…>/debug/boot.bin (NASM -f bin, no link)
|
||||
```
|
||||
|
||||
## Disk image after build
|
||||
|
||||
```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"
|
||||
```
|
||||
|
||||
* `format`: `fat12`, `fat16`, or `fat32`
|
||||
* `size`: bytes or `K`/`KB`/`M`/`MB`/`G`/`GB` (default ~1.44 MiB)
|
||||
* `bootsector`: written only when `offset` is omitted or `0`
|
||||
* `from` may be a glob; `{profile}` is substituted in paths
|
||||
|
||||
## C kernel → flat binary
|
||||
|
||||
```toml
|
||||
[build]
|
||||
language = "c"
|
||||
compiler = "clang"
|
||||
kind = "flat-bin"
|
||||
freestanding = true
|
||||
filename = "kernel"
|
||||
extension = "bin"
|
||||
ldflags = ["-T", "linker.ld"]
|
||||
```
|
||||
|
||||
Pipeline: objects → temporary linked ELF → `objcopy -O binary` → `kernel.bin`. Requires `objcopy` / `llvm-objcopy` in PATH.
|
||||
|
||||
## Other assemblers
|
||||
|
||||
| Tool | Notes |
|
||||
| -------- | --------------------------------------------------------------------------------------- |
|
||||
| **FASM** | Write `format binary` in the source; DCR writes `\<stem>.bin` directly |
|
||||
| **GAS** | Assemble `.s` → obj → `objcopy -O binary` |
|
||||
| **LLC** | `language = "llvm_ir"` → obj → objcopy |
|
||||
| **MASM** | COFF obj → objcopy (needs binutils/LLVM objcopy) |
|
||||
|
||||
## Notes
|
||||
|
||||
* Single-file `roots` are supported: `roots = ["src/boot.asm"]`.
|
||||
* `--force` re-runs `build.steps` / `build.post_steps` as well as recompilation.
|
||||
* Prefer `kind = "elf"` if you need a relocatable ELF kernel without stripping to raw binary.
|
||||
@@ -56,7 +56,7 @@ moc = "moc {in} -o {out}"
|
||||
### GAS / NASM / MASM / FASM / LLVM-IR
|
||||
|
||||
* GAS: `-I`, `-c -o`, `--defsym`
|
||||
* NASM: `-I`, `-o`, `-D`, `-f` (format: win64/elf64/macho64/macho32/elf32)
|
||||
* NASM: `-I`, `-o`, `-D`, `-f` (format: win64/elf64/macho64/macho32/elf32; **`bin` when `kind = "flat-bin"`**)
|
||||
* MASM: `/nologo /c /Fo\<obj> <source>`
|
||||
* FASM: `<source> \<output>` (output path is the object file)
|
||||
* LLVM IR: `-filetype=obj <source> -o \<output>`
|
||||
@@ -78,15 +78,20 @@ Three levels of incrementality:
|
||||
|
||||
## 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>` |
|
||||
| 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>` |
|
||||
| `flat-bin` | Raw binary | ASM: `\<stem>.bin` (NASM `-f bin` / FASM / GAS·MASM·LLC via objcopy); C/C++: `\<name>.bin` (link + objcopy) |
|
||||
|
||||
## Disk images (`[archive]`)
|
||||
|
||||
After a successful build, if `[archive]` is present in `dcr.toml`, DCR formats a FAT volume and copies files from `layout` into the image. See [dcr.toml → archive](/docs/reference/dcr-toml#archive).
|
||||
|
||||
## Build Steps
|
||||
|
||||
|
||||
@@ -57,14 +57,8 @@ dcr build --target aarch64-none-elf
|
||||
|
||||
## Target Directory
|
||||
|
||||
On Linux with explicit target:
|
||||
By default, the compilation output directories are structured as follows:
|
||||
|
||||
```
|
||||
target/<triple>/<profile>/
|
||||
```
|
||||
|
||||
On macOS/Windows or without target:
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
```
|
||||
* **Linux and BSD**: Always output to `target/\<triple>/\<profile>/` (using host triple if no target is specified).
|
||||
* **macOS and Windows (without target)**: Output to `target/\<profile>/`.
|
||||
* **macOS and Windows (with explicit target)**: Output to `target/\<triple>/\<profile>/`.
|
||||
|
||||
@@ -33,6 +33,9 @@ Main project configuration file. Located at the project root.
|
||||
|
||||
[run]
|
||||
# run settings
|
||||
|
||||
[archive]
|
||||
# optional: pack FAT disk image after build
|
||||
```
|
||||
|
||||
## [package]
|
||||
@@ -60,36 +63,36 @@ author = "John Doe"
|
||||
|
||||
* `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) |
|
||||
| Field | Default | Description |
|
||||
| ---------------- | ------------- | --------------------------------------------------------------------------------------------------------- |
|
||||
| `language` | `"c"` | `"c"`, `"c++"`, `"cpp"`, `"cxx"`, `"asm"`, `"llvm_ir"`, `"llvm-ir"`, `"ll"` (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`, `flat-bin` |
|
||||
| `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 (for `flat-bin`, default is `bin`) |
|
||||
| `roots` | `["src"]` | Source roots: directories and/or individual source/header files |
|
||||
| `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):
|
||||
|
||||
@@ -97,7 +100,7 @@ Settings from raw config (not in typed struct):
|
||||
* `ldscript` — linker script path
|
||||
* `build.steps` / `build.post_steps` — codegen steps
|
||||
|
||||
## Per-language overrides: `[build.c]`, `[build.cxx]`, `[build.asm]`
|
||||
## 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:
|
||||
|
||||
@@ -117,6 +120,9 @@ 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.
|
||||
@@ -174,3 +180,82 @@ Default `cmd` = `./target/{profile}/{name}` (macOS/Windows) or `./target/\<tripl
|
||||
## [workspace]
|
||||
|
||||
See [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]`).
|
||||
|
||||
| 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` → `\<stem>.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 `\<filename|name>.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 `\<stem>.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).
|
||||
|
||||
@@ -67,6 +67,8 @@ mylib = { path = "/abs/path/to/lib" }
|
||||
mylib = { path = "../relative/path" }
|
||||
```
|
||||
|
||||
*Note: Header resolution automatically checks the packaged `target/include` directory of path dependencies, ensuring consumer packages can find headers from compiled static or dynamic libraries.*
|
||||
|
||||
## dcr.lock
|
||||
|
||||
Dependency lock file. Contains package names and sources.
|
||||
|
||||
@@ -11,17 +11,18 @@ DCR normalizes target triples. Short platform names are expanded to full triples
|
||||
### Linux
|
||||
|
||||
```
|
||||
target/<arch>-unknown-linux-gnu/<profile>/
|
||||
target/<arch>-unknown-linux-<env>/<profile>/
|
||||
```
|
||||
|
||||
Architectures: `x86_64`, `aarch64` (host-detected).
|
||||
Architectures: `x86_64`, `aarch64`, `i686`, `armv7`, `riscv64` (host-detected).
|
||||
Environments: `gnu` (default), `musl`.
|
||||
|
||||
Artifact type: ELF. Extensions: `.so` (sharedlib), `.a` (staticlib).
|
||||
|
||||
### macOS
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
target/<profile>/ (default) or target/<triple>/<profile>/ (with target)
|
||||
```
|
||||
|
||||
Architectures: `x86_64`, `aarch64` (host-detected).
|
||||
@@ -31,10 +32,11 @@ Extensions: `.dylib` (sharedlib), `.a` (staticlib).
|
||||
### Windows
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
target/<profile>/ (default) or target/<triple>/<profile>/ (with target)
|
||||
```
|
||||
|
||||
Architectures: `x86_64`, `aarch64`.
|
||||
Environments: `msvc` (default), `gnu` (MinGW).
|
||||
|
||||
Extensions: `.exe` (bin), `.lib` (staticlib), `.dll` (sharedlib), `.efi` (UEFI).
|
||||
|
||||
|
||||
@@ -43,7 +43,10 @@ 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.
|
||||
When building a workspace, DCR automatically injects include and library paths of dependent workspace members:
|
||||
|
||||
* **Include Paths**: Automatically resolves and injects header directories of dependencies, including the member's `src/` directory, local `include/` directory, and the packaged `target/include` directory.
|
||||
* **Library Paths**: Injects compiled library search paths (`target/lib` as well as target-specific build folders) to allow automatic linking with member libraries.
|
||||
|
||||
## Clean
|
||||
|
||||
|
||||
@@ -51,8 +51,9 @@ dcr gen vscode
|
||||
|
||||
* **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
|
||||
* **7 backends** — gcc/clang (unix_cc), MSVC/clang-cl (msvc), GAS, NASM, MASM, FASM, LLVM IR
|
||||
* **8 project kinds** — bin, staticlib, sharedlib, efi, elf, none, custom, flat-bin
|
||||
* **Disk images** — optional `[archive]` packs FAT12/16/32 images after build
|
||||
* **Cross-compilation** — short names and full triples
|
||||
* **Profiles** — debug / release with field overrides
|
||||
* **Workspaces** — multi-package projects with topological sort
|
||||
|
||||
@@ -4,6 +4,108 @@ sidebar_label: Changelog
|
||||
|
||||
# Changelog
|
||||
|
||||
## 0.8.1 (2026-07-20)
|
||||
|
||||
### Added
|
||||
|
||||
* **`build.kind = "flat-bin"`** — raw binary (default `.bin`) for OS-dev payloads:
|
||||
* **NASM** — `-f bin` → `\<stem>.bin`
|
||||
* **FASM** — direct output (`format binary` in source)
|
||||
* **GAS / MASM / LLC** — object → `objcopy -O binary` → `\<stem>.bin`
|
||||
* **C/C++** — objects → freestanding link → `objcopy -O binary` → `\<name>.bin`
|
||||
* Requires `llvm-objcopy` / `objcopy` / `gobjcopy` except for NASM/FASM direct emit
|
||||
* **`[archive]` section** — after a successful build, pack a FAT disk image (`fatfs`): `output`, `format` (`fat12`/`fat16`/`fat32`), optional `size` (default 1.44 MiB), `offset`, `label`, `bootsector`, and `layout` (`from` → `to`, supports globs). `{profile}` works in paths.
|
||||
* **Single-file `build.roots`** — a root may be a single source or header file, not only a directory.
|
||||
|
||||
### Changed
|
||||
|
||||
* **`--force`** also re-runs `build.steps` and `build.post_steps`.
|
||||
* **`dcr run` on workspace-only root** — if `[run].cmd` is set, run that after build; otherwise delegate to a workspace member.
|
||||
|
||||
### Dependencies
|
||||
|
||||
* `fatfs = "0.3"` for FAT image packing.
|
||||
|
||||
## 0.8.0 (2026-07-18)
|
||||
|
||||
### Added
|
||||
|
||||
* **Dedicated Build Engine (`src/core/build/engine.rs`)** — decoupled the build orchestration logic completely from the CLI front-end wrapper in `src/cli/build.rs` to a reusable, decoupled core build engine.
|
||||
* **Polymorphic Language Model (`Language` trait)** — introduced the abstract `Language` trait (`src/core/build/language/mod.rs`). File scanning, compiler resolution, and flags handling are now encapsulated in dedicated language modules for C, C++ (including Qt code generation), LLVM IR, and ASM (GAS, NASM, FASM, MASM).
|
||||
* **Polymorphic Compilation Dispatch (`Builder` trait)** — introduced the `Builder` trait to generalize builder invocations (`src/core/build/builder/mod.rs`). Consolidated GCC/Clang logic into `builder/cc_common.rs` and Microsoft Visual C++ logic into `builder/msvc/`.
|
||||
* **Per-Language Configuration overrides (`[build.\<lang>]`)** — introduced support for configuring language-specific compiler, standard, and flags (e.g. `[build.c]`, `[build.cxx]`, `[build.asm]`) independently in `dcr.toml`.
|
||||
* **Automatic Workspace Dependency Injection** — during workspace builds, include/lib paths of dependent workspace members (including their source headers, local `include/` folders, and build target `target/include` / `target/lib` folders) are automatically resolved and injected.
|
||||
* **`BuildReporter` Event System** — decoupled build orchestration output into a structured event-driven reporter model (`src/core/build/report.rs`), making DCR suitable for library embedding and IDE integrations without stderr capturing.
|
||||
* **Build Cancellation Support** — introduced thread-safe cancellation tokens (`Arc\<AtomicBool>`) allowing clients to safely abort compile runs mid-execution.
|
||||
* **TOML Formatting & Custom Keys Preservation** — migrated the config editor to `toml_edit`, preserving all unknown/user-defined TOML keys, structures, and comments during file write operations (e.g., in `dcr add`).
|
||||
* **Path Dependencies Target Include Resolution** — local path dependencies configured via tables now correctly expose headers built and packaged into their `target/include` folder to consumer packages.
|
||||
* **Modular Integration Test Suite** — refactored the monolith `tests/cli_basic.rs` file into clean, specialized integration tests: `cli_build.rs`, `cli_deps.rs`, `cli_lint.rs`, `cli_new.rs`, `cli_qt.rs`, `cli_test.rs`, `cli_workspace.rs`.
|
||||
|
||||
### Changed
|
||||
|
||||
* **Consolidated Linking and Archiving** — artifact generation (linking executables/shared libraries and archiving static libraries) consolidated into a single `src/core/build/builder/artifact.rs` module.
|
||||
* **Workspace-Aware member execution** — `dcr run` executed at the workspace root of a `workspace_only` project now triggers the member build inside the workspace context using the `--workspace` parameter, preventing standalone build issues.
|
||||
* **Elimination of Global State** — removed global variables and states from the build core, encapsulating build logic inside isolated `BuildContext` structs for thread safety.
|
||||
* **Build Cache Separation** — relocated mtime tracking, incremental caching, and header-dependency checking logic to `src/core/build/cache.rs`.
|
||||
* **Modularized Pre-build Steps** — decoupled generator scripts and pre-build commands parsing into `src/core/build/steps.rs`.
|
||||
|
||||
## 0.7.4 (2026-06-17)
|
||||
|
||||
### Added
|
||||
|
||||
* **Native Qt support** — automatic meta-object handling (MOC, UIC, RCC) added when `build.qt = true` is set in `dcr.toml`.
|
||||
* **`dcr lint` command** — C/C++ static analysis via `clang-tidy`. Supports `--fix` for automatic fixes. Respects `build.roots` and `build.src_disable` from config.
|
||||
* **Three new assembler backends**:
|
||||
* **MASM** (`compiler = "ml"` / `"ml64"`) — Microsoft Macro Assembler.
|
||||
* **FASM** (`compiler = "fasm"`) — Flat Assembler.
|
||||
* **LLVM IR** (`compiler = "llc"`) — compiles `.ll` files via `llc -filetype=obj`.
|
||||
* **Shared ASM pipeline** — linking and archiving logic consolidated into `core/builder/asm.rs`. Adding a new assembler backend now takes ~30 lines.
|
||||
* **Filesystem utilities** — `to_hex()` and `home_dir()` extracted to `utils/fs.rs`.
|
||||
* **Build utilities** — `normalize_target()`, `normalize_kind()`, `normalize_platform()`, `default_profile_flags()` extracted to `utils/build.rs`.
|
||||
* **Backend helpers** — `asm_lang_flag()`, `source_extensions()`, `elapsed_secs()` added to `core/builder/common.rs`.
|
||||
* **Full Bare-Metal / Freestanding Automation** — introduced the `build.freestanding = true` configuration option. When enabled (or when a bare-metal target is detected), DCR automatically injects `-ffreestanding` during compilation and both `-nostdlib` and `-static` during linking.
|
||||
* **Artifact Optimization (LTO & Strip)** — added `build.lto` (auto-injects `-flto` for compiler and linker) and `build.strip` (automatically strips debug symbols via linker `-s` flag) options to `dcr.toml`.
|
||||
* **Compilation Thread Control** — added the `build.codegen-units` option to strictly limit the maximum number of parallel jobs utilized by the custom `parallel_build` worker pool.
|
||||
* **Panic Behavior Management** — added `build.panic = "abort"` support. For C++ targets, it automatically strips exception handling and unwind tables via `-fno-exceptions`, `-fno-unwind-tables`, and `-fno-asynchronous-unwind-tables`.
|
||||
|
||||
### Changed
|
||||
|
||||
* **Intelligent Default Flags Generation** — automated injection of fallback optimization (`-O3`/`-O0`), debug (`-g`), and warning (`-Wall -Wextra`) flags is now suppressed for bare-metal and freestanding builds if `build.cflags` are overridden.
|
||||
* **Centralized Bare-Metal Detection** — relocated the `is_bare_metal_target` helper to common build utilities (`src/utils/build.rs`) for unified access across the building core.
|
||||
* **Architectural Refactoring**:
|
||||
* Renamed `src/config.rs` to `src/templates.rs`.
|
||||
* Started consolidation of configuration and build orchestration logic.
|
||||
|
||||
## 0.7.3 (2026-06-13)
|
||||
|
||||
### Added
|
||||
|
||||
* **`--vcs` option for `new` and `init` commands** — introduced explicit version control system selection via `--vcs \<git|none>`.
|
||||
* **Git metadata integration in `--version`** — the CLI now appends the current short commit hash and a `-dirty` suffix if there are uncommitted changes in the DCR repository.
|
||||
* **Automatic `.gitignore` generation** — Git repository initialization now automatically writes a `.gitignore` file excluding the `/target` directory.
|
||||
* **Nested repository prevention** — automatic Git initialization is now skipped if `dcr new` or `dcr init` is executed inside an already existing Git repository.
|
||||
* **VCS verification tests** — added `new_vcs_options_work` and `init_vcs_options_work` integration tests to ensure reliable repository behavior.
|
||||
|
||||
### Changed
|
||||
|
||||
* **Complete removal of `git2` dependency** — all Git actions (dependency fetching, VCS setup, status checks) are now delegated to the system `git` executable via `Command`. This simplifies compilation and drops the need for `vendored` and `openssl` features.
|
||||
* **Migrated from `reqwest` to `ureq`** — replaced the heavy `reqwest` crate in `flag_update.rs` with the lightweight synchronous `ureq 2.10` client, reducing overhead and the final binary size.
|
||||
|
||||
## 0.7.2 (2026-06-07)
|
||||
|
||||
### Added
|
||||
|
||||
* `default_target_triple()` now respects `target_env` — Linux (gnu/musl) and Windows (msvc/gnu) use the correct environment instead of hardcoded values.
|
||||
|
||||
### Fixed
|
||||
|
||||
* **macOS Apple Silicon builds failed with `_main` undefined** — `--target=` is now passed to ldflags, not just cflags. `default_target_triple()` uses `std::env::consts::ARCH` on macOS instead of hardcoded `x86_64`.
|
||||
* **GitHub Stars and GPL-3.0 badges not rendering in README** — badge block converted to pure HTML.
|
||||
|
||||
### Changed
|
||||
|
||||
* Default target resolution extracted into shared `default_target_triple()` — removed duplication across build, run, clean.
|
||||
|
||||
## 0.7.1 (2026-06-02)
|
||||
|
||||
### Added
|
||||
|
||||
@@ -13,7 +13,7 @@ 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 --force # full rebuild (also re-runs build.steps / post_steps)
|
||||
dcr build --clean # clean + build
|
||||
dcr build --verbose # show compilation commands
|
||||
dcr build --workspace pkg-a # build specific workspace package
|
||||
@@ -21,6 +21,8 @@ dcr build --workspace pkg-a # build specific workspace package
|
||||
|
||||
Artifacts: `target/\<triple>/\<profile>/\<binary-name>` (Linux with explicit target).
|
||||
|
||||
With `[archive]` in `dcr.toml`, a FAT disk image is packed after a successful build.
|
||||
|
||||
## `dcr run`
|
||||
|
||||
Builds (if sources are newer than artifacts) and runs the binary.
|
||||
@@ -28,8 +30,11 @@ Builds (if sources are newer than artifacts) and runs the binary.
|
||||
```bash
|
||||
dcr run
|
||||
dcr run --release
|
||||
dcr run --force # force rebuild then run
|
||||
```
|
||||
|
||||
On a **workspace-only** root: if `[run].cmd` is set, that command is used after build; otherwise DCR delegates to a workspace member.
|
||||
|
||||
## `dcr clean`
|
||||
|
||||
Removes `target/` directory (or `target/\<target>/\<profile>`).
|
||||
|
||||
@@ -46,6 +46,6 @@ CI runs:
|
||||
|
||||
* `cargo fmt --check`
|
||||
* `cargo clippy --all-targets -- -D warnings`
|
||||
* `cargo test --all-targets`
|
||||
* `cargo check --all-targets --all-features`
|
||||
* Build on Linux, macOS, Windows
|
||||
* Integration tests
|
||||
* Integration tests (compilation check)
|
||||
|
||||
@@ -39,27 +39,6 @@ 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.
|
||||
@@ -76,6 +55,12 @@ See [Cross-Compile Recipe](/docs/recipes/cross-to-windows).
|
||||
|
||||
See [Workspace Recipe](/docs/recipes/multi-package-workspace).
|
||||
|
||||
## Bootloader / pure NASM OS image
|
||||
|
||||
Use `kind = "flat-bin"` (NASM `-f bin`) and optional `[archive]` for a FAT disk image.
|
||||
|
||||
See [OS-dev recipe](/docs/recipes/os-flat-bin-archive).
|
||||
|
||||
## 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`.
|
||||
|
||||
@@ -70,3 +70,10 @@ dcr test # run tests
|
||||
```bash
|
||||
dcr fmt # clang-format with .clang-format
|
||||
```
|
||||
|
||||
## Linting
|
||||
|
||||
```bash
|
||||
dcr lint # clang-tidy checks
|
||||
dcr lint --fix # apply fixes automatically
|
||||
```
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
---
|
||||
sidebar_label: OS-dev (flat-bin + archive)
|
||||
---
|
||||
|
||||
# Pure ASM / boot image (flat-bin + archive)
|
||||
|
||||
Minimal OS-dev style pipeline: assemble raw binaries with NASM, then pack a FAT floppy/image with an optional boot sector.
|
||||
|
||||
## Project layout
|
||||
|
||||
```
|
||||
myos/
|
||||
dcr.toml
|
||||
src/
|
||||
boot.asm # boot sector (512 bytes)
|
||||
kernel.asm # payload
|
||||
```
|
||||
|
||||
For multiple flat artifacts, use a **workspace** (one member per binary) or separate packages; a single `flat-bin` package produces one binary per source stem.
|
||||
|
||||
## Boot package (`flat-bin`)
|
||||
|
||||
```toml
|
||||
[package]
|
||||
name = "boot"
|
||||
version = "0.1.0"
|
||||
|
||||
[build]
|
||||
language = "asm"
|
||||
compiler = "nasm"
|
||||
kind = "flat-bin"
|
||||
extension = "bin"
|
||||
roots = ["src/boot.asm"]
|
||||
```
|
||||
|
||||
```bash
|
||||
dcr build
|
||||
# → target/<…>/debug/boot.bin (NASM -f bin, no link)
|
||||
```
|
||||
|
||||
## Disk image after build
|
||||
|
||||
```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"
|
||||
```
|
||||
|
||||
* `format`: `fat12`, `fat16`, or `fat32`
|
||||
* `size`: bytes or `K`/`KB`/`M`/`MB`/`G`/`GB` (default ~1.44 MiB)
|
||||
* `bootsector`: written only when `offset` is omitted or `0`
|
||||
* `from` may be a glob; `{profile}` is substituted in paths
|
||||
|
||||
## C kernel → flat binary
|
||||
|
||||
```toml
|
||||
[build]
|
||||
language = "c"
|
||||
compiler = "clang"
|
||||
kind = "flat-bin"
|
||||
freestanding = true
|
||||
filename = "kernel"
|
||||
extension = "bin"
|
||||
ldflags = ["-T", "linker.ld"]
|
||||
```
|
||||
|
||||
Pipeline: objects → temporary linked ELF → `objcopy -O binary` → `kernel.bin`. Requires `objcopy` / `llvm-objcopy` in PATH.
|
||||
|
||||
## Other assemblers
|
||||
|
||||
| Tool | Notes |
|
||||
| -------- | --------------------------------------------------------------------------------------- |
|
||||
| **FASM** | Write `format binary` in the source; DCR writes `\<stem>.bin` directly |
|
||||
| **GAS** | Assemble `.s` → obj → `objcopy -O binary` |
|
||||
| **LLC** | `language = "llvm_ir"` → obj → objcopy |
|
||||
| **MASM** | COFF obj → objcopy (needs binutils/LLVM objcopy) |
|
||||
|
||||
## Notes
|
||||
|
||||
* Single-file `roots` are supported: `roots = ["src/boot.asm"]`.
|
||||
* `--force` re-runs `build.steps` / `build.post_steps` as well as recompilation.
|
||||
* Prefer `kind = "elf"` if you need a relocatable ELF kernel without stripping to raw binary.
|
||||
@@ -56,7 +56,7 @@ moc = "moc {in} -o {out}"
|
||||
### GAS / NASM / MASM / FASM / LLVM-IR
|
||||
|
||||
* GAS: `-I`, `-c -o`, `--defsym`
|
||||
* NASM: `-I`, `-o`, `-D`, `-f` (format: win64/elf64/macho64/macho32/elf32)
|
||||
* NASM: `-I`, `-o`, `-D`, `-f` (format: win64/elf64/macho64/macho32/elf32; **`bin` when `kind = "flat-bin"`**)
|
||||
* MASM: `/nologo /c /Fo\<obj> <source>`
|
||||
* FASM: `<source> \<output>` (output path is the object file)
|
||||
* LLVM IR: `-filetype=obj <source> -o \<output>`
|
||||
@@ -78,15 +78,20 @@ Three levels of incrementality:
|
||||
|
||||
## 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>` |
|
||||
| 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>` |
|
||||
| `flat-bin` | Raw binary | ASM: `\<stem>.bin` (NASM `-f bin` / FASM / GAS·MASM·LLC via objcopy); C/C++: `\<name>.bin` (link + objcopy) |
|
||||
|
||||
## Disk images (`[archive]`)
|
||||
|
||||
After a successful build, if `[archive]` is present in `dcr.toml`, DCR formats a FAT volume and copies files from `layout` into the image. See [dcr.toml → archive](/docs/reference/dcr-toml#archive).
|
||||
|
||||
## Build Steps
|
||||
|
||||
|
||||
@@ -57,14 +57,8 @@ dcr build --target aarch64-none-elf
|
||||
|
||||
## Target Directory
|
||||
|
||||
On Linux with explicit target:
|
||||
By default, the compilation output directories are structured as follows:
|
||||
|
||||
```
|
||||
target/<triple>/<profile>/
|
||||
```
|
||||
|
||||
On macOS/Windows or without target:
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
```
|
||||
* **Linux and BSD**: Always output to `target/\<triple>/\<profile>/` (using host triple if no target is specified).
|
||||
* **macOS and Windows (without target)**: Output to `target/\<profile>/`.
|
||||
* **macOS and Windows (with explicit target)**: Output to `target/\<triple>/\<profile>/`.
|
||||
|
||||
@@ -33,6 +33,9 @@ Main project configuration file. Located at the project root.
|
||||
|
||||
[run]
|
||||
# run settings
|
||||
|
||||
[archive]
|
||||
# optional: pack FAT disk image after build
|
||||
```
|
||||
|
||||
## [package]
|
||||
@@ -60,36 +63,36 @@ author = "John Doe"
|
||||
|
||||
* `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) |
|
||||
| Field | Default | Description |
|
||||
| ---------------- | ------------- | --------------------------------------------------------------------------------------------------------- |
|
||||
| `language` | `"c"` | `"c"`, `"c++"`, `"cpp"`, `"cxx"`, `"asm"`, `"llvm_ir"`, `"llvm-ir"`, `"ll"` (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`, `flat-bin` |
|
||||
| `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 (for `flat-bin`, default is `bin`) |
|
||||
| `roots` | `["src"]` | Source roots: directories and/or individual source/header files |
|
||||
| `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):
|
||||
|
||||
@@ -97,7 +100,7 @@ Settings from raw config (not in typed struct):
|
||||
* `ldscript` — linker script path
|
||||
* `build.steps` / `build.post_steps` — codegen steps
|
||||
|
||||
## Per-language overrides: `[build.c]`, `[build.cxx]`, `[build.asm]`
|
||||
## 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:
|
||||
|
||||
@@ -117,6 +120,9 @@ 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.
|
||||
@@ -174,3 +180,82 @@ Default `cmd` = `./target/{profile}/{name}` (macOS/Windows) or `./target/\<tripl
|
||||
## [workspace]
|
||||
|
||||
See [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]`).
|
||||
|
||||
| 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` → `\<stem>.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 `\<filename|name>.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 `\<stem>.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).
|
||||
|
||||
@@ -67,6 +67,8 @@ mylib = { path = "/abs/path/to/lib" }
|
||||
mylib = { path = "../relative/path" }
|
||||
```
|
||||
|
||||
*Note: Header resolution automatically checks the packaged `target/include` directory of path dependencies, ensuring consumer packages can find headers from compiled static or dynamic libraries.*
|
||||
|
||||
## dcr.lock
|
||||
|
||||
Dependency lock file. Contains package names and sources.
|
||||
|
||||
@@ -11,17 +11,18 @@ DCR normalizes target triples. Short platform names are expanded to full triples
|
||||
### Linux
|
||||
|
||||
```
|
||||
target/<arch>-unknown-linux-gnu/<profile>/
|
||||
target/<arch>-unknown-linux-<env>/<profile>/
|
||||
```
|
||||
|
||||
Architectures: `x86_64`, `aarch64` (host-detected).
|
||||
Architectures: `x86_64`, `aarch64`, `i686`, `armv7`, `riscv64` (host-detected).
|
||||
Environments: `gnu` (default), `musl`.
|
||||
|
||||
Artifact type: ELF. Extensions: `.so` (sharedlib), `.a` (staticlib).
|
||||
|
||||
### macOS
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
target/<profile>/ (default) or target/<triple>/<profile>/ (with target)
|
||||
```
|
||||
|
||||
Architectures: `x86_64`, `aarch64` (host-detected).
|
||||
@@ -31,10 +32,11 @@ Extensions: `.dylib` (sharedlib), `.a` (staticlib).
|
||||
### Windows
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
target/<profile>/ (default) or target/<triple>/<profile>/ (with target)
|
||||
```
|
||||
|
||||
Architectures: `x86_64`, `aarch64`.
|
||||
Environments: `msvc` (default), `gnu` (MinGW).
|
||||
|
||||
Extensions: `.exe` (bin), `.lib` (staticlib), `.dll` (sharedlib), `.efi` (UEFI).
|
||||
|
||||
|
||||
@@ -43,7 +43,10 @@ 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.
|
||||
When building a workspace, DCR automatically injects include and library paths of dependent workspace members:
|
||||
|
||||
* **Include Paths**: Automatically resolves and injects header directories of dependencies, including the member's `src/` directory, local `include/` directory, and the packaged `target/include` directory.
|
||||
* **Library Paths**: Injects compiled library search paths (`target/lib` as well as target-specific build folders) to allow automatic linking with member libraries.
|
||||
|
||||
## Clean
|
||||
|
||||
|
||||
@@ -41,8 +41,9 @@ dcr run
|
||||
|
||||
* **Инкрементальная сборка** — mtime + `.d` headers + SHA256 fingerprint
|
||||
* **Параллельная компиляция** — thread::scope, атомарная очередь задач
|
||||
* **4 бэкенда** — gcc/clang, MSVC/clang-cl, GAS, NASM
|
||||
* **7 типов проекта** — bin, staticlib, sharedlib, efi, elf, none, custom
|
||||
* **7 backends** — gcc/clang (unix_cc), MSVC/clang-cl (msvc), GAS, NASM, MASM, FASM, LLVM IR
|
||||
* **8 project kinds** — bin, staticlib, sharedlib, efi, elf, none, custom, flat-bin
|
||||
* **Disk images** — optional `[archive]` packs FAT12/16/32 images after build
|
||||
* **Cross-compilation** — short names (linux, windows, macos) и полные triples
|
||||
* **Профили** — debug / release с переопределением любого поля
|
||||
* **Workspaces** — мультипакетные проекты с топологической сортировкой
|
||||
|
||||
@@ -4,10 +4,112 @@ sidebar_label: Список изменений
|
||||
|
||||
# Список изменений
|
||||
|
||||
## 0.7.1 (02.06.2026)
|
||||
## 0.8.1 (2026-07-20)
|
||||
|
||||
### Добавлено:
|
||||
|
||||
* **`build.kind = "flat-bin"`** — raw binary (default `.bin`) for OS-dev payloads:
|
||||
* **NASM** — `-f bin` → `\<stem>.bin`
|
||||
* **FASM** — direct output (`format binary` in source)
|
||||
* **GAS / MASM / LLC** — object → `objcopy -O binary` → `\<stem>.bin`
|
||||
* **C/C++** — objects → freestanding link → `objcopy -O binary` → `\<name>.bin`
|
||||
* Requires `llvm-objcopy` / `objcopy` / `gobjcopy` except for NASM/FASM direct emit
|
||||
* **`[archive]` section** — after a successful build, pack a FAT disk image (`fatfs`): `output`, `format` (`fat12`/`fat16`/`fat32`), optional `size` (default 1.44 MiB), `offset`, `label`, `bootsector`, and `layout` (`from` → `to`, supports globs). `{profile}` works in paths.
|
||||
* **Single-file `build.roots`** — a root may be a single source or header file, not only a directory.
|
||||
|
||||
### Изменено:
|
||||
|
||||
* **`--force`** also re-runs `build.steps` and `build.post_steps`.
|
||||
* **`dcr run` on workspace-only root** — if `[run].cmd` is set, run that after build; otherwise delegate to a workspace member.
|
||||
|
||||
### Dependencies
|
||||
|
||||
* `fatfs = "0.3"` for FAT image packing.
|
||||
|
||||
## 0.8.0 (2026-07-18)
|
||||
|
||||
### Добавлено
|
||||
|
||||
* **Dedicated Build Engine (`src/core/build/engine.rs`)** — decoupled the build orchestration logic completely from the CLI front-end wrapper in `src/cli/build.rs` to a reusable, decoupled core build engine.
|
||||
* **Polymorphic Language Model (`Language` trait)** — introduced the abstract `Language` trait (`src/core/build/language/mod.rs`). File scanning, compiler resolution, and flags handling are now encapsulated in dedicated language modules for C, C++ (including Qt code generation), LLVM IR, and ASM (GAS, NASM, FASM, MASM).
|
||||
* **Polymorphic Compilation Dispatch (`Builder` trait)** — introduced the `Builder` trait to generalize builder invocations (`src/core/build/builder/mod.rs`). Consolidated GCC/Clang logic into `builder/cc_common.rs` and Microsoft Visual C++ logic into `builder/msvc/`.
|
||||
* **Per-Language Configuration overrides (`[build.\<lang>]`)** — introduced support for configuring language-specific compiler, standard, and flags (e.g. `[build.c]`, `[build.cxx]`, `[build.asm]`) independently in `dcr.toml`.
|
||||
* **Automatic Workspace Dependency Injection** — during workspace builds, include/lib paths of dependent workspace members (including their source headers, local `include/` folders, and build target `target/include` / `target/lib` folders) are automatically resolved and injected.
|
||||
* **`BuildReporter` Event System** — decoupled build orchestration output into a structured event-driven reporter model (`src/core/build/report.rs`), making DCR suitable for library embedding and IDE integrations without stderr capturing.
|
||||
* **Build Cancellation Support** — introduced thread-safe cancellation tokens (`Arc\<AtomicBool>`) allowing clients to safely abort compile runs mid-execution.
|
||||
* **TOML Formatting & Custom Keys Preservation** — migrated the config editor to `toml_edit`, preserving all unknown/user-defined TOML keys, structures, and comments during file write operations (e.g., in `dcr add`).
|
||||
* **Path Dependencies Target Include Resolution** — local path dependencies configured via tables now correctly expose headers built and packaged into their `target/include` folder to consumer packages.
|
||||
* **Modular Integration Test Suite** — refactored the monolith `tests/cli_basic.rs` file into clean, specialized integration tests: `cli_build.rs`, `cli_deps.rs`, `cli_lint.rs`, `cli_new.rs`, `cli_qt.rs`, `cli_test.rs`, `cli_workspace.rs`.
|
||||
|
||||
### Изменено
|
||||
|
||||
* **Consolidated Linking and Archiving** — artifact generation (linking executables/shared libraries and archiving static libraries) consolidated into a single `src/core/build/builder/artifact.rs` module.
|
||||
* **Workspace-Aware member execution** — `dcr run` executed at the workspace root of a `workspace_only` project now triggers the member build inside the workspace context using the `--workspace` parameter, preventing standalone build issues.
|
||||
* **Elimination of Global State** — removed global variables and states from the build core, encapsulating build logic inside isolated `BuildContext` structs for thread safety.
|
||||
* **Build Cache Separation** — relocated mtime tracking, incremental caching, and header-dependency checking logic to `src/core/build/cache.rs`.
|
||||
* **Modularized Pre-build Steps** — decoupled generator scripts and pre-build commands parsing into `src/core/build/steps.rs`.
|
||||
|
||||
## 0.7.4 (2026-06-17)
|
||||
|
||||
### Added
|
||||
|
||||
* **Native Qt support** — automatic meta-object handling (MOC, UIC, RCC) added when `build.qt = true` is set in `dcr.toml`.
|
||||
* **`dcr lint` command** — C/C++ static analysis via `clang-tidy`. Supports `--fix` for automatic fixes. Respects `build.roots` and `build.src_disable` from config.
|
||||
* **Three new assembler backends**:
|
||||
* **MASM** (`compiler = "ml"` / `"ml64"`) — Microsoft Macro Assembler.
|
||||
* **FASM** (`compiler = "fasm"`) — Flat Assembler.
|
||||
* **LLVM IR** (`compiler = "llc"`) — compiles `.ll` files via `llc -filetype=obj`.
|
||||
* **Shared ASM pipeline** — linking and archiving logic consolidated into `core/builder/asm.rs`. Adding a new assembler backend now takes ~30 lines.
|
||||
* **Filesystem utilities** — `to_hex()` and `home_dir()` extracted to `utils/fs.rs`.
|
||||
* **Build utilities** — `normalize_target()`, `normalize_kind()`, `normalize_platform()`, `default_profile_flags()` extracted to `utils/build.rs`.
|
||||
* **Backend helpers** — `asm_lang_flag()`, `source_extensions()`, `elapsed_secs()` added to `core/builder/common.rs`.
|
||||
* **Full Bare-Metal / Freestanding Automation** — introduced the `build.freestanding = true` configuration option. When enabled (or when a bare-metal target is detected), DCR automatically injects `-ffreestanding` during compilation and both `-nostdlib` and `-static` during linking.
|
||||
* **Artifact Optimization (LTO & Strip)** — added `build.lto` (auto-injects `-flto` for compiler and linker) and `build.strip` (automatically strips debug symbols via linker `-s` flag) options to `dcr.toml`.
|
||||
* **Compilation Thread Control** — added the `build.codegen-units` option to strictly limit the maximum number of parallel jobs utilized by the custom `parallel_build` worker pool.
|
||||
* **Panic Behavior Management** — added `build.panic = "abort"` support. For C++ targets, it automatically strips exception handling and unwind tables via `-fno-exceptions`, `-fno-unwind-tables`, and `-fno-asynchronous-unwind-tables`.
|
||||
|
||||
### Changed
|
||||
|
||||
* **Intelligent Default Flags Generation** — automated injection of fallback optimization (`-O3`/`-O0`), debug (`-g`), and warning (`-Wall -Wextra`) flags is now suppressed for bare-metal and freestanding builds if `build.cflags` are overridden.
|
||||
* **Centralized Bare-Metal Detection** — relocated the `is_bare_metal_target` helper to common build utilities (`src/utils/build.rs`) for unified access across the building core.
|
||||
* **Architectural Refactoring**:
|
||||
* Renamed `src/config.rs` to `src/templates.rs`.
|
||||
* Started consolidation of configuration and build orchestration logic.
|
||||
|
||||
## 0.7.3 (2026-06-13)
|
||||
|
||||
### Added
|
||||
|
||||
* **`--vcs` option for `new` and `init` commands** — introduced explicit version control system selection via `--vcs \<git|none>`.
|
||||
* **Git metadata integration in `--version`** — the CLI now appends the current short commit hash and a `-dirty` suffix if there are uncommitted changes in the DCR repository.
|
||||
* **Automatic `.gitignore` generation** — Git repository initialization now automatically writes a `.gitignore` file excluding the `/target` directory.
|
||||
* **Nested repository prevention** — automatic Git initialization is now skipped if `dcr new` or `dcr init` is executed inside an already existing Git repository.
|
||||
* **VCS verification tests** — added `new_vcs_options_work` and `init_vcs_options_work` integration tests to ensure reliable repository behavior.
|
||||
|
||||
### Changed
|
||||
|
||||
* **Complete removal of `git2` dependency** — all Git actions (dependency fetching, VCS setup, status checks) are now delegated to the system `git` executable via `Command`. This simplifies compilation and drops the need for `vendored` and `openssl` features.
|
||||
* **Migrated from `reqwest` to `ureq`** — replaced the heavy `reqwest` crate in `flag_update.rs` with the lightweight synchronous `ureq 2.10` client, reducing overhead and the final binary size.
|
||||
|
||||
## 0.7.2 (2026-06-07)
|
||||
|
||||
### Added
|
||||
|
||||
* `default_target_triple()` now respects `target_env` — Linux (gnu/musl) and Windows (msvc/gnu) use the correct environment instead of hardcoded values.
|
||||
|
||||
### Исправлено:
|
||||
|
||||
* **macOS Apple Silicon builds failed with `_main` undefined** — `--target=` is now passed to ldflags, not just cflags. `default_target_triple()` uses `std::env::consts::ARCH` on macOS instead of hardcoded `x86_64`.
|
||||
* **GitHub Stars and GPL-3.0 badges not rendering in README** — badge block converted to pure HTML.
|
||||
|
||||
### Changed
|
||||
|
||||
* Default target resolution extracted into shared `default_target_triple()` — removed duplication across build, run, clean.
|
||||
|
||||
## 0.7.1 (02.06.2026)
|
||||
|
||||
### Added
|
||||
|
||||
* **`--help` для всех команд** — `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`,
|
||||
@@ -29,7 +131,7 @@ sidebar_label: Список изменений
|
||||
* **Публикация Snap** — автоматическая публикация Snapcraft в рамках непрерывной интеграции (CI).
|
||||
* **Значок Snap** — в файле README.
|
||||
|
||||
### Изменено:
|
||||
### Changed
|
||||
|
||||
* **`validate_package_name` стал общедоступным** — его можно вызывать из команд CLI.
|
||||
* **Таблица платформы README** — реорганизована: варианты libc вынесены в отдельные строки по ОС,
|
||||
@@ -38,7 +140,7 @@ sidebar_label: Список изменений
|
||||
* **`tree.rs`, `fmt.rs` и `setup.rs`** — теперь поддерживают аргументы для опции `--help`.
|
||||
* **Команды установки из файла README** — `| bash` → `| sh` для обеспечения совместимости с POSIX.
|
||||
|
||||
### Исправлено:
|
||||
### Исправлено
|
||||
|
||||
* **`dcr new \<invalid-name>` создает каталог, а затем завершается с ошибкой** — теперь проверка
|
||||
выполняется до начала любых операций с файлами.
|
||||
@@ -50,7 +152,7 @@ sidebar_label: Список изменений
|
||||
|
||||
## 0.7.0 (01.06.2026)
|
||||
|
||||
### Добавлено
|
||||
### Added
|
||||
|
||||
* **Поддержка целевых платформ OpenBSD и NetBSD** — полная маршрутизация по платформам с динамически генерируемыми тройками целевых параметров с использованием `std::env::consts::ARCH` и `std::env::consts::OS`. Затрагивает команды `build`, `run`, `clean` и модуль платформы.
|
||||
* **`src/platform/bsd.rs`** — новый специальный модуль платформы BSD, общий для FreeBSD, OpenBSD и NetBSD, предоставляющий `bin_path`, `lib_path`, `elf_path`, `efi_path` и `shared_lib_path`.
|
||||
@@ -65,7 +167,7 @@ sidebar_label: Список изменений
|
||||
* **Интеграционные тесты** — `build_with_target_config` (проверяет `build.target = «linux»`) и `build_with_out_dir` (проверяет настраиваемый каталог вывода).
|
||||
* **`get_build_string_with_profile` стал `pub`** — чтобы `run.rs` мог определять конфигурацию настраиваемого каталога вывода.
|
||||
|
||||
### Изменено
|
||||
### Changed
|
||||
|
||||
* **Изменена семантика `build.target`** — теперь строго содержит тройку целей (например, `x86_64-unknown-linux-gnu`) или короткое имя (`linux`, `macos`, `windows`). Больше не используется в качестве пользовательского каталога вывода — эта функциональность перенесена в `build.out_dir`.
|
||||
* **`build.standard` стал опциональным** — изменен с `String` на `Option\<String>`. Проверка обеспечивает только непустоту для языков, отличных от ASM. Пропускается в выводе `dcr.toml`, если пуст.
|
||||
@@ -75,7 +177,7 @@ sidebar_label: Список изменений
|
||||
* **Таблица совместимости README** — статус сборки/работы на FreeBSD, OpenBSD, NetBSD повышен с «сообщество/по возможности» до «официально поддерживается».
|
||||
* **Обновлена документация** — `build-section.md` описывает новые поля `build.target` и `build.out_dir`. `target-directory.md` переписан для уточнения различия.
|
||||
|
||||
### Исправлено
|
||||
### Fixed
|
||||
|
||||
* **stdout/stderr `dcr run` не наследуются** — вывод дочернего процесса захватывался и выводился вручную, что приводило к сбоям интерактивных программ. Исправлено путем перехода на `Command::status()`.
|
||||
* **Условие гонки в CI релиза** — задания матрицы сборки могли загружать ресурсы в релиз, который еще не существовал. Исправлено добавлением специального задания `create-release`.
|
||||
|
||||
@@ -9,19 +9,20 @@ sidebar_label: Команды сборки (build, run, clean)
|
||||
Собирает проект по `dcr.toml`.
|
||||
|
||||
```bash
|
||||
dcr build # debug профиль
|
||||
dcr build --release # release профиль
|
||||
dcr build --debug # явно debug
|
||||
dcr build --profile custom # произвольный профиль
|
||||
dcr build # debug profile
|
||||
dcr build --release # release build
|
||||
dcr build --debug # explicit debug
|
||||
dcr build --target aarch64-unknown-linux-gnu
|
||||
dcr build --force # пересобрать всё с нуля
|
||||
dcr build --force # full rebuild (also re-runs build.steps / post_steps)
|
||||
dcr build --clean # clean + build
|
||||
dcr build --verbose # показать команды компиляции
|
||||
dcr build --workspace pkg-a # собрать конкретный пакет в workspace
|
||||
dcr build --verbose # show compilation commands
|
||||
dcr build --workspace pkg-a # build specific workspace package
|
||||
```
|
||||
|
||||
Артефакты: `target/\<triple>/\<profile>/\<binary-name>` (Linux с явным целевым объектом).
|
||||
|
||||
With `[archive]` in `dcr.toml`, a FAT disk image is packed after a successful build.
|
||||
|
||||
## `dcr run`
|
||||
|
||||
Собирает (если исходники новее артефакта) и запускает бинарник.
|
||||
@@ -29,8 +30,11 @@ dcr build --workspace pkg-a # собрать конкретный паке
|
||||
```bash
|
||||
dcr run
|
||||
dcr run --release
|
||||
dcr run --force # force rebuild then run
|
||||
```
|
||||
|
||||
On a **workspace-only** root: if `[run].cmd` is set, that command is used after build; otherwise DCR delegates to a workspace member.
|
||||
|
||||
## `dcr clean`
|
||||
|
||||
Удаляет директорию `target/`(или `target/\<target>/\<profile>`).
|
||||
|
||||
@@ -46,6 +46,6 @@ cargo clippy --all-targets -- -D warnings
|
||||
|
||||
* `cargo fmt --check`
|
||||
* `cargo clippy --all-targets -- -D warnings`
|
||||
* `cargo test --all-targets`
|
||||
* `cargo check --all-targets --all-features`
|
||||
* Сборка под Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD
|
||||
* Интеграционные тесты
|
||||
* Integration tests (compilation check)
|
||||
|
||||
@@ -39,27 +39,6 @@ echo $DCR_INDEX_PATH
|
||||
|
||||
Или укажите явно через `[toolchain]` или `DCR_COMPILER`.
|
||||
|
||||
## Сбой сборки openssl-sys
|
||||
|
||||
При сборке DCR из исходников:
|
||||
|
||||
```
|
||||
Ошибка: не удалось выполнить пользовательскую команду сборки для openssl-sys
|
||||
```
|
||||
|
||||
**Решение:** Установите OpenSSL development headers:
|
||||
|
||||
```bash
|
||||
# Ubuntu/Debian
|
||||
sudo apt install libssl-dev
|
||||
|
||||
# Fedora
|
||||
sudo dnf install openssl-devel
|
||||
|
||||
# macOS
|
||||
brew install openssl
|
||||
```
|
||||
|
||||
## Ctrl+C во время сборки
|
||||
|
||||
DCR корректно обрабатывает SIGINT: прерывает текущую компиляцию и завершает процесс с ненулевым кодом.
|
||||
@@ -76,6 +55,12 @@ DCR корректно обрабатывает SIGINT: прерывает те
|
||||
|
||||
См. [Workspace Recipe](/docs/recipes/multi-package-workspace).
|
||||
|
||||
## Bootloader / pure NASM OS image
|
||||
|
||||
Use `kind = "flat-bin"` (NASM `-f bin`) and optional `[archive]` for a FAT disk image.
|
||||
|
||||
See [OS-dev recipe](/docs/recipes/os-flat-bin-archive).
|
||||
|
||||
## Lock-файл устарел
|
||||
|
||||
При изменении зависимостей `dcr.lock` автоматически обновляется при следующем `dcr add`. Если нужно принудительно обновить — удалите `dcr.lock` и выполните `dcr build`.
|
||||
|
||||
@@ -70,3 +70,10 @@ dcr test # запустить тесты
|
||||
```bash
|
||||
dcr fmt # clang-format по .clang-format
|
||||
```
|
||||
|
||||
## Linting
|
||||
|
||||
```bash
|
||||
dcr lint # clang-tidy checks
|
||||
dcr lint --fix # apply fixes automatically
|
||||
```
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
---
|
||||
sidebar_label: OS-dev (flat-bin + archive)
|
||||
---
|
||||
|
||||
# Pure ASM / boot image (flat-bin + archive)
|
||||
|
||||
Minimal OS-dev style pipeline: assemble raw binaries with NASM, then pack a FAT floppy/image with an optional boot sector.
|
||||
|
||||
## Project layout
|
||||
|
||||
```
|
||||
myos/
|
||||
dcr.toml
|
||||
src/
|
||||
boot.asm # boot sector (512 bytes)
|
||||
kernel.asm # payload
|
||||
```
|
||||
|
||||
For multiple flat artifacts, use a **workspace** (one member per binary) or separate packages; a single `flat-bin` package produces one binary per source stem.
|
||||
|
||||
## Boot package (`flat-bin`)
|
||||
|
||||
```toml
|
||||
[package]
|
||||
name = "boot"
|
||||
version = "0.1.0"
|
||||
|
||||
[build]
|
||||
language = "asm"
|
||||
compiler = "nasm"
|
||||
kind = "flat-bin"
|
||||
extension = "bin"
|
||||
roots = ["src/boot.asm"]
|
||||
```
|
||||
|
||||
```bash
|
||||
dcr build
|
||||
# → target/<…>/debug/boot.bin (NASM -f bin, no link)
|
||||
```
|
||||
|
||||
## Disk image after build
|
||||
|
||||
```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"
|
||||
```
|
||||
|
||||
* `format`: `fat12`, `fat16`, or `fat32`
|
||||
* `size`: bytes or `K`/`KB`/`M`/`MB`/`G`/`GB` (default ~1.44 MiB)
|
||||
* `bootsector`: written only when `offset` is omitted or `0`
|
||||
* `from` may be a glob; `{profile}` is substituted in paths
|
||||
|
||||
## C kernel → flat binary
|
||||
|
||||
```toml
|
||||
[build]
|
||||
language = "c"
|
||||
compiler = "clang"
|
||||
kind = "flat-bin"
|
||||
freestanding = true
|
||||
filename = "kernel"
|
||||
extension = "bin"
|
||||
ldflags = ["-T", "linker.ld"]
|
||||
```
|
||||
|
||||
Pipeline: objects → temporary linked ELF → `objcopy -O binary` → `kernel.bin`. Requires `objcopy` / `llvm-objcopy` in PATH.
|
||||
|
||||
## Other assemblers
|
||||
|
||||
| Tool | Notes |
|
||||
| -------- | --------------------------------------------------------------------------------------- |
|
||||
| **FASM** | Write `format binary` in the source; DCR writes `\<stem>.bin` directly |
|
||||
| **GAS** | Assemble `.s` → obj → `objcopy -O binary` |
|
||||
| **LLC** | `language = "llvm_ir"` → obj → objcopy |
|
||||
| **MASM** | COFF obj → objcopy (needs binutils/LLVM objcopy) |
|
||||
|
||||
## Notes
|
||||
|
||||
* Single-file `roots` are supported: `roots = ["src/boot.asm"]`.
|
||||
* `--force` re-runs `build.steps` / `build.post_steps` as well as recompilation.
|
||||
* Prefer `kind = "elf"` if you need a relocatable ELF kernel without stripping to raw binary.
|
||||
@@ -56,7 +56,7 @@ moc = "moc {in} -o {out}"
|
||||
### GAS / NASM
|
||||
|
||||
* GAS: `-I`, `-c -o`, `--defsym`
|
||||
* NASM: `-I`, `-c -o`, `-D`, `-f` (формат: win64/elf64/macho64/macho32/elf32)
|
||||
* NASM: `-I`, `-o`, `-D`, `-f` (format: win64/elf64/macho64/macho32/elf32; **`bin` when `kind = "flat-bin"`**)
|
||||
* MASM: `/nologo /c /Fo\<obj> <source>`
|
||||
* FASM: `<source> \<output>` (путь вывода — объектный файл)
|
||||
* LLVM IR: `-filetype=obj <source> -o \<output>`
|
||||
@@ -78,15 +78,20 @@ moc = "moc {in} -o {out}"
|
||||
|
||||
## Типы сборок
|
||||
|
||||
| Тип | Тип | Путь (пример для Linux) |
|
||||
| ------------------ | ------------------------------------ | ----------------------------------------------------------------------------------------------- |
|
||||
| `bin` | Исполняемый файл | `target/\<profile>/\<name>` (.exe) |
|
||||
| `staticlib` | Статическая библиотека | `target/\<profile>/lib\<name>.a` (.lib) |
|
||||
| `sharedlib` | Динамическая библиотека | `target/\<profile>/lib\<name>.so` (.dll/.dylib) |
|
||||
| `efi` | UEFI приложение | `target/\<profile>/\<name>.efi` |
|
||||
| `эльф` | ELF без стандартной библиотеки | `target/\<profile>/\<name>` |
|
||||
| `нет` | Только компиляция, без линковки | — |
|
||||
| `пользовательский` | Полный контроль filename + extension | `target/\<profile>/\<filename>.\<extension>` |
|
||||
| Тип | Тип | Путь (пример для Linux) |
|
||||
| ------------------ | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `bin` | Исполняемый файл | `target/\<profile>/\<name>` (.exe) |
|
||||
| `staticlib` | Статическая библиотека | `target/\<profile>/lib\<name>.a` (.lib) |
|
||||
| `sharedlib` | Динамическая библиотека | `target/\<profile>/lib\<name>.so` (.dll/.dylib) |
|
||||
| `efi` | UEFI приложение | `target/\<profile>/\<name>.efi` |
|
||||
| `эльф` | ELF без стандартной библиотеки | `target/\<profile>/\<name>` |
|
||||
| `нет` | Только компиляция, без линковки | — |
|
||||
| `пользовательский` | Полный контроль filename + extension | `target/\<profile>/\<filename>.\<extension>` |
|
||||
| `flat-bin` | Raw binary | ASM: `\<stem>.bin` (NASM `-f bin` / FASM / GAS·MASM·LLC via objcopy); C/C++: `\<name>.bin` (link + objcopy) |
|
||||
|
||||
## Disk images (`[archive]`)
|
||||
|
||||
After a successful build, if `[archive]` is present in `dcr.toml`, DCR formats a FAT volume and copies files from `layout` into the image. See [dcr.toml → archive](/docs/reference/dcr-toml#archive).
|
||||
|
||||
## Этапы сборки
|
||||
|
||||
|
||||
@@ -57,14 +57,8 @@ dcr build --target aarch64-none-elf
|
||||
|
||||
## Целевой каталог
|
||||
|
||||
В Linux с явным указанием цели:
|
||||
By default, the compilation output directories are structured as follows:
|
||||
|
||||
```
|
||||
target/<triple>/<profile>/
|
||||
```
|
||||
|
||||
В macOS/Windows или без указания целевой платформы:
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
```
|
||||
* **Linux and BSD**: Always output to `target/\<triple>/\<profile>/` (using host triple if no target is specified).
|
||||
* **macOS and Windows (without target)**: Output to `target/\<profile>/`.
|
||||
* **macOS and Windows (with explicit target)**: Output to `target/\<triple>/\<profile>/`.
|
||||
|
||||
@@ -10,30 +10,32 @@ sidebar_label: Обзор dcr.toml
|
||||
|
||||
```toml
|
||||
[package]
|
||||
# обязательные поля
|
||||
# required fields
|
||||
|
||||
[build]
|
||||
# настройки сборки
|
||||
# build settings
|
||||
|
||||
[build.debug] # опционально: переопределение для debug
|
||||
[build.release] # опционально: переопределение для release
|
||||
[build.debug] # optional: debug override
|
||||
[build.release] # optional: release override
|
||||
|
||||
[build.linux] # опционально: переопределение для Linux
|
||||
[build.windows] # опционально: переопределение для Windows
|
||||
[build.windows.debug] # комбинация target + profile
|
||||
[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.release] # опционально: переопределение для release
|
||||
# настройки запуска
|
||||
# run settings
|
||||
|
||||
[archive]
|
||||
# optional: pack FAT disk image after build
|
||||
```
|
||||
|
||||
## [пакет]
|
||||
@@ -61,36 +63,36 @@ author = "John Doe"
|
||||
|
||||
* `build.qt` — (bool) Включить автоматическую обработку метаобъектов Qt (MOC, UIC, RCC). Требуется установка модулей `qt6` с помощью `pkg-config`.
|
||||
|
||||
| Поле | По умолчанию | Описание |
|
||||
| ------------------------ | ------------- | ---------------------------------------------------------------------------------------------------- |
|
||||
| `язык` | `"c"` | `"c"`, `"c++"`, `"cpp"`, `"cxx"`, `"asm"` (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` |
|
||||
| `target` | хост | Target triple для кросс-компиляции |
|
||||
| `платформа` | `"нативный"` | `native`, `efi`, `freestanding` |
|
||||
| `cflags` | `[]` | Дополнительные флаги C++ |
|
||||
| `ldflags` | `[]` | Дополнительные флаги линковки |
|
||||
| `имя файла` | `""` | Кастомное имя выходного файла |
|
||||
| `расширение` | `""` | Пользовательское расширение файла |
|
||||
| `корни` | `["src"]` | Корневые директории с исходниками |
|
||||
| `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) |
|
||||
| Поле | По умолчанию | Описание |
|
||||
| ------------------------ | ------------- | --------------------------------------------------------------------------------------------------------- |
|
||||
| `язык` | `"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) |
|
||||
|
||||
Параметры из исходного файла конфигурации (не в виде типизированной структуры):
|
||||
|
||||
@@ -98,7 +100,7 @@ author = "John Doe"
|
||||
* Путь к linker script
|
||||
* `build.steps` / `build.post_steps` — этапы генерации кода
|
||||
|
||||
## Per-language overrides: `[build.c]`, `[build.cxx]`, `[build.asm]`
|
||||
## 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:
|
||||
|
||||
@@ -118,6 +120,9 @@ 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.
|
||||
@@ -175,3 +180,82 @@ 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]`).
|
||||
|
||||
| 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` → `\<stem>.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 `\<filename|name>.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 `\<stem>.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).
|
||||
|
||||
@@ -71,6 +71,8 @@ mylib = { path = "/abs/path/to/lib" }
|
||||
mylib = { path = "../relative/path" }
|
||||
```
|
||||
|
||||
*Note: Header resolution automatically checks the packaged `target/include` directory of path dependencies, ensuring consumer packages can find headers from compiled static or dynamic libraries.*
|
||||
|
||||
## dcr.lock
|
||||
|
||||
Dependency lock file. Contains package names and sources.
|
||||
|
||||
@@ -11,17 +11,18 @@ DCR нормализует target triple через `platform_triple::normalize_
|
||||
### Linux
|
||||
|
||||
```
|
||||
target/<arch>-unknown-linux-gnu/<profile>/
|
||||
target/<arch>-unknown-linux-<env>/<profile>/
|
||||
```
|
||||
|
||||
Поддержка архитектур: `x86_64`, `aarch64`.
|
||||
Architectures: `x86_64`, `aarch64`, `i686`, `armv7`, `riscv64` (host-detected).
|
||||
Environments: `gnu` (default), `musl`.
|
||||
|
||||
Тип артефакта: ELF. Расширения: `.so` для sharedlib, `.a` для staticlib
|
||||
|
||||
### macOS
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
target/<profile>/ (default) or target/<triple>/<profile>/ (with target)
|
||||
```
|
||||
|
||||
Поддержка архитектур: `x86_64`, `aarch64`.
|
||||
@@ -31,10 +32,11 @@ target/<profile>/
|
||||
### Windows
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
target/<profile>/ (default) or target/<triple>/<profile>/ (with target)
|
||||
```
|
||||
|
||||
Поддержка архитектур: `x86_64`, `aarch64`.
|
||||
Environments: `msvc` (default), `gnu` (MinGW).
|
||||
|
||||
Расширения: `.exe` (бинарный файл), `.lib` (статическая библиотека), `.dll` (общая библиотека), `.efi` (UEFI).
|
||||
|
||||
|
||||
@@ -38,7 +38,10 @@ dcr build # собрать все пакеты
|
||||
dcr build --workspace pkg-a # собрать только pkg-a
|
||||
```
|
||||
|
||||
При сборке workspace выходные файлы member-ов (библиотеки) автоматически добавляются в include/lib пути зависимых пакетов.
|
||||
When building a workspace, DCR automatically injects include and library paths of dependent workspace members:
|
||||
|
||||
* **Include Paths**: Automatically resolves and injects header directories of dependencies, including the member's `src/` directory, local `include/` directory, and the packaged `target/include` directory.
|
||||
* **Library Paths**: Injects compiled library search paths (`target/lib` as well as target-specific build folders) to allow automatic linking with member libraries.
|
||||
|
||||
## Очистка
|
||||
|
||||
|
||||
@@ -51,8 +51,9 @@ dcr gen vscode
|
||||
|
||||
* **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
|
||||
* **7 backends** — gcc/clang (unix_cc), MSVC/clang-cl (msvc), GAS, NASM, MASM, FASM, LLVM IR
|
||||
* **8 project kinds** — bin, staticlib, sharedlib, efi, elf, none, custom, flat-bin
|
||||
* **Disk images** — optional `[archive]` packs FAT12/16/32 images after build
|
||||
* **Cross-compilation** — short names and full triples
|
||||
* **Profiles** — debug / release with field overrides
|
||||
* **Workspaces** — multi-package projects with topological sort
|
||||
|
||||
@@ -4,6 +4,108 @@ sidebar_label: Changelog
|
||||
|
||||
# Changelog
|
||||
|
||||
## 0.8.1 (2026-07-20)
|
||||
|
||||
### Added
|
||||
|
||||
* **`build.kind = "flat-bin"`** — raw binary (default `.bin`) for OS-dev payloads:
|
||||
* **NASM** — `-f bin` → `\<stem>.bin`
|
||||
* **FASM** — direct output (`format binary` in source)
|
||||
* **GAS / MASM / LLC** — object → `objcopy -O binary` → `\<stem>.bin`
|
||||
* **C/C++** — objects → freestanding link → `objcopy -O binary` → `\<name>.bin`
|
||||
* Requires `llvm-objcopy` / `objcopy` / `gobjcopy` except for NASM/FASM direct emit
|
||||
* **`[archive]` section** — after a successful build, pack a FAT disk image (`fatfs`): `output`, `format` (`fat12`/`fat16`/`fat32`), optional `size` (default 1.44 MiB), `offset`, `label`, `bootsector`, and `layout` (`from` → `to`, supports globs). `{profile}` works in paths.
|
||||
* **Single-file `build.roots`** — a root may be a single source or header file, not only a directory.
|
||||
|
||||
### Changed
|
||||
|
||||
* **`--force`** also re-runs `build.steps` and `build.post_steps`.
|
||||
* **`dcr run` on workspace-only root** — if `[run].cmd` is set, run that after build; otherwise delegate to a workspace member.
|
||||
|
||||
### Dependencies
|
||||
|
||||
* `fatfs = "0.3"` for FAT image packing.
|
||||
|
||||
## 0.8.0 (2026-07-18)
|
||||
|
||||
### Added
|
||||
|
||||
* **Dedicated Build Engine (`src/core/build/engine.rs`)** — decoupled the build orchestration logic completely from the CLI front-end wrapper in `src/cli/build.rs` to a reusable, decoupled core build engine.
|
||||
* **Polymorphic Language Model (`Language` trait)** — introduced the abstract `Language` trait (`src/core/build/language/mod.rs`). File scanning, compiler resolution, and flags handling are now encapsulated in dedicated language modules for C, C++ (including Qt code generation), LLVM IR, and ASM (GAS, NASM, FASM, MASM).
|
||||
* **Polymorphic Compilation Dispatch (`Builder` trait)** — introduced the `Builder` trait to generalize builder invocations (`src/core/build/builder/mod.rs`). Consolidated GCC/Clang logic into `builder/cc_common.rs` and Microsoft Visual C++ logic into `builder/msvc/`.
|
||||
* **Per-Language Configuration overrides (`[build.\<lang>]`)** — introduced support for configuring language-specific compiler, standard, and flags (e.g. `[build.c]`, `[build.cxx]`, `[build.asm]`) independently in `dcr.toml`.
|
||||
* **Automatic Workspace Dependency Injection** — during workspace builds, include/lib paths of dependent workspace members (including their source headers, local `include/` folders, and build target `target/include` / `target/lib` folders) are automatically resolved and injected.
|
||||
* **`BuildReporter` Event System** — decoupled build orchestration output into a structured event-driven reporter model (`src/core/build/report.rs`), making DCR suitable for library embedding and IDE integrations without stderr capturing.
|
||||
* **Build Cancellation Support** — introduced thread-safe cancellation tokens (`Arc\<AtomicBool>`) allowing clients to safely abort compile runs mid-execution.
|
||||
* **TOML Formatting & Custom Keys Preservation** — migrated the config editor to `toml_edit`, preserving all unknown/user-defined TOML keys, structures, and comments during file write operations (e.g., in `dcr add`).
|
||||
* **Path Dependencies Target Include Resolution** — local path dependencies configured via tables now correctly expose headers built and packaged into their `target/include` folder to consumer packages.
|
||||
* **Modular Integration Test Suite** — refactored the monolith `tests/cli_basic.rs` file into clean, specialized integration tests: `cli_build.rs`, `cli_deps.rs`, `cli_lint.rs`, `cli_new.rs`, `cli_qt.rs`, `cli_test.rs`, `cli_workspace.rs`.
|
||||
|
||||
### Changed
|
||||
|
||||
* **Consolidated Linking and Archiving** — artifact generation (linking executables/shared libraries and archiving static libraries) consolidated into a single `src/core/build/builder/artifact.rs` module.
|
||||
* **Workspace-Aware member execution** — `dcr run` executed at the workspace root of a `workspace_only` project now triggers the member build inside the workspace context using the `--workspace` parameter, preventing standalone build issues.
|
||||
* **Elimination of Global State** — removed global variables and states from the build core, encapsulating build logic inside isolated `BuildContext` structs for thread safety.
|
||||
* **Build Cache Separation** — relocated mtime tracking, incremental caching, and header-dependency checking logic to `src/core/build/cache.rs`.
|
||||
* **Modularized Pre-build Steps** — decoupled generator scripts and pre-build commands parsing into `src/core/build/steps.rs`.
|
||||
|
||||
## 0.7.4 (2026-06-17)
|
||||
|
||||
### Added
|
||||
|
||||
* **Native Qt support** — automatic meta-object handling (MOC, UIC, RCC) added when `build.qt = true` is set in `dcr.toml`.
|
||||
* **`dcr lint` command** — C/C++ static analysis via `clang-tidy`. Supports `--fix` for automatic fixes. Respects `build.roots` and `build.src_disable` from config.
|
||||
* **Three new assembler backends**:
|
||||
* **MASM** (`compiler = "ml"` / `"ml64"`) — Microsoft Macro Assembler.
|
||||
* **FASM** (`compiler = "fasm"`) — Flat Assembler.
|
||||
* **LLVM IR** (`compiler = "llc"`) — compiles `.ll` files via `llc -filetype=obj`.
|
||||
* **Shared ASM pipeline** — linking and archiving logic consolidated into `core/builder/asm.rs`. Adding a new assembler backend now takes ~30 lines.
|
||||
* **Filesystem utilities** — `to_hex()` and `home_dir()` extracted to `utils/fs.rs`.
|
||||
* **Build utilities** — `normalize_target()`, `normalize_kind()`, `normalize_platform()`, `default_profile_flags()` extracted to `utils/build.rs`.
|
||||
* **Backend helpers** — `asm_lang_flag()`, `source_extensions()`, `elapsed_secs()` added to `core/builder/common.rs`.
|
||||
* **Full Bare-Metal / Freestanding Automation** — introduced the `build.freestanding = true` configuration option. When enabled (or when a bare-metal target is detected), DCR automatically injects `-ffreestanding` during compilation and both `-nostdlib` and `-static` during linking.
|
||||
* **Artifact Optimization (LTO & Strip)** — added `build.lto` (auto-injects `-flto` for compiler and linker) and `build.strip` (automatically strips debug symbols via linker `-s` flag) options to `dcr.toml`.
|
||||
* **Compilation Thread Control** — added the `build.codegen-units` option to strictly limit the maximum number of parallel jobs utilized by the custom `parallel_build` worker pool.
|
||||
* **Panic Behavior Management** — added `build.panic = "abort"` support. For C++ targets, it automatically strips exception handling and unwind tables via `-fno-exceptions`, `-fno-unwind-tables`, and `-fno-asynchronous-unwind-tables`.
|
||||
|
||||
### Changed
|
||||
|
||||
* **Intelligent Default Flags Generation** — automated injection of fallback optimization (`-O3`/`-O0`), debug (`-g`), and warning (`-Wall -Wextra`) flags is now suppressed for bare-metal and freestanding builds if `build.cflags` are overridden.
|
||||
* **Centralized Bare-Metal Detection** — relocated the `is_bare_metal_target` helper to common build utilities (`src/utils/build.rs`) for unified access across the building core.
|
||||
* **Architectural Refactoring**:
|
||||
* Renamed `src/config.rs` to `src/templates.rs`.
|
||||
* Started consolidation of configuration and build orchestration logic.
|
||||
|
||||
## 0.7.3 (2026-06-13)
|
||||
|
||||
### Added
|
||||
|
||||
* **`--vcs` option for `new` and `init` commands** — introduced explicit version control system selection via `--vcs \<git|none>`.
|
||||
* **Git metadata integration in `--version`** — the CLI now appends the current short commit hash and a `-dirty` suffix if there are uncommitted changes in the DCR repository.
|
||||
* **Automatic `.gitignore` generation** — Git repository initialization now automatically writes a `.gitignore` file excluding the `/target` directory.
|
||||
* **Nested repository prevention** — automatic Git initialization is now skipped if `dcr new` or `dcr init` is executed inside an already existing Git repository.
|
||||
* **VCS verification tests** — added `new_vcs_options_work` and `init_vcs_options_work` integration tests to ensure reliable repository behavior.
|
||||
|
||||
### Changed
|
||||
|
||||
* **Complete removal of `git2` dependency** — all Git actions (dependency fetching, VCS setup, status checks) are now delegated to the system `git` executable via `Command`. This simplifies compilation and drops the need for `vendored` and `openssl` features.
|
||||
* **Migrated from `reqwest` to `ureq`** — replaced the heavy `reqwest` crate in `flag_update.rs` with the lightweight synchronous `ureq 2.10` client, reducing overhead and the final binary size.
|
||||
|
||||
## 0.7.2 (2026-06-07)
|
||||
|
||||
### Added
|
||||
|
||||
* `default_target_triple()` now respects `target_env` — Linux (gnu/musl) and Windows (msvc/gnu) use the correct environment instead of hardcoded values.
|
||||
|
||||
### Fixed
|
||||
|
||||
* **macOS Apple Silicon builds failed with `_main` undefined** — `--target=` is now passed to ldflags, not just cflags. `default_target_triple()` uses `std::env::consts::ARCH` on macOS instead of hardcoded `x86_64`.
|
||||
* **GitHub Stars and GPL-3.0 badges not rendering in README** — badge block converted to pure HTML.
|
||||
|
||||
### Changed
|
||||
|
||||
* Default target resolution extracted into shared `default_target_triple()` — removed duplication across build, run, clean.
|
||||
|
||||
## 0.7.1 (2026-06-02)
|
||||
|
||||
### Added
|
||||
|
||||
@@ -13,7 +13,7 @@ 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 --force # full rebuild (also re-runs build.steps / post_steps)
|
||||
dcr build --clean # clean + build
|
||||
dcr build --verbose # show compilation commands
|
||||
dcr build --workspace pkg-a # build specific workspace package
|
||||
@@ -21,6 +21,8 @@ dcr build --workspace pkg-a # build specific workspace package
|
||||
|
||||
Artifacts: `target/\<triple>/\<profile>/\<binary-name>` (Linux with explicit target).
|
||||
|
||||
With `[archive]` in `dcr.toml`, a FAT disk image is packed after a successful build.
|
||||
|
||||
## `dcr run`
|
||||
|
||||
Builds (if sources are newer than artifacts) and runs the binary.
|
||||
@@ -28,8 +30,11 @@ Builds (if sources are newer than artifacts) and runs the binary.
|
||||
```bash
|
||||
dcr run
|
||||
dcr run --release
|
||||
dcr run --force # force rebuild then run
|
||||
```
|
||||
|
||||
On a **workspace-only** root: if `[run].cmd` is set, that command is used after build; otherwise DCR delegates to a workspace member.
|
||||
|
||||
## `dcr clean`
|
||||
|
||||
Removes `target/` directory (or `target/\<target>/\<profile>`).
|
||||
|
||||
@@ -46,6 +46,6 @@ CI runs:
|
||||
|
||||
* `cargo fmt --check`
|
||||
* `cargo clippy --all-targets -- -D warnings`
|
||||
* `cargo test --all-targets`
|
||||
* `cargo check --all-targets --all-features`
|
||||
* Build on Linux, macOS, Windows
|
||||
* Integration tests
|
||||
* Integration tests (compilation check)
|
||||
|
||||
@@ -39,27 +39,6 @@ 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.
|
||||
@@ -76,6 +55,12 @@ See [Cross-Compile Recipe](/docs/recipes/cross-to-windows).
|
||||
|
||||
See [Workspace Recipe](/docs/recipes/multi-package-workspace).
|
||||
|
||||
## Bootloader / pure NASM OS image
|
||||
|
||||
Use `kind = "flat-bin"` (NASM `-f bin`) and optional `[archive]` for a FAT disk image.
|
||||
|
||||
See [OS-dev recipe](/docs/recipes/os-flat-bin-archive).
|
||||
|
||||
## 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`.
|
||||
|
||||
@@ -70,3 +70,10 @@ dcr test # run tests
|
||||
```bash
|
||||
dcr fmt # clang-format with .clang-format
|
||||
```
|
||||
|
||||
## Linting
|
||||
|
||||
```bash
|
||||
dcr lint # clang-tidy checks
|
||||
dcr lint --fix # apply fixes automatically
|
||||
```
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
---
|
||||
sidebar_label: OS-dev (flat-bin + archive)
|
||||
---
|
||||
|
||||
# Pure ASM / boot image (flat-bin + archive)
|
||||
|
||||
Minimal OS-dev style pipeline: assemble raw binaries with NASM, then pack a FAT floppy/image with an optional boot sector.
|
||||
|
||||
## Project layout
|
||||
|
||||
```
|
||||
myos/
|
||||
dcr.toml
|
||||
src/
|
||||
boot.asm # boot sector (512 bytes)
|
||||
kernel.asm # payload
|
||||
```
|
||||
|
||||
For multiple flat artifacts, use a **workspace** (one member per binary) or separate packages; a single `flat-bin` package produces one binary per source stem.
|
||||
|
||||
## Boot package (`flat-bin`)
|
||||
|
||||
```toml
|
||||
[package]
|
||||
name = "boot"
|
||||
version = "0.1.0"
|
||||
|
||||
[build]
|
||||
language = "asm"
|
||||
compiler = "nasm"
|
||||
kind = "flat-bin"
|
||||
extension = "bin"
|
||||
roots = ["src/boot.asm"]
|
||||
```
|
||||
|
||||
```bash
|
||||
dcr build
|
||||
# → target/<…>/debug/boot.bin (NASM -f bin, no link)
|
||||
```
|
||||
|
||||
## Disk image after build
|
||||
|
||||
```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"
|
||||
```
|
||||
|
||||
* `format`: `fat12`, `fat16`, or `fat32`
|
||||
* `size`: bytes or `K`/`KB`/`M`/`MB`/`G`/`GB` (default ~1.44 MiB)
|
||||
* `bootsector`: written only when `offset` is omitted or `0`
|
||||
* `from` may be a glob; `{profile}` is substituted in paths
|
||||
|
||||
## C kernel → flat binary
|
||||
|
||||
```toml
|
||||
[build]
|
||||
language = "c"
|
||||
compiler = "clang"
|
||||
kind = "flat-bin"
|
||||
freestanding = true
|
||||
filename = "kernel"
|
||||
extension = "bin"
|
||||
ldflags = ["-T", "linker.ld"]
|
||||
```
|
||||
|
||||
Pipeline: objects → temporary linked ELF → `objcopy -O binary` → `kernel.bin`. Requires `objcopy` / `llvm-objcopy` in PATH.
|
||||
|
||||
## Other assemblers
|
||||
|
||||
| Tool | Notes |
|
||||
| -------- | --------------------------------------------------------------------------------------- |
|
||||
| **FASM** | Write `format binary` in the source; DCR writes `\<stem>.bin` directly |
|
||||
| **GAS** | Assemble `.s` → obj → `objcopy -O binary` |
|
||||
| **LLC** | `language = "llvm_ir"` → obj → objcopy |
|
||||
| **MASM** | COFF obj → objcopy (needs binutils/LLVM objcopy) |
|
||||
|
||||
## Notes
|
||||
|
||||
* Single-file `roots` are supported: `roots = ["src/boot.asm"]`.
|
||||
* `--force` re-runs `build.steps` / `build.post_steps` as well as recompilation.
|
||||
* Prefer `kind = "elf"` if you need a relocatable ELF kernel without stripping to raw binary.
|
||||
@@ -56,7 +56,7 @@ moc = "moc {in} -o {out}"
|
||||
### GAS / NASM / MASM / FASM / LLVM-IR
|
||||
|
||||
* GAS: `-I`, `-c -o`, `--defsym`
|
||||
* NASM: `-I`, `-o`, `-D`, `-f` (format: win64/elf64/macho64/macho32/elf32)
|
||||
* NASM: `-I`, `-o`, `-D`, `-f` (format: win64/elf64/macho64/macho32/elf32; **`bin` when `kind = "flat-bin"`**)
|
||||
* MASM: `/nologo /c /Fo\<obj> <source>`
|
||||
* FASM: `<source> \<output>` (output path is the object file)
|
||||
* LLVM IR: `-filetype=obj <source> -o \<output>`
|
||||
@@ -78,15 +78,20 @@ Three levels of incrementality:
|
||||
|
||||
## 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>` |
|
||||
| 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>` |
|
||||
| `flat-bin` | Raw binary | ASM: `\<stem>.bin` (NASM `-f bin` / FASM / GAS·MASM·LLC via objcopy); C/C++: `\<name>.bin` (link + objcopy) |
|
||||
|
||||
## Disk images (`[archive]`)
|
||||
|
||||
After a successful build, if `[archive]` is present in `dcr.toml`, DCR formats a FAT volume and copies files from `layout` into the image. See [dcr.toml → archive](/docs/reference/dcr-toml#archive).
|
||||
|
||||
## Build Steps
|
||||
|
||||
|
||||
@@ -57,14 +57,8 @@ dcr build --target aarch64-none-elf
|
||||
|
||||
## Target Directory
|
||||
|
||||
On Linux with explicit target:
|
||||
By default, the compilation output directories are structured as follows:
|
||||
|
||||
```
|
||||
target/<triple>/<profile>/
|
||||
```
|
||||
|
||||
On macOS/Windows or without target:
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
```
|
||||
* **Linux and BSD**: Always output to `target/\<triple>/\<profile>/` (using host triple if no target is specified).
|
||||
* **macOS and Windows (without target)**: Output to `target/\<profile>/`.
|
||||
* **macOS and Windows (with explicit target)**: Output to `target/\<triple>/\<profile>/`.
|
||||
|
||||
@@ -33,6 +33,9 @@ Main project configuration file. Located at the project root.
|
||||
|
||||
[run]
|
||||
# run settings
|
||||
|
||||
[archive]
|
||||
# optional: pack FAT disk image after build
|
||||
```
|
||||
|
||||
## [package]
|
||||
@@ -60,36 +63,36 @@ author = "John Doe"
|
||||
|
||||
* `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) |
|
||||
| Field | Default | Description |
|
||||
| ---------------- | ------------- | --------------------------------------------------------------------------------------------------------- |
|
||||
| `language` | `"c"` | `"c"`, `"c++"`, `"cpp"`, `"cxx"`, `"asm"`, `"llvm_ir"`, `"llvm-ir"`, `"ll"` (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`, `flat-bin` |
|
||||
| `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 (for `flat-bin`, default is `bin`) |
|
||||
| `roots` | `["src"]` | Source roots: directories and/or individual source/header files |
|
||||
| `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):
|
||||
|
||||
@@ -97,7 +100,7 @@ Settings from raw config (not in typed struct):
|
||||
* `ldscript` — linker script path
|
||||
* `build.steps` / `build.post_steps` — codegen steps
|
||||
|
||||
## Per-language overrides: `[build.c]`, `[build.cxx]`, `[build.asm]`
|
||||
## 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:
|
||||
|
||||
@@ -117,6 +120,9 @@ 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.
|
||||
@@ -174,3 +180,82 @@ Default `cmd` = `./target/{profile}/{name}` (macOS/Windows) or `./target/\<tripl
|
||||
## [workspace]
|
||||
|
||||
See [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]`).
|
||||
|
||||
| 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` → `\<stem>.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 `\<filename|name>.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 `\<stem>.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).
|
||||
|
||||
@@ -67,6 +67,8 @@ mylib = { path = "/abs/path/to/lib" }
|
||||
mylib = { path = "../relative/path" }
|
||||
```
|
||||
|
||||
*Note: Header resolution automatically checks the packaged `target/include` directory of path dependencies, ensuring consumer packages can find headers from compiled static or dynamic libraries.*
|
||||
|
||||
## dcr.lock
|
||||
|
||||
Dependency lock file. Contains package names and sources.
|
||||
|
||||
@@ -11,17 +11,18 @@ DCR normalizes target triples. Short platform names are expanded to full triples
|
||||
### Linux
|
||||
|
||||
```
|
||||
target/<arch>-unknown-linux-gnu/<profile>/
|
||||
target/<arch>-unknown-linux-<env>/<profile>/
|
||||
```
|
||||
|
||||
Architectures: `x86_64`, `aarch64` (host-detected).
|
||||
Architectures: `x86_64`, `aarch64`, `i686`, `armv7`, `riscv64` (host-detected).
|
||||
Environments: `gnu` (default), `musl`.
|
||||
|
||||
Artifact type: ELF. Extensions: `.so` (sharedlib), `.a` (staticlib).
|
||||
|
||||
### macOS
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
target/<profile>/ (default) or target/<triple>/<profile>/ (with target)
|
||||
```
|
||||
|
||||
Architectures: `x86_64`, `aarch64` (host-detected).
|
||||
@@ -31,10 +32,11 @@ Extensions: `.dylib` (sharedlib), `.a` (staticlib).
|
||||
### Windows
|
||||
|
||||
```
|
||||
target/<profile>/
|
||||
target/<profile>/ (default) or target/<triple>/<profile>/ (with target)
|
||||
```
|
||||
|
||||
Architectures: `x86_64`, `aarch64`.
|
||||
Environments: `msvc` (default), `gnu` (MinGW).
|
||||
|
||||
Extensions: `.exe` (bin), `.lib` (staticlib), `.dll` (sharedlib), `.efi` (UEFI).
|
||||
|
||||
|
||||
@@ -43,7 +43,10 @@ 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.
|
||||
When building a workspace, DCR automatically injects include and library paths of dependent workspace members:
|
||||
|
||||
* **Include Paths**: Automatically resolves and injects header directories of dependencies, including the member's `src/` directory, local `include/` directory, and the packaged `target/include` directory.
|
||||
* **Library Paths**: Injects compiled library search paths (`target/lib` as well as target-specific build folders) to allow automatic linking with member libraries.
|
||||
|
||||
## Clean
|
||||
|
||||
|
||||
Reference in New Issue
Block a user