- Custom build flags: `build.cflags` and `build.ldflags`
- Recursive source discovery inside `src/`
- Path dependencies with auto include/lib resolution and `dcr.lock` generation (experimental)
- Add docs/index.md and docs/dcr-toml.md
This commit is contained in:
2026-02-22 15:04:02 +08:00
parent ff12ca2758
commit 210e82f026
18 changed files with 758 additions and 29 deletions

53
docs/dcr-toml.md Normal file
View File

@@ -0,0 +1,53 @@
# dcr.toml
`dcr.toml` describes your project, build options, and dependencies.
## Example
```toml
[package]
name = "neoarc-frontent"
version = "0.1.0"
[build]
language = "c"
standard = "c11"
compiler = "gcc"
# Custom compile/link flags (optional)
cflags = ["-D_POSIX_C_SOURCE=200809L", "-Wall", "-Wextra", "-O2", "-Ilib/frecli"]
ldflags = ["-Llib/frecli", "-lfrecli", "-lm"]
[dependencies]
frecli = { path = "./lib/frecli", include = ["."], lib = ["."], libs = ["frecli"] }
```
## Sections
### [package]
- `name` (string, required)
- `version` (string, required)
### [build]
- `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`
- `cflags` (string[], optional): additional compile flags
- `ldflags` (string[], optional): additional link flags
### [dependencies]
Only `path` dependencies are supported right now.
```toml
[dependencies]
fmt = { path = "./lib/fmt", include = ["include"], lib = ["lib"], libs = ["fmt"] }
```
Rules:
- `path` can be absolute or relative to the project root.
- If `include`/`lib` are missing, DCR looks for `include`, `lib`, or `lib64` under the dependency path.
- If not found, build fails with a message suggesting to add `include`/`lib`.
- `libs` defaults to the dependency name.
## Source Discovery
DCR compiles all `.c`/`.cpp` files under `src/` recursively. The file containing `main()` can be located anywhere in that tree.

41
docs/index.md Normal file
View File

@@ -0,0 +1,41 @@
# DCR Documentation
DCR is a lightweight build tool for C/C++ projects with a Cargo-like workflow.
## Quick Start
```sh
dcr new hello
cd hello
dcr run
```
## Configuration
Project configuration lives in `dcr.toml`.
See `docs/dcr-toml.md` for the full schema and examples.
## Build Flags
You can add custom compile and link flags in `[build]`:
```toml
[build]
compiler = "gcc"
standard = "c99"
cflags = ["-D_POSIX_C_SOURCE=200809L", "-Wall", "-Wextra", "-O2", "-Ilib/frecli"]
ldflags = ["-Llib/frecli", "-lfrecli", "-lm"]
```
## Dependencies
Path dependencies can be declared in `[dependencies]` and are resolved on build.
```toml
[dependencies]
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.

View File

@@ -114,8 +114,10 @@ hello/
## Профили сборки
Поддерживаются два профиля:
- `--debug` (по умолчанию) — флаги: `-O0 -g -Wall -Wextra -fno-omit-frame-pointer -DDEBUG`(Clang)
- `--release` — флаги: `-O3 -DNDEBUG -march=native`(Clang)
- `--debug` (по умолчанию) — встроенные флаги для каждого компилятора
- `--release` — встроенные флаги для каждого компилятора
Кастомные флаги можно добавить через `build.cflags` и `build.ldflags` в `dcr.toml`.
## Конфигурация
Основной файл проекта — `dcr.toml`.
@@ -131,10 +133,15 @@ version = "0.1.0"
language = "c"
standard = "c11"
compiler = "clang"
# Опциональные флаги
cflags = ["-Wall", "-Wextra"]
ldflags = ["-lm"]
[dependencies]
```
Поддерживаются path-зависимости. DCR резолвит их при сборке и создаёт `dcr.lock`.
## Требования
- Rust toolchain (`rustc`, `cargo`) - Для ручной сборки DCR
- C-компилятор (`clang`, `gcc` или 'cl'(msvc))