mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 20:49:41 +00:00
83 lines
2.1 KiB
Plaintext
83 lines
2.1 KiB
Plaintext
---
|
||
sidebar_label: dcr build --profile lto
|
||
---
|
||
|
||
# Встроенные профили
|
||
|
||
Профили позволяют переопределять любые поля секции `[build]` для конкретного режима сборки.
|
||
|
||
## Конфигурация
|
||
|
||
```toml
|
||
[build]
|
||
language = "c"
|
||
standard = "c17"
|
||
cflags = ["-Wall"]
|
||
|
||
[build.debug]
|
||
cflags = ["-O0", "-g"]
|
||
|
||
[build.release]
|
||
cflags = ["-O3", "-flto"]
|
||
```
|
||
|
||
## Правила
|
||
|
||
Поля из `[build.\<profile>]` **мержатся поверх** `[build]`
|
||
|
||
* **Scalar fields** (strings, numbers, bools) — replaced
|
||
* Массивы (`cflags`, `ldflags`, ...) **заменяются полностью**, а не дополняются
|
||
|
||
Set `inherit = false` to disable array inheritance (only profile's own arrays are used).
|
||
|
||
## Кастомные профили
|
||
|
||
The default flags for each profile are composed from three config fields:
|
||
|
||
| Field | Default cflags | Профили сборки |
|
||
| ----------- | ------------------ | -------------- |
|
||
| `opt_level` | `-O0 -g` | `"3"` |
|
||
| `debug` | `true` | `false` |
|
||
| `warnings` | `["all", "extra"]` | `[]` |
|
||
|
||
Which produce the equivalent compiler flags:
|
||
|
||
| Профиль | Effective flags |
|
||
| --------- | ---------------------------------------------------------- |
|
||
| `debug` | `-O0 -g -Wall -Wextra -fno-omit-frame-pointer -DDCR_DEBUG` |
|
||
| `release` | `-O3 -DNDEBUG` |
|
||
|
||
Additional build options can be toggled per-profile:
|
||
|
||
```toml
|
||
[build.release]
|
||
opt_level = "z"
|
||
lto = true
|
||
strip = true
|
||
panic = "abort"
|
||
codegen-units = "1"
|
||
|
||
[build.debug]
|
||
opt_level = "1"
|
||
debug = false
|
||
warnings = ["all", "error"]
|
||
```
|
||
|
||
## Target-specific профили
|
||
|
||
```toml
|
||
[build.linux]
|
||
cflags = ["-DLINUX"]
|
||
|
||
[build.windows.debug]
|
||
cflags = ["-DWIN32", "-O0", "-g"]
|
||
```
|
||
|
||
Application order (highest priority first):
|
||
|
||
1. `[build.\<target>.\<profile>]`
|
||
2. `[build.\<profile>.\<target>]`
|
||
3. ]`или`[build.\<target>]\`
|
||
4. `[build.\<profile>]`.
|
||
5. `[build]`
|