New translations build-system.mdx (Russian)

[ci skip]
This commit is contained in:
2026-07-06 02:21:36 +08:00
parent 028c9ef16c
commit b926bbdb31

View File

@@ -1,19 +1,19 @@
--- ---
sidebar_label: Build system sidebar_label: Система сборки
--- ---
# Build System # Build System
## Compiler Backends ## Compiler Backends
DCR supports 7 compilation backends. Selection is automatic based on file extension and `build.compiler` value. DCR поддерживает 4 бэкенда компиляции. Выбор происходит автоматически на основе расширения файла и target triple.
| Backend | Files | When used | | Backend | Файлы | Когда используется |
| --------- | --------------------------------- | ------------------------------------- | | --------- | --------------------------------------- | ------------------------------- |
| `unix_cc` | `.c`, `.cpp`, `.cxx`, `.cc`, `.S` | gcc/clang on Linux/macOS/BSD | | `unix_cc` | `.c`, `.cpp`, `.cxx`, `.cc`, `.s`, `.S` | gcc/clang на Linux/macOS/BSD |
| `msvc` | `.c`, `.cpp`, `.cxx`, `.cc` | Windows (cl, clang-cl) | | `msvc` | `.c`, `.cpp`, `.cxx`, `.cc` | Windows (cl, clang-cl) |
| `gas` | `.s` | ARM/ARM64 assembler (no preprocessor) | | `gas` | `.s`, `.S` | ARM/ARM64 ассемблер |
| `nasm` | `.asm`, `.s` | x86/x86_64 NASM assembler | | `nasm` | `.asm`, `.s` | x86/x86_64 ассемблер |
| `masm` | `.asm` | MASM (ml/ml64) on Windows | | `masm` | `.asm` | MASM (ml/ml64) on Windows |
| `fasm` | `.asm`, `.fasm` | Flat Assembler | | `fasm` | `.asm`, `.fasm` | Flat Assembler |
| `llvm_ir` | `.ll` | LLVM IR via `llc -filetype=obj` | | `llvm_ir` | `.ll` | LLVM IR via `llc -filetype=obj` |
@@ -40,9 +40,9 @@ moc = "moc {in} -o {out}"
### Unix CC ### Unix CC
* Compiler resolved via `resolve_compiler()`: `DCR_COMPILER` > `DCR_CC` > `[toolchain]` > `build.compiler` > `PATH` * Компилятор определяется через `resolve_compiler()`: CC/CXX из [toolchain], DCR_COMPILER/env, PATH
* Supports `.d` files for header dependency tracking * Поддерживает генерацию `.d` файлов для header dependency tracking
* Flags: `-std=`, `-MMD -MF`, `-c -o`, `-I`, `-L`, `-l` * Флаги: `-std=`, `-MMD -MF`, `-c -o`, `-I`, `-L`, `-l`
* Conditional flags based on config: * Conditional flags based on config:
* `freestanding` or bare-metal target: `-ffreestanding` (compile), `-nostdlib -static` (link) * `freestanding` or bare-metal target: `-ffreestanding` (compile), `-nostdlib -static` (link)
* `lto`: `-flto` (compile + link) * `lto`: `-flto` (compile + link)
@@ -50,54 +50,54 @@ moc = "moc {in} -o {out}"
### MSVC ### MSVC
* Supports cl.exe and clang-cl.exe * Поддерживает cl.exe и clang-cl.exe
* Flags: `/std:`, `/Fo:`, `/Fe:`, `/I`, `/link` * Флаги: `/std:`, `/Fo:`, `/Fe:`, `/I`, `/link`
### GAS / NASM / MASM / FASM / LLVM-IR ### GAS / NASM
* GAS: `-I`, `-c -o`, `--defsym` * GAS: `-I`, `-c -o`, `--defsym`
* NASM: `-I`, `-o`, `-D`, `-f` (format: win64/elf64/macho64/macho32/elf32) * NASM: `-I`, `-c -o`, `-D`, `-f` (формат: win64/elf64/macho64/macho32/elf32)
* MASM: `/nologo /c /Fo\<obj> <source>` * MASM: `/nologo /c /Fo\<obj> <source>`
* FASM: `<source> \<output>` (output path is the object file) * FASM: `<source> \<output>` (output path is the object file)
* LLVM IR: `-filetype=obj <source> -o \<output>` * LLVM IR: `-filetype=obj <source> -o \<output>`
## Incremental Builds ## Incremental Builds
Three levels of incrementality: Три уровня инкрементальности:
1. **mtime** — if output is newer than all inputs, skip 1. **mtime** — если выходной файл новее всех входных, файл не перекомпилируется
2. **`.d` files** — header change tracking (including transitive) 2. **`.d` files** — отслеживание изменений в заголовочных файлах (включая транзитивные)
3. **SHA256 fingerprint** — recompile if compiler flags changed (stored in `.dcr_fingerprint`) 3. **SHA256 fingerprint** — если флаги компиляции изменились, файл перекомпилируется (fingerprint хранится в `.dcr_fingerprint`)
## Parallel Compilation ## Parallel Compilation
* `thread::scope` for thread pool * Используется `thread::scope` для создания пула потоков
* Atomic task queue (`AtomicU64`) * Атомарная очередь задач (`AtomicU64`)
* Mutex on stdout (`OUTPUT_MUTEX`) * Мьютекс на запись в stdout (`OUTPUT_MUTEX`)
* Thread count = `available_parallelism()`, capped by `build.codegen-units` if set * Thread count = `available_parallelism()`, capped by `build.codegen-units` if set
## Build Kinds ## Build Kinds
| Kind | Type | Path (Linux example) | | Kind | Тип | Path (Linux example) |
| ----------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | ----------- | ------------------------------------ | ----------------------------------------------------------------------------------------------- |
| `bin` | Executable | `target/\<triple>/\<profile>/\<name>` (.exe on Windows) | | `bin` | Executable | `target/\<profile>/\<name>` (.exe) |
| `staticlib` | Static library | `target/\<triple>/\<profile>/lib\<name>.a` (.lib) | | `staticlib` | Статическая библиотека | `target/\<profile>/lib\<name>.a` (.lib) |
| `sharedlib` | Dynamic library | `target/\<triple>/\<profile>/lib\<name>.so` (.dll/.dylib) | | `sharedlib` | Динамическая библиотека | `target/\<profile>/lib\<name>.so` (.dll/.dylib) |
| `efi` | UEFI application | `target/\<triple>/\<profile>/\<name>.efi` | | `efi` | UEFI приложение | `target/\<profile>/\<name>.efi` |
| `elf` | ELF without stdlib | `target/\<triple>/\<profile>/\<name>` | | `elf` | ELF без стандартной библиотеки | `target/\<profile>/\<name>` |
| `none` | Compile only, no link | — | | `none` | Compile only, no link | — |
| `custom` | Full filename+extension control | `target/\<triple>/\<profile>/\<filename>.\<extension>` | | `custom` | Полный контроль filename + extension | `target/\<profile>/\<filename>.\<extension>` |
## Build Steps ## Build Steps
DCR supports pre-build and post-build steps: DCR поддерживает pre-build и post-build шаги через Qt codegen:
* `build.steps` — commands before compilation * `build.steps` — commands before compilation
* `build.post_steps` — commands after compilation * `build.post_steps` — commands after compilation
Substitutions: `{stem}`, `{in}`, `{out}`, `{profile}`, `{version}`, `{name}`. Подстановки: `{stem}`, `{in}`, `{out}`.
Example Qt codegen via build steps: `rcc` — Resource Compiler: `{stem}.qrc → qrc_{stem}.cpp`
```toml ```toml
[build.steps] [build.steps]
@@ -113,19 +113,19 @@ Automatic lookup (read from raw config):
pkg_config = ["sdl2", "gl"] pkg_config = ["sdl2", "gl"]
``` ```
DCR runs `pkg-config --cflags sdl2 gl` and `pkg-config --libs sdl2 gl` and adds results to compiler/linker flags. DCR вызывает `pkg-config --cflags sdl2 gl` и `pkg-config --libs sdl2 gl` и добавляет результат в флаги компиляции/линковки.
## Variable Substitution ## Variable Substitution
Supported variables: Supported variables:
| Variable | Description | | Variable | Описание |
| ----------------------- | ---------------------------- | | ----------------------- | ------------------------------- |
| `{version}` | Package version | | `{version}` | Версия пакета |
| `{version_major}` | Major version part | | `{version_major}` | Major version part |
| `{version_minor}` | Minor version part | | `{version_minor}` | Minor version part |
| `{version_patch}` | Patch version | | `{version_patch}` | Переменная |
| `{version_suffix}` | Suffix (e.g., `-rc1`) | | `{version_suffix}` | Suffix (e.g., `-rc1`) |
| `{version_suffix_dash}` | Suffix with dash | | `{version_suffix_dash}` | Suffix with dash |
| `{profile}` | Profile name (debug/release) | | `{profile}` | Имя профиля (debug/release/...) |
| `{name}` | Package name | | `{name}` | Имя пакета |