mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 15:20:51 +00:00
Compare commits
13 Commits
v0.7.1-dev
...
v0.7.2
| Author | SHA1 | Date | |
|---|---|---|---|
| c8ef38a99b | |||
| 8e0c535cfd | |||
| de88c160ad | |||
| 595b7ac105 | |||
|
|
11ae3762d0 | ||
|
|
4c439317e3 | ||
| 0aa3f87f99 | |||
| a6ce0a3332 | |||
| cea43e99c8 | |||
| de4fb0bc29 | |||
| 59e27b6f5d | |||
| c8cb155e5a | |||
| 6424aab69d |
62
.github/workflows/release.yml
vendored
62
.github/workflows/release.yml
vendored
@@ -41,10 +41,6 @@ on:
|
|||||||
description: "Publish to crates.io"
|
description: "Publish to crates.io"
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
run_snap:
|
|
||||||
description: "Publish to Snap Store (dcrup)"
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
run_brew:
|
run_brew:
|
||||||
description: "Update Homebrew tap"
|
description: "Update Homebrew tap"
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -83,24 +79,40 @@ jobs:
|
|||||||
notes:
|
notes:
|
||||||
needs: setup
|
needs: setup
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
release_name: ${{ steps.extract.outputs.release_name }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ needs.setup.outputs.tag }}
|
ref: ${{ needs.setup.outputs.tag }}
|
||||||
|
|
||||||
- name: Prepare Release Notes
|
- name: Prepare Release Notes
|
||||||
|
id: extract
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
tag="${{ needs.setup.outputs.version }}"
|
tag="${{ needs.setup.outputs.version }}"
|
||||||
notes_file=".github/release-notes.md"
|
notes_file=".github/release-notes.md"
|
||||||
if grep -q "^## \\[${tag}\\]" CHANGELOG.md; then
|
if grep -q "^## \\[${tag}\\]" CHANGELOG.md; then
|
||||||
|
# Extract release name from header: ## [0.7.1] - 2026-06-02 "Title"
|
||||||
|
release_name=$(awk -v ver="$tag" '
|
||||||
|
$0 ~ "^## \\[" ver "\\]" {
|
||||||
|
match($0, /"([^"]+)"/, arr)
|
||||||
|
if (arr[1] != "") {
|
||||||
|
print "v" ver " - " arr[1]
|
||||||
|
} else {
|
||||||
|
print "v" ver
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' CHANGELOG.md)
|
||||||
|
echo "release_name=${release_name}" >> "$GITHUB_OUTPUT"
|
||||||
awk -v ver="$tag" '
|
awk -v ver="$tag" '
|
||||||
$0 ~ "^## \\[" ver "\\]" {found=1; next}
|
$0 ~ "^## \\[" ver "\\]" {found=1; next}
|
||||||
found && $0 ~ "^## \\[" {exit}
|
found && $0 ~ "^## \\[" {exit}
|
||||||
found {print}
|
found {print}
|
||||||
' CHANGELOG.md | sed -e '${/^$/d;}' > "$notes_file"
|
' CHANGELOG.md | sed -e '${/^$/d;}' > "$notes_file"
|
||||||
else
|
else
|
||||||
|
echo "release_name=v${tag}" >> "$GITHUB_OUTPUT"
|
||||||
echo "No CHANGELOG section for $tag." > "$notes_file"
|
echo "No CHANGELOG section for $tag." > "$notes_file"
|
||||||
git log -1 --pretty=format:"%s%n%n%b" >> "$notes_file"
|
git log -1 --pretty=format:"%s%n%n%b" >> "$notes_file"
|
||||||
fi
|
fi
|
||||||
@@ -126,6 +138,7 @@ jobs:
|
|||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ needs.setup.outputs.tag }}
|
tag_name: ${{ needs.setup.outputs.tag }}
|
||||||
|
name: ${{ needs.notes.outputs.release_name }}
|
||||||
body_path: .github/release-notes.md
|
body_path: .github/release-notes.md
|
||||||
prerelease: ${{ needs.setup.outputs.prerelease == 'true' }}
|
prerelease: ${{ needs.setup.outputs.prerelease == 'true' }}
|
||||||
|
|
||||||
@@ -651,6 +664,8 @@ jobs:
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
PKG
|
PKG
|
||||||
|
|
||||||
|
cat > packages/aur/dcr/.SRCINFO <<SRC
|
||||||
pkgbase = dcr
|
pkgbase = dcr
|
||||||
pkgdesc = Cargo-like utility to manage C/C++ projects
|
pkgdesc = Cargo-like utility to manage C/C++ projects
|
||||||
pkgver = ${PKGVER_CLEAN}
|
pkgver = ${PKGVER_CLEAN}
|
||||||
@@ -1229,34 +1244,11 @@ jobs:
|
|||||||
git commit -m "dcr ${{ needs.setup.outputs.version }}"
|
git commit -m "dcr ${{ needs.setup.outputs.version }}"
|
||||||
git push
|
git push
|
||||||
|
|
||||||
# ── Snap Store (dcrup) ─────────────────────────────────────────────────────
|
# ── Snap Store (dcrup) — temporarily disabled ────────────────────────────
|
||||||
publish-snap:
|
# Classic confinement was denied for this project (too new).
|
||||||
if: |
|
# Snap artifact is still built and attached to the release via
|
||||||
(github.event_name == 'push' && needs.setup.outputs.prerelease == 'false') ||
|
# publish-dexoron-packages. Users can install manually:
|
||||||
(github.event_name == 'workflow_dispatch' && github.event.inputs.run_snap == 'true')
|
# sudo snap install --classic --dangerous dcrup_*.snap
|
||||||
needs: [setup, build-linux-packages]
|
#
|
||||||
runs-on: ubuntu-latest
|
# publish-snap:
|
||||||
steps:
|
# if: ...
|
||||||
- name: Download Built Packages
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: snap-package
|
|
||||||
path: dist-packages
|
|
||||||
|
|
||||||
- name: Resolve Snap File
|
|
||||||
id: snap-file
|
|
||||||
run: |
|
|
||||||
snap_file=$(ls dist-packages/*.snap 2>/dev/null | head -1)
|
|
||||||
if [ -z "$snap_file" ]; then
|
|
||||||
echo "No .snap file found in dist-packages/"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "snap=$snap_file" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Publish to Snap Store
|
|
||||||
uses: snapcore/action-publish@v1
|
|
||||||
env:
|
|
||||||
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
|
|
||||||
with:
|
|
||||||
snap: ${{ steps.snap-file.outputs.snap }}
|
|
||||||
release: stable
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,6 +2,7 @@ target/
|
|||||||
sandbox/**
|
sandbox/**
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.cargo/
|
||||||
.env
|
.env
|
||||||
|
|
||||||
personal/
|
personal/
|
||||||
39
CHANGELOG.md
39
CHANGELOG.md
@@ -1,5 +1,31 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.7.2] - 2026-06-07 "Исправление Таргетов и Линковки / Target & Linker Fixes"
|
||||||
|
|
||||||
|
### RU
|
||||||
|
|
||||||
|
**Добавлено:**
|
||||||
|
- Учтён `target_env` в `default_target_triple()` — Linux (gnu/musl) и Windows (msvc/gnu) теперь используют правильное окружение, а не хардкод.
|
||||||
|
|
||||||
|
**Исправлено:**
|
||||||
|
- **Сборка на macOS Apple Silicon падала с `_main` undefined** — `--target=` теперь передаётся и в ldflags, не только в cflags. `default_target_triple()` на macOS использует `std::env::consts::ARCH` вместо хардкода `x86_64`.
|
||||||
|
- **Бейджи GitHub Stars и GPL-3.0 не рендерились в README** — блок бейджей переведён на чистый HTML.
|
||||||
|
|
||||||
|
**Изменено:**
|
||||||
|
- Вычисление таргета по умолчанию вынесено в общую функцию `default_target_triple()` — устранено дублирование в build, run, clean.
|
||||||
|
|
||||||
|
### EN
|
||||||
|
|
||||||
|
**Added:**
|
||||||
|
- `default_target_triple()` now respects `target_env` — Linux (gnu/musl) and Windows (msvc/gnu) use the correct environment instead of hardcoded values.
|
||||||
|
|
||||||
|
**Fixed:**
|
||||||
|
- **macOS Apple Silicon builds failed with `_main` undefined** — `--target=` is now passed to ldflags, not just cflags. `default_target_triple()` uses `std::env::consts::ARCH` on macOS instead of hardcoded `x86_64`.
|
||||||
|
- **GitHub Stars and GPL-3.0 badges not rendering in README** — badge block converted to pure HTML.
|
||||||
|
|
||||||
|
**Changed:**
|
||||||
|
- Default target resolution extracted into shared `default_target_triple()` — removed duplication across build, run, clean.
|
||||||
|
|
||||||
## [0.7.1] - 2026-06-02 "Мультиархитектурное расширение / The Multi-Arch Expansion"
|
## [0.7.1] - 2026-06-02 "Мультиархитектурное расширение / The Multi-Arch Expansion"
|
||||||
|
|
||||||
### RU
|
### RU
|
||||||
@@ -12,7 +38,7 @@
|
|||||||
- Оптимизация сборки: `opt-level = "z"`, LTO, `codegen-units = 1`, `panic = "abort"`, `strip = true`.
|
- Оптимизация сборки: `opt-level = "z"`, LTO, `codegen-units = 1`, `panic = "abort"`, `strip = true`.
|
||||||
- Поддержка новых архитектур (i686, armv7, riscv64gc, aarch64) в рабочих процессах и установочных скриптах.
|
- Поддержка новых архитектур (i686, armv7, riscv64gc, aarch64) в рабочих процессах и установочных скриптах.
|
||||||
- Сборка пакетов `deb` и `rpm` для всех 5 архитектур Linux через `cargo-zigbuild`.
|
- Сборка пакетов `deb` и `rpm` для всех 5 архитектур Linux через `cargo-zigbuild`.
|
||||||
- Пакеты AUR (`dcr-dev`, `dcr-dev-bin`) и публикация Snap в CI.
|
- Пакеты AUR (`dcr-dev`, `dcr-dev-bin`) и сборка Snap в CI.
|
||||||
|
|
||||||
**Изменено:**
|
**Изменено:**
|
||||||
- Функция `validate_package_name` стала публичной.
|
- Функция `validate_package_name` стала публичной.
|
||||||
@@ -20,6 +46,15 @@
|
|||||||
- Инструкция в README изменена с `| bash` на `| sh` для POSIX.
|
- Инструкция в README изменена с `| bash` на `| sh` для POSIX.
|
||||||
- Отключена архитектура Windows 32-bit (GNU) из-за проблем со сборкой.
|
- Отключена архитектура Windows 32-bit (GNU) из-за проблем со сборкой.
|
||||||
|
|
||||||
|
**Исправлено:**
|
||||||
|
|
||||||
|
- **`dcr new <invalid-name>` создаёт директорию, затем падает** — валидация теперь происходит до операций с файлами.
|
||||||
|
- **`dcr init` создаёт dcr.toml, затем падает при невалидном имени директории** — то же исправление.
|
||||||
|
- **Man-страницы отсутствовали после установки** — теперь устанавливаются через скрипты установки, пакетные менеджеры и Homebrew.
|
||||||
|
- **Ложное срабатывание на букву диска в Windows** — в парсинге файлов зависимостей.
|
||||||
|
- **CRLF `\r\n` ломает парсер зависимостей** — теперь обрабатываются смешанные окончания строк.
|
||||||
|
- **Новая строка после обратного слеша не поглощалась** — в обработке escape-последовательностей `parse_d_file`.
|
||||||
|
|
||||||
### EN
|
### EN
|
||||||
|
|
||||||
**Added:**
|
**Added:**
|
||||||
@@ -30,7 +65,7 @@
|
|||||||
- Release profile optimizations (`opt-level = "z"`, LTO, `codegen-units = 1`, `panic = "abort"`, `strip = true`).
|
- Release profile optimizations (`opt-level = "z"`, LTO, `codegen-units = 1`, `panic = "abort"`, `strip = true`).
|
||||||
- Linux i686, armv7, riscv64gc, aarch64 architecture support in release workflows and installation scripts.
|
- Linux i686, armv7, riscv64gc, aarch64 architecture support in release workflows and installation scripts.
|
||||||
- Multi-arch `deb` and `rpm` package builds for all 5 Linux architectures via `cargo-zigbuild`.
|
- Multi-arch `deb` and `rpm` package builds for all 5 Linux architectures via `cargo-zigbuild`.
|
||||||
- AUR packages (`dcr-dev`, `dcr-dev-bin`) and automated Snapcraft publishing in CI.
|
- AUR packages (`dcr-dev`, `dcr-dev-bin`) and Snap build in CI.
|
||||||
|
|
||||||
**Changed:**
|
**Changed:**
|
||||||
- `validate_package_name` made public and callable from CLI commands directly.
|
- `validate_package_name` made public and callable from CLI commands directly.
|
||||||
|
|||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -112,7 +112,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dcr"
|
name = "dcr"
|
||||||
version = "0.7.1"
|
version = "0.7.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ctrlc",
|
"ctrlc",
|
||||||
"git2",
|
"git2",
|
||||||
|
|||||||
26
Cargo.toml
26
Cargo.toml
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "dcr"
|
name = "dcr"
|
||||||
version = "0.7.1"
|
version = "0.7.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
description = "DCR is a utility for managing C/C++ projects in a Cargo-like style."
|
description = "DCR is a utility for managing C/C++ projects in a Cargo-like style."
|
||||||
@@ -69,16 +69,32 @@ toml = "1.0.3"
|
|||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
ctrlc = "3"
|
ctrlc = "3"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["vendored"]
|
||||||
|
vendored = [
|
||||||
|
"git2/vendored-libgit2",
|
||||||
|
"git2/vendored-openssl",
|
||||||
|
"openssl/vendored",
|
||||||
|
]
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
git2 = { version = "0.20.4", features = ["vendored-libgit2", "vendored-openssl"] }
|
git2 = "0.20.4"
|
||||||
openssl = { version = "0.10", features = ["vendored"] }
|
openssl = "0.10"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
git2 = { version = "0.20.4", features = ["vendored-libgit2"] }
|
git2 = "0.20.4"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = "z"
|
opt-level = "z"
|
||||||
lto = true
|
lto = "thin"
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
strip = true
|
strip = true
|
||||||
|
|
||||||
|
[profile.fast]
|
||||||
|
inherits = "release"
|
||||||
|
opt-level = 1
|
||||||
|
lto = false
|
||||||
|
codegen-units = 16
|
||||||
|
panic = "abort"
|
||||||
|
strip = true
|
||||||
39
README.md
39
README.md
@@ -1,22 +1,21 @@
|
|||||||
<div align="center">
|
<h1 align="center">DCR — Dexoron Cargo Realization</h1>
|
||||||
|
|
||||||
# DCR — Dexoron Cargo Realization
|
<p align="center"><strong>A Cargo-style build tool for C/C++ projects</strong></p>
|
||||||
|
|
||||||
**A Cargo-style build tool for C/C++ projects**
|
<p align="center">
|
||||||
|
<a href="https://github.com/dexoron/dcr/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/dexoron/dcr/actions/workflows/ci.yml/badge.svg"></a>
|
||||||
|
<a href="https://github.com/dexoron/dcr/releases/latest"><img alt="GitHub Release" src="https://img.shields.io/github/v/release/dexoron/dcr"></a>
|
||||||
|
<a href="https://github.com/dexoron/dcr/releases"><img alt="Platform" src="https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-lightgrey"></a>
|
||||||
|
<br>
|
||||||
|
<a href="https://aur.archlinux.org/packages/dcr"><img alt="AUR" src="https://img.shields.io/aur/version/dcr"></a>
|
||||||
|
<a href="https://crates.io/crates/dcr"><img alt="Crates.io" src="https://img.shields.io/crates/v/dcr"></a>
|
||||||
|
<a href="https://github.com/dexoron/homebrew-dexoron"><img alt="Homebrew" src="https://img.shields.io/badge/homebrew-dexoron%2Fdexoron-orange"></a>
|
||||||
|
<br>
|
||||||
|
<a href="https://github.com/dexoron/dcr/stargazers"><img alt="GitHub Stars" src="https://img.shields.io/github/stars/dexoron/dcr?style=flat"></a>
|
||||||
|
<a href="LICENSE"><img alt="License: GPL-3.0" src="https://img.shields.io/badge/License-GPL--3.0-blue.svg"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
[](https://github.com/dexoron/dcr/actions/workflows/ci.yml)
|
<!-- Snap badge removed: classic confinement was denied for this project. -->
|
||||||
[](https://github.com/dexoron/dcr/releases/latest)
|
|
||||||
[](https://github.com/dexoron/dcr/releases)
|
|
||||||
<br/>
|
|
||||||
[](https://aur.archlinux.org/packages/dcr)
|
|
||||||
[](https://crates.io/crates/dcr)
|
|
||||||
[](https://github.com/dexoron/homebrew-dexoron)
|
|
||||||
[](https://snapcraft.io/dcrup)
|
|
||||||
<br/>
|
|
||||||
[](https://github.com/dexoron/dcr/stargazers)
|
|
||||||
[](LICENSE)
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -127,8 +126,11 @@ curl -fsSL https://dcr.dexoron.su/install_bsd.sh | sh
|
|||||||
<td><b>Snap (Linux)</b></td>
|
<td><b>Snap (Linux)</b></td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
|
> Snap Store publishing temporarily disabled — see [#51671](https://forum.snapcraft.io/t/classic-confinement-request-for-dcrup/51671).
|
||||||
|
> Download the `.snap` from [GitHub Releases](https://github.com/dexoron/dcr/releases/latest) and install manually:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo snap install dcrup
|
sudo snap install --classic --dangerous dcrup_*.snap
|
||||||
```
|
```
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
@@ -226,7 +228,7 @@ other in [docs/](docs/), `dcr --help` and `dcr <command> --help`
|
|||||||
| Linux (Musl) | ✅ | ✅ | ✅ | ✅ | 🚧 |
|
| Linux (Musl) | ✅ | ✅ | ✅ | ✅ | 🚧 |
|
||||||
| macOS | ✅ | ✅ | ❌ | ❌ | ❌ |
|
| macOS | ✅ | ✅ | ❌ | ❌ | ❌ |
|
||||||
| Windows (MSVC) | ✅ | ✅ | ❌ | ✅ | ❌ |
|
| Windows (MSVC) | ✅ | ✅ | ❌ | ✅ | ❌ |
|
||||||
| Windows (MinGW) | ✅ | 🚧 | ❌ | ✅ | ❌ |
|
| Windows (MinGW) | ✅ | 🚧 | ❌ | ❌ | ❌ |
|
||||||
| FreeBSD | ✅ | 🚧 | ❌ | ❌ | ❌ |
|
| FreeBSD | ✅ | 🚧 | ❌ | ❌ | ❌ |
|
||||||
| OpenBSD | ✅ | 🚧 | ❌ | ❌ | ❌ |
|
| OpenBSD | ✅ | 🚧 | ❌ | ❌ | ❌ |
|
||||||
| NetBSD | ✅ | 🚧 | ❌ | ❌ | ❌ |
|
| NetBSD | ✅ | 🚧 | ❌ | ❌ | ❌ |
|
||||||
@@ -271,6 +273,7 @@ cargo test
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
GPL-3.0 — see [LICENSE](LICENSE)<br/>
|
GPL-3.0 — see [LICENSE](LICENSE)<br/>
|
||||||
|
DCR is a build tool, not a library. The GPL applies only to DCR's own source code, not to projects built with it.<br/>
|
||||||
Made with ❤️ by [Dexoron](https://github.com/dexoron) and contributors.
|
Made with ❤️ by [Dexoron](https://github.com/dexoron) and contributors.
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ dcr gen vscode
|
|||||||
| [Self Update](/docs/self-update) | Auto-update |
|
| [Self Update](/docs/self-update) | Auto-update |
|
||||||
| [FAQ](/docs/faq) | Frequently asked questions |
|
| [FAQ](/docs/faq) | Frequently asked questions |
|
||||||
| [Changelog](/docs/changelog) | Version history |
|
| [Changelog](/docs/changelog) | Version history |
|
||||||
|
| [License](/docs/license) | DCR and vendored library licenses |
|
||||||
| [Contributing](/docs/contributing) | DCR development |
|
| [Contributing](/docs/contributing) | DCR development |
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|||||||
46
docs/license.mdx
Normal file
46
docs/license.mdx
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: License
|
||||||
|
---
|
||||||
|
|
||||||
|
# License
|
||||||
|
|
||||||
|
## DCR
|
||||||
|
|
||||||
|
DCR itself is [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later.html) licensed.
|
||||||
|
|
||||||
|
> **Note:** DCR is a build tool, not a library. The GPL applies only to DCR's own source code. Projects built with DCR are not subject to DCR's license — their licensing is determined solely by their own code and dependencies.
|
||||||
|
|
||||||
|
## Vendored libraries
|
||||||
|
|
||||||
|
DCR statically links the following C libraries through its vendored Rust dependencies:
|
||||||
|
|
||||||
|
| Library | License | Bundled by |
|
||||||
|
|---|---|---|
|
||||||
|
| [libgit2](https://libgit2.org) | MIT OR Apache-2.0 | `git2` / `libgit2-sys` |
|
||||||
|
| [libssh2](https://libssh2.org) | MIT OR Apache-2.0 | `libgit2-sys` |
|
||||||
|
| [zlib](https://zlib.net) | MIT OR Apache-2.0 | `libgit2-sys` |
|
||||||
|
| [OpenSSL](https://openssl.org) | Apache-2.0 | `openssl-sys` / `openssl-src` |
|
||||||
|
| [ring](https://github.com/briansmith/ring) | Apache-2.0 AND ISC | `rustls` |
|
||||||
|
|
||||||
|
## Rust dependencies
|
||||||
|
|
||||||
|
DCR is written in Rust. The following notable Rust crates are statically linked:
|
||||||
|
|
||||||
|
| Crate | License |
|
||||||
|
|---|---|
|
||||||
|
| [`reqwest`](https://crates.io/crates/reqwest) | MIT OR Apache-2.0 |
|
||||||
|
| [`rustls`](https://crates.io/crates/rustls) | Apache-2.0 OR ISC OR MIT |
|
||||||
|
| [`serde`](https://crates.io/crates/serde) | MIT OR Apache-2.0 |
|
||||||
|
| [`toml`](https://crates.io/crates/toml) | MIT OR Apache-2.0 |
|
||||||
|
| [`sha2`](https://crates.io/crates/sha2) | MIT OR Apache-2.0 |
|
||||||
|
| [`git2`](https://crates.io/crates/git2) | MIT OR Apache-2.0 |
|
||||||
|
| [`openssl`](https://crates.io/crates/openssl) | Apache-2.0 |
|
||||||
|
| [`tokio`](https://crates.io/crates/tokio) | MIT |
|
||||||
|
| [`hyper`](https://crates.io/crates/hyper) | MIT |
|
||||||
|
| [`ctrlc`](https://crates.io/crates/ctrlc) | MIT OR Apache-2.0 |
|
||||||
|
|
||||||
|
Full dependency tree (143 packages) is available in [`Cargo.lock`](https://github.com/dexoron/dcr/blob/main/Cargo.lock). The overwhelming majority are dual-licensed under MIT OR Apache-2.0.
|
||||||
|
|
||||||
|
## Additional credits
|
||||||
|
|
||||||
|
- DCR's CLI design and project model are inspired by [Cargo](https://doc.rust-lang.org/cargo/).
|
||||||
@@ -34,9 +34,12 @@ pub struct AddArgs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn add(args: &[String]) -> i32 {
|
pub fn add(args: &[String]) -> i32 {
|
||||||
if args.first().map_or(false, |a| a == "--help") {
|
if args.first().is_some_and(|a| a == "--help") {
|
||||||
printc("USAGE:", BOLD_GREEN);
|
printc("USAGE:", BOLD_GREEN);
|
||||||
printc(" dcr add <name> <source> [--branch <b>] [--tag <t>] [--rev <r>]", BOLD_CYAN);
|
printc(
|
||||||
|
" dcr add <name> <source> [--branch <b>] [--tag <t>] [--rev <r>]",
|
||||||
|
BOLD_CYAN,
|
||||||
|
);
|
||||||
println!();
|
println!();
|
||||||
printc("DESCRIPTION:", BOLD_GREEN);
|
printc("DESCRIPTION:", BOLD_GREEN);
|
||||||
println!(" Adds a dependency to the project.");
|
println!(" Adds a dependency to the project.");
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ use crate::core::config::Config;
|
|||||||
use crate::core::deps::{register, resolve_deps};
|
use crate::core::deps::{register, resolve_deps};
|
||||||
use crate::core::workspace::parse_workspace;
|
use crate::core::workspace::parse_workspace;
|
||||||
use crate::utils::build::{
|
use crate::utils::build::{
|
||||||
get_bool_with_profile, get_config_opt, get_config_str, get_language_with_profile,
|
default_target_triple, get_bool_with_profile, get_config_opt, get_config_str,
|
||||||
normalize_target_os, parse_version_info, profile_table, resolve_compiler,
|
get_language_with_profile, normalize_target_os, parse_version_info, prepend_clang_target_flag,
|
||||||
resolve_pkg_config_flags, resolve_tool,
|
profile_table, resolve_compiler, resolve_pkg_config_flags, resolve_tool,
|
||||||
};
|
};
|
||||||
use crate::utils::fs::{check_dir, find_project_root, with_dir};
|
use crate::utils::fs::{check_dir, find_project_root, with_dir};
|
||||||
use crate::utils::log::error;
|
use crate::utils::log::error;
|
||||||
@@ -42,9 +42,12 @@ static BUILD_INTERRUPTED: AtomicBool = AtomicBool::new(false);
|
|||||||
static SIGNAL_HANDLER: Once = Once::new();
|
static SIGNAL_HANDLER: Once = Once::new();
|
||||||
|
|
||||||
pub fn build(args: &[String]) -> i32 {
|
pub fn build(args: &[String]) -> i32 {
|
||||||
if args.first().map_or(false, |a| a == "--help") {
|
if args.first().is_some_and(|a| a == "--help") {
|
||||||
printc("USAGE:", BOLD_GREEN);
|
printc("USAGE:", BOLD_GREEN);
|
||||||
printc(" dcr build [--debug | --release] [--target <triple>] [--force] [--clean] [--verbose]", BOLD_CYAN);
|
printc(
|
||||||
|
" dcr build [--debug | --release] [--target <triple>] [--force] [--clean] [--verbose]",
|
||||||
|
BOLD_CYAN,
|
||||||
|
);
|
||||||
println!();
|
println!();
|
||||||
printc("DESCRIPTION:", BOLD_GREEN);
|
printc("DESCRIPTION:", BOLD_GREEN);
|
||||||
println!(" Compiles the project. Default profile is --debug.");
|
println!(" Compiles the project. Default profile is --debug.");
|
||||||
@@ -97,27 +100,7 @@ pub fn build(args: &[String]) -> i32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if flags.target.is_none() {
|
if flags.target.is_none() {
|
||||||
let default_target = if cfg!(target_os = "linux") {
|
flags.target = Some(default_target_triple());
|
||||||
format!("{}-unknown-linux-gnu", std::env::consts::ARCH)
|
|
||||||
} else if cfg!(target_os = "macos") {
|
|
||||||
"x86_64-apple-darwin".to_string()
|
|
||||||
} else if cfg!(target_os = "windows") {
|
|
||||||
"x86_64-pc-windows-msvc".to_string()
|
|
||||||
} else if cfg!(any(
|
|
||||||
target_os = "freebsd",
|
|
||||||
target_os = "openbsd",
|
|
||||||
target_os = "netbsd",
|
|
||||||
target_os = "dragonfly"
|
|
||||||
)) {
|
|
||||||
format!(
|
|
||||||
"{}-unknown-{}",
|
|
||||||
std::env::consts::ARCH,
|
|
||||||
std::env::consts::OS
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
"unknown".to_string()
|
|
||||||
};
|
|
||||||
flags.target = Some(default_target);
|
|
||||||
}
|
}
|
||||||
if flags.clean {
|
if flags.clean {
|
||||||
let mut clean_args = Vec::new();
|
let mut clean_args = Vec::new();
|
||||||
@@ -715,19 +698,13 @@ fn build_project_at(
|
|||||||
tc_cxx.as_deref(),
|
tc_cxx.as_deref(),
|
||||||
tc_as.as_deref(),
|
tc_as.as_deref(),
|
||||||
);
|
);
|
||||||
if let Some(t) = build_target
|
|
||||||
&& !t.trim().is_empty()
|
|
||||||
&& resolved_compiler.to_lowercase().contains("clang")
|
|
||||||
{
|
|
||||||
let target_flag = format!("--target={}", t.trim());
|
|
||||||
if !build_cflags
|
|
||||||
.iter()
|
|
||||||
.any(|f| f == &target_flag || f.starts_with("--target="))
|
|
||||||
{
|
|
||||||
build_cflags.insert(0, target_flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let resolved_linker = resolve_tool("DCR_LD", tc_ld.as_deref());
|
let resolved_linker = resolve_tool("DCR_LD", tc_ld.as_deref());
|
||||||
|
prepend_clang_target_flag(&mut build_cflags, build_target, &resolved_compiler);
|
||||||
|
prepend_clang_target_flag(
|
||||||
|
&mut build_ldflags,
|
||||||
|
build_target,
|
||||||
|
resolved_linker.as_deref().unwrap_or(&resolved_compiler),
|
||||||
|
);
|
||||||
let resolved_archiver = resolve_tool("DCR_AR", tc_ar.as_deref());
|
let resolved_archiver = resolve_tool("DCR_AR", tc_ar.as_deref());
|
||||||
|
|
||||||
let out_dir_config = get_build_string_with_profile(&config, "out_dir", profile);
|
let out_dir_config = get_build_string_with_profile(&config, "out_dir", profile);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
use crate::config::flags;
|
use crate::config::flags;
|
||||||
use crate::core::config::Config;
|
use crate::core::config::Config;
|
||||||
use crate::core::workspace::parse_workspace;
|
use crate::core::workspace::parse_workspace;
|
||||||
use crate::utils::build::parse_version_info;
|
use crate::utils::build::{default_target_triple, parse_version_info};
|
||||||
use crate::utils::fs::{check_dir, find_project_root, with_dir};
|
use crate::utils::fs::{check_dir, find_project_root, with_dir};
|
||||||
use crate::utils::log::{error, warn};
|
use crate::utils::log::{error, warn};
|
||||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
||||||
@@ -27,9 +27,12 @@ use std::fs;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn clean(args: &[String]) -> i32 {
|
pub fn clean(args: &[String]) -> i32 {
|
||||||
if args.first().map_or(false, |a| a == "--help") {
|
if args.first().is_some_and(|a| a == "--help") {
|
||||||
printc("USAGE:", BOLD_GREEN);
|
printc("USAGE:", BOLD_GREEN);
|
||||||
printc(" dcr clean [--debug | --release] [--target <triple>] [--all]", BOLD_CYAN);
|
printc(
|
||||||
|
" dcr clean [--debug | --release] [--target <triple>] [--all]",
|
||||||
|
BOLD_CYAN,
|
||||||
|
);
|
||||||
println!();
|
println!();
|
||||||
printc("DESCRIPTION:", BOLD_GREEN);
|
printc("DESCRIPTION:", BOLD_GREEN);
|
||||||
println!(" Removes build artifacts from the target directory.");
|
println!(" Removes build artifacts from the target directory.");
|
||||||
@@ -133,28 +136,7 @@ fn clean_from_root(root: &Path, flags: &CleanFlags) -> Result<(), String> {
|
|||||||
.map(|s| s.trim().to_string())
|
.map(|s| s.trim().to_string())
|
||||||
.filter(|s| !s.is_empty())
|
.filter(|s| !s.is_empty())
|
||||||
})
|
})
|
||||||
.or_else(|| {
|
.or_else(|| Some(default_target_triple()));
|
||||||
Some(if cfg!(target_os = "linux") {
|
|
||||||
format!("{}-unknown-linux-gnu", std::env::consts::ARCH)
|
|
||||||
} else if cfg!(target_os = "macos") {
|
|
||||||
"x86_64-apple-darwin".to_string()
|
|
||||||
} else if cfg!(target_os = "windows") {
|
|
||||||
"x86_64-pc-windows-msvc".to_string()
|
|
||||||
} else if cfg!(any(
|
|
||||||
target_os = "freebsd",
|
|
||||||
target_os = "openbsd",
|
|
||||||
target_os = "netbsd",
|
|
||||||
target_os = "dragonfly"
|
|
||||||
)) {
|
|
||||||
format!(
|
|
||||||
"{}-unknown-{}",
|
|
||||||
std::env::consts::ARCH,
|
|
||||||
std::env::consts::OS
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
"unknown".to_string()
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
if flags.all
|
if flags.all
|
||||||
&& let Some(workspace) = parse_workspace(
|
&& let Some(workspace) = parse_workspace(
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ struct ReleaseAsset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn flag_update(args: &[String]) -> i32 {
|
pub fn flag_update(args: &[String]) -> i32 {
|
||||||
if args.first().map_or(false, |a| a == "--help") {
|
if args.first().is_some_and(|a| a == "--help") {
|
||||||
printc("USAGE:", BOLD_GREEN);
|
printc("USAGE:", BOLD_GREEN);
|
||||||
printc(" dcr --update", BOLD_CYAN);
|
printc(" dcr --update", BOLD_CYAN);
|
||||||
println!();
|
println!();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use glob::glob;
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
pub fn fmt(args: &[String]) -> i32 {
|
pub fn fmt(args: &[String]) -> i32 {
|
||||||
if args.first().map_or(false, |a| a == "--help") {
|
if args.first().is_some_and(|a| a == "--help") {
|
||||||
printc("USAGE:", BOLD_GREEN);
|
printc("USAGE:", BOLD_GREEN);
|
||||||
printc(" dcr fmt", BOLD_CYAN);
|
printc(" dcr fmt", BOLD_CYAN);
|
||||||
println!();
|
println!();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::config::FILE_MAIN_C;
|
use crate::config::FILE_MAIN_C;
|
||||||
use crate::core::config::{validate_package_name, Config};
|
use crate::core::config::{Config, validate_package_name};
|
||||||
use crate::utils::fs::check_dir;
|
use crate::utils::fs::check_dir;
|
||||||
use crate::utils::log::{error, warn};
|
use crate::utils::log::{error, warn};
|
||||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
||||||
@@ -25,7 +25,7 @@ use std::io::Write;
|
|||||||
use toml::Value;
|
use toml::Value;
|
||||||
|
|
||||||
pub fn init(args: &[String]) -> i32 {
|
pub fn init(args: &[String]) -> i32 {
|
||||||
if args.first().map_or(false, |a| a == "--help") {
|
if args.first().is_some_and(|a| a == "--help") {
|
||||||
printc("USAGE:", BOLD_GREEN);
|
printc("USAGE:", BOLD_GREEN);
|
||||||
printc(" dcr init", BOLD_CYAN);
|
printc(" dcr init", BOLD_CYAN);
|
||||||
println!();
|
println!();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use crate::config::FILE_MAIN_C;
|
use crate::config::FILE_MAIN_C;
|
||||||
use crate::core::config::{validate_package_name, Config};
|
use crate::core::config::{Config, validate_package_name};
|
||||||
use crate::utils::fs::check_dir;
|
use crate::utils::fs::check_dir;
|
||||||
use crate::utils::log::{error, warn};
|
use crate::utils::log::{error, warn};
|
||||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
||||||
@@ -25,7 +25,7 @@ use std::io::Write;
|
|||||||
use toml::Value;
|
use toml::Value;
|
||||||
|
|
||||||
pub fn new(args: &[String]) -> i32 {
|
pub fn new(args: &[String]) -> i32 {
|
||||||
if args.first().map_or(false, |a| a == "--help") {
|
if args.first().is_some_and(|a| a == "--help") {
|
||||||
printc("USAGE:", BOLD_GREEN);
|
printc("USAGE:", BOLD_GREEN);
|
||||||
printc(" dcr new <name>", BOLD_CYAN);
|
printc(" dcr new <name>", BOLD_CYAN);
|
||||||
println!();
|
println!();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use crate::cli::build::build;
|
|||||||
use crate::cli::flags::parse_build_run_flags;
|
use crate::cli::flags::parse_build_run_flags;
|
||||||
use crate::core::config::Config;
|
use crate::core::config::Config;
|
||||||
use crate::core::runner::run_binary;
|
use crate::core::runner::run_binary;
|
||||||
use crate::utils::build::{normalize_target_os, parse_version_info};
|
use crate::utils::build::{default_target_triple, normalize_target_os, parse_version_info};
|
||||||
use crate::utils::fs::find_project_root;
|
use crate::utils::fs::find_project_root;
|
||||||
use crate::utils::fs::with_dir;
|
use crate::utils::fs::with_dir;
|
||||||
use crate::utils::log::error;
|
use crate::utils::log::error;
|
||||||
@@ -56,9 +56,12 @@ fn get_run_cmd(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(args: &[String]) -> i32 {
|
pub fn run(args: &[String]) -> i32 {
|
||||||
if args.first().map_or(false, |a| a == "--help") {
|
if args.first().is_some_and(|a| a == "--help") {
|
||||||
printc("USAGE:", BOLD_GREEN);
|
printc("USAGE:", BOLD_GREEN);
|
||||||
printc(" dcr run [--debug | --release] [--target <triple>] [--force] [--clean] [--verbose]", BOLD_CYAN);
|
printc(
|
||||||
|
" dcr run [--debug | --release] [--target <triple>] [--force] [--clean] [--verbose]",
|
||||||
|
BOLD_CYAN,
|
||||||
|
);
|
||||||
println!();
|
println!();
|
||||||
printc("DESCRIPTION:", BOLD_GREEN);
|
printc("DESCRIPTION:", BOLD_GREEN);
|
||||||
println!(" Builds and runs the project. Only available for kind = \"bin\".");
|
println!(" Builds and runs the project. Only available for kind = \"bin\".");
|
||||||
@@ -175,27 +178,7 @@ fn run_project(
|
|||||||
// If no target specified, use default host target for target-specific config
|
// If no target specified, use default host target for target-specific config
|
||||||
let mut target = flags.target.clone();
|
let mut target = flags.target.clone();
|
||||||
if target.is_none() {
|
if target.is_none() {
|
||||||
let default_target = if cfg!(target_os = "linux") {
|
target = Some(default_target_triple());
|
||||||
format!("{}-unknown-linux-gnu", std::env::consts::ARCH)
|
|
||||||
} else if cfg!(target_os = "macos") {
|
|
||||||
"x86_64-apple-darwin".to_string()
|
|
||||||
} else if cfg!(target_os = "windows") {
|
|
||||||
"x86_64-pc-windows-msvc".to_string()
|
|
||||||
} else if cfg!(any(
|
|
||||||
target_os = "freebsd",
|
|
||||||
target_os = "openbsd",
|
|
||||||
target_os = "netbsd",
|
|
||||||
target_os = "dragonfly"
|
|
||||||
)) {
|
|
||||||
format!(
|
|
||||||
"{}-unknown-{}",
|
|
||||||
std::env::consts::ARCH,
|
|
||||||
std::env::consts::OS
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
"unknown".to_string()
|
|
||||||
};
|
|
||||||
target = Some(default_target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let build_kind = config
|
let build_kind = config
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc};
|
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc};
|
||||||
|
|
||||||
pub fn setup(args: &[String]) -> i32 {
|
pub fn setup(args: &[String]) -> i32 {
|
||||||
if args.first().map_or(false, |a| a == "--help") {
|
if args.first().is_some_and(|a| a == "--help") {
|
||||||
printc("USAGE:", BOLD_GREEN);
|
printc("USAGE:", BOLD_GREEN);
|
||||||
printc(" dcr setup", BOLD_CYAN);
|
printc(" dcr setup", BOLD_CYAN);
|
||||||
println!();
|
println!();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use std::path::{Path, PathBuf};
|
|||||||
use toml::Value;
|
use toml::Value;
|
||||||
|
|
||||||
pub fn tree(args: &[String]) -> i32 {
|
pub fn tree(args: &[String]) -> i32 {
|
||||||
if args.first().map_or(false, |a| a == "--help") {
|
if args.first().is_some_and(|a| a == "--help") {
|
||||||
printc("USAGE:", BOLD_GREEN);
|
printc("USAGE:", BOLD_GREEN);
|
||||||
printc(" dcr tree", BOLD_CYAN);
|
printc(" dcr tree", BOLD_CYAN);
|
||||||
println!();
|
println!();
|
||||||
|
|||||||
@@ -72,6 +72,53 @@ pub fn normalize_target_os(target: &str) -> &str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn default_target_triple() -> String {
|
||||||
|
let arch = std::env::consts::ARCH;
|
||||||
|
if cfg!(target_os = "linux") {
|
||||||
|
let env = if cfg!(target_env = "musl") {
|
||||||
|
"musl"
|
||||||
|
} else {
|
||||||
|
"gnu"
|
||||||
|
};
|
||||||
|
format!("{arch}-unknown-linux-{env}")
|
||||||
|
} else if cfg!(target_os = "macos") {
|
||||||
|
format!("{arch}-apple-darwin")
|
||||||
|
} else if cfg!(target_os = "windows") {
|
||||||
|
let env = if cfg!(target_env = "gnu") {
|
||||||
|
"gnu"
|
||||||
|
} else {
|
||||||
|
"msvc"
|
||||||
|
};
|
||||||
|
format!("{arch}-pc-windows-{env}")
|
||||||
|
} else if cfg!(any(
|
||||||
|
target_os = "freebsd",
|
||||||
|
target_os = "openbsd",
|
||||||
|
target_os = "netbsd",
|
||||||
|
target_os = "dragonfly"
|
||||||
|
)) {
|
||||||
|
format!("{arch}-unknown-{}", std::env::consts::OS)
|
||||||
|
} else {
|
||||||
|
"unknown".to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn prepend_clang_target_flag(flags: &mut Vec<String>, target: Option<&str>, tool: &str) {
|
||||||
|
let Some(target) = target.map(str::trim).filter(|t| !t.is_empty()) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
if !tool.to_lowercase().contains("clang") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let target_flag = format!("--target={target}");
|
||||||
|
if !flags
|
||||||
|
.iter()
|
||||||
|
.any(|f| f == &target_flag || f.starts_with("--target="))
|
||||||
|
{
|
||||||
|
flags.insert(0, target_flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_config_str(config: &Config, key: &str) -> String {
|
pub fn get_config_str(config: &Config, key: &str) -> String {
|
||||||
config
|
config
|
||||||
.get(key)
|
.get(key)
|
||||||
@@ -380,6 +427,61 @@ mod tests {
|
|||||||
assert_eq!(normalize_target_os("unknown"), "unknown");
|
assert_eq!(normalize_target_os("unknown"), "unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn default_target_triple_uses_host_arch() {
|
||||||
|
let target = default_target_triple();
|
||||||
|
if cfg!(target_os = "linux") {
|
||||||
|
assert_eq!(
|
||||||
|
target,
|
||||||
|
format!("{}-unknown-linux-gnu", std::env::consts::ARCH)
|
||||||
|
);
|
||||||
|
} else if cfg!(target_os = "macos") {
|
||||||
|
assert_eq!(target, format!("{}-apple-darwin", std::env::consts::ARCH));
|
||||||
|
} else if cfg!(target_os = "windows") {
|
||||||
|
assert_eq!(
|
||||||
|
target,
|
||||||
|
format!("{}-pc-windows-msvc", std::env::consts::ARCH)
|
||||||
|
);
|
||||||
|
} else if cfg!(any(
|
||||||
|
target_os = "freebsd",
|
||||||
|
target_os = "openbsd",
|
||||||
|
target_os = "netbsd",
|
||||||
|
target_os = "dragonfly"
|
||||||
|
)) {
|
||||||
|
assert_eq!(
|
||||||
|
target,
|
||||||
|
format!(
|
||||||
|
"{}-unknown-{}",
|
||||||
|
std::env::consts::ARCH,
|
||||||
|
std::env::consts::OS
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
assert_eq!(target, "unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn prepend_clang_target_flag_adds_once_for_clang() {
|
||||||
|
let mut flags = vec!["-O2".to_string()];
|
||||||
|
prepend_clang_target_flag(&mut flags, Some("aarch64-apple-darwin"), "clang");
|
||||||
|
prepend_clang_target_flag(&mut flags, Some("aarch64-apple-darwin"), "clang");
|
||||||
|
assert_eq!(
|
||||||
|
flags,
|
||||||
|
vec![
|
||||||
|
"--target=aarch64-apple-darwin".to_string(),
|
||||||
|
"-O2".to_string()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn prepend_clang_target_flag_ignores_non_clang_tools() {
|
||||||
|
let mut flags = vec!["-O2".to_string()];
|
||||||
|
prepend_clang_target_flag(&mut flags, Some("aarch64-apple-darwin"), "gcc");
|
||||||
|
assert_eq!(flags, vec!["-O2".to_string()]);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_version_parts() {
|
fn parse_version_parts() {
|
||||||
let info = parse_version_info("1.2.3-beta");
|
let info = parse_version_info("1.2.3-beta");
|
||||||
|
|||||||
Reference in New Issue
Block a user