mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 22:49:42 +00:00
89 lines
2.3 KiB
Plaintext
89 lines
2.3 KiB
Plaintext
---
|
||
sidebar_label: Зависимости
|
||
---
|
||
|
||
# Зависимости
|
||
|
||
## Форматы
|
||
|
||
В секции `[dependencies]` поддерживаются три формата:
|
||
|
||
### String (registry)
|
||
|
||
```toml
|
||
[dependencies]
|
||
fmt = "10.1.1"
|
||
spdlog = "^1.12"
|
||
catch2 = ">=3.0,<4.0"
|
||
```
|
||
|
||
The version string is used as-is for registry lookup.
|
||
|
||
### Табличный (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" }
|
||
```
|
||
|
||
## Registry
|
||
|
||
## RegistryDCR использует реестр пакетов для поиска зависимостей по имени.```toml
|
||
# ~/.dcr/config.toml
|
||
[registry]
|
||
main = { url = "https://github.com/dcr-ports/dcr-index", priority = 1 }
|
||
```
|
||
|
||
```toml
|
||
# ~/.dcr/config.toml
|
||
[[registry]]
|
||
name = "default"
|
||
url = "https://index.dcr.pm"
|
||
```
|
||
|
||
Registry priority: order in `config.toml`. Переменная `DCR_INDEX_PATH` переопределяет путь к index.json.
|
||
|
||
## Git-зависимости
|
||
|
||
При добавлении git-зависимости DCR клонирует репозиторий через `git2`:
|
||
|
||
* `branch` — переключиться на ветку
|
||
* `tag` — переключиться на тег
|
||
* `rev` — переключиться на конкретный коммит
|
||
* `features` — feature flags (parsed, but does not affect build)
|
||
|
||
Cache path: `~/.dcr/git/\<hash>/`.
|
||
|
||
## Path-зависимости
|
||
|
||
Локальные пути. DCR автоматически находит include и lib директории.
|
||
|
||
```toml
|
||
[dependencies]
|
||
mylib = { path = "/abs/path/to/lib" }
|
||
mylib = { path = "../relative/path" }
|
||
```
|
||
|
||
## dcr.lock
|
||
|
||
Файл блокировки зависимостей. Содержит точные версии, хеши и источники.
|
||
|
||
Created during `dcr build` when registry dependencies are present. Автоматически обновляется при `dcr add`.
|
||
|
||
## Процесс резолва
|
||
|
||
1. Загружаются все зависимости (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. Собираются include_dirs, lib_dirs, libs для передачи компилятору
|