mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 09:28:35 +00:00
Compare commits
21 Commits
v0.7.0-dev
...
39fad31c4f
| Author | SHA1 | Date | |
|---|---|---|---|
| 39fad31c4f | |||
| c8ef38a99b | |||
| 8e0c535cfd | |||
| de88c160ad | |||
| 4daca925a0 | |||
| 595b7ac105 | |||
|
|
11ae3762d0 | ||
|
|
4c439317e3 | ||
| 0aa3f87f99 | |||
| a6ce0a3332 | |||
| cea43e99c8 | |||
| de4fb0bc29 | |||
| 59e27b6f5d | |||
| c8cb155e5a | |||
| 6424aab69d | |||
|
|
dabeb411d3 | ||
|
|
b8338c752b | ||
| b70438b16d | |||
| 0597b5ddb2 | |||
|
|
8866fb0796 | ||
|
|
7d853482aa |
188
.github/workflows/release.yml
vendored
188
.github/workflows/release.yml
vendored
@@ -41,10 +41,6 @@ on:
|
||||
description: "Publish to crates.io"
|
||||
type: boolean
|
||||
default: false
|
||||
run_snap:
|
||||
description: "Publish to Snap Store (dcrup)"
|
||||
type: boolean
|
||||
default: false
|
||||
run_brew:
|
||||
description: "Update Homebrew tap"
|
||||
type: boolean
|
||||
@@ -83,24 +79,40 @@ jobs:
|
||||
notes:
|
||||
needs: setup
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
release_name: ${{ steps.extract.outputs.release_name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.setup.outputs.tag }}
|
||||
|
||||
- name: Prepare Release Notes
|
||||
id: extract
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
tag="${{ needs.setup.outputs.version }}"
|
||||
notes_file=".github/release-notes.md"
|
||||
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" '
|
||||
$0 ~ "^## \\[" ver "\\]" {found=1; next}
|
||||
found && $0 ~ "^## \\[" {exit}
|
||||
found {print}
|
||||
' CHANGELOG.md | sed -e '${/^$/d;}' > "$notes_file"
|
||||
else
|
||||
echo "release_name=v${tag}" >> "$GITHUB_OUTPUT"
|
||||
echo "No CHANGELOG section for $tag." > "$notes_file"
|
||||
git log -1 --pretty=format:"%s%n%n%b" >> "$notes_file"
|
||||
fi
|
||||
@@ -126,6 +138,37 @@ jobs:
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ needs.setup.outputs.tag }}
|
||||
name: ${{ needs.notes.outputs.release_name }}
|
||||
body_path: .github/release-notes.md
|
||||
prerelease: ${{ needs.setup.outputs.prerelease == 'true' }}
|
||||
|
||||
# ── Man Pages Archive ──────────────────────────────────────────────────────
|
||||
man-pages:
|
||||
if: ${{ github.event_name == 'push' || github.event.inputs.run_linux == 'true' }}
|
||||
needs: [setup, notes, create-release]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.setup.outputs.tag }}
|
||||
|
||||
- name: Download Release Notes
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: release-notes
|
||||
path: .github
|
||||
|
||||
- name: Create Man Pages Archive
|
||||
run: |
|
||||
tar czf "dcr-man-pages-${{ needs.setup.outputs.version }}.tar.gz" \
|
||||
--transform 's/^man\/man1\//usr\/share\/man\/man1\//' \
|
||||
man/man1/*.1
|
||||
|
||||
- name: Upload Man Pages to Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ needs.setup.outputs.tag }}
|
||||
files: dcr-man-pages-${{ needs.setup.outputs.version }}.tar.gz
|
||||
body_path: .github/release-notes.md
|
||||
prerelease: ${{ needs.setup.outputs.prerelease == 'true' }}
|
||||
|
||||
@@ -205,41 +248,73 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- package_type: deb
|
||||
artifact_name: debian-package
|
||||
- package_type: rpm
|
||||
artifact_name: rpm-package
|
||||
package_type: [deb, rpm, arch, snap]
|
||||
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, i686-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, riscv64gc-unknown-linux-gnu]
|
||||
exclude:
|
||||
- package_type: arch
|
||||
artifact_name: arch-package
|
||||
target: aarch64-unknown-linux-gnu
|
||||
- package_type: arch
|
||||
target: i686-unknown-linux-gnu
|
||||
- package_type: arch
|
||||
target: armv7-unknown-linux-gnueabihf
|
||||
- package_type: arch
|
||||
target: riscv64gc-unknown-linux-gnu
|
||||
- package_type: snap
|
||||
artifact_name: snap-package
|
||||
target: aarch64-unknown-linux-gnu
|
||||
- package_type: snap
|
||||
target: i686-unknown-linux-gnu
|
||||
- package_type: snap
|
||||
target: armv7-unknown-linux-gnueabihf
|
||||
- package_type: snap
|
||||
target: riscv64gc-unknown-linux-gnu
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.setup.outputs.tag }}
|
||||
|
||||
- name: Setup Rust (For non-container builds)
|
||||
- name: Install cargo-zigbuild
|
||||
if: matrix.package_type == 'deb' || matrix.package_type == 'rpm'
|
||||
run: |
|
||||
pip install cargo-zigbuild
|
||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Setup Zig
|
||||
if: (matrix.package_type == 'deb' || matrix.package_type == 'rpm') && matrix.target != 'x86_64-unknown-linux-gnu'
|
||||
uses: mlugg/setup-zig@v1
|
||||
with:
|
||||
version: 0.13.0
|
||||
|
||||
- name: Setup Rust
|
||||
if: matrix.package_type != 'arch'
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
# ── DEB Build ──
|
||||
- name: Build Debian Package
|
||||
if: matrix.package_type == 'deb'
|
||||
run: |
|
||||
cargo install cargo-deb
|
||||
cargo build --release
|
||||
cargo deb --no-build
|
||||
mkdir -p dist-packages && cp target/debian/*.deb dist-packages/
|
||||
if [ "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]; then
|
||||
cargo zigbuild --release --target ${{ matrix.target }}
|
||||
else
|
||||
cargo build --release --target ${{ matrix.target }}
|
||||
fi
|
||||
cargo deb --no-build --target ${{ matrix.target }}
|
||||
mkdir -p dist-packages && cp target/${{ matrix.target }}/debian/*.deb dist-packages/
|
||||
|
||||
# ── RPM Build ──
|
||||
- name: Build RPM Package
|
||||
if: matrix.package_type == 'rpm'
|
||||
run: |
|
||||
cargo install cargo-generate-rpm
|
||||
cargo build --release
|
||||
cargo generate-rpm
|
||||
mkdir -p dist-packages && cp target/generate-rpm/*.rpm dist-packages/
|
||||
if [ "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]; then
|
||||
cargo zigbuild --release --target ${{ matrix.target }}
|
||||
else
|
||||
cargo build --release --target ${{ matrix.target }}
|
||||
fi
|
||||
cargo generate-rpm --target ${{ matrix.target }}
|
||||
mkdir -p dist-packages && cp target/${{ matrix.target }}/generate-rpm/*.rpm dist-packages/
|
||||
|
||||
# ── Snap Build ──
|
||||
- name: Build Snap Package
|
||||
@@ -248,6 +323,7 @@ jobs:
|
||||
cargo build --release
|
||||
mkdir -p packaging/snap/dist/bin
|
||||
cp target/release/dcr packaging/snap/dist/bin/
|
||||
cp -r man packaging/snap/dist/man
|
||||
|
||||
- name: Snapcraft Build Action
|
||||
if: matrix.package_type == 'snap'
|
||||
@@ -289,9 +365,12 @@ jobs:
|
||||
cargo build --release --locked
|
||||
}
|
||||
package() {
|
||||
cd "\$srcdir/\$pkgname-${PKGVER_ORIG}"
|
||||
cd "\$srcdir/dcr-${PKGVER_ORIG}"
|
||||
install -Dm755 "target/release/dcr" "\$pkgdir/usr/bin/dcr"
|
||||
install -Dm644 LICENSE "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE"
|
||||
for manpage in man/man1/*.1; do
|
||||
install -Dm644 "\$manpage" "\$pkgdir/usr/share/man/man1/\$(basename "\$manpage")"
|
||||
done
|
||||
}
|
||||
PKG
|
||||
docker run --rm \
|
||||
@@ -311,7 +390,7 @@ jobs:
|
||||
- name: Upload Package Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact_name }}
|
||||
name: ${{ matrix.package_type }}-package-${{ matrix.target }}
|
||||
path: dist-packages/*
|
||||
if-no-files-found: ignore
|
||||
|
||||
@@ -336,10 +415,10 @@ jobs:
|
||||
with:
|
||||
tag_name: ${{ needs.setup.outputs.tag }}
|
||||
files: |
|
||||
collected-packages/debian-package/*
|
||||
collected-packages/rpm-package/*
|
||||
collected-packages/arch-package/*
|
||||
collected-packages/snap-package/*
|
||||
collected-packages/deb-package-*/*
|
||||
collected-packages/rpm-package-*/*
|
||||
collected-packages/arch-package-*/*
|
||||
collected-packages/snap-package-*/*
|
||||
body_path: .github/release-notes.md
|
||||
prerelease: ${{ needs.setup.outputs.prerelease == 'true' }}
|
||||
|
||||
@@ -487,7 +566,6 @@ jobs:
|
||||
- target: aarch64-pc-windows-msvc
|
||||
- target: i686-pc-windows-msvc
|
||||
- target: x86_64-pc-windows-gnu
|
||||
- target: i686-pc-windows-gnu
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -581,6 +659,9 @@ jobs:
|
||||
cd "\$srcdir/\$pkgname-${PKGVER_ORIG}"
|
||||
install -Dm755 "target/release/dcr" "\$pkgdir/usr/bin/dcr"
|
||||
install -Dm644 LICENSE "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE"
|
||||
for manpage in man/man1/*.1; do
|
||||
install -Dm644 "\$manpage" "\$pkgdir/usr/share/man/man1/\$(basename "\$manpage")"
|
||||
done
|
||||
}
|
||||
PKG
|
||||
|
||||
@@ -840,9 +921,12 @@ jobs:
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "\$srcdir/dcr-${PKGVER_ORIG}"
|
||||
cd "\$srcdir/\$pkgname-${PKGVER_ORIG}"
|
||||
install -Dm755 "target/release/dcr" "\$pkgdir/usr/bin/dcr"
|
||||
install -Dm644 LICENSE "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE"
|
||||
for manpage in man/man1/*.1; do
|
||||
install -Dm644 "\$manpage" "\$pkgdir/usr/share/man/man1/\$(basename "\$manpage")"
|
||||
done
|
||||
}
|
||||
PKG
|
||||
|
||||
@@ -1090,6 +1174,7 @@ jobs:
|
||||
echo "linux_arm=$(download_sha "dcr-aarch64-unknown-linux-gnu-${VERSION}")" >> "$GITHUB_OUTPUT"
|
||||
echo "macos_x86=$(download_sha "dcr-x86_64-apple-darwin-${VERSION}")" >> "$GITHUB_OUTPUT"
|
||||
echo "macos_arm=$(download_sha "dcr-aarch64-apple-darwin-${VERSION}")" >> "$GITHUB_OUTPUT"
|
||||
echo "man_pages=$(download_sha "dcr-man-pages-${VERSION}.tar.gz")" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Checkout homebrew-dexoron
|
||||
uses: actions/checkout@v4
|
||||
@@ -1132,6 +1217,18 @@ jobs:
|
||||
bin.install Dir["dcr*"].first => "dcr"
|
||||
end
|
||||
|
||||
resource "man-pages" do
|
||||
url "https://github.com/dexoron/dcr/releases/download/v#{version}/dcr-man-pages-#{version}.tar.gz"
|
||||
sha256 "${{ steps.sha.outputs.man_pages }}"
|
||||
end
|
||||
|
||||
def install
|
||||
bin.install Dir["dcr*"].first => "dcr"
|
||||
resource("man-pages").stage do
|
||||
man1.install Dir["usr/share/man/man1/*.1"]
|
||||
end
|
||||
end
|
||||
|
||||
test do
|
||||
system "#{bin}/dcr", "--version"
|
||||
end
|
||||
@@ -1147,34 +1244,11 @@ jobs:
|
||||
git commit -m "dcr ${{ needs.setup.outputs.version }}"
|
||||
git push
|
||||
|
||||
# ── Snap Store (dcrup) ─────────────────────────────────────────────────────
|
||||
publish-snap:
|
||||
if: |
|
||||
(github.event_name == 'push' && needs.setup.outputs.prerelease == 'false') ||
|
||||
(github.event_name == 'workflow_dispatch' && github.event.inputs.run_snap == 'true')
|
||||
needs: [setup, build-linux-packages]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- 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
|
||||
# ── Snap Store (dcrup) — temporarily disabled ────────────────────────────
|
||||
# Classic confinement was denied for this project (too new).
|
||||
# Snap artifact is still built and attached to the release via
|
||||
# publish-dexoron-packages. Users can install manually:
|
||||
# sudo snap install --classic --dangerous dcrup_*.snap
|
||||
#
|
||||
# publish-snap:
|
||||
# if: ...
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,6 +2,7 @@ target/
|
||||
sandbox/**
|
||||
.idea/
|
||||
.vscode/
|
||||
.cargo/
|
||||
.env
|
||||
|
||||
personal/
|
||||
84
CHANGELOG.md
84
CHANGELOG.md
@@ -1,5 +1,89 @@
|
||||
# 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"
|
||||
|
||||
### RU
|
||||
|
||||
**Добавлено:**
|
||||
- Вывод `--help` для всех команд с цветным форматированием.
|
||||
- man-страницы (12 штук в `man/man1/`) и их установка во всех пакетах.
|
||||
- Валидация имен проектов в `dcr init` и `dcr new` (только ASCII буквы, цифры, `_` и `-`).
|
||||
- Метаданные `documentation` и `homepage` в `Cargo.toml`.
|
||||
- Оптимизация сборки: `opt-level = "z"`, LTO, `codegen-units = 1`, `panic = "abort"`, `strip = true`.
|
||||
- Поддержка новых архитектур (i686, armv7, riscv64gc, aarch64) в рабочих процессах и установочных скриптах.
|
||||
- Сборка пакетов `deb` и `rpm` для всех 5 архитектур Linux через `cargo-zigbuild`.
|
||||
- Пакеты AUR (`dcr-dev`, `dcr-dev-bin`) и сборка Snap в CI.
|
||||
|
||||
**Изменено:**
|
||||
- Функция `validate_package_name` стала публичной.
|
||||
- Команды `gen`, `tree`, `fmt`, `setup` больше не игнорируют аргументы и используют цветной вывод.
|
||||
- Инструкция в README изменена с `| bash` на `| sh` для POSIX.
|
||||
- Отключена архитектура Windows 32-bit (GNU) из-за проблем со сборкой.
|
||||
|
||||
**Исправлено:**
|
||||
|
||||
- **`dcr new <invalid-name>` создаёт директорию, затем падает** — валидация теперь происходит до операций с файлами.
|
||||
- **`dcr init` создаёт dcr.toml, затем падает при невалидном имени директории** — то же исправление.
|
||||
- **Man-страницы отсутствовали после установки** — теперь устанавливаются через скрипты установки, пакетные менеджеры и Homebrew.
|
||||
- **Ложное срабатывание на букву диска в Windows** — в парсинге файлов зависимостей.
|
||||
- **CRLF `\r\n` ломает парсер зависимостей** — теперь обрабатываются смешанные окончания строк.
|
||||
- **Новая строка после обратного слеша не поглощалась** — в обработке escape-последовательностей `parse_d_file`.
|
||||
|
||||
### EN
|
||||
|
||||
**Added:**
|
||||
- `--help` for all commands with styled headers and usage lines.
|
||||
- Man pages (12 troff man pages in `man/man1/`) and their installation across all packaging formats.
|
||||
- Project name validation in `dcr init` and `dcr new` (ASCII letters, digits, `_`, `-` only).
|
||||
- `documentation` and `homepage` metadata in `Cargo.toml`.
|
||||
- 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.
|
||||
- Multi-arch `deb` and `rpm` package builds for all 5 Linux architectures via `cargo-zigbuild`.
|
||||
- AUR packages (`dcr-dev`, `dcr-dev-bin`) and Snap build in CI.
|
||||
|
||||
**Changed:**
|
||||
- `validate_package_name` made public and callable from CLI commands directly.
|
||||
- `gen.rs`, `tree.rs`, `fmt.rs`, `setup.rs` no longer ignore arguments and use styled output.
|
||||
- README install instructions changed from `| bash` to `| sh` for POSIX compatibility.
|
||||
- Disabled Windows 32-bit (GNU) target due to build issues.
|
||||
|
||||
Fixed:
|
||||
|
||||
- **`dcr new <invalid-name>` creates directory then fails** — validation now happens
|
||||
before any file operations.
|
||||
- **`dcr init` creates dcr.toml then fails on invalid directory name** — same fix.
|
||||
- **Man pages missing after installation** — now installed via install scripts,
|
||||
package managers, and Homebrew.
|
||||
- **Windows drive letter false positive** — in dependency file parsing.
|
||||
- **CRLF `\r\n` breaks dependency parser** — now handles mixed line endings.
|
||||
- **Newline after backslash not consumed** — in `parse_d_file` escape handling.
|
||||
|
||||
## [0.7.0] - 2026-06-02
|
||||
|
||||
Added:
|
||||
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -112,7 +112,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dcr"
|
||||
version = "0.7.0"
|
||||
version = "0.7.2"
|
||||
dependencies = [
|
||||
"ctrlc",
|
||||
"git2",
|
||||
|
||||
54
Cargo.toml
54
Cargo.toml
@@ -1,11 +1,13 @@
|
||||
[package]
|
||||
name = "dcr"
|
||||
version = "0.7.0"
|
||||
version = "0.7.2"
|
||||
edition = "2024"
|
||||
build = "build.rs"
|
||||
description = "DCR is a utility for managing C/C++ projects in a Cargo-like style."
|
||||
license = "GPL-3.0-or-later"
|
||||
repository = "https://github.com/dexoron/dcr"
|
||||
documentation = "https://dcr.dexoron.su/docs"
|
||||
homepage = "https://dcr.dexoron.su"
|
||||
|
||||
[package.metadata.binstall]
|
||||
pkg-fmt = "bin"
|
||||
@@ -21,6 +23,18 @@ section = "devel"
|
||||
priority = "optional"
|
||||
assets = [
|
||||
["target/release/dcr", "usr/bin/dcr", "755"],
|
||||
["man/man1/dcr.1", "usr/share/man/man1/dcr.1", "644"],
|
||||
["man/man1/dcr-add.1", "usr/share/man/man1/dcr-add.1", "644"],
|
||||
["man/man1/dcr-build.1", "usr/share/man/man1/dcr-build.1", "644"],
|
||||
["man/man1/dcr-clean.1", "usr/share/man/man1/dcr-clean.1", "644"],
|
||||
["man/man1/dcr-fmt.1", "usr/share/man/man1/dcr-fmt.1", "644"],
|
||||
["man/man1/dcr-gen.1", "usr/share/man/man1/dcr-gen.1", "644"],
|
||||
["man/man1/dcr-init.1", "usr/share/man/man1/dcr-init.1", "644"],
|
||||
["man/man1/dcr-new.1", "usr/share/man/man1/dcr-new.1", "644"],
|
||||
["man/man1/dcr-run.1", "usr/share/man/man1/dcr-run.1", "644"],
|
||||
["man/man1/dcr-setup.1", "usr/share/man/man1/dcr-setup.1", "644"],
|
||||
["man/man1/dcr-test.1", "usr/share/man/man1/dcr-test.1", "644"],
|
||||
["man/man1/dcr-tree.1", "usr/share/man/man1/dcr-tree.1", "644"],
|
||||
]
|
||||
|
||||
[package.metadata.generate-rpm]
|
||||
@@ -30,7 +44,19 @@ Cargo-like utility to manage C/C++ projects.
|
||||
"""
|
||||
|
||||
assets = [
|
||||
{ source = "target/release/dcr", dest = "/usr/bin/dcr", mode = "755" }
|
||||
{ source = "target/release/dcr", dest = "/usr/bin/dcr", mode = "755" },
|
||||
{ source = "man/man1/dcr.1", dest = "/usr/share/man/man1/dcr.1", mode = "644" },
|
||||
{ source = "man/man1/dcr-add.1", dest = "/usr/share/man/man1/dcr-add.1", mode = "644" },
|
||||
{ source = "man/man1/dcr-build.1", dest = "/usr/share/man/man1/dcr-build.1", mode = "644" },
|
||||
{ source = "man/man1/dcr-clean.1", dest = "/usr/share/man/man1/dcr-clean.1", mode = "644" },
|
||||
{ source = "man/man1/dcr-fmt.1", dest = "/usr/share/man/man1/dcr-fmt.1", mode = "644" },
|
||||
{ source = "man/man1/dcr-gen.1", dest = "/usr/share/man/man1/dcr-gen.1", mode = "644" },
|
||||
{ source = "man/man1/dcr-init.1", dest = "/usr/share/man/man1/dcr-init.1", mode = "644" },
|
||||
{ source = "man/man1/dcr-new.1", dest = "/usr/share/man/man1/dcr-new.1", mode = "644" },
|
||||
{ source = "man/man1/dcr-run.1", dest = "/usr/share/man/man1/dcr-run.1", mode = "644" },
|
||||
{ source = "man/man1/dcr-setup.1", dest = "/usr/share/man/man1/dcr-setup.1", mode = "644" },
|
||||
{ source = "man/man1/dcr-test.1", dest = "/usr/share/man/man1/dcr-test.1", mode = "644" },
|
||||
{ source = "man/man1/dcr-tree.1", dest = "/usr/share/man/man1/dcr-tree.1", mode = "644" },
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
@@ -43,16 +69,32 @@ toml = "1.0.3"
|
||||
serde_json = "1"
|
||||
ctrlc = "3"
|
||||
|
||||
[features]
|
||||
default = ["vendored"]
|
||||
vendored = [
|
||||
"git2/vendored-libgit2",
|
||||
"git2/vendored-openssl",
|
||||
"openssl/vendored",
|
||||
]
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
git2 = { version = "0.20.4", features = ["vendored-libgit2", "vendored-openssl"] }
|
||||
openssl = { version = "0.10", features = ["vendored"] }
|
||||
git2 = "0.20.4"
|
||||
openssl = "0.10"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
git2 = { version = "0.20.4", features = ["vendored-libgit2"] }
|
||||
git2 = "0.20.4"
|
||||
|
||||
[profile.release]
|
||||
opt-level = "z"
|
||||
lto = true
|
||||
lto = "thin"
|
||||
codegen-units = 1
|
||||
panic = "abort"
|
||||
strip = true
|
||||
|
||||
[profile.fast]
|
||||
inherits = "release"
|
||||
opt-level = 1
|
||||
lto = false
|
||||
codegen-units = 16
|
||||
panic = "abort"
|
||||
strip = true
|
||||
71
README.md
71
README.md
@@ -1,31 +1,32 @@
|
||||
<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)
|
||||
[](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)
|
||||
<br/>
|
||||
[](https://github.com/dexoron/dcr/stargazers)
|
||||
[](LICENSE)
|
||||
|
||||
</div>
|
||||
<!-- Snap badge removed: classic confinement was denied for this project. -->
|
||||
|
||||
---
|
||||
|
||||
## Why DCR?
|
||||
|
||||
- **No boilerplate** — one config file, predictable structure
|
||||
- **Cargo-like workflow** — `build`, `run`, `clean`, `test`, `add`
|
||||
- **Cargo-like workflow** — `build`, `run`, `clean`, `test`, `add`, `fmt`
|
||||
- **Cross-compilation** — full target triple support with short names
|
||||
- **IDE integration** — VS Code, CLion, `compile_commands.json` out of the box
|
||||
- **Dependencies** — path, git, and registry-based with lock file
|
||||
- **Man pages** — `man dcr` and per-command pages (`man dcr-build`, `man dcr-new`, etc.)
|
||||
|
||||
---
|
||||
|
||||
@@ -119,6 +120,19 @@ curl -fsSL https://dcr.dexoron.su/install.sh | sh
|
||||
curl -fsSL https://dcr.dexoron.su/install_bsd.sh | sh
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Snap (Linux)</b></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
|
||||
sudo snap install --classic --dangerous dcrup_*.snap
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -200,24 +214,26 @@ kind = "bin"
|
||||
| `dcr gen <vscode\|clion\|compile-commands>` | Generate IDE integration |
|
||||
| `dcr setup` | Initialize DCR registry |
|
||||
|
||||
other in [docs/](docs/) and `dcr --help`
|
||||
other in [docs/](docs/), `dcr --help` and `dcr <command> --help`
|
||||
|
||||
---
|
||||
|
||||
## Platforms(pre-build source)
|
||||
## Platforms (pre-built binary)
|
||||
|
||||
<div align="center">
|
||||
|
||||
| OS | x86_64 | aarch64 | armv7 | i686 | riscv64 | GNU | Musl | MSVC | MinGW |
|
||||
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|
||||
| Linux | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ |
|
||||
| macOS | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
| Windows | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
|
||||
| FreeBSD | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
||||
| OpenBSD | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
||||
| NetBSD | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
||||
| OS | x86_64 | aarch64 | armv7 | i686 | riscv64 |
|
||||
|:---:|:---:|:---:|:---:|:---:|:---:|
|
||||
| Linux (GNU) | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Linux (Musl) | ✅ | ✅ | ✅ | ✅ | 🚧 |
|
||||
| macOS | ✅ | ✅ | ❌ | ❌ | ❌ |
|
||||
| Windows (MSVC) | ✅ | ✅ | ❌ | ✅ | ❌ |
|
||||
| Windows (MinGW) | ✅ | 🚧 | ❌ | ❌ | ❌ |
|
||||
| FreeBSD | ✅ | 🚧 | ❌ | ❌ | ❌ |
|
||||
| OpenBSD | ✅ | 🚧 | ❌ | ❌ | ❌ |
|
||||
| NetBSD | ✅ | 🚧 | ❌ | ❌ | ❌ |
|
||||
|
||||
✅ officially supported · ⚠️ community / best-effort · ❌ not supported
|
||||
✅ pre-built binary · 🚧 planned · ❌ not supported by platform or CI
|
||||
|
||||
</div>
|
||||
|
||||
@@ -257,6 +273,7 @@ cargo test
|
||||
<div align="center">
|
||||
|
||||
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.
|
||||
|
||||
</div>
|
||||
|
||||
@@ -44,6 +44,7 @@ dcr gen vscode
|
||||
| [Self Update](/docs/self-update) | Auto-update |
|
||||
| [FAQ](/docs/faq) | Frequently asked questions |
|
||||
| [Changelog](/docs/changelog) | Version history |
|
||||
| [License](/docs/license) | DCR and vendored library licenses |
|
||||
| [Contributing](/docs/contributing) | DCR development |
|
||||
|
||||
## Features
|
||||
@@ -58,3 +59,5 @@ dcr gen vscode
|
||||
- **Registry + Git + Path** — three dependency mechanisms
|
||||
- **IDE generation** — VS Code, CLion, compile_commands.json, JSON metadata
|
||||
- **pkg-config** — automatic system library discovery
|
||||
- **Per-command `--help`** — `dcr build --help`, `dcr new --help`, etc.
|
||||
- **Man pages** — `man dcr`, `man dcr-build`, `man dcr-new`
|
||||
|
||||
@@ -4,6 +4,50 @@ sidebar_label: Changelog
|
||||
|
||||
# Changelog
|
||||
|
||||
## 0.7.1 (2026-06-02)
|
||||
|
||||
### Added
|
||||
|
||||
- **`--help` for all commands** — `dcr build --help`, `dcr run --help`, `dcr new --help`,
|
||||
`dcr init --help`, `dcr clean --help`, `dcr add --help`, `dcr fmt --help`,
|
||||
`dcr setup --help`, `dcr tree --help`, `dcr gen --help`, `dcr --update --help`,
|
||||
`dcr test --help`. All output uses styled headers (green) and usage lines (cyan).
|
||||
- **Man pages** — 12 troff pages in `man/man1/`: `dcr.1`, `dcr-build.1`,
|
||||
`dcr-run.1`, `dcr-new.1`, `dcr-init.1`, `dcr-clean.1`, `dcr-add.1`, `dcr-test.1`,
|
||||
`dcr-gen.1`, `dcr-fmt.1`, `dcr-tree.1`, `dcr-setup.1`.
|
||||
- **Man pages in all packaging** — install.sh, install_bsd.sh, AUR PKGBUILD,
|
||||
Debian (cargo-deb), RPM (cargo-generate-rpm), Nix (postInstall), Homebrew
|
||||
(resource), Snap, GitHub Release assets.
|
||||
- **Project name validation** — `dcr init` and `dcr new` now validate names before
|
||||
creating files. Only ASCII letters, digits, `_` and `-` are allowed.
|
||||
- **`documentation` and `homepage` fields** — added to `Cargo.toml`.
|
||||
- **Release profile optimizations** — `opt-level = "z"`, LTO, `codegen-units = 1`,
|
||||
`panic = "abort"`, `strip = true` for smaller binaries.
|
||||
- **Linux i686, armv7, riscv64 targets** — added to release workflow and install scripts.
|
||||
- **Linux musl i686, armv7 targets** — cross-compiled via zigbuild in CI.
|
||||
- **AUR packages** — `dcr-dev`, `dcr-dev-bin` publishing workflow.
|
||||
- **Snap publishing** — automated Snapcraft publishing in CI.
|
||||
- **Snap badge** — in README.
|
||||
|
||||
### Changed
|
||||
|
||||
- **`validate_package_name` made public** — callable from CLI commands.
|
||||
- **README platform table** — reorganized: libc variants as separate OS rows,
|
||||
removed extra columns. Linux architecture list updated.
|
||||
- **`gen.rs` no-args output** — now uses styled output instead of raw `eprintln!`.
|
||||
- **`tree.rs`, `fmt.rs`, and `setup.rs`** — now accept arguments for `--help`.
|
||||
- **README install commands** — `| bash` → `| sh` for POSIX compatibility.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **`dcr new <invalid-name>` creates directory then fails** — validation now
|
||||
happens before any file operations.
|
||||
- **`dcr init` on invalid directory name** — same fix.
|
||||
- **Man pages missing in installed packages** — now shipped in all formats.
|
||||
- **Windows drive letter false positive** — in dependency file parser.
|
||||
- **CRLF (`\r\n`) breaks dependency parser** — now handles mixed line endings.
|
||||
- **Newline after backslash not consumed** — in `parse_d_file` escape handling.
|
||||
|
||||
## 0.7.0 (2026-06-01)
|
||||
|
||||
### Added
|
||||
|
||||
@@ -8,6 +8,8 @@ sidebar_label: Project commands (new, init)
|
||||
|
||||
Creates a new project with a standard structure and `dcr.toml`. The `name` argument is required.
|
||||
|
||||
Only ASCII letters, digits, underscores `_` and hyphens `-` are allowed in the project name.
|
||||
|
||||
```bash
|
||||
dcr new my-app
|
||||
```
|
||||
@@ -25,4 +27,4 @@ mkdir app && cd app
|
||||
dcr init
|
||||
```
|
||||
|
||||
The project name is taken from the current directory name.
|
||||
The project name is taken from the current directory name. The directory name must follow the same naming rules as `dcr new`.
|
||||
|
||||
@@ -36,6 +36,12 @@ brew tap dexoron/dexoron
|
||||
brew install dcr
|
||||
```
|
||||
|
||||
## Snap (Linux)
|
||||
|
||||
```sh
|
||||
sudo snap install dcrup
|
||||
```
|
||||
|
||||
## Nix (flake)
|
||||
|
||||
```sh
|
||||
@@ -53,13 +59,13 @@ cargo install dcr
|
||||
## Linux / macOS (script)
|
||||
|
||||
```sh
|
||||
curl -fsSL https://dcr.dexoron.su/install.sh | bash
|
||||
curl -fsSL https://dcr.dexoron.su/install.sh | sh
|
||||
```
|
||||
|
||||
## BSD (script)
|
||||
|
||||
```sh
|
||||
curl -fsSL https://dcr.dexoron.su/install_bsd.sh | bash
|
||||
curl -fsSL https://dcr.dexoron.su/install_bsd.sh | sh
|
||||
```
|
||||
|
||||
## Windows (PowerShell)
|
||||
@@ -84,6 +90,13 @@ Verify the installation:
|
||||
dcr --version
|
||||
```
|
||||
|
||||
Man pages are available after installation:
|
||||
|
||||
```bash
|
||||
man dcr
|
||||
man dcr-build
|
||||
```
|
||||
|
||||
To use the registry, create `~/.dcr/config.toml`:
|
||||
|
||||
```toml
|
||||
|
||||
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/).
|
||||
@@ -64,6 +64,10 @@
|
||||
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
install -Dm644 man/man1/*.1 -t $out/share/man/man1/
|
||||
'';
|
||||
|
||||
# Tests require external services; run separately.
|
||||
doCheck = false;
|
||||
};
|
||||
|
||||
12
install.sh
12
install.sh
@@ -4,6 +4,7 @@ set -Eeuo pipefail
|
||||
TMPDIR="/tmp/dcr-install"
|
||||
INSTALL_PATH="$HOME/.local/share/dcr"
|
||||
BINPATH="$HOME/.local/bin"
|
||||
MANPATH="${XDG_DATA_HOME:-$HOME/.local/share}/man"
|
||||
LOGFILE="$HOME/.cache/dcr-install.log"
|
||||
REPO_URL="https://github.com/dexoron/dcr"
|
||||
GITHUB_API_LATEST="https://api.github.com/repos/dexoron/dcr/releases/latest"
|
||||
@@ -199,6 +200,16 @@ install_link() {
|
||||
success "Command 'dcr' added to $BINPATH"
|
||||
}
|
||||
|
||||
install_man() {
|
||||
log "Installing man pages..."
|
||||
local man_src="$TMPDIR/man/man1"
|
||||
if [[ -d "$man_src" ]]; then
|
||||
mkdir -p "$MANPATH/man1"
|
||||
cp "$man_src"/*.1 "$MANPATH/man1/"
|
||||
success "Man pages installed to $MANPATH/man1"
|
||||
fi
|
||||
}
|
||||
|
||||
check_path() {
|
||||
if ! echo "$PATH" | grep -q "$BINPATH"; then
|
||||
warn "Directory $BINPATH not found in PATH"
|
||||
@@ -231,6 +242,7 @@ main() {
|
||||
fi
|
||||
|
||||
install_link
|
||||
install_man
|
||||
check_path
|
||||
cleanup
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ set -eu
|
||||
TMPDIR="/tmp/dcr-install"
|
||||
INSTALL_PATH="$HOME/.local/share/dcr"
|
||||
BINPATH="$HOME/.local/bin"
|
||||
MANPATH="${XDG_DATA_HOME:-$HOME/.local/share}/man"
|
||||
LOGFILE="$HOME/.cache/dcr-install.log"
|
||||
REPO_URL="https://github.com/dexoron/dcr"
|
||||
GITHUB_API_LATEST="https://api.github.com/repos/dexoron/dcr/releases/latest"
|
||||
@@ -187,6 +188,16 @@ install_link() {
|
||||
success "Command 'dcr' added to $BINPATH"
|
||||
}
|
||||
|
||||
install_man() {
|
||||
log "Installing man pages..."
|
||||
man_src="$TMPDIR/man/man1"
|
||||
if [ -d "$man_src" ]; then
|
||||
mkdir -p "$MANPATH/man1"
|
||||
cp "$man_src"/*.1 "$MANPATH/man1/"
|
||||
success "Man pages installed to $MANPATH/man1"
|
||||
fi
|
||||
}
|
||||
|
||||
check_path() {
|
||||
if ! echo "$PATH" | grep -q "$BINPATH"; then
|
||||
warn "Directory $BINPATH not found in PATH"
|
||||
@@ -219,6 +230,7 @@ main() {
|
||||
fi
|
||||
|
||||
install_link
|
||||
install_man
|
||||
check_path
|
||||
cleanup
|
||||
|
||||
|
||||
42
man/man1/dcr-add.1
Normal file
42
man/man1/dcr-add.1
Normal file
@@ -0,0 +1,42 @@
|
||||
.TH DCR-ADD 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr-add \- Add a dependency to a DCR project
|
||||
.SH SYNOPSIS
|
||||
.B dcr add \fI<name>\fR \fI<source>\fR
|
||||
[\fB\-\-branch\fR \fI<b>\fR]
|
||||
[\fB\-\-tag\fR \fI<t>\fR]
|
||||
[\fB\-\-rev\fR \fI<r>\fR]
|
||||
.SH DESCRIPTION
|
||||
Adds a dependency to the project.
|
||||
.SH SOURCES
|
||||
.TP
|
||||
.B user/repo
|
||||
GitHub shorthand.
|
||||
.TP
|
||||
.B github:user/repo
|
||||
Full GitHub repository.
|
||||
.TP
|
||||
.B gitlab:user/repo
|
||||
GitLab repository.
|
||||
.TP
|
||||
.B git:host.com/user/repo
|
||||
Generic git repository.
|
||||
.TP
|
||||
.B path:./path/to/lib
|
||||
Local path dependency.
|
||||
.TP
|
||||
.B <version>
|
||||
Version from registry.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-\-branch \fI<name>\fR
|
||||
Use a specific branch.
|
||||
.TP
|
||||
.B \-\-tag \fI<name>\fR
|
||||
Use a specific tag.
|
||||
.TP
|
||||
.B \-\-rev \fI<hash>\fR
|
||||
Use a specific commit hash.
|
||||
.SH SEE ALSO
|
||||
.BR dcr (1),
|
||||
.BR dcr-tree (1)
|
||||
37
man/man1/dcr-build.1
Normal file
37
man/man1/dcr-build.1
Normal file
@@ -0,0 +1,37 @@
|
||||
.TH DCR-BUILD 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr-build \- Compile a DCR project
|
||||
.SH SYNOPSIS
|
||||
.B dcr build
|
||||
[\fB\-\-debug\fR | \fB\-\-release\fR]
|
||||
[\fB\-\-target\fR \fI<triple>\fR]
|
||||
[\fB\-\-force\fR]
|
||||
[\fB\-\-clean\fR]
|
||||
[\fB\-\-verbose\fR]
|
||||
[\fB\-\-workspace\fR \fI<name>\fR]
|
||||
.SH DESCRIPTION
|
||||
Compiles the project. Default profile is \fB\-\-debug\fR.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-\-debug
|
||||
Build with debug profile (default). Enables debug symbols.
|
||||
.TP
|
||||
.B \-\-release
|
||||
Build with release profile. Enables full optimization.
|
||||
.TP
|
||||
.B \-\-target \fI<triple>\fR
|
||||
Cross-compile for the given target.
|
||||
.TP
|
||||
.B \-\-force
|
||||
Force a full rebuild, ignoring cached artifacts.
|
||||
.TP
|
||||
.B \-\-clean
|
||||
Clean before building.
|
||||
.TP
|
||||
.B \-\-verbose
|
||||
Print detailed build output including compiler commands.
|
||||
.TP
|
||||
.B \-\-workspace \fI<name>\fR
|
||||
Build a specific workspace member.
|
||||
.SH SEE ALSO
|
||||
.BR dcr (1)
|
||||
26
man/man1/dcr-clean.1
Normal file
26
man/man1/dcr-clean.1
Normal file
@@ -0,0 +1,26 @@
|
||||
.TH DCR-CLEAN 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr-clean \- Remove build artifacts
|
||||
.SH SYNOPSIS
|
||||
.B dcr clean
|
||||
[\fB\-\-debug\fR | \fB\-\-release\fR]
|
||||
[\fB\-\-target\fR \fI<triple>\fR]
|
||||
[\fB\-\-all\fR]
|
||||
.SH DESCRIPTION
|
||||
Removes build artifacts from the target directory.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-\-debug
|
||||
Clean debug artifacts (default).
|
||||
.TP
|
||||
.B \-\-release
|
||||
Clean release artifacts.
|
||||
.TP
|
||||
.B \-\-target \fI<triple>\fR
|
||||
Clean artifacts for a specific target.
|
||||
.TP
|
||||
.B \-\-all
|
||||
Clean all workspace members.
|
||||
.SH SEE ALSO
|
||||
.BR dcr (1),
|
||||
.BR dcr-build (1)
|
||||
10
man/man1/dcr-fmt.1
Normal file
10
man/man1/dcr-fmt.1
Normal file
@@ -0,0 +1,10 @@
|
||||
.TH DCR-FMT 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr-fmt \- Format C/C++ source files
|
||||
.SH SYNOPSIS
|
||||
.B dcr fmt
|
||||
.SH DESCRIPTION
|
||||
Formats all C/C++ source files using clang-format. Scans \fBsrc/\fR
|
||||
and \fBtests/\fR directories recursively.
|
||||
.SH SEE ALSO
|
||||
.BR dcr (1)
|
||||
23
man/man1/dcr-gen.1
Normal file
23
man/man1/dcr-gen.1
Normal file
@@ -0,0 +1,23 @@
|
||||
.TH DCR-GEN 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr-gen \- Generate IDE and tooling integration files
|
||||
.SH SYNOPSIS
|
||||
.B dcr gen \fI<subcommand>\fR
|
||||
.SH DESCRIPTION
|
||||
Generates IDE and tooling integration files for DCR projects.
|
||||
.SH SUBCOMMANDS
|
||||
.TP
|
||||
.B project-info
|
||||
Print project metadata as JSON to stdout.
|
||||
.TP
|
||||
.B compile-commands
|
||||
Generate \fBcompile_commands.json\fR for IDE tooling.
|
||||
.TP
|
||||
.B vscode
|
||||
Generate \fB.vscode/\fR integration files (tasks, launch configurations).
|
||||
.TP
|
||||
.B clion
|
||||
Generate \fB.idea/\fR integration files for CLion.
|
||||
.SH SEE ALSO
|
||||
.BR dcr (1),
|
||||
.BR dcr-build (1)
|
||||
11
man/man1/dcr-init.1
Normal file
11
man/man1/dcr-init.1
Normal file
@@ -0,0 +1,11 @@
|
||||
.TH DCR-INIT 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr-init \- Initialize a directory as a DCR project
|
||||
.SH SYNOPSIS
|
||||
.B dcr init
|
||||
.SH DESCRIPTION
|
||||
Initializes the current directory as a DCR project. The directory must
|
||||
be empty.
|
||||
.SH SEE ALSO
|
||||
.BR dcr (1),
|
||||
.BR dcr-new (1)
|
||||
13
man/man1/dcr-new.1
Normal file
13
man/man1/dcr-new.1
Normal file
@@ -0,0 +1,13 @@
|
||||
.TH DCR-NEW 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr-new \- Create a new DCR project
|
||||
.SH SYNOPSIS
|
||||
.B dcr new \fI<name>\fR
|
||||
.SH DESCRIPTION
|
||||
Creates a new C/C++ project with the given name. The name may only
|
||||
contain ASCII letters, digits, underscores and hyphens.
|
||||
.SH EXAMPLE
|
||||
.B dcr new my-project
|
||||
.SH SEE ALSO
|
||||
.BR dcr (1),
|
||||
.BR dcr-init (1)
|
||||
35
man/man1/dcr-run.1
Normal file
35
man/man1/dcr-run.1
Normal file
@@ -0,0 +1,35 @@
|
||||
.TH DCR-RUN 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr-run \- Build and run a DCR project
|
||||
.SH SYNOPSIS
|
||||
.B dcr run
|
||||
[\fB\-\-debug\fR | \fB\-\-release\fR]
|
||||
[\fB\-\-target\fR \fI<triple>\fR]
|
||||
[\fB\-\-force\fR]
|
||||
[\fB\-\-clean\fR]
|
||||
[\fB\-\-verbose\fR]
|
||||
.SH DESCRIPTION
|
||||
Builds and runs the project. Only available for projects with
|
||||
\fBkind = "bin"\fR.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-\-debug
|
||||
Run with debug profile (default).
|
||||
.TP
|
||||
.B \-\-release
|
||||
Run with release profile.
|
||||
.TP
|
||||
.B \-\-target \fI<triple>\fR
|
||||
Cross-compile for the given target.
|
||||
.TP
|
||||
.B \-\-force
|
||||
Force a full rebuild.
|
||||
.TP
|
||||
.B \-\-clean
|
||||
Clean before building.
|
||||
.TP
|
||||
.B \-\-verbose
|
||||
Print detailed build output.
|
||||
.SH SEE ALSO
|
||||
.BR dcr (1),
|
||||
.BR dcr-build (1)
|
||||
11
man/man1/dcr-setup.1
Normal file
11
man/man1/dcr-setup.1
Normal file
@@ -0,0 +1,11 @@
|
||||
.TH DCR-SETUP 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr-setup \- Set up DCR registries
|
||||
.SH SYNOPSIS
|
||||
.B dcr setup
|
||||
.SH DESCRIPTION
|
||||
Sets up DCR registries. Downloads and indexes package registries
|
||||
for dependency resolution.
|
||||
.SH SEE ALSO
|
||||
.BR dcr (1),
|
||||
.BR dcr-add (1)
|
||||
24
man/man1/dcr-test.1
Normal file
24
man/man1/dcr-test.1
Normal file
@@ -0,0 +1,24 @@
|
||||
.TH DCR-TEST 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr-test \- Run project tests
|
||||
.SH SYNOPSIS
|
||||
.B dcr test
|
||||
[\fB\-\-init\fR]
|
||||
[\fB\-\-debug\fR | \fB\-\-release\fR]
|
||||
.SH ALIASES
|
||||
.B dcr tests
|
||||
.SH DESCRIPTION
|
||||
Runs project tests and prints a unified testsuite report.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-\-init
|
||||
Create \fBtests/dcr_test.h\fR in the current project.
|
||||
.TP
|
||||
.B \-\-debug
|
||||
Build and run tests with debug profile (default).
|
||||
.TP
|
||||
.B \-\-release
|
||||
Build and run tests with release profile.
|
||||
.SH SEE ALSO
|
||||
.BR dcr (1),
|
||||
.BR dcr-build (1)
|
||||
11
man/man1/dcr-tree.1
Normal file
11
man/man1/dcr-tree.1
Normal file
@@ -0,0 +1,11 @@
|
||||
.TH DCR-TREE 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr-tree \- Display the dependency tree
|
||||
.SH SYNOPSIS
|
||||
.B dcr tree
|
||||
.SH DESCRIPTION
|
||||
Displays the dependency tree of the current project, showing all
|
||||
transitive dependencies and their versions.
|
||||
.SH SEE ALSO
|
||||
.BR dcr (1),
|
||||
.BR dcr-add (1)
|
||||
204
man/man1/dcr.1
Normal file
204
man/man1/dcr.1
Normal file
@@ -0,0 +1,204 @@
|
||||
.TH DCR 1 "2026-06-02" "dcr 0.7.0" "DCR Manual"
|
||||
.SH NAME
|
||||
dcr \- Cargo\-like build tool and package manager for C/C++ projects
|
||||
.SH SYNOPSIS
|
||||
.B dcr
|
||||
[\fIcommand\fR] [\fIoptions\fR]
|
||||
.SH DESCRIPTION
|
||||
DCR is a comprehensive build tool and package manager for C and C++ projects,
|
||||
inspired by Cargo from the Rust ecosystem. It handles project creation,
|
||||
building, dependency management, testing, formatting, and IDE integration.
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
.B new \fI<name>\fR
|
||||
Create a new C/C++ project with the given name. Only ASCII letters, digits,
|
||||
underscores and hyphens are allowed.
|
||||
.TP
|
||||
.B init
|
||||
Initialize the current (empty) directory as a DCR project.
|
||||
.TP
|
||||
.B build [\fIoptions\fR]
|
||||
Compile the project. Default profile is \fB\-\-debug\fR.
|
||||
.TP
|
||||
.B run [\fIoptions\fR]
|
||||
Build and run the project. Only available for binary projects.
|
||||
.TP
|
||||
.B clean [\fIoptions\fR]
|
||||
Remove build artifacts from the target directory.
|
||||
.TP
|
||||
.B test [\fI\-\-init\fR] [\fI\-\-debug\fR|\fI\-\-release\fR]
|
||||
Run project tests (alias: \fBdcr tests\fR).
|
||||
.TP
|
||||
.B add \fI<name>\fR \fI<source>\fR [\fIoptions\fR]
|
||||
Add a dependency to the project.
|
||||
.TP
|
||||
.B tree
|
||||
Display the dependency tree of the current project.
|
||||
.TP
|
||||
.B fmt
|
||||
Format all C/C++ source files using clang-format.
|
||||
.TP
|
||||
.B gen \fI<subcommand>\fR
|
||||
Generate IDE integration files (vscode, clion, compile-commands, project-info).
|
||||
.TP
|
||||
.B setup
|
||||
Set up DCR registries for dependency resolution.
|
||||
.SH GLOBAL FLAGS
|
||||
.TP
|
||||
.B \-\-help
|
||||
Show this help message and exit.
|
||||
.TP
|
||||
.B \-\-version
|
||||
Print version information and exit.
|
||||
.TP
|
||||
.B \-\-update
|
||||
Update DCR to the latest version from GitHub Releases.
|
||||
.SH BUILD OPTIONS
|
||||
The following options apply to \fBbuild\fR and \fBrun\fR commands:
|
||||
.TP
|
||||
.B \-\-debug
|
||||
Build with debug profile (default). Enables debug symbols and minimal optimization.
|
||||
.TP
|
||||
.B \-\-release
|
||||
Build with release profile. Enables full optimization without debug symbols.
|
||||
.TP
|
||||
.B \-\-target \fI<triple>\fR
|
||||
Cross-compile for the given target (e.g. \fBaarch64-linux-gnu\fR, \fBx86_64-w64-mingw32\fR).
|
||||
Short names like \fBlinux\fR, \fBmacos\fR, \fBwindows\fR are also supported.
|
||||
.TP
|
||||
.B \-\-force
|
||||
Force a full rebuild, ignoring cached build artifacts.
|
||||
.TP
|
||||
.B \-\-clean
|
||||
Clean build artifacts before building.
|
||||
.TP
|
||||
.B \-\-verbose
|
||||
Print detailed build output including compiler commands.
|
||||
.TP
|
||||
.B \-\-workspace \fI<name>\fR
|
||||
Build a specific workspace member.
|
||||
.SH CLEAN OPTIONS
|
||||
.TP
|
||||
.B \-\-debug
|
||||
Clean debug artifacts (default).
|
||||
.TP
|
||||
.B \-\-release
|
||||
Clean release artifacts.
|
||||
.TP
|
||||
.B \-\-target \fI<triple>\fR
|
||||
Clean artifacts for a specific target.
|
||||
.TP
|
||||
.B \-\-all
|
||||
Clean all workspace members.
|
||||
.SH ADD OPTIONS
|
||||
.TP
|
||||
.B \-\-branch \fI<name>\fR
|
||||
Use a specific branch when adding a git dependency.
|
||||
.TP
|
||||
.B \-\-tag \fI<name>\fR
|
||||
Use a specific tag when adding a git dependency.
|
||||
.TP
|
||||
.B \-\-rev \fI<hash>\fR
|
||||
Use a specific commit hash when adding a git dependency.
|
||||
.SH DEPENDENCY SOURCES
|
||||
.TP
|
||||
.B user/repo
|
||||
GitHub shorthand (e.g. \fBuser/repo\fR).
|
||||
.TP
|
||||
.B github:user/repo
|
||||
Full GitHub repository URL shorthand.
|
||||
.TP
|
||||
.B gitlab:user/repo
|
||||
GitLab repository URL shorthand.
|
||||
.TP
|
||||
.B git:host.com/user/repo
|
||||
Generic git repository.
|
||||
.TP
|
||||
.B path:./path/to/lib
|
||||
Local path dependency.
|
||||
.TP
|
||||
.B \fI<version>\fR
|
||||
Version from registry (e.g. \fB1.2.3\fR).
|
||||
.SH GEN SUBCOMMANDS
|
||||
.TP
|
||||
.B project-info
|
||||
Print project metadata as JSON to stdout.
|
||||
.TP
|
||||
.B compile-commands
|
||||
Generate \fBcompile_commands.json\fR for IDE tooling.
|
||||
.TP
|
||||
.B vscode
|
||||
Generate \fB.vscode/\fR integration files (tasks, launch configurations).
|
||||
.TP
|
||||
.B clion
|
||||
Generate \fB.idea/\fR integration files for CLion.
|
||||
.SH TEST OPTIONS
|
||||
.TP
|
||||
.B \-\-init
|
||||
Create \fBtests/dcr_test.h\fR in the current project.
|
||||
.TP
|
||||
.B \-\-debug
|
||||
Build and run tests with debug profile (default).
|
||||
.TP
|
||||
.B \-\-release
|
||||
Build and run tests with release profile.
|
||||
.SH PROJECT CONFIGURATION
|
||||
DCR uses \fBdcr.toml\fR for project configuration. Key settings include:
|
||||
.TP
|
||||
.B package.name
|
||||
Project name (required).
|
||||
.TP
|
||||
.B package.version
|
||||
Project version (default: \fB0.1.0\fR).
|
||||
.TP
|
||||
.B build.language
|
||||
Programming language: \fBc\fR or \fBc++\fR (default: \fBc\fR).
|
||||
.TP
|
||||
.B build.standard
|
||||
Language standard (e.g. \fBc11\fR, \fBc17\fR, \fBc++20\fR; default: \fBc11\fR).
|
||||
.TP
|
||||
.B build.compiler
|
||||
Compiler to use: \fBclang\fR, \fBgcc\fR, \fBcl\fR, \fBclang-cl\fR (default: \fBclang\fR).
|
||||
.TP
|
||||
.B build.kind
|
||||
Output type: \fBbin\fR, \fBlib\fR (static or dynamic), \fBstaticlib\fR, \fBsharedlib\fR (default: \fBbin\fR).
|
||||
.SH FILES
|
||||
.TP
|
||||
.I dcr.toml
|
||||
Project manifest file.
|
||||
.TP
|
||||
.I ~/.dcr/config.toml
|
||||
User-level DCR configuration.
|
||||
.TP
|
||||
.I ~/.dcr/index.json
|
||||
Local registry index.
|
||||
.SH ENVIRONMENT
|
||||
.TP
|
||||
.B DCR_COMPILER
|
||||
Override the compiler used for building.
|
||||
.TP
|
||||
.B DCR_CC
|
||||
Alternative way to override the compiler.
|
||||
.SH EXAMPLES
|
||||
.TP
|
||||
Create a new project:
|
||||
.B dcr new hello
|
||||
.TP
|
||||
Initialize from current directory:
|
||||
.B dcr init
|
||||
.TP
|
||||
Build with release profile:
|
||||
.B dcr build \-\-release
|
||||
.TP
|
||||
Cross-compile for Windows:
|
||||
.B dcr build \-\-target windows
|
||||
.TP
|
||||
Add a dependency:
|
||||
.BR "dcr add curl git:https://github.com/curl/curl" .
|
||||
.TP
|
||||
Generate VS Code integration:
|
||||
.B dcr gen vscode
|
||||
.SH SEE ALSO
|
||||
.IR https://dcr.dexoron.su ", " https://github.com/dexoron/dcr
|
||||
.SH AUTHORS
|
||||
Dexoron (Bezotechestvo Vladimir) <main@dexoron.su>
|
||||
@@ -27,4 +27,7 @@ package() {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
install -Dm755 "target/release/dcr" "$pkgdir/usr/bin/dcr"
|
||||
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
for manpage in man/man1/*.1; do
|
||||
install -Dm644 "$manpage" "$pkgdir/usr/share/man/man1/$(basename "$manpage")"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::core::config::Config;
|
||||
use crate::core::deps::register;
|
||||
use crate::utils::fs::find_project_root;
|
||||
use crate::utils::log::error;
|
||||
use crate::utils::text::{BOLD_GREEN, colored};
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
||||
use toml::Value;
|
||||
use toml::map::Map;
|
||||
|
||||
@@ -34,6 +34,31 @@ pub struct AddArgs {
|
||||
}
|
||||
|
||||
pub fn add(args: &[String]) -> i32 {
|
||||
if args.first().is_some_and(|a| a == "--help") {
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(
|
||||
" dcr add <name> <source> [--branch <b>] [--tag <t>] [--rev <r>]",
|
||||
BOLD_CYAN,
|
||||
);
|
||||
println!();
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Adds a dependency to the project.");
|
||||
println!();
|
||||
printc("SOURCES:", BOLD_GREEN);
|
||||
println!(" user/repo GitHub shorthand");
|
||||
println!(" github:user/repo GitHub repository");
|
||||
println!(" gitlab:user/repo GitLab repository");
|
||||
println!(" git:host.com/user/repo Generic git repository");
|
||||
println!(" path:./path/to/lib Local path dependency");
|
||||
println!(" <version> Version from registry");
|
||||
println!();
|
||||
printc("OPTIONS:", BOLD_GREEN);
|
||||
println!(" --branch <b> Use a specific branch");
|
||||
println!(" --tag <t> Use a specific tag");
|
||||
println!(" --rev <r> Use a specific commit hash");
|
||||
return 0;
|
||||
}
|
||||
|
||||
let add_args = match parse_add_args(args) {
|
||||
Ok(a) => a,
|
||||
Err(code) => return code,
|
||||
|
||||
@@ -23,13 +23,13 @@ use crate::core::config::Config;
|
||||
use crate::core::deps::{register, resolve_deps};
|
||||
use crate::core::workspace::parse_workspace;
|
||||
use crate::utils::build::{
|
||||
get_bool_with_profile, get_config_opt, get_config_str, get_language_with_profile,
|
||||
normalize_target_os, parse_version_info, profile_table, resolve_compiler,
|
||||
resolve_pkg_config_flags, resolve_tool,
|
||||
default_target_triple, get_bool_with_profile, get_config_opt, get_config_str,
|
||||
get_language_with_profile, normalize_target_os, parse_version_info, prepend_clang_target_flag,
|
||||
profile_table, resolve_compiler, resolve_pkg_config_flags, resolve_tool,
|
||||
};
|
||||
use crate::utils::fs::{check_dir, find_project_root, with_dir};
|
||||
use crate::utils::log::error;
|
||||
use crate::utils::text::{BOLD_GREEN, colored};
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
||||
use glob::glob;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::fs;
|
||||
@@ -42,6 +42,27 @@ static BUILD_INTERRUPTED: AtomicBool = AtomicBool::new(false);
|
||||
static SIGNAL_HANDLER: Once = Once::new();
|
||||
|
||||
pub fn build(args: &[String]) -> i32 {
|
||||
if args.first().is_some_and(|a| a == "--help") {
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(
|
||||
" dcr build [--debug | --release] [--target <triple>] [--force] [--clean] [--verbose]",
|
||||
BOLD_CYAN,
|
||||
);
|
||||
println!();
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Compiles the project. Default profile is --debug.");
|
||||
println!();
|
||||
printc("OPTIONS:", BOLD_GREEN);
|
||||
println!(" --debug Build with debug profile (default)");
|
||||
println!(" --release Build with release profile");
|
||||
println!(" --target <triple> Cross-compile for the given target");
|
||||
println!(" --force Force a full rebuild");
|
||||
println!(" --clean Clean before building");
|
||||
println!(" --verbose Print detailed build output");
|
||||
println!(" --workspace <name> Build a specific workspace member");
|
||||
return 0;
|
||||
}
|
||||
|
||||
install_signal_handler();
|
||||
BUILD_INTERRUPTED.store(false, Ordering::SeqCst);
|
||||
let start_dir = match std::env::current_dir() {
|
||||
@@ -79,27 +100,7 @@ pub fn build(args: &[String]) -> i32 {
|
||||
}
|
||||
}
|
||||
if flags.target.is_none() {
|
||||
let default_target = 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()
|
||||
};
|
||||
flags.target = Some(default_target);
|
||||
flags.target = Some(default_target_triple());
|
||||
}
|
||||
if flags.clean {
|
||||
let mut clean_args = Vec::new();
|
||||
@@ -697,19 +698,13 @@ fn build_project_at(
|
||||
tc_cxx.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());
|
||||
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 out_dir_config = get_build_string_with_profile(&config, "out_dir", profile);
|
||||
|
||||
@@ -18,15 +18,33 @@
|
||||
use crate::config::flags;
|
||||
use crate::core::config::Config;
|
||||
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::log::{error, warn};
|
||||
use crate::utils::text::{BOLD_GREEN, colored};
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
||||
use glob::glob;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
pub fn clean(args: &[String]) -> i32 {
|
||||
if args.first().is_some_and(|a| a == "--help") {
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(
|
||||
" dcr clean [--debug | --release] [--target <triple>] [--all]",
|
||||
BOLD_CYAN,
|
||||
);
|
||||
println!();
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Removes build artifacts from the target directory.");
|
||||
println!();
|
||||
printc("OPTIONS:", BOLD_GREEN);
|
||||
println!(" --debug Clean debug artifacts (default)");
|
||||
println!(" --release Clean release artifacts");
|
||||
println!(" --target <triple> Clean artifacts for a specific target");
|
||||
println!(" --all Clean all workspace members");
|
||||
return 0;
|
||||
}
|
||||
|
||||
let start_dir = match std::env::current_dir() {
|
||||
Ok(dir) => dir,
|
||||
Err(_) => {
|
||||
@@ -118,28 +136,7 @@ fn clean_from_root(root: &Path, flags: &CleanFlags) -> Result<(), String> {
|
||||
.map(|s| s.trim().to_string())
|
||||
.filter(|s| !s.is_empty())
|
||||
})
|
||||
.or_else(|| {
|
||||
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()
|
||||
})
|
||||
});
|
||||
.or_else(|| Some(default_target_triple()));
|
||||
|
||||
if flags.all
|
||||
&& let Some(workspace) = parse_workspace(
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::utils::log::{error, warn};
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc};
|
||||
use reqwest::blocking::Client;
|
||||
use serde::Deserialize;
|
||||
use std::fs;
|
||||
@@ -39,6 +40,15 @@ struct ReleaseAsset {
|
||||
}
|
||||
|
||||
pub fn flag_update(args: &[String]) -> i32 {
|
||||
if args.first().is_some_and(|a| a == "--help") {
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(" dcr --update", BOLD_CYAN);
|
||||
println!();
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Updates DCR to the latest version from GitHub Releases.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if !args.is_empty() {
|
||||
warn("Command does not support additional arguments");
|
||||
return 1;
|
||||
|
||||
@@ -16,11 +16,21 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::utils::log::error;
|
||||
use crate::utils::text::{BOLD_GREEN, colored};
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
||||
use glob::glob;
|
||||
use std::process::Command;
|
||||
|
||||
pub fn fmt(_args: &[String]) -> i32 {
|
||||
pub fn fmt(args: &[String]) -> i32 {
|
||||
if args.first().is_some_and(|a| a == "--help") {
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(" dcr fmt", BOLD_CYAN);
|
||||
println!();
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Formats all C/C++ source files using clang-format.");
|
||||
println!(" Scans src/ and tests/ directories recursively.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
let patterns = [
|
||||
"src/**/*.c",
|
||||
"src/**/*.cpp",
|
||||
|
||||
@@ -27,6 +27,7 @@ use crate::utils::build::{
|
||||
};
|
||||
use crate::utils::fs::find_project_root;
|
||||
use crate::utils::log::error;
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Like `deps::resolve_deps` but does NOT require lib directories to exist.
|
||||
@@ -186,13 +187,30 @@ pub struct ProjectInfo {
|
||||
|
||||
pub fn r#gen(args: &[String]) -> i32 {
|
||||
let subcommand = match args.first() {
|
||||
Some(s) if s == "--help" => {
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(" dcr gen <subcommand>", BOLD_CYAN);
|
||||
println!();
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Generates IDE and tooling integration files.");
|
||||
println!();
|
||||
printc("SUBCOMMANDS:", BOLD_GREEN);
|
||||
println!(" project-info Print project metadata as JSON");
|
||||
println!(" compile-commands Generate compile_commands.json");
|
||||
println!(" vscode Generate .vscode/ integration files");
|
||||
println!(" clion Generate .idea/ integration files");
|
||||
return 0;
|
||||
}
|
||||
Some(s) => s.as_str(),
|
||||
None => {
|
||||
eprintln!("Usage: dcr gen <subcommand>");
|
||||
eprintln!(" project-info Print project metadata as JSON");
|
||||
eprintln!(" compile-commands Generate compile_commands.json");
|
||||
eprintln!(" vscode Generate .vscode/ integration files");
|
||||
eprintln!(" clion Generate .idea/ integration files");
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(" dcr gen <subcommand>", BOLD_CYAN);
|
||||
println!();
|
||||
printc("SUBCOMMANDS:", BOLD_GREEN);
|
||||
println!(" project-info Print project metadata as JSON");
|
||||
println!(" compile-commands Generate compile_commands.json");
|
||||
println!(" vscode Generate .vscode/ integration files");
|
||||
println!(" clion Generate .idea/ integration files");
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
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::log::{error, warn};
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
||||
@@ -25,6 +25,16 @@ use std::io::Write;
|
||||
use toml::Value;
|
||||
|
||||
pub fn init(args: &[String]) -> i32 {
|
||||
if args.first().is_some_and(|a| a == "--help") {
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(" dcr init", BOLD_CYAN);
|
||||
println!();
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Initializes the current directory as a DCR project.");
|
||||
println!(" The directory must be empty.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if !args.is_empty() {
|
||||
warn("Command does not support additional arguments");
|
||||
return 1;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
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::log::{error, warn};
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
||||
@@ -25,6 +25,16 @@ use std::io::Write;
|
||||
use toml::Value;
|
||||
|
||||
pub fn new(args: &[String]) -> i32 {
|
||||
if args.first().is_some_and(|a| a == "--help") {
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(" dcr new <name>", BOLD_CYAN);
|
||||
println!();
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Creates a new C/C++ project with the given name.");
|
||||
println!(" The name may only contain ASCII letters, digits, '_' and '-'.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
let items = check_dir(None).unwrap_or_default();
|
||||
|
||||
if args.is_empty() {
|
||||
|
||||
@@ -19,11 +19,11 @@ use crate::cli::build::build;
|
||||
use crate::cli::flags::parse_build_run_flags;
|
||||
use crate::core::config::Config;
|
||||
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::with_dir;
|
||||
use crate::utils::log::error;
|
||||
use crate::utils::text::{BOLD_GREEN, colored};
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
@@ -56,6 +56,26 @@ fn get_run_cmd(
|
||||
}
|
||||
|
||||
pub fn run(args: &[String]) -> i32 {
|
||||
if args.first().is_some_and(|a| a == "--help") {
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(
|
||||
" dcr run [--debug | --release] [--target <triple>] [--force] [--clean] [--verbose]",
|
||||
BOLD_CYAN,
|
||||
);
|
||||
println!();
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Builds and runs the project. Only available for kind = \"bin\".");
|
||||
println!();
|
||||
printc("OPTIONS:", BOLD_GREEN);
|
||||
println!(" --debug Run with debug profile (default)");
|
||||
println!(" --release Run with release profile");
|
||||
println!(" --target <triple> Cross-compile for the given target");
|
||||
println!(" --force Force a full rebuild");
|
||||
println!(" --clean Clean before building");
|
||||
println!(" --verbose Print detailed build output");
|
||||
return 0;
|
||||
}
|
||||
|
||||
let start_dir = match std::env::current_dir() {
|
||||
Ok(dir) => dir,
|
||||
Err(_) => {
|
||||
@@ -158,27 +178,7 @@ fn run_project(
|
||||
// If no target specified, use default host target for target-specific config
|
||||
let mut target = flags.target.clone();
|
||||
if target.is_none() {
|
||||
let default_target = 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()
|
||||
};
|
||||
target = Some(default_target);
|
||||
target = Some(default_target_triple());
|
||||
}
|
||||
|
||||
let build_kind = config
|
||||
|
||||
@@ -15,7 +15,19 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
pub fn setup(_args: &[String]) -> i32 {
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc};
|
||||
|
||||
pub fn setup(args: &[String]) -> i32 {
|
||||
if args.first().is_some_and(|a| a == "--help") {
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(" dcr setup", BOLD_CYAN);
|
||||
println!();
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Sets up DCR registries. Downloads and indexes");
|
||||
println!(" package registries for dependency resolution.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
println!("Setting up DCR registries...");
|
||||
match crate::core::registry::RegistryManager::load() {
|
||||
Ok(manager) => {
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::utils::build::{
|
||||
};
|
||||
use crate::utils::fs::{find_project_root, with_dir};
|
||||
use crate::utils::log::error;
|
||||
use crate::utils::text::{BOLD_GREEN, BOLD_RED, RESET, colored};
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, BOLD_RED, RESET, colored, printc};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
@@ -36,16 +36,16 @@ pub fn test(args: &[String]) -> i32 {
|
||||
let mut profile = "debug";
|
||||
for arg in args {
|
||||
if arg == "--help" {
|
||||
println!("USAGE:");
|
||||
println!(" dcr test [--init] [--debug | --release]");
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(" dcr test [--init] [--debug | --release]", BOLD_CYAN);
|
||||
println!();
|
||||
println!("ALIASES:");
|
||||
printc("ALIASES:", BOLD_GREEN);
|
||||
println!(" dcr tests");
|
||||
println!();
|
||||
println!("DESCRIPTION:");
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Runs project tests and prints a unified testsuite report.");
|
||||
println!();
|
||||
println!("OPTIONS:");
|
||||
printc("OPTIONS:", BOLD_GREEN);
|
||||
println!(" --init Create tests/dcr_test.h in current project");
|
||||
println!(" --debug Build and run tests with debug profile (default)");
|
||||
println!(" --release Build and run tests with release profile");
|
||||
|
||||
@@ -17,12 +17,21 @@
|
||||
|
||||
use crate::core::config::Config;
|
||||
use crate::utils::log::error;
|
||||
use crate::utils::text::{BOLD_CYAN, printc};
|
||||
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc};
|
||||
use std::collections::HashSet;
|
||||
use std::path::{Path, PathBuf};
|
||||
use toml::Value;
|
||||
|
||||
pub fn tree(_args: &[String]) -> i32 {
|
||||
pub fn tree(args: &[String]) -> i32 {
|
||||
if args.first().is_some_and(|a| a == "--help") {
|
||||
printc("USAGE:", BOLD_GREEN);
|
||||
printc(" dcr tree", BOLD_CYAN);
|
||||
println!();
|
||||
printc("DESCRIPTION:", BOLD_GREEN);
|
||||
println!(" Displays the dependency tree of the current project.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
let current_dir = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
|
||||
let config = match Config::open("dcr.toml") {
|
||||
Ok(c) => c,
|
||||
|
||||
@@ -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 {
|
||||
config
|
||||
.get(key)
|
||||
@@ -380,6 +427,61 @@ mod tests {
|
||||
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]
|
||||
fn parse_version_parts() {
|
||||
let info = parse_version_info("1.2.3-beta");
|
||||
|
||||
Reference in New Issue
Block a user