mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 12:38:30 +00:00
68 lines
1.4 KiB
Plaintext
68 lines
1.4 KiB
Plaintext
---
|
|
sidebar_label: Workspaces
|
|
---
|
|
|
|
# Workspaces
|
|
|
|
Workspaces allow managing multiple packages in a single repository.
|
|
|
|
## Configuration
|
|
|
|
```toml
|
|
[workspace.lib-core]
|
|
path = "lib-core"
|
|
|
|
[workspace.lib-utils]
|
|
path = "lib-utils"
|
|
deps = ["lib-core"]
|
|
|
|
[workspace.app]
|
|
path = "app"
|
|
deps = ["lib-core", "lib-utils"]
|
|
main = true
|
|
```
|
|
|
|
### Member fields
|
|
|
|
| Field | Description |
|
|
|-------|-------------|
|
|
| `path` | Path to the package (relative to workspace root) |
|
|
| `deps` | Dependencies on other members |
|
|
| `main` | Mark as the main package |
|
|
|
|
## Topological sort
|
|
|
|
DCR automatically sorts packages by dependencies: package A is built before B if B depends on A.
|
|
|
|
Cyclic dependencies are detected and cause an error.
|
|
|
|
## Build
|
|
|
|
```bash
|
|
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.
|
|
|
|
## Clean
|
|
|
|
```bash
|
|
dcr clean # clean only root target/
|
|
dcr clean --all # clean target/ of all packages
|
|
```
|
|
|
|
## Inheritance
|
|
|
|
If a member has `inherit = true` in its `[build]` section, fields from the root `[build]` are merged into the member:
|
|
|
|
```toml
|
|
# root dcr.toml
|
|
[build]
|
|
inherit = true
|
|
language = "c"
|
|
standard = "c17"
|
|
|
|
# member inherits language and standard
|
|
```
|