mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 12:28:30 +00:00
fix: add missing .cxx/.cc/.hxx/.hh extensions to fmt; update docs for 0.7.0
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
* [dcr clean](commands/dcr-clean.md)
|
||||
* [dcr gen](commands/dcr-gen.md)
|
||||
* [dcr test](commands/dcr-test.md)
|
||||
* [dcr fmt](commands/dcr-fmt.md)
|
||||
* [dcr tree](commands/dcr-tree.md)
|
||||
|
||||
## Dependencies & Build
|
||||
|
||||
@@ -30,9 +30,12 @@ dcr build --debug --clean
|
||||
- `build.compiler`
|
||||
- `build.language`
|
||||
- `build.standard`
|
||||
- `build.cxx_standard`
|
||||
- `build.kind`
|
||||
- `build.target`
|
||||
- `build.out_dir`
|
||||
- `build.platform`
|
||||
- `package.type`
|
||||
- `build.cflags`
|
||||
- `build.ldflags`
|
||||
- `build.ldscript`
|
||||
@@ -58,8 +61,9 @@ dcr build --debug --clean
|
||||
|
||||
- Profile flag (`--debug` / `--release`) can appear in any argument position (duplicates are rejected).
|
||||
- Unknown profile flags return an error.
|
||||
- `--target <triple>` builds for specified target (short names: `linux`, `macos`, `windows`).
|
||||
- `--target <triple>` builds for specified target (short names: `linux`, `macos`, `windows`, `freebsd`, `openbsd`, `netbsd`).
|
||||
- `--verbose` prints the compiler/linker command lines to stderr (also works via `DCR_DEBUG` env var).
|
||||
- `--workspace <name>` filters build to a specific workspace member.
|
||||
- If no `--target`, builds for `build.targets` or native.
|
||||
- Incremental rebuild checks source/object mtime and tracked header dependencies.
|
||||
- `--force` skips build cache checks and recompiles.
|
||||
|
||||
19
docs/commands/dcr-fmt.md
Normal file
19
docs/commands/dcr-fmt.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# dcr fmt
|
||||
|
||||
Formats all C/C++ source files using `clang-format`.
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
dcr fmt
|
||||
```
|
||||
|
||||
## Behavior
|
||||
|
||||
1. Scans `src/` and `tests/` directories recursively.
|
||||
2. Formats all C/C++ source and header files (`.c`, `.cpp`, `.cxx`, `.cc`, `.h`, `.hpp`, `.hxx`, `.hh`) using `clang-format`.
|
||||
3. Uses `.clang-format` if present in the project root, otherwise falls back to LLVM style.
|
||||
|
||||
## Requirements
|
||||
|
||||
- `clang-format` must be installed and available in PATH.
|
||||
@@ -23,11 +23,12 @@ dcr run --debug --clean
|
||||
|
||||
## Restrictions
|
||||
|
||||
- If `build.kind` (or `build.{profile}.kind`) is `"staticlib"` or `"sharedlib"`, `run` exits with error.
|
||||
- If `build.kind` (or `build.{profile}.kind`) is `"staticlib"`, `"sharedlib"`, `"efi"`, or `"elf"`, `run` exits with error.
|
||||
- The profile is selected from the first argument.
|
||||
- `--target <triple>` runs the binary for specified target (short names: `linux`, `macos`, `windows`).
|
||||
- `--target <triple>` runs the binary for specified target (short names: `linux`, `macos`, `windows`, `freebsd`, `openbsd`, `netbsd`).
|
||||
- `--force` skips build cache checks and recompiles.
|
||||
- `--clean` removes `target/<profile>` and `build.clean` paths before building.
|
||||
- `--workspace <name>` filters build to a specific workspace member.
|
||||
|
||||
## `run.cmd` variables
|
||||
|
||||
|
||||
@@ -30,10 +30,13 @@ You can also add `--force` or `--clean` to `build`/`run`.
|
||||
|
||||
## Artifacts
|
||||
|
||||
By default:
|
||||
By default (for `kind = "bin"`):
|
||||
|
||||
- `target/debug/<name>` (or `.exe` on Windows)
|
||||
- `target/release/<name>` (or `.exe` on Windows)
|
||||
- `target/<target>/debug/<name>` (or `.exe` on Windows)
|
||||
- `target/<target>/release/<name>` (or `.exe` on Windows)
|
||||
|
||||
Where `<target>` is `native` or a target triple.
|
||||
Use `build.out_dir` to override the output directory.
|
||||
|
||||
Default compiler flags:
|
||||
|
||||
@@ -58,6 +61,14 @@ Shared library mode (`kind = "sharedlib"`):
|
||||
- macOS: `lib<name>.dylib`
|
||||
- Windows: `<name>.dll`
|
||||
|
||||
UEFI executable mode (`kind = "efi"`):
|
||||
|
||||
- All platforms: `<name>.efi`
|
||||
|
||||
Bare-metal ELF mode (`kind = "elf"`):
|
||||
|
||||
- All platforms: `<name>` (no extension)
|
||||
|
||||
## Profile overrides
|
||||
|
||||
Use `[build.debug]` and `[build.release]` to override build settings per profile.
|
||||
|
||||
@@ -32,11 +32,11 @@ kind = "bin"
|
||||
|
||||
- `language` (string or array, required): `c`, `c++`, `cpp`, `cxx`, or `asm`.
|
||||
Mixed languages can be specified as an array, for example `["c", "c++", "asm"]`.
|
||||
- `standard` (string, required): C language standard passed to compiler (e.g. `c11`, `c17`, `gnu11`).
|
||||
- `standard` (string, optional): C language standard passed to compiler (e.g. `c11`, `c17`, `gnu11`). Defaults to `c11`.
|
||||
- `cxx_standard` (string, optional): C++ language standard passed to compiler for `.cpp`/`.cxx`/`.cc` files
|
||||
(e.g. `c++17`, `gnu++17`, `c++20`). When set, overrides `standard` for C++ sources.
|
||||
- `compiler` (string, required): compiler command (for example `clang`, `gcc`, `cl`).
|
||||
- `kind` (string, required): `bin`, `staticlib`, `sharedlib`, `efi`, or `elf`.
|
||||
- `kind` (string, optional): `bin`, `staticlib`, `sharedlib`, `efi`, `elf`, `none`, or `custom`. Defaults to `bin`.
|
||||
- `filename` (string, optional): custom output filename (without extension). Overrides `package.name` for the final artifact.
|
||||
- `extension` (string, optional): custom file extension without the leading dot (e.g. `BIN`, `efi`, `EFI`). Combined with `filename`.
|
||||
- `inherit` (bool, optional): inherit settings from base `[build]` (default `true`). If `false`, only use target/profile specific settings.
|
||||
|
||||
@@ -35,17 +35,16 @@ Workspace-only root:
|
||||
- `package.name`
|
||||
- `package.version`
|
||||
- `build.language`
|
||||
- `build.standard`
|
||||
- `build.compiler`
|
||||
- `build.kind`
|
||||
|
||||
`build.kind` must be either `bin`, `staticlib`, or `sharedlib`.
|
||||
|
||||
## Optional keys
|
||||
|
||||
- `build.standard` (default: `c11`)
|
||||
- `build.kind` (default: `bin`; valid: `bin`, `staticlib`, `sharedlib`, `efi`, `elf`, `none`, `custom`)
|
||||
- `build.inherit`
|
||||
- `build.targets`
|
||||
- `build.target`
|
||||
- `build.out_dir`
|
||||
- `build.platform`
|
||||
- `build.cflags`
|
||||
- `build.ldflags`
|
||||
|
||||
@@ -18,6 +18,8 @@ frecli = { path = "./lib/frecli", include = ["."], lib = ["."], libs = ["frecli"
|
||||
|
||||
### Registry dependencies
|
||||
Defined by name and version string. DCR automatically resolves the package from the configured registry index.
|
||||
- `version` (string, required): version requirement.
|
||||
- `features` (string array, optional): enable specific features.
|
||||
|
||||
### Git dependencies
|
||||
Defined by repository URL and optionally branch, tag, or revision.
|
||||
|
||||
@@ -23,6 +23,9 @@ dcr run --target linux --release
|
||||
- `linux` → `x86_64-unknown-linux-gnu`
|
||||
- `macos` → `x86_64-apple-darwin`
|
||||
- `windows` → `x86_64-pc-windows-msvc`
|
||||
- `freebsd` → `x86_64-unknown-freebsd`
|
||||
- `openbsd` → `x86_64-unknown-openbsd`
|
||||
- `netbsd` → `x86_64-unknown-netbsd`
|
||||
|
||||
### Full Target Triples
|
||||
DCR supports any valid target triple in the format `<arch>-<vendor>-<os>-<abi>`. Common examples:
|
||||
@@ -32,6 +35,9 @@ DCR supports any valid target triple in the format `<arch>-<vendor>-<os>-<abi>`.
|
||||
- `aarch64-apple-darwin`
|
||||
- `x86_64-pc-windows-msvc`
|
||||
- `i686-pc-windows-gnu`
|
||||
- `x86_64-unknown-freebsd`
|
||||
- `x86_64-unknown-openbsd`
|
||||
- `x86_64-unknown-netbsd`
|
||||
|
||||
## Configuration
|
||||
|
||||
@@ -40,11 +46,11 @@ DCR supports any valid target triple in the format `<arch>-<vendor>-<os>-<abi>`.
|
||||
Configure multiple targets to build simultaneously:
|
||||
|
||||
```toml
|
||||
[build.targets]
|
||||
[build]
|
||||
targets = ["linux", "macos", "windows"]
|
||||
|
||||
# Or per profile
|
||||
[build.release.targets]
|
||||
[build.release]
|
||||
targets = ["linux", "macos"]
|
||||
```
|
||||
|
||||
@@ -66,6 +72,10 @@ cflags = ["-Wall", "-O2", "-arch", "x86_64"]
|
||||
[build.windows]
|
||||
compiler = "x86_64-w64-mingw32-gcc"
|
||||
ldflags = ["-static"]
|
||||
|
||||
[build.freebsd]
|
||||
compiler = "clang"
|
||||
cflags = ["-Wall", "-O2"]
|
||||
```
|
||||
|
||||
### Target-Specific Toolchain
|
||||
@@ -99,6 +109,9 @@ cmd = "open ./target/macos/release/myapp.app"
|
||||
|
||||
[run.windows]
|
||||
cmd = "wine ./target/windows/release/myapp.exe"
|
||||
|
||||
[run.freebsd]
|
||||
cmd = "./target/freebsd/release/myapp"
|
||||
```
|
||||
|
||||
## Workspace and Dependencies Inheritance
|
||||
@@ -151,7 +164,10 @@ target/
|
||||
├── x86_64-unknown-linux-gnu/
|
||||
│ ├── debug/
|
||||
│ └── release/
|
||||
└── aarch64-linux-gnu/
|
||||
├── aarch64-linux-gnu/
|
||||
│ ├── debug/
|
||||
│ └── release/
|
||||
└── x86_64-unknown-freebsd/
|
||||
├── debug/
|
||||
└── release/
|
||||
```
|
||||
|
||||
@@ -26,6 +26,8 @@ json = { git = "https://github.com/nlohmann/json", tag = "v3.11.2" }
|
||||
- `include`: optional include subpaths (absolute or relative to dep root).
|
||||
- `lib`: optional library subpaths (absolute or relative to dep root).
|
||||
- `libs`: optional linker library names.
|
||||
- `features`: optional feature flags for registry dependencies.
|
||||
- `default-features`: whether to include default features (default `true`).
|
||||
|
||||
## Common valid compact forms
|
||||
|
||||
@@ -35,6 +37,8 @@ mylib = { path = "./libs/mylib" }
|
||||
gitlib = { git = "https://github.com/user/repo" }
|
||||
# Shortest form for path
|
||||
simple = "./libs/simple"
|
||||
# Registry with features
|
||||
sdl2 = { version = "2.0.0", features = ["vulkan"] }
|
||||
```
|
||||
|
||||
In these forms DCR will try defaults for include/lib dirs and use the dependency name as the linker library name.
|
||||
|
||||
@@ -37,4 +37,4 @@ project/
|
||||
- `target/<target>/<profile>/lib<name>.a` (or `<name>.lib` on Windows): output for `kind = "staticlib"`.
|
||||
- `target/<target>/<profile>/lib<name>.so` (or `.dylib` on macOS, `<name>.dll` on Windows): output for `kind = "sharedlib"`.
|
||||
|
||||
If `build.target` is set, the final artifact is written to that custom directory, while object cache still stays in `target/<target>/<profile>/obj`.
|
||||
If `build.out_dir` is set, the final artifact is written to that custom directory, while object cache still stays in `target/<target>/<profile>/obj`.
|
||||
|
||||
@@ -13,6 +13,8 @@ dcr clean [--debug|--release] [--all]
|
||||
dcr tree
|
||||
dcr test
|
||||
dcr gen <subcommand>
|
||||
dcr fmt
|
||||
dcr setup
|
||||
dcr --help
|
||||
dcr --version
|
||||
dcr --update
|
||||
@@ -20,11 +22,13 @@ dcr --update
|
||||
|
||||
## Notes on argument parsing
|
||||
|
||||
- `build`/`run` parse flags in any order (`--debug|--release`, `--force`, `--clean`, `--verbose`) and reject duplicates.
|
||||
- `build`/`run` parse flags in any order (`--debug|--release`, `--force`, `--clean`, `--verbose`, `--workspace`) and reject duplicates.
|
||||
- `new` requires exactly one argument.
|
||||
- `init` and `--update` do not accept extra arguments.
|
||||
- `clean` accepts `--debug|--release` and optional `--all`.
|
||||
- `gen` supports `project-info`, `compile-commands`, `vscode`, `clion`.
|
||||
- `fmt` formats C/C++ sources (`.c`, `.cpp`, `.cxx`, `.cc`, `.h`, `.hpp`, `.hxx`, `.hh`) in `src/` and `tests/` using `clang-format`.
|
||||
- `setup` initializes DCR registries and local configuration.
|
||||
- `tree` shows a dependency tree (similar to `cargo tree`).
|
||||
- `test` / `tests` runs the project's tests.
|
||||
|
||||
|
||||
@@ -19,13 +19,14 @@ categories = ["string", "..."] # optional
|
||||
|
||||
[build]
|
||||
language = "c|c++|cpp|cxx|asm" # required (string or array)
|
||||
standard = "string" # required (e.g. "c11", "gnu11")
|
||||
standard = "string" # optional (default "c11")
|
||||
cxx_standard = "string" # optional (e.g. "c++17", "gnu++17")
|
||||
compiler = "string" # required (e.g. "clang", "gcc")
|
||||
kind = "bin|staticlib|sharedlib|efi|elf" # required
|
||||
kind = "bin|staticlib|sharedlib|efi|elf|none|custom" # optional (default "bin")
|
||||
target = "string" # optional (cross-compilation target triple)
|
||||
out_dir = "string" # optional (custom output directory)
|
||||
platform = "string" # optional (architecture hint, -march)
|
||||
type = "string" # optional
|
||||
|
||||
cflags = ["string", "..."] # optional (supports {version} etc.)
|
||||
ldflags = ["string", "..."] # optional (supports {version} etc.)
|
||||
ldscript = "string" # optional (linker script path)
|
||||
@@ -121,14 +122,15 @@ rev = "string" # optional (git commit)
|
||||
include = ["string", "..."] # optional (include dirs)
|
||||
lib = ["string", "..."] # optional (lib dirs)
|
||||
libs = ["string", "..."] # optional (link libs)
|
||||
features = ["string", "..."] # optional (registry features)
|
||||
features = ["string", "..."] # optional (registry features)
|
||||
default-features = true # optional (include default features)
|
||||
```
|
||||
|
||||
## Validation rules
|
||||
|
||||
- `[package]`, `[build]`, `[dependencies]` must exist.
|
||||
- Required string fields must be non-empty.
|
||||
- `build.kind` must be `bin`, `staticlib`, `sharedlib`, `efi`, or `elf`.
|
||||
- `build.kind` must be `bin`, `staticlib`, `sharedlib`, `efi`, `elf`, `none`, or `custom`.
|
||||
- Dependency fields `include/lib/libs` must be string arrays when provided.
|
||||
- `build.exclude`/`build.include` must be string arrays when provided.
|
||||
- `build.roots` must be a string array when provided.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## What commands are available?
|
||||
|
||||
`new`, `init`, `build`, `run`, `clean`, `gen`, `--help`, `--version`, `--update`.
|
||||
`new`, `init`, `add`, `build`, `run`, `clean`, `test`, `fmt`, `tree`, `gen`, `setup`, `--help`, `--version`, `--update`.
|
||||
|
||||
## Is `dcr.toml` mandatory?
|
||||
|
||||
|
||||
@@ -8,8 +8,11 @@ Used with `dcr build` and `dcr run`:
|
||||
|
||||
- `--debug`: select debug profile.
|
||||
- `--release`: select release profile.
|
||||
- `--target <triple>`: build for specified target (short names: `linux`, `macos`, `windows`, `freebsd`, `openbsd`, `netbsd`).
|
||||
- `--force`: ignore incremental cache checks and rebuild.
|
||||
- `--clean`: remove `target/<profile>` and `build.clean` paths before build.
|
||||
- `--verbose`: print compiler/linker command lines to stderr.
|
||||
- `--workspace <name>`: filter build to a specific workspace member.
|
||||
|
||||
Notes:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user