Files
dcr/docs-crowdin-export/ru-RU/docs/recipes/multi-package-workspace.mdx.mdx

98 lines
1.8 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: Рабочая область с несколькими пакетами
---
# Рабочая область с несколькими пакетами
Проект из трёх пакетов: библиотека, утилита и основной бинарник.
## Структура
```
workspace/
├── dcr.toml # корневой workspace
├── lib-core/
│ ├── dcr.toml
│ └── src/lib.rs
├── lib-utils/
│ ├── dcr.toml
│ └── src/utils.c
└── app/
├── dcr.toml
└── src/main.c
```
## Корневой dcr.toml
```toml
[package]
name = "my-workspace"
version = "0.1.0"
type = "none"
[build]
inherit = true
language = "c"
standard = "c17"
[workspace]
members = [
{ path = "lib-core" },
{ path = "lib-utils", deps = ["lib-core"] },
{ path = "app", deps = ["lib-core", "lib-utils"], main = true },
]
```
## Пакеты
`lib-core/dcr.toml`:
```toml
[package]
name = "lib-core"
version = "0.1.0"
type = "lib"
[build]
kind = "staticlib"
```
`lib-utils/dcr.toml`:
```toml
[package]
name = "lib-utils"
version = "0.1.0"
type = "lib"
[build]
kind = "staticlib"
```
`app/dcr.toml`:
```toml
[package]
name = "app"
version = "0.1.0"
type = "app"
[build]
kind = "bin"
```
## Сборка
```bash
cd workspace
dcr build # собирает всё в правильном порядке
dcr build --workspace app # только app (lib-core и lib-utils собираются как зависимости)
dcr run # собирает и запускает main-пакет
```
Порядок сборки (топологическая сортировка):
1. `lib-core`
2. `lib-utils` (зависит от lib-core)
3. `app` (зависит от lib-core, lib-utils)