- Incremental builds (object caching by mtime)
- `build.kind` with `staticlib` support
- Custom output directory via `build.target`
This commit is contained in:
2026-02-26 17:03:35 +08:00
parent 9fe2604154
commit 7817834790
19 changed files with 410 additions and 56 deletions

View File

@@ -13,6 +13,8 @@ version = "0.1.0"
language = "c"
standard = "c11"
compiler = "gcc"
# Build kind: "bin" (default) or "staticlib"
kind = "bin"
# Output directory for binary (optional)
target = "./dist"
# Custom compile/link flags (optional)
@@ -33,10 +35,15 @@ frecli = { path = "./lib/frecli", include = ["."], lib = ["."], libs = ["frecli"
- `language` (string, required): `c`, `c++`, `cpp`, or `cxx`
- `standard` (string, required): e.g. `c99`, `c11`, `c++17`
- `compiler` (string, required): `gcc`, `clang`, `cl`(msvc), or `clang-cl`
- `kind` (string, optional): `bin` (default) or `staticlib`
- `target` (string, optional): output directory for the binary (profile-independent)
- `cflags` (string[], optional): additional compile flags
- `ldflags` (string[], optional): additional link flags
Notes:
- `dcr run` is supported only for `kind = "bin"`.
- Incremental rebuild currently tracks source file changes (`.c/.cpp`) only.
### [dependencies]
Only `path` dependencies are supported right now.

View File

@@ -23,6 +23,7 @@ You can add custom compile and link flags in `[build]`:
[build]
compiler = "gcc"
standard = "c99"
kind = "bin"
target = "./dist"
cflags = ["-D_POSIX_C_SOURCE=200809L", "-Wall", "-Wextra", "-O2", "-Ilib/frecli"]
ldflags = ["-Llib/frecli", "-lfrecli", "-lm"]
@@ -40,3 +41,8 @@ frecli = { path = "./lib/frecli", include = ["."], lib = ["."], libs = ["frecli"
## Source Discovery
DCR compiles all `.c`/`.cpp` files under `src/` recursively. The file containing `main()` can be in any subdirectory.
## Notes
- `dcr run` works only for `kind = "bin"`.
- Incremental rebuild currently tracks source file changes only (`.c/.cpp`).

View File

@@ -119,6 +119,8 @@ hello/
Кастомные флаги можно добавить через `build.cflags` и `build.ldflags` в `dcr.toml`.
Можно указать `build.target`, чтобы задать директорию выхода бинарника (без привязки к профилю).
Используйте `build.kind = "staticlib"`, чтобы собрать статическую библиотеку вместо бинарника.
`dcr run` работает только для `build.kind = "bin"` и завершится ошибкой для `staticlib`.
## Конфигурация
Основной файл проекта — `dcr.toml`.
@@ -143,6 +145,8 @@ ldflags = ["-lm"]
Поддерживаются path-зависимости. DCR резолвит их при сборке и создаёт `dcr.lock`.
Примечание по инкрементальной сборке: пересборка объектников идёт по изменениям `.c/.cpp`. Учет зависимостей заголовков пока не реализован.
## Требования
- Rust toolchain (`rustc`, `cargo`) - Для ручной сборки DCR
- C-компилятор (`clang`, `gcc` или 'cl'(msvc))