diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 61542f9..93b36a1 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -38,5 +38,8 @@ * [CLI reference](reference-and-help/cli-reference.md) * [Config reference](reference-and-help/config-reference.md) +* [Workspace guide](reference-and-help/workspace-guide.md) +* [Flags & environment](reference-and-help/flags-and-environment.md) +* [Troubleshooting map](reference-and-help/troubleshooting-map.md) * [FAQ](reference-and-help/faq.md) * [Contributing & Bug reports](reference-and-help/contributing-and-bug-reports.md) diff --git a/docs/commands/dcr-build.md b/docs/commands/dcr-build.md index f0170a3..7e805f5 100644 --- a/docs/commands/dcr-build.md +++ b/docs/commands/dcr-build.md @@ -52,9 +52,9 @@ dcr build --debug --clean ## Notes -- The profile is selected from the first argument only. +- Profile flag (`--debug` / `--release`) can appear in any argument position (duplicates are rejected). - Unknown profile flags return an error. -- Incremental rebuild is based on source/object mtime comparison. +- Incremental rebuild checks source/object mtime and tracked header dependencies. - `--force` skips build cache checks and recompiles. - `--clean` removes `target/` and `build.clean` paths before building. - For `language = "asm"` with `compiler = "as"`/`"gas"`, use `.s` files (no preprocessing). For `.S`, use `gcc` or `clang`. diff --git a/docs/configuration/dcr.toml-overview.md b/docs/configuration/dcr.toml-overview.md index 0f6b74b..22f9734 100644 --- a/docs/configuration/dcr.toml-overview.md +++ b/docs/configuration/dcr.toml-overview.md @@ -27,7 +27,8 @@ kind = "bin" - `[dependencies]` Workspace-only root: -- `[workspace]` may be used instead of `[package]`/`[build]` for a workspace root. +- `[workspace]` can be added to a normal root config to define members and dependency order. +- Root config still requires `[package]`, `[build]`, and `[dependencies]`. ## Required keys diff --git a/docs/getting-started/build-and-run.md b/docs/getting-started/build-and-run.md index 87ec5b1..24c1040 100644 --- a/docs/getting-started/build-and-run.md +++ b/docs/getting-started/build-and-run.md @@ -46,7 +46,7 @@ dcr clean --release --all ## Notes - `run` is unavailable for `build.kind = "staticlib"` and `build.kind = "sharedlib"`. -- Build profile flag is parsed from the first command argument. +- Build profile flag (`--debug` / `--release`) can be passed in any argument position. - Unknown profile flags produce an error. - In workspace root, `clean --all` cleans all member projects. - `--clean` for `build`/`run` removes `target/` and paths from `build.clean`. diff --git a/docs/reference-and-help/cli-reference.md b/docs/reference-and-help/cli-reference.md index ea93c8c..f625f66 100644 --- a/docs/reference-and-help/cli-reference.md +++ b/docs/reference-and-help/cli-reference.md @@ -8,6 +8,7 @@ dcr init dcr build [--debug|--release] dcr run [--debug|--release] dcr clean [--debug|--release] [--all] +dcr gen dcr --help dcr --version dcr --update @@ -15,12 +16,13 @@ dcr --update ## Notes on argument parsing -- Most commands parse profile from the first argument. +- `build`/`run` parse flags in any order (`--debug|--release`, `--force`, `--clean`) 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`. ## Exit behavior overview - Successful command execution returns `0`. -- Validation/build/runtime errors return non-zero status. +- Validation/build/runtime failures return non-zero status. diff --git a/docs/reference-and-help/faq.md b/docs/reference-and-help/faq.md index e223667..65a0ab2 100644 --- a/docs/reference-and-help/faq.md +++ b/docs/reference-and-help/faq.md @@ -2,7 +2,7 @@ ## What commands are available? -`new`, `init`, `build`, `run`, `clean`, `--help`, `--version`, `--update`. +`new`, `init`, `build`, `run`, `clean`, `gen`, `--help`, `--version`, `--update`. ## Is `dcr.toml` mandatory? @@ -21,7 +21,8 @@ Yes. Set `build.compiler` in `dcr.toml` (for example `gcc`, `clang`, `cl`, `clan ## How does incremental rebuild work? -It compares source file mtime with object file mtime. Header dependency tracking is not implemented yet. +It compares source file mtime with object file mtime. +Header dependencies are tracked too: if an included header changes (or disappears), rebuild is triggered. ## What does `dcr run` do if build fails? diff --git a/docs/reference-and-help/flags-and-environment.md b/docs/reference-and-help/flags-and-environment.md new file mode 100644 index 0000000..d776410 --- /dev/null +++ b/docs/reference-and-help/flags-and-environment.md @@ -0,0 +1,48 @@ +# Flags & environment + +This page summarizes runtime flags and environment variables that affect DCR behavior. + +## Build/run flags + +Used with `dcr build` and `dcr run`: + +- `--debug`: select debug profile. +- `--release`: select release profile. +- `--force`: ignore incremental cache checks and rebuild. +- `--clean`: remove `target/` and `build.clean` paths before build. + +Notes: + +- Flags can be passed in any order. +- Duplicate profile flags are rejected. + +## Clean flags + +Used with `dcr clean`: + +- `--debug` / `--release`: clean only selected profile directory. +- `--all`: in workspace root, also clean all members. + +## Environment variables + +Tool selection overrides: + +- `DCR_COMPILER` (all languages) +- `DCR_CC`, `DCR_CXX`, `DCR_AS`, `DCR_AR`, `DCR_LD` + +Diagnostics: + +- `DCR_DEBUG=1` enables verbose build logging. + +## Quick examples + +```sh +# Force full release rebuild +dcr build --release --force + +# Clean before debug run +dcr run --clean --debug + +# Use custom compiler from env +DCR_CC=clang-18 dcr build --debug +``` diff --git a/docs/reference-and-help/troubleshooting-map.md b/docs/reference-and-help/troubleshooting-map.md new file mode 100644 index 0000000..c8f9cf9 --- /dev/null +++ b/docs/reference-and-help/troubleshooting-map.md @@ -0,0 +1,75 @@ +# Troubleshooting map + +Fast mapping from symptom to likely cause and first action. + +## `dcr.toml file not found` + +Likely cause: +- you are outside project root (or member root). + +First action: +```sh +pwd +ls +``` +Run DCR from directory that contains `dcr.toml`. + +## `Invalid config: missing [package]` / `missing [build]` + +Likely cause: +- incomplete config in root project. + +First action: +- ensure root `dcr.toml` includes `[package]`, `[build]`, and `[dependencies]`. +- for workspace setups, keep these sections in root and add `[workspace]` additionally. + +## `Unknown build flag` or profile-flag errors + +Likely cause: +- typo in flag or duplicate profile flag. + +First action: +```sh +dcr --help +``` +Use only supported flags and at most one of `--debug` / `--release`. + +## Dependency include/lib path errors + +Likely cause: +- path in `[dependencies]` does not exist. + +First action: +- verify `path`, `include`, `lib` values. +- if using profile placeholders, confirm expanded paths exist for selected profile. + +## `Cannot run library build` + +Likely cause: +- `build.kind` is `staticlib` or `sharedlib`. + +First action: +- switch `build.kind` to `bin`, or set `[run].cmd` if you intentionally need custom run command. + +## Build succeeds but output is stale + +Likely cause: +- stale artifacts or generated files from previous runs. + +First action: +```sh +dcr clean --all +dcr build --force +``` + +## `dcr --update` suggests package manager update + +Likely cause: +- DCR binary is managed by pacman/AUR. + +First action: +```sh +yay -Syu dcr +# or +paru -Syu dcr +``` diff --git a/docs/reference-and-help/workspace-guide.md b/docs/reference-and-help/workspace-guide.md new file mode 100644 index 0000000..55f7eae --- /dev/null +++ b/docs/reference-and-help/workspace-guide.md @@ -0,0 +1,53 @@ +# Workspace guide + +`[workspace]` lets you build related DCR projects in dependency order from one root. + +## Important rule + +Workspace root still needs a valid root project config: + +- `[package]` +- `[build]` +- `[dependencies]` + +`[workspace]` augments that root config; it does not replace required root sections. + +## Minimal example + +```toml +[package] +name = "root-app" +version = "0.1.0" + +[build] +language = "c" +standard = "c11" +compiler = "clang" +kind = "bin" + +[dependencies] + +[workspace] +core = { path = "./modules/core", deps = [] } +net = { path = "./modules/net", deps = ["core"] } +app = { path = "./modules/app", deps = ["core", "net"] } +``` + +Each member path must point to a directory containing its own `dcr.toml`. + +## Build behavior + +- Running `dcr build` in workspace root builds members in topological dependency order, then builds the root project. + +- Running `dcr clean --all` in workspace root cleans all members too. + +- `dcr gen` in workspace root includes root + members in generated outputs. + +## Common errors + +- `workspace..path does not contain dcr.toml`: + member path is wrong or config is missing. +- `workspace dependency '' not found`: + `deps` references unknown member. +- `workspace dependency cycle at `: + cyclic dependencies in member graph.