Files
dcr/docs-crowdin-export/ru-RU/docs/reference/workspaces.mdx.mdx
2026-07-18 20:13:06 +08:00

78 lines
2.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
sidebar_label: Рабочие пространства
---
# Рабочие пространства
Workspaces позволяют управлять несколькими пакетами в одном репозитории.
## Конфигурация
```toml
[workspace]
members = [
{ path = "pkg-a" },
{ path = "pkg-b", deps = ["pkg-a"] },
{ path = "pkg-c", deps = ["pkg-a", "pkg-b"], main = true },
]
```
### Поля member
| Поле | Описание |
| ------ | -------------------------------------------- |
| `path` | Путь к пакету (относительно корня workspace) |
| `deps` | Зависимости от других member-ов |
| `main` | Пометить как главный пакет |
## Топологическая сортировка
DCR автоматически сортирует пакеты по зависимостям: пакет A собирается раньше B, если B зависит от A.
Циклические зависимости обнаруживаются и приводят к ошибке.
## Сборка
```bash
dcr build # собрать все пакеты
dcr build --workspace pkg-a # собрать только pkg-a
```
При сборке workspace выходные файлы member-ов (библиотеки) автоматически добавляются в include/lib пути зависимых пакетов.
## Очистка
```bash
dcr clean # очистить только корневой target/
dcr clean --all # очистить target/ всех пакетов
```
## Наследование
Если у member-а нет своей секции `[build]`, а в корневом `[build]` указано `inherit = true`:
```toml
[build]
inherit = true
language = "c"
standard = "c17"
```
## Workspace-only root (no build of its own)
A workspace root can set `workspace_only = true` — it won't be built itself, and doesn't need `language` or `compiler`:
```toml
[package]
name = "my-workspace"
version = "0.1.0"
[build]
workspace_only = true
kind = "bin"
[workspace]
lib-core = { path = "lib-core" }
app = { path = "app", deps = ["lib-core"] }
```