Files
dcr/docs-crowdin-export/ru-RU/docs/reference/dependencies.mdx.mdx
2026-07-21 18:17:11 +08:00

89 lines
2.5 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: Зависимости
---
# Зависимости
## Форматы
В секции `[dependencies]` поддерживаются три формата:
### Строка (реестр)
```toml
[dependencies]
fmt = "10.1.1"
spdlog = "^1.12"
catch2 = ">=3.0,<4.0"
```
Строка версии используется без изменений для поиска в реестре.
### Табличный (git)
```toml
[dependencies]
fmt = { git = "https://github.com/fmtlib/fmt", tag = "10.1.1" }
```
Поля: `git`, `branch`, `tag`, `rev`, `features`.
### Табличный (path)
```toml
[dependencies]
mylib = { path = "../mylib" }
```
## Реестр
## RegistryDCR использует реестр пакетов для поиска зависимостей по имени.```toml
# ~/.dcr/config.toml
[registry]
main = { url = "https://github.com/dcr-ports/dcr-index", priority = 1 }
```
```toml
# ~/.dcr/config.toml
[registry.default]
url = "https://index.dcr.pm"
priority = 1
```
Приоритет реестра: порядок в файле `config.toml`. Переменная `DCR_INDEX_PATH` переопределяет путь к index.json.
## Git-зависимости
Git dependencies are parsed and recorded in `dcr.lock`. DCR supports specifying branch/tag/rev for git sources:
* `branch` — переключиться на ветку
* `tag` — переключиться на тег
* `rev` — переключиться на конкретный коммит
* `features` — флаги функций (проанализированы, но не влияют на сборку)
## Path dependencies
Local paths. DCR automatically discovers include and lib directories from the neighbor's `dcr.toml`.
```toml
[dependencies]
mylib = { path = "/abs/path/to/lib" }
mylib = { path = "../relative/path" }
```
*Note: Header resolution automatically checks the packaged `target/include` directory of path dependencies, ensuring consumer packages can find headers from compiled static or dynamic libraries.*
## dcr.lock
Dependency lock file. Contains package names and sources.
Created during `dcr build` when registry dependencies are present. Not updated during `dcr add` — only on the next `dcr build`.
## Resolution process
1. Load all dependencies (registry → git → path)
2. For path deps: recursively read their `dcr.toml`
3. For registry deps: search `index.json`
4. For git deps: clone to cache
5. Collect `include_dirs`, `lib_dirs`, `libs` for the compiler