mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 23:09:36 +00:00
Compare commits
33 Commits
v0.6.8
...
478d1ad0c5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
478d1ad0c5 | ||
|
|
060b92111f | ||
|
|
86f0566dc2 | ||
|
|
768e2fc0dc | ||
|
|
619493bcbd | ||
|
|
1dac8661b6 | ||
|
|
80a6d574a3 | ||
|
|
daf465368f | ||
|
|
800fe38fba | ||
|
|
a7f9b79b93 | ||
|
|
b03660a9d7 | ||
|
|
2cb02aa102 | ||
|
|
06a8458ca7 | ||
| c2ef5483a0 | |||
| eb24d616c5 | |||
| 4f76f54b63 | |||
| 37b9b855ec | |||
| 8f0f67ad62 | |||
| 49945aa65d | |||
| 83593aa592 | |||
| 2835188da9 | |||
| 78160e2bb9 | |||
| 7f9cd3d643 | |||
| 4d1bd1dbdc | |||
| 7bc571ea27 | |||
| f431c3d018 | |||
| 9fd1652ebb | |||
| c59d6de54f | |||
| 73b6ce903e | |||
| e97b9b6e00 | |||
| 12d1bc5111 | |||
| 8c9dd39503 | |||
| e3c35793ec |
138
.github/workflows/aur.yml
vendored
138
.github/workflows/aur.yml
vendored
@@ -1,138 +0,0 @@
|
||||
name: AUR Publish
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "Tag version without v prefix (e.g. 0.2.2)"
|
||||
required: true
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
publish-aur:
|
||||
# Не публикуем dev/pre-release теги в AUR
|
||||
if: "!contains(github.ref_name, '-')"
|
||||
runs-on: ubuntu-latest
|
||||
environment: aur
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Derive version and checksum
|
||||
id: meta
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
|
||||
PKGVER="${{ inputs.version }}"
|
||||
else
|
||||
PKGVER="${GITHUB_REF_NAME#v}"
|
||||
fi
|
||||
SRC_URL="https://github.com/dexoron/dcr/archive/refs/tags/v${PKGVER}.tar.gz"
|
||||
SHA256="$(curl -fsSL "$SRC_URL" | sha256sum | awk '{print $1}')"
|
||||
|
||||
echo "pkgver=$PKGVER" >> "$GITHUB_OUTPUT"
|
||||
echo "source_url=$SRC_URL" >> "$GITHUB_OUTPUT"
|
||||
echo "sha256=$SHA256" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Render AUR metadata
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
PKGVER='${{ steps.meta.outputs.pkgver }}'
|
||||
SRC_URL='${{ steps.meta.outputs.source_url }}'
|
||||
SHA256='${{ steps.meta.outputs.sha256 }}'
|
||||
|
||||
cat > packaging/aur/dcr/PKGBUILD <<PKG
|
||||
pkgname=dcr
|
||||
pkgver=${PKGVER}
|
||||
pkgrel=1
|
||||
pkgdesc="Cargo-like utility to manage C/C++ projects"
|
||||
arch=('x86_64' 'aarch64')
|
||||
url="https://github.com/dexoron/dcr"
|
||||
license=('MIT')
|
||||
depends=('gcc-libs')
|
||||
makedepends=('cargo')
|
||||
options=('!lto')
|
||||
optdepends=(
|
||||
'gcc: build C/C++ projects with GCC'
|
||||
'clang: build C/C++ projects with Clang'
|
||||
)
|
||||
source=("\$pkgname-\$pkgver.tar.gz::\$url/archive/refs/tags/v\$pkgver.tar.gz")
|
||||
sha256sums=('${SHA256}')
|
||||
|
||||
build() {
|
||||
cd "\$srcdir/\$pkgname-\$pkgver"
|
||||
export CARGO_PROFILE_RELEASE_LTO=false
|
||||
export RUSTFLAGS="\${RUSTFLAGS:-}"
|
||||
export RUSTFLAGS="\${RUSTFLAGS/-C link-arg=-fuse-ld=lld/}"
|
||||
cargo build --release --locked
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "\$srcdir/\$pkgname-\$pkgver"
|
||||
install -Dm755 "target/release/dcr" "\$pkgdir/usr/bin/dcr"
|
||||
install -Dm644 LICENSE "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE"
|
||||
}
|
||||
PKG
|
||||
|
||||
cat > packaging/aur/dcr/.SRCINFO <<SRC
|
||||
pkgbase = dcr
|
||||
pkgdesc = Cargo-like utility to manage C/C++ projects
|
||||
pkgver = ${PKGVER}
|
||||
pkgrel = 1
|
||||
url = https://github.com/dexoron/dcr
|
||||
arch = x86_64
|
||||
arch = aarch64
|
||||
license = MIT
|
||||
makedepends = cargo
|
||||
depends = gcc-libs
|
||||
optdepends = gcc: build C/C++ projects with GCC
|
||||
optdepends = clang: build C/C++ projects with Clang
|
||||
options = !lto
|
||||
source = dcr-${PKGVER}.tar.gz::${SRC_URL}
|
||||
sha256sums = ${SHA256}
|
||||
|
||||
pkgname = dcr
|
||||
SRC
|
||||
|
||||
- name: Push to AUR
|
||||
env:
|
||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
AUR_PACKAGE: dcr
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z "${AUR_SSH_PRIVATE_KEY:-}" ]]; then
|
||||
echo "AUR_SSH_PRIVATE_KEY secret is missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install -d -m 700 ~/.ssh
|
||||
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur
|
||||
chmod 600 ~/.ssh/aur
|
||||
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
|
||||
|
||||
export GIT_SSH_COMMAND='ssh -i ~/.ssh/aur -o IdentitiesOnly=yes'
|
||||
git clone "ssh://aur@aur.archlinux.org/${AUR_PACKAGE}.git" aur-repo
|
||||
cp packaging/aur/dcr/PKGBUILD aur-repo/PKGBUILD
|
||||
cp packaging/aur/dcr/.SRCINFO aur-repo/.SRCINFO
|
||||
|
||||
cd aur-repo
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
if git diff --quiet; then
|
||||
echo "No AUR changes"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git add PKGBUILD .SRCINFO
|
||||
git commit -m "dcr ${{ steps.meta.outputs.pkgver }}"
|
||||
git push
|
||||
109
.github/workflows/dexoron-packages-index.yml
vendored
Normal file
109
.github/workflows/dexoron-packages-index.yml
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
name: Dexoron Packages Index
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Версия (тег) для ручного импорта пакетов (например, v0.6.9)"
|
||||
required: true
|
||||
type: string
|
||||
workflow_run:
|
||||
workflows: ["Release"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
update-packages-index:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event_name == 'workflow_dispatch' || github.event_workflow_run.conclusion == 'success' }}
|
||||
|
||||
steps:
|
||||
- name: Checkout Central Packages Repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: 'dexoron/packages'
|
||||
token: ${{ secrets.PACKAGES_REPO_TOKEN }}
|
||||
path: 'central-packages'
|
||||
|
||||
- name: Import GPG Key
|
||||
uses: crazy-max/ghaction-import-gpg@v6
|
||||
with:
|
||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
|
||||
# --- Загрузка артефактов (сохранена прежняя логика) ---
|
||||
- name: Download Artifacts
|
||||
if: ${{ github.event_name == 'workflow_run' }}
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: central-packages/
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ github.event.workflow_run.id }}
|
||||
|
||||
- name: Download Packages from Release Assets
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
TAG: ${{ inputs.tag }}
|
||||
run: |
|
||||
gh release download "$TAG" --repo dexoron/dcr --pattern "*.pkg.tar.zst" --dir central-packages/archlinux/x86_64/ --clobber
|
||||
gh release download "$TAG" --repo dexoron/dcr --pattern "*.deb" --dir central-packages/debian/ --clobber
|
||||
gh release download "$TAG" --repo dexoron/dcr --pattern "*.rpm" --dir central-packages/fedora/x86_64/ --clobber
|
||||
|
||||
# --- ИНДЕКСАЦИЯ И ПОДПИСЬ ---
|
||||
|
||||
- name: Update Pacman Database
|
||||
run: |
|
||||
docker run --rm \
|
||||
-v ${{ github.workspace }}/central-packages:/packages \
|
||||
-v ~/.gnupg:/root/.gnupg \
|
||||
archlinux:latest \
|
||||
bash -c '
|
||||
cd /packages/archlinux/x86_64 && \
|
||||
packages=(*.pkg.tar.zst) && \
|
||||
repo-add --sign dexoron.db.tar.gz "${packages[@]}" && \
|
||||
ln -sf dexoron.db.tar.gz dexoron.db && \
|
||||
ln -sf dexoron.files.tar.gz dexoron.files
|
||||
'
|
||||
- name: Fix GPG permissions after Docker
|
||||
run: sudo chown -R runner:runner ~/.gnupg
|
||||
|
||||
- name: Update Debian APT Repository Index
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y dpkg-dev
|
||||
cd central-packages/debian
|
||||
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
|
||||
|
||||
echo "Origin: Dexoron Packages" > Release
|
||||
echo "Label: Dexoron Packages" >> Release
|
||||
echo "Suite: stable" >> Release
|
||||
echo "Codename: stable" >> Release
|
||||
echo "Architectures: amd64" >> Release
|
||||
echo "Components: main" >> Release
|
||||
echo "Description: Dexoron binary package repository" >> Release
|
||||
echo "Date: $(date -uR)" >> Release
|
||||
echo "SHA256:" >> Release
|
||||
echo " $(sha256sum Packages.gz | awk '{print $1" "$2}')" >> Release
|
||||
|
||||
gpg --batch --yes --pinentry-mode loopback --local-user 74322D39483E9C9E8C86C0AA0770A5C2A2A82DAC --detach-sign --armor --output Release.gpg Release
|
||||
gpg --batch --yes --pinentry-mode loopback --local-user 74322D39483E9C9E8C86C0AA0770A5C2A2A82DAC --clearsign --output InRelease Release
|
||||
|
||||
- name: Update Fedora DNF Repository Index
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y createrepo-c
|
||||
cd central-packages/fedora/x86_64
|
||||
createrepo_c .
|
||||
gpg --batch --yes --detach-sign --armor --output repodata/repomd.xml.asc repodata/repomd.xml
|
||||
|
||||
- name: Push to dexoron/packages
|
||||
run: |
|
||||
cd central-packages
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add .
|
||||
if ! git diff --cached --quiet; then
|
||||
git commit -m "chore: update and sign repositories"
|
||||
git push
|
||||
fi
|
||||
488
.github/workflows/release.yml
vendored
488
.github/workflows/release.yml
vendored
@@ -13,6 +13,14 @@ on:
|
||||
description: "Build Linux"
|
||||
type: boolean
|
||||
default: true
|
||||
run_linux_packages:
|
||||
description: "Build Linux Packages (.deb, .rpm, .snap, .pkg.tar.zst)"
|
||||
type: boolean
|
||||
default: true
|
||||
run_aur:
|
||||
description: "Update AUR packages (dcr & dcr-bin)"
|
||||
type: boolean
|
||||
default: false
|
||||
run_bsd:
|
||||
description: "Build BSD"
|
||||
type: boolean
|
||||
@@ -92,10 +100,28 @@ jobs:
|
||||
name: release-notes
|
||||
path: .github/release-notes.md
|
||||
|
||||
# ── Linux ──────────────────────────────────────────────────────────────────
|
||||
# ── Create Release (prevent race conditions) ───────────────────────────────
|
||||
create-release:
|
||||
needs: [setup, notes]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download Release Notes
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: release-notes
|
||||
path: .github
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ needs.setup.outputs.tag }}
|
||||
body_path: .github/release-notes.md
|
||||
prerelease: ${{ needs.setup.outputs.prerelease == 'true' }}
|
||||
|
||||
# ── Linux Binaries Matrix ──────────────────────────────────────────────────
|
||||
build-linux:
|
||||
if: ${{ github.event_name == 'push' || github.event.inputs.run_linux == 'true' }}
|
||||
needs: [setup, notes]
|
||||
needs: [setup, notes, create-release]
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -121,6 +147,12 @@ jobs:
|
||||
pip install cargo-zigbuild
|
||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Setup Zig
|
||||
if: matrix.target != 'x86_64-unknown-linux-gnu'
|
||||
uses: mlugg/setup-zig@v1
|
||||
with:
|
||||
version: 0.13.0
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
@@ -148,10 +180,154 @@ jobs:
|
||||
body_path: .github/release-notes.md
|
||||
prerelease: ${{ needs.setup.outputs.prerelease == 'true' }}
|
||||
|
||||
# ── macOS ──────────────────────────────────────────────────────────────────
|
||||
# ── Linux Packages Matrix (.deb, .rpm, .pkg.tar.zst, .snap) ────────────────
|
||||
build-linux-packages:
|
||||
if: ${{ github.event_name == 'push' || github.event.inputs.run_linux_packages == 'true' }}
|
||||
needs: [setup, notes]
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- package_type: deb
|
||||
artifact_name: debian-package
|
||||
- package_type: rpm
|
||||
artifact_name: rpm-package
|
||||
- package_type: arch
|
||||
artifact_name: arch-package
|
||||
- package_type: snap
|
||||
artifact_name: snap-package
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.setup.outputs.tag }}
|
||||
|
||||
- name: Setup Rust (For non-container builds)
|
||||
if: matrix.package_type != 'arch'
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
# ── 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/
|
||||
|
||||
# ── 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/
|
||||
|
||||
# ── Snap Build ──
|
||||
- name: Build Snap Package
|
||||
if: matrix.package_type == 'snap'
|
||||
run: |
|
||||
cargo build --release
|
||||
mkdir -p packaging/snap/dist/bin
|
||||
cp target/release/dcr packaging/snap/dist/bin/
|
||||
|
||||
- name: Snapcraft Build Action
|
||||
if: matrix.package_type == 'snap'
|
||||
uses: snapcore/action-build@v1
|
||||
with:
|
||||
path: packaging/snap
|
||||
|
||||
- name: Prepare Snap Output
|
||||
if: matrix.package_type == 'snap'
|
||||
run: mkdir -p dist-packages && cp packaging/snap/*.snap dist-packages/
|
||||
|
||||
# ── Arch Linux Native Build ──
|
||||
- name: Build Arch Package inside Container
|
||||
if: matrix.package_type == 'arch'
|
||||
run: |
|
||||
PKGVER_ORIG='${{ needs.setup.outputs.version }}'
|
||||
PKGVER_CLEAN="${PKGVER_ORIG//-/.}"
|
||||
TAG='${{ needs.setup.outputs.tag }}'
|
||||
SRC_URL="https://github.com/dexoron/dcr/archive/refs/tags/${TAG}.tar.gz"
|
||||
SHA256="$(curl -fsSL "$SRC_URL" | sha256sum | awk '{print $1}')"
|
||||
mkdir -p arch-build
|
||||
cat > arch-build/PKGBUILD <<PKG
|
||||
pkgname=dcr
|
||||
pkgver=${PKGVER_CLEAN}
|
||||
pkgrel=1
|
||||
pkgdesc="Cargo-like utility to manage C/C++ projects"
|
||||
arch=('x86_64')
|
||||
url="https://github.com/dexoron/dcr"
|
||||
license=('GPL-3.0-or-later')
|
||||
depends=('gcc-libs')
|
||||
makedepends=('cargo')
|
||||
options=('!lto')
|
||||
source=("\$pkgname-\$pkgver.tar.gz::\$url/archive/refs/tags/${TAG}.tar.gz")
|
||||
sha256sums=('${SHA256}')
|
||||
build() {
|
||||
cd "\$srcdir/\$pkgname-${PKGVER_ORIG}"
|
||||
cargo build --release --locked
|
||||
}
|
||||
package() {
|
||||
cd "\$srcdir/\$pkgname-${PKGVER_ORIG}"
|
||||
install -Dm755 "target/release/dcr" "\$pkgdir/usr/bin/dcr"
|
||||
install -Dm644 LICENSE "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE"
|
||||
}
|
||||
PKG
|
||||
docker run --rm \
|
||||
-v ${{ github.workspace }}/arch-build:/build \
|
||||
archlinux:latest \
|
||||
bash -c "
|
||||
pacman -Syu --noconfirm base-devel cargo gcc-libs git && \
|
||||
useradd -m builduser && \
|
||||
echo 'builduser ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \
|
||||
chown -R builduser:builduser /build && \
|
||||
cd /build && \
|
||||
su builduser -c 'makepkg -s --noconfirm'
|
||||
"
|
||||
mkdir -p dist-packages && cp arch-build/*.pkg.tar.zst dist-packages/
|
||||
|
||||
# ── Upload Artifacts ──
|
||||
- name: Upload Package Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact_name }}
|
||||
path: dist-packages/*
|
||||
if-no-files-found: ignore
|
||||
|
||||
# ── Publish Packages to Release (Out of Matrix) ────────────────────────────
|
||||
publish-dexoron-packages:
|
||||
needs: [setup, notes, build-linux-packages, create-release]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download Release Notes
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: release-notes
|
||||
path: .github
|
||||
|
||||
- name: Download Built Packages
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: collected-packages
|
||||
|
||||
- name: Upload Everything to GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ needs.setup.outputs.tag }}
|
||||
files: |
|
||||
collected-packages/debian-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' }}
|
||||
|
||||
# ── macOS Matrix ───────────────────────────────────────────────────────────
|
||||
build-macos:
|
||||
if: ${{ github.event_name == 'push' || github.event.inputs.run_macos == 'true' }}
|
||||
needs: [setup, notes]
|
||||
needs: [setup, notes, create-release]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -194,17 +370,15 @@ jobs:
|
||||
body_path: .github/release-notes.md
|
||||
prerelease: ${{ needs.setup.outputs.prerelease == 'true' }}
|
||||
|
||||
# ── BSD ────────────────────────────────────────────────────────────────────
|
||||
# ── BSD Systems Matrix ─────────────────────────────────────────────────────
|
||||
build-bsd:
|
||||
if: ${{ github.event_name == 'push' || github.event.inputs.run_bsd == 'true' }}
|
||||
needs: [setup, notes]
|
||||
needs: [setup, notes, create-release]
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- target: x86_64-unknown-freebsd
|
||||
# При необходимости сюда можно докинуть x86_64-unknown-netbsd
|
||||
system: [freebsd, openbsd, netbsd]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -216,37 +390,77 @@ jobs:
|
||||
name: release-notes
|
||||
path: .github
|
||||
|
||||
- name: Install cargo-zigbuild
|
||||
run: |
|
||||
pip install cargo-zigbuild
|
||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
# --- FREEBSD ---
|
||||
- name: Build in FreeBSD VM
|
||||
if: matrix.system == 'freebsd'
|
||||
uses: vmactions/freebsd-vm@v1
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
usesh: true
|
||||
run: |
|
||||
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
|
||||
pkg install -y rust perl5 gmake
|
||||
cargo build --release
|
||||
|
||||
- name: Build
|
||||
run: cargo zigbuild --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Prepare Artifact
|
||||
- name: Prepare FreeBSD Artifact
|
||||
if: matrix.system == 'freebsd'
|
||||
run: |
|
||||
ASSET="dcr-${{ matrix.target }}-${{ needs.setup.outputs.version }}"
|
||||
cp target/${{ matrix.target }}/release/dcr "$ASSET"
|
||||
echo "ASSET_NAME=${ASSET}" >> "$GITHUB_ENV"
|
||||
ASSET="dcr-x86_64-unknown-freebsd-${{ needs.setup.outputs.version }}"
|
||||
cp target/release/dcr "$ASSET"
|
||||
echo "BSD_ASSET=${ASSET}" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Upload Release Asset
|
||||
# --- OPENBSD ---
|
||||
- name: Build in OpenBSD VM
|
||||
if: matrix.system == 'openbsd'
|
||||
uses: vmactions/openbsd-vm@v1
|
||||
with:
|
||||
usesh: true
|
||||
run: |
|
||||
export PATH="/usr/local/bin:$PATH"
|
||||
pkg_add rust perl gmake
|
||||
cargo build --release
|
||||
|
||||
- name: Prepare OpenBSD Artifact
|
||||
if: matrix.system == 'openbsd'
|
||||
run: |
|
||||
ASSET="dcr-x86_64-unknown-openbsd-${{ needs.setup.outputs.version }}"
|
||||
cp target/release/dcr "$ASSET"
|
||||
echo "BSD_ASSET=${ASSET}" >> "$GITHUB_ENV"
|
||||
|
||||
# --- NETBSD ---
|
||||
- name: Build in NetBSD VM
|
||||
if: matrix.system == 'netbsd'
|
||||
uses: vmactions/netbsd-vm@v1
|
||||
with:
|
||||
usesh: true
|
||||
run: |
|
||||
pkg_add rust perl gmake
|
||||
mkdir -p /tmp/bin
|
||||
ln -sf /usr/pkg/bin/gmake /tmp/bin/make
|
||||
export PATH="/tmp/bin:/usr/pkg/bin:/usr/pkg/sbin:$PATH"
|
||||
cargo build --release
|
||||
|
||||
- name: Prepare NetBSD Artifact
|
||||
if: matrix.system == 'netbsd'
|
||||
run: |
|
||||
ASSET="dcr-x86_64-unknown-netbsd-${{ needs.setup.outputs.version }}"
|
||||
cp target/release/dcr "$ASSET"
|
||||
echo "BSD_ASSET=${ASSET}" >> "$GITHUB_ENV"
|
||||
|
||||
|
||||
|
||||
# --- UPLOAD TARGET ---
|
||||
- name: Upload BSD Asset to Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ needs.setup.outputs.tag }}
|
||||
files: ${{ env.ASSET_NAME }}
|
||||
files: ${{ env.BSD_ASSET }}
|
||||
body_path: .github/release-notes.md
|
||||
prerelease: ${{ needs.setup.outputs.prerelease == 'true' }}
|
||||
|
||||
# ── Windows ────────────────────────────────────────────────────────────────
|
||||
# ── Windows Matrix ─────────────────────────────────────────────────────────
|
||||
build-windows:
|
||||
if: ${{ github.event_name == 'push' || github.event.inputs.run_windows == 'true' }}
|
||||
needs: [setup, notes]
|
||||
needs: [setup, notes, create-release]
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -288,6 +502,219 @@ jobs:
|
||||
files: ${{ env.ASSET_NAME }}
|
||||
body_path: .github/release-notes.md
|
||||
prerelease: ${{ needs.setup.outputs.prerelease == 'true' }}
|
||||
|
||||
# ── Arch User Repository (dcr) ───────────────────────────────────
|
||||
publish-aur:
|
||||
if: ${{ (github.event_name == 'push' && needs.setup.outputs.prerelease == 'false') || github.event.inputs.run_aur == 'true' }}
|
||||
needs: [setup]
|
||||
runs-on: ubuntu-latest
|
||||
environment: aur
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Derive checksum
|
||||
id: meta
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
SRC_URL="https://github.com/dexoron/dcr/archive/refs/tags/${{ needs.setup.outputs.tag }}.tar.gz"
|
||||
SHA256="$(curl -fsSL "$SRC_URL" | sha256sum | awk '{print $1}')"
|
||||
echo "source_url=$SRC_URL" >> "$GITHUB_OUTPUT"
|
||||
echo "sha256=$SHA256" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Render AUR metadata
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
PKGVER_ORIG='${{ needs.setup.outputs.version }}'
|
||||
PKGVER_CLEAN="${PKGVER_ORIG//-/.}"
|
||||
SRC_URL='${{ steps.meta.outputs.source_url }}'
|
||||
SHA256='${{ steps.meta.outputs.sha256 }}'
|
||||
|
||||
mkdir -p packages/aur/dcr
|
||||
cat > packages/aur/dcr/PKGBUILD <<PKG
|
||||
pkgname=dcr
|
||||
pkgver=${PKGVER_CLEAN}
|
||||
pkgrel=1
|
||||
pkgdesc="Cargo-like utility to manage C/C++ projects"
|
||||
arch=('x86_64' 'aarch64')
|
||||
url="https://github.com/dexoron/dcr"
|
||||
license=('GPL-3.0-or-later')
|
||||
depends=('gcc-libs')
|
||||
makedepends=('cargo')
|
||||
options=('!lto')
|
||||
optdepends=(
|
||||
'gcc: build C/C++ projects with GCC'
|
||||
'clang: build C/C++ projects with Clang'
|
||||
)
|
||||
source=("\$pkgname-\$pkgver.tar.gz::\${SRC_URL}")
|
||||
sha256sums=('${SHA256}')
|
||||
|
||||
build() {
|
||||
cd "\$srcdir/\$pkgname-${PKGVER_ORIG}"
|
||||
export CARGO_PROFILE_RELEASE_LTO=false
|
||||
export RUSTFLAGS="\${RUSTFLAGS:-}"
|
||||
export RUSTFLAGS="\${RUSTFLAGS/-C link-arg=-fuse-ld=lld/}"
|
||||
cargo build --release --locked
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "\$srcdir/\$pkgname-${PKGVER_ORIG}"
|
||||
install -Dm755 "target/release/dcr" "\$pkgdir/usr/bin/dcr"
|
||||
install -Dm644 LICENSE "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE"
|
||||
}
|
||||
PKG
|
||||
|
||||
cat > packages/aur/dcr/.SRCINFO <<SRC
|
||||
pkgbase = dcr
|
||||
pkgdesc = Cargo-like utility to manage C/C++ projects
|
||||
pkgver = ${PKGVER_CLEAN}
|
||||
pkgrel = 1
|
||||
url = https://github.com/dexoron/dcr
|
||||
arch = x86_64
|
||||
arch = aarch64
|
||||
license = GPL-3.0-or-later
|
||||
makedepends = cargo
|
||||
depends = gcc-libs
|
||||
optdepends = gcc: build C/C++ projects with GCC
|
||||
optdepends = clang: build C/C++ projects with Clang
|
||||
options = !lto
|
||||
source = dcr-${PKGVER_CLEAN}.tar.gz::${SRC_URL}
|
||||
sha256sums = ${SHA256}
|
||||
|
||||
pkgname = dcr
|
||||
SRC
|
||||
|
||||
- name: Push to AUR
|
||||
env:
|
||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
AUR_PACKAGE: dcr
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
install -d -m 700 ~/.ssh
|
||||
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur
|
||||
chmod 600 ~/.ssh/aur
|
||||
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
|
||||
|
||||
export GIT_SSH_COMMAND='ssh -i ~/.ssh/aur -o IdentitiesOnly=yes'
|
||||
git clone "ssh://aur@aur.archlinux.org/${AUR_PACKAGE}.git" aur-repo
|
||||
cp packages/aur/dcr/PKGBUILD aur-repo/PKGBUILD
|
||||
cp packages/aur/dcr/.SRCINFO aur-repo/.SRCINFO
|
||||
|
||||
cd aur-repo
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
if git diff --quiet; then
|
||||
echo "No AUR changes"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git add PKGBUILD .SRCINFO
|
||||
git commit -m "dcr ${{ needs.setup.outputs.version }}"
|
||||
git push
|
||||
|
||||
# ── Arch User Repository (dcr-bin) ────────────────────────────────
|
||||
publish-aur-bin:
|
||||
if: ${{ (github.event_name == 'push' && needs.setup.outputs.prerelease == 'false') || github.event.inputs.run_aur == 'true' }}
|
||||
needs: [setup, build-linux]
|
||||
runs-on: ubuntu-latest
|
||||
environment: aur
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Derive checksum
|
||||
id: meta
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
BIN_URL="https://github.com/dexoron/dcr/releases/download/${{ needs.setup.outputs.tag }}/dcr-x86_64-unknown-linux-musl-${{ needs.setup.outputs.version }}"
|
||||
SHA256="$(curl -fsSL "$BIN_URL" | sha256sum | awk '{print $1}')"
|
||||
echo "bin_url=$BIN_URL" >> "$GITHUB_OUTPUT"
|
||||
echo "sha256=$SHA256" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Render AUR Metadata
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
PKGVER_ORIG='${{ needs.setup.outputs.version }}'
|
||||
PKGVER_CLEAN="${PKGVER_ORIG//-/.}"
|
||||
BIN_URL='${{ steps.meta.outputs.bin_url }}'
|
||||
SHA256='${{ steps.meta.outputs.sha256 }}'
|
||||
|
||||
mkdir -p packages/aur/dcr-bin
|
||||
cat > packages/aur/dcr-bin/PKGBUILD <<PKG
|
||||
pkgname=dcr-bin
|
||||
pkgver=${PKGVER_CLEAN}
|
||||
pkgrel=1
|
||||
pkgdesc="Cargo-like utility to manage C/C++ projects (pre-compiled musl binary)"
|
||||
arch=('x86_64')
|
||||
url="https://github.com/dexoron/dcr"
|
||||
license=('GPL-3.0-or-later')
|
||||
provides=('dcr')
|
||||
conflicts=('dcr')
|
||||
optdepends=(
|
||||
'gcc: build C/C++ projects with GCC'
|
||||
'clang: build C/C++ projects with Clang'
|
||||
)
|
||||
source_x86_64=("dcr-\$pkgver::${BIN_URL}")
|
||||
sha256sums_x86_64=('${SHA256}')
|
||||
|
||||
package() {
|
||||
install -Dm755 "\$srcdir/dcr-\$pkgver" "\$pkgdir/usr/bin/dcr"
|
||||
}
|
||||
PKG
|
||||
|
||||
cat > packages/aur/dcr-bin/.SRCINFO <<SRC
|
||||
pkgbase = dcr-bin
|
||||
pkgdesc = Cargo-like utility to manage C/C++ projects (pre-compiled musl binary)
|
||||
pkgver = ${PKGVER_CLEAN}
|
||||
pkgrel = 1
|
||||
url = https://github.com/dexoron/dcr
|
||||
arch = x86_64
|
||||
license = GPL-3.0-or-later
|
||||
provides = dcr
|
||||
conflicts = dcr
|
||||
optdepends = gcc: build C/C++ projects with GCC
|
||||
optdepends = clang: build C/C++ projects with Clang
|
||||
source_x86_64 = dcr-${PKGVER_CLEAN}::${BIN_URL}
|
||||
sha256sums_x86_64 = ${SHA256}
|
||||
|
||||
pkgname = dcr-bin
|
||||
SRC
|
||||
|
||||
- name: Push to AUR
|
||||
env:
|
||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
AUR_PACKAGE: dcr-bin
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
install -d -m 700 ~/.ssh
|
||||
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur
|
||||
chmod 600 ~/.ssh/aur
|
||||
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
|
||||
|
||||
export GIT_SSH_COMMAND='ssh -i ~/.ssh/aur -o IdentitiesOnly=yes'
|
||||
git clone "ssh://aur@aur.archlinux.org/${AUR_PACKAGE}.git" aur-repo
|
||||
cp packages/aur/dcr-bin/PKGBUILD aur-repo/PKGBUILD
|
||||
cp packages/aur/dcr-bin/.SRCINFO aur-repo/.SRCINFO
|
||||
|
||||
cd aur-repo
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
if git diff --quiet; then
|
||||
echo "No AUR changes"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git add PKGBUILD .SRCINFO
|
||||
git commit -m "dcr-bin ${{ needs.setup.outputs.version }}"
|
||||
git push
|
||||
|
||||
# ── crates.io ──────────────────────────────────────────────────────────────
|
||||
publish-crates:
|
||||
@@ -296,6 +723,9 @@ jobs:
|
||||
(github.event_name == 'workflow_dispatch' && github.event.inputs.run_publish == 'true')
|
||||
needs: [setup, build-linux, build-macos, build-windows, build-bsd]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -304,7 +734,7 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Publish to crates.io
|
||||
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||
run: cargo publish
|
||||
|
||||
# ── Homebrew tap ───────────────────────────────────────────────────────────
|
||||
publish-brew:
|
||||
|
||||
53
CHANGELOG.md
53
CHANGELOG.md
@@ -1,5 +1,58 @@
|
||||
# Changelog
|
||||
|
||||
## [0.7.0] - 2026-05-28
|
||||
|
||||
Added:
|
||||
|
||||
- **FreeBSD, OpenBSD, NetBSD, DragonflyBSD target support** — full platform routing and dynamically generated target triples.
|
||||
|
||||
## [0.6.9] - 2026-05-28
|
||||
|
||||
Added:
|
||||
|
||||
- **Dexoron Packages Index** — new standalone CI workflow (`.github/workflows/dexoron-packages-index.yml`)
|
||||
that automatically updates the `dexoron/packages` repository indexes after a release.
|
||||
Supports Arch Linux (`repo-add`), Debian (`dpkg-scanpackages`), and Fedora (`createrepo_c`).
|
||||
Triggered by `workflow_dispatch` or `workflow_run` on the Release workflow.
|
||||
|
||||
- **Arch Linux native package** (`.pkg.tar.zst`) build inside the release workflow —
|
||||
builds from source in an `archlinux:latest` Docker container using a dynamically
|
||||
generated PKGBUILD.
|
||||
|
||||
- **AUR publish support** — new `run_aur` workflow dispatch input and `publish-aur` /
|
||||
`publish-aur-bin` jobs that push PKGBUILD / `.SRCINFO` to `aur.archlinux.org`.
|
||||
|
||||
Changed:
|
||||
|
||||
- **Release workflow refactored** — Linux packages (deb, rpm, snap, arch) and BSD
|
||||
builds now use `strategy.matrix` instead of separate jobs. A new
|
||||
`publish-dexoron-packages` job collects all package artifacts and uploads them
|
||||
to the GitHub Release in one step. Removed standalone `build-arch-package`,
|
||||
`build-snap`, `build-deb-rpm` jobs. The old `run_arch_native` input is now
|
||||
`run_linux_packages`.
|
||||
|
||||
- **Dexoron Packages Index workflow** extracted from `release.yml` into its own
|
||||
file with support for Debian and RPM repository indexes in addition to Arch.
|
||||
|
||||
- **git2 vendoring** — enabled `vendored-libgit2` and `vendored-openssl` features
|
||||
for reproducible CI builds without system libraries.
|
||||
|
||||
- **cargo-generate-rpm metadata** — updated to the current `package.metadata.rpm`
|
||||
format (uses `files` table instead of `assets` array).
|
||||
|
||||
Fixed:
|
||||
|
||||
- **`--target=<triple>` no longer passed to GCC** — the flag is now only injected into
|
||||
cflags when the resolved compiler name contains `"clang"`. GCC rejects this flag
|
||||
with `unrecognized command-line option`.
|
||||
|
||||
- **Workspace clean test** — removed assertions for member-local `target/`
|
||||
directories. Workspace members share the root `target/` directory, so their
|
||||
individual `src/<name>/target/` is never created.
|
||||
|
||||
- **Release build test path** — corrected expected directory from `target/release`
|
||||
to `target/x86_64-unknown-linux-gnu/release`.
|
||||
|
||||
## [0.6.8] - 2026-05-27
|
||||
|
||||
Added:
|
||||
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -112,7 +112,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dcr"
|
||||
version = "0.6.8"
|
||||
version = "0.7.0"
|
||||
dependencies = [
|
||||
"ctrlc",
|
||||
"git2",
|
||||
|
||||
33
Cargo.toml
33
Cargo.toml
@@ -1,12 +1,38 @@
|
||||
[package]
|
||||
name = "dcr"
|
||||
version = "0.6.8"
|
||||
version = "0.7.0"
|
||||
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"
|
||||
|
||||
[package.metadata.binstall]
|
||||
pkg-fmt = "bin"
|
||||
pkg-url = "{ repo }/releases/download/v{ version }/dcr-{ target }-{ version }{ bin-suffix }"
|
||||
|
||||
[package.metadata.deb]
|
||||
maintainer = "Dexoron (Bezotechestvo Vladimir) <main@dexoron.su>"
|
||||
copyright = "2026, Dexoron"
|
||||
extended-description = """
|
||||
Cargo-like utility to manage C/C++ projects.
|
||||
"""
|
||||
section = "devel"
|
||||
priority = "optional"
|
||||
assets = [
|
||||
["target/release/dcr", "usr/bin/dcr", "755"],
|
||||
]
|
||||
|
||||
[package.metadata.generate-rpm]
|
||||
summary = "Cargo-like utility to manage C/C++ projects"
|
||||
description = """
|
||||
Cargo-like utility to manage C/C++ projects.
|
||||
"""
|
||||
|
||||
assets = [
|
||||
{ source = "target/release/dcr", dest = "/usr/bin/dcr", mode = "755" }
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
glob = "0.3"
|
||||
reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"] }
|
||||
@@ -14,9 +40,12 @@ serde = { version = "1", features = ["derive"] }
|
||||
self-replace = "1"
|
||||
sha2 = "0.10"
|
||||
toml = "1.0.3"
|
||||
git2 = "0.20.4"
|
||||
serde_json = "1"
|
||||
ctrlc = "3"
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
git2 = { version = "0.20.4", features = ["vendored-libgit2", "vendored-openssl"] }
|
||||
openssl = { version = "0.10", features = ["vendored"] }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
git2 = { version = "0.20.4", features = ["vendored-libgit2"] }
|
||||
16
README.md
16
README.md
@@ -71,6 +71,16 @@ cargo install dcr
|
||||
curl -fsSL https://dcr.dexoron.su/install.sh | bash
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>BSD (script)</b></td>
|
||||
<td>
|
||||
|
||||
```sh
|
||||
curl -fsSL https://raw.githubusercontent.com/dexoron/dcr/dev/install_bsd.sh | bash
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -159,9 +169,9 @@ other in [docs/](docs/) and `dcr --help`
|
||||
| Linux | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ |
|
||||
| macOS | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
| Windows | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
|
||||
| FreeBSD | ⚠️ | ⚠️ | ❌ | ❌ | ❌ | ⚠️ | ❌ | ❌ | ❌ |
|
||||
| OpenBSD | ⚠️ | ⚠️ | ❌ | ❌ | ❌ | ⚠️ | ❌ | ❌ | ❌ |
|
||||
| NetBSD | ⚠️ | ⚠️ | ❌ | ❌ | ❌ | ⚠️ | ❌ | ❌ | ❌ |
|
||||
| FreeBSD | ✅ | ⚠️ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
||||
| OpenBSD | ✅ | ⚠️ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
||||
| NetBSD | ✅ | ⚠️ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
||||
|
||||
✅ officially supported · ⚠️ community / best-effort · ❌ not supported
|
||||
|
||||
|
||||
44
install.sh
44
install.sh
@@ -30,8 +30,8 @@ CHANNEL=""
|
||||
|
||||
check_os() {
|
||||
case "$(uname -s)" in
|
||||
Linux|Darwin) ;;
|
||||
*) error "Only Linux and macOS are supported"; exit 1 ;;
|
||||
Linux|Darwin|FreeBSD|OpenBSD|NetBSD) ;;
|
||||
*) error "Only Linux, macOS, and BSD systems are supported"; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
@@ -41,15 +41,26 @@ detect_target() {
|
||||
arch="$(uname -m)"
|
||||
|
||||
case "$os:$arch" in
|
||||
Linux:x86_64) TARGET_TRIPLE="x86_64-unknown-linux-gnu" ;;
|
||||
Darwin:x86_64) TARGET_TRIPLE="x86_64-apple-darwin" ;;
|
||||
Darwin:arm64|Darwin:aarch64) TARGET_TRIPLE="aarch64-apple-darwin" ;;
|
||||
Linux:x86_64) TARGET_TRIPLE="x86_64-unknown-linux-gnu" ;;
|
||||
Linux:aarch64|Linux:arm64) TARGET_TRIPLE="aarch64-unknown-linux-gnu" ;;
|
||||
Darwin:x86_64) TARGET_TRIPLE="x86_64-apple-darwin" ;;
|
||||
Darwin:arm64|Darwin:aarch64) TARGET_TRIPLE="aarch64-apple-darwin" ;;
|
||||
FreeBSD:x86_64|FreeBSD:amd64) TARGET_TRIPLE="x86_64-unknown-freebsd" ;;
|
||||
OpenBSD:x86_64|OpenBSD:amd64) TARGET_TRIPLE="x86_64-unknown-openbsd" ;;
|
||||
NetBSD:x86_64|NetBSD:amd64) TARGET_TRIPLE="x86_64-unknown-netbsd" ;;
|
||||
|
||||
*) error "Unsupported platform: $os/$arch"; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_common_dependencies() {
|
||||
command -v curl >/dev/null 2>&1 || { error "curl is not installed"; exit 1; }
|
||||
if [[ "$CHANNEL" == "dev" ]]; then
|
||||
if ! command -v python3 >/dev/null 2>&1 && ! command -v jq >/dev/null 2>&1; then
|
||||
error "For dev installations, either 'python3' or 'jq' must be installed to parse GitHub API response."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check_build_dependencies() {
|
||||
@@ -83,15 +94,16 @@ select_install_mode() {
|
||||
esac
|
||||
}
|
||||
|
||||
# Возвращает JSON нужного релиза в stdout
|
||||
# Returns JSON of the requested release to stdout
|
||||
fetch_release_json() {
|
||||
if [[ "$CHANNEL" == "dev" ]]; then
|
||||
log "Looking for latest dev (pre-release)..."
|
||||
local json
|
||||
local json result
|
||||
json="$(curl -fsSL "$GITHUB_API_ALL")"
|
||||
# Первый pre-release в списке
|
||||
local result
|
||||
result="$(printf '%s' "$json" | python3 - <<'EOF'
|
||||
if command -v jq >/dev/null 2>&1; then
|
||||
result="$(printf '%s' "$json" | jq -e -c 'map(select(.prerelease == true))[0]')"
|
||||
else
|
||||
result="$(printf '%s' "$json" | python3 - <<'EOF'
|
||||
import sys, json
|
||||
releases = json.load(sys.stdin)
|
||||
pre = [r for r in releases if r.get("prerelease", False)]
|
||||
@@ -101,7 +113,9 @@ else:
|
||||
print(json.dumps(pre[0]), end="")
|
||||
EOF
|
||||
)"
|
||||
if [[ -z "$result" || "$result" == "{}" ]]; then
|
||||
fi
|
||||
|
||||
if [[ -z "$result" || "$result" == "{}" || "$result" == "null" ]]; then
|
||||
error "No dev (pre-release) found on GitHub"
|
||||
exit 1
|
||||
fi
|
||||
@@ -123,9 +137,9 @@ download_binary() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Версия без ведущего 'v'
|
||||
# Version without leading 'v'
|
||||
version="${tag#v}"
|
||||
# Имя бинарника: dcr-<triple>-<version>
|
||||
# Binary name: dcr-<triple>-<version>
|
||||
asset_name="dcr-${TARGET_TRIPLE}-${version}"
|
||||
|
||||
log "Fetching release ${tag} (channel: ${CHANNEL})..."
|
||||
@@ -149,7 +163,7 @@ prepare_sources() {
|
||||
rm -rf "$TMPDIR"
|
||||
git clone --depth 1 "$REPO_URL" "$TMPDIR"
|
||||
if [[ "$CHANNEL" == "dev" ]]; then
|
||||
# Клонируем dev ветку, если она есть
|
||||
# Clone dev branch if it exists
|
||||
git clone --depth 1 --branch dev "$REPO_URL" "$TMPDIR" 2>/dev/null || \
|
||||
git clone --depth 1 "$REPO_URL" "$TMPDIR"
|
||||
fi
|
||||
@@ -193,8 +207,8 @@ main() {
|
||||
|
||||
check_os
|
||||
detect_target
|
||||
check_common_dependencies
|
||||
select_channel
|
||||
check_common_dependencies
|
||||
select_install_mode
|
||||
cleanup
|
||||
|
||||
|
||||
223
install_bsd.sh
Executable file
223
install_bsd.sh
Executable file
@@ -0,0 +1,223 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
TMPDIR="/tmp/dcr-install"
|
||||
INSTALL_PATH="$HOME/.local/share/dcr"
|
||||
BINPATH="$HOME/.local/bin"
|
||||
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"
|
||||
GITHUB_API_ALL="https://api.github.com/repos/dexoron/dcr/releases"
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
mkdir -p "$(dirname "$LOGFILE")"
|
||||
|
||||
log() { printf "${BLUE}[%s]${NC} %s\n" "$(date '+%Y-%m-%d %H:%M:%S')" "$1" | tee -a "$LOGFILE"; }
|
||||
success() { printf "${GREEN}✔ %s${NC}\n" "$1" | tee -a "$LOGFILE"; }
|
||||
warn() { printf "${YELLOW}⚠ %s${NC}\n" "$1" | tee -a "$LOGFILE"; }
|
||||
error() { printf "${RED}✖ %s${NC}\n" "$1" | tee -a "$LOGFILE" >&2; }
|
||||
|
||||
INSTALL_MODE=""
|
||||
CHANNEL=""
|
||||
|
||||
check_os() {
|
||||
case "$(uname -s)" in
|
||||
FreeBSD|OpenBSD|NetBSD|DragonFly) ;;
|
||||
*) error "Only BSD systems (FreeBSD, OpenBSD, NetBSD, DragonFly) are supported by this script"; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
detect_target() {
|
||||
local os arch
|
||||
os="$(uname -s)"
|
||||
arch="$(uname -m)"
|
||||
|
||||
case "$os:$arch" in
|
||||
FreeBSD:x86_64|FreeBSD:amd64) TARGET_TRIPLE="x86_64-unknown-freebsd" ;;
|
||||
OpenBSD:x86_64|OpenBSD:amd64) TARGET_TRIPLE="x86_64-unknown-openbsd" ;;
|
||||
NetBSD:x86_64|NetBSD:amd64) TARGET_TRIPLE="x86_64-unknown-netbsd" ;;
|
||||
DragonFly:x86_64|DragonFly:amd64) TARGET_TRIPLE="x86_64-unknown-dragonfly" ;;
|
||||
*) error "Unsupported BSD platform: $os/$arch"; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_common_dependencies() {
|
||||
command -v curl >/dev/null 2>&1 || { error "curl is not installed"; exit 1; }
|
||||
if [ "$CHANNEL" = "dev" ]; then
|
||||
if ! command -v python3 >/dev/null 2>&1 && ! command -v jq >/dev/null 2>&1; then
|
||||
error "For dev installations, either 'python3' or 'jq' must be installed to parse GitHub API response."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
check_build_dependencies() {
|
||||
command -v git >/dev/null 2>&1 || { error "git is not installed"; exit 1; }
|
||||
command -v cargo >/dev/null 2>&1 || { error "cargo is not installed"; exit 1; }
|
||||
}
|
||||
|
||||
select_channel() {
|
||||
echo "Choose channel:"
|
||||
echo " 1) Latest stable release (default)"
|
||||
echo " 2) Latest dev (pre-release)"
|
||||
printf "Enter 1 or 2 [1]: "
|
||||
read -r choice
|
||||
|
||||
case "${choice:-1}" in
|
||||
1) CHANNEL="stable" ;;
|
||||
2) CHANNEL="dev" ;;
|
||||
*) error "Unknown option"; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
select_install_mode() {
|
||||
echo "Choose installation mode:"
|
||||
echo " 1) Download prebuilt binary from GitHub Release (recommended)"
|
||||
echo " 2) Build from git"
|
||||
printf "Enter 1 or 2 [1]: "
|
||||
read -r choice
|
||||
|
||||
case "${choice:-1}" in
|
||||
1) INSTALL_MODE="release" ;;
|
||||
2) INSTALL_MODE="build" ;;
|
||||
*) error "Unknown option"; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
fetch_release_json() {
|
||||
if [ "$CHANNEL" = "dev" ]; then
|
||||
log "Looking for latest dev (pre-release)..."
|
||||
local json result
|
||||
json="$(curl -fsSL "$GITHUB_API_ALL")"
|
||||
if command -v jq >/dev/null 2>&1; then
|
||||
result="$(printf '%s' "$json" | jq -e -c 'map(select(.prerelease == true))[0]')"
|
||||
else
|
||||
result="$(printf '%s' "$json" | python3 - <<'EOF'
|
||||
import sys, json
|
||||
releases = json.load(sys.stdin)
|
||||
pre = [r for r in releases if r.get("prerelease", False)]
|
||||
if not pre:
|
||||
print("{}", end="")
|
||||
else:
|
||||
print(json.dumps(pre[0]), end="")
|
||||
EOF
|
||||
)"
|
||||
fi
|
||||
|
||||
if [ -z "$result" ] || [ "$result" = "{}" ] || [ "$result" = "null" ]; then
|
||||
error "No dev (pre-release) found on GitHub"
|
||||
exit 1
|
||||
fi
|
||||
printf '%s' "$result"
|
||||
else
|
||||
curl -fsSL "$GITHUB_API_LATEST"
|
||||
fi
|
||||
}
|
||||
|
||||
download_binary() {
|
||||
local release_json tag version asset_name download_url
|
||||
|
||||
release_json="$(fetch_release_json)"
|
||||
|
||||
tag="$(printf '%s\n' "$release_json" | \
|
||||
sed -n 's/.*"tag_name": "\([^"]*\)".*/\1/p' | head -n1)"
|
||||
if [ -z "$tag" ]; then
|
||||
error "Failed to determine release version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version="${tag#v}"
|
||||
asset_name="dcr-${TARGET_TRIPLE}-${version}"
|
||||
|
||||
log "Fetching release ${tag} (channel: ${CHANNEL})..."
|
||||
|
||||
download_url="$(printf '%s\n' "$release_json" | \
|
||||
sed -n "s#.*\"browser_download_url\": \"\([^\"]*/${asset_name}\)\".*#\1#p" | head -n1)"
|
||||
|
||||
if [ -z "$download_url" ]; then
|
||||
error "Asset ${asset_name} not found in release ${tag}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$INSTALL_PATH"
|
||||
curl -fL "$download_url" -o "$INSTALL_PATH/dcr"
|
||||
chmod +x "$INSTALL_PATH/dcr"
|
||||
success "Binary ${asset_name} downloaded (${tag})"
|
||||
}
|
||||
|
||||
prepare_sources() {
|
||||
log "Fetching sources..."
|
||||
rm -rf "$TMPDIR"
|
||||
git clone --depth 1 "$REPO_URL" "$TMPDIR"
|
||||
if [ "$CHANNEL" = "dev" ]; then
|
||||
git clone --depth 1 --branch dev "$REPO_URL" "$TMPDIR" 2>/dev/null || \
|
||||
git clone --depth 1 "$REPO_URL" "$TMPDIR"
|
||||
fi
|
||||
success "Sources fetched"
|
||||
}
|
||||
|
||||
build_binary() {
|
||||
log "Building release binary..."
|
||||
(cd "$TMPDIR" && cargo build --release)
|
||||
success "Build completed"
|
||||
}
|
||||
|
||||
install_built_binary() {
|
||||
mkdir -p "$INSTALL_PATH"
|
||||
cp "$TMPDIR/target/release/dcr" "$INSTALL_PATH/dcr"
|
||||
chmod +x "$INSTALL_PATH/dcr"
|
||||
success "Binary installed from source"
|
||||
}
|
||||
|
||||
install_link() {
|
||||
log "Creating symlink..."
|
||||
mkdir -p "$BINPATH"
|
||||
ln -sf "$INSTALL_PATH/dcr" "$BINPATH/dcr"
|
||||
success "Command 'dcr' added to $BINPATH"
|
||||
}
|
||||
|
||||
check_path() {
|
||||
if ! echo "$PATH" | grep -q "$BINPATH"; then
|
||||
warn "Directory $BINPATH not found in PATH"
|
||||
echo "Add this to ~/.bashrc, ~/.zshrc or ~/.profile:"
|
||||
echo "export PATH=\"$BINPATH:\$PATH\""
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$TMPDIR" 2>/dev/null || true
|
||||
}
|
||||
|
||||
main() {
|
||||
log "Starting DCR installation for BSD"
|
||||
|
||||
check_os
|
||||
select_channel
|
||||
check_common_dependencies
|
||||
detect_target
|
||||
select_install_mode
|
||||
cleanup
|
||||
|
||||
if [ "$INSTALL_MODE" = "build" ]; then
|
||||
check_build_dependencies
|
||||
prepare_sources
|
||||
build_binary
|
||||
install_built_binary
|
||||
else
|
||||
download_binary
|
||||
fi
|
||||
|
||||
install_link
|
||||
check_path
|
||||
cleanup
|
||||
|
||||
success "Installation completed successfully"
|
||||
log "Log saved to $LOGFILE"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
1
packaging/aur/dcr-git
Submodule
1
packaging/aur/dcr-git
Submodule
Submodule packaging/aur/dcr-git added at 12038a613e
18
packaging/snap/snapcraft.yaml
Normal file
18
packaging/snap/snapcraft.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
name: dcr
|
||||
base: core22
|
||||
version: '0.6.9'
|
||||
summary: Cargo-like utility to manage C/C++ projects
|
||||
description: |
|
||||
A build tool and package manager for C/C++ projects inspired by Rust's Cargo.
|
||||
|
||||
grade: stable
|
||||
confinement: classic
|
||||
|
||||
apps:
|
||||
dcr:
|
||||
command: bin/dcr
|
||||
|
||||
parts:
|
||||
dcr:
|
||||
plugin: dump
|
||||
source: dist/
|
||||
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "stable"
|
||||
216
src/cli/build.rs
216
src/cli/build.rs
@@ -69,7 +69,9 @@ pub fn build(args: &[String]) -> i32 {
|
||||
|
||||
if flags.target.is_none() {
|
||||
let config_path = root.join("dcr.toml");
|
||||
if let Ok(config) = Config::open(config_path.to_str().unwrap()) {
|
||||
if let Ok(config) = Config::open(config_path.to_str().unwrap())
|
||||
&& !config.is_workspace_only()
|
||||
{
|
||||
let bt = get_build_string_with_profile(&config, "target", "debug");
|
||||
if !bt.is_empty() {
|
||||
flags.target = Some(bt);
|
||||
@@ -78,15 +80,26 @@ pub fn build(args: &[String]) -> i32 {
|
||||
}
|
||||
if flags.target.is_none() {
|
||||
let default_target = if cfg!(target_os = "linux") {
|
||||
"x86_64-unknown-linux-gnu"
|
||||
format!("{}-unknown-linux-gnu", std::env::consts::ARCH)
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"x86_64-apple-darwin"
|
||||
"x86_64-apple-darwin".to_string()
|
||||
} else if cfg!(target_os = "windows") {
|
||||
"x86_64-pc-windows-msvc"
|
||||
"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"
|
||||
"unknown".to_string()
|
||||
};
|
||||
flags.target = Some(default_target.to_string());
|
||||
flags.target = Some(default_target);
|
||||
}
|
||||
if flags.clean {
|
||||
let mut clean_args = Vec::new();
|
||||
@@ -100,6 +113,7 @@ pub fn build(args: &[String]) -> i32 {
|
||||
flags.target.as_deref(),
|
||||
flags.force,
|
||||
flags.verbose,
|
||||
flags.workspace.as_deref(),
|
||||
)
|
||||
}) {
|
||||
Ok(()) => 0,
|
||||
@@ -372,8 +386,13 @@ fn get_build_steps_with_profile(
|
||||
get_build_steps(config, &format!("build.{field}"))
|
||||
}
|
||||
|
||||
fn ensure_target_dirs(items: &[String], profile: &str, target_dir: Option<String>) {
|
||||
if !items.contains(&"target".to_string()) {
|
||||
fn ensure_target_dirs(
|
||||
items: &[String],
|
||||
profile: &str,
|
||||
target_dir: Option<String>,
|
||||
skip_local_target: bool,
|
||||
) {
|
||||
if !skip_local_target && !items.contains(&"target".to_string()) {
|
||||
let _ = fs::create_dir("./target");
|
||||
}
|
||||
if let Some(dir) = &target_dir {
|
||||
@@ -382,6 +401,15 @@ fn ensure_target_dirs(items: &[String], profile: &str, target_dir: Option<String
|
||||
let default_dir = if cfg!(target_os = "linux") {
|
||||
let arch = std::env::consts::ARCH;
|
||||
format!("{arch}-unknown-linux-gnu/{profile}")
|
||||
} else if cfg!(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
)) {
|
||||
let arch = std::env::consts::ARCH;
|
||||
let os = std::env::consts::OS;
|
||||
format!("{arch}-unknown-{os}/{profile}")
|
||||
} else {
|
||||
profile.to_string()
|
||||
};
|
||||
@@ -414,8 +442,38 @@ fn build_from_root(
|
||||
target: Option<&str>,
|
||||
force: bool,
|
||||
verbose: bool,
|
||||
workspace: Option<&str>,
|
||||
) -> Result<(), String> {
|
||||
let config = Config::open("./dcr.toml").map_err(|err| err.to_string())?;
|
||||
|
||||
if config.is_workspace_only() {
|
||||
let ws = parse_workspace(&config, profile, target, root)?
|
||||
.ok_or_else(|| "Workspace root has no members defined".to_string())?;
|
||||
let members: Vec<_> = if let Some(filter_name) = workspace {
|
||||
ws.members
|
||||
.into_iter()
|
||||
.filter(|m| m.name == filter_name)
|
||||
.collect()
|
||||
} else {
|
||||
ws.members
|
||||
};
|
||||
if members.is_empty() {
|
||||
return Err("No matching workspace members to build".to_string());
|
||||
}
|
||||
for member in &members {
|
||||
build_project_at(
|
||||
&member.path,
|
||||
profile,
|
||||
target,
|
||||
&[],
|
||||
force,
|
||||
verbose,
|
||||
Some(root),
|
||||
)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let project_name = get_config_str(&config, "package.name");
|
||||
let project_version = get_config_str(&config, "package.version");
|
||||
|
||||
@@ -454,20 +512,50 @@ fn build_from_root(
|
||||
)
|
||||
);
|
||||
}
|
||||
if let Some(workspace) = parse_workspace(&config, profile, build_target.as_deref(), root)? {
|
||||
build_workspace(&workspace, profile, build_target.as_deref(), force, verbose)?;
|
||||
let excludes: Vec<std::path::PathBuf> =
|
||||
workspace.members.iter().map(|m| m.path.clone()).collect();
|
||||
if let Some(ws) = parse_workspace(&config, profile, build_target.as_deref(), root)? {
|
||||
if let Some(filter_name) = workspace {
|
||||
for member in ws.members.iter().filter(|m| m.name == filter_name) {
|
||||
build_project_at(
|
||||
&member.path,
|
||||
profile,
|
||||
build_target.as_deref(),
|
||||
&[],
|
||||
force,
|
||||
verbose,
|
||||
Some(root),
|
||||
)?;
|
||||
}
|
||||
} else {
|
||||
build_workspace(
|
||||
&ws,
|
||||
profile,
|
||||
build_target.as_deref(),
|
||||
force,
|
||||
verbose,
|
||||
Some(root),
|
||||
)?;
|
||||
let excludes: Vec<std::path::PathBuf> =
|
||||
ws.members.iter().map(|m| m.path.clone()).collect();
|
||||
build_project_at(
|
||||
root,
|
||||
profile,
|
||||
build_target.as_deref(),
|
||||
&excludes,
|
||||
force,
|
||||
verbose,
|
||||
None,
|
||||
)?;
|
||||
}
|
||||
} else {
|
||||
build_project_at(
|
||||
root,
|
||||
profile,
|
||||
build_target.as_deref(),
|
||||
&excludes,
|
||||
&[],
|
||||
force,
|
||||
verbose,
|
||||
None,
|
||||
)?;
|
||||
} else {
|
||||
build_project_at(root, profile, build_target.as_deref(), &[], force, verbose)?;
|
||||
}
|
||||
}
|
||||
let elapsed = ((start_time.elapsed().as_secs_f64() * 100.0).trunc()) / 100.0;
|
||||
@@ -485,9 +573,18 @@ fn build_workspace(
|
||||
target: Option<&str>,
|
||||
force: bool,
|
||||
verbose: bool,
|
||||
workspace_root: Option<&Path>,
|
||||
) -> Result<(), String> {
|
||||
for member in &workspace.members {
|
||||
build_project_at(&member.path, profile, target, &[], force, verbose)?;
|
||||
build_project_at(
|
||||
&member.path,
|
||||
profile,
|
||||
target,
|
||||
&[],
|
||||
force,
|
||||
verbose,
|
||||
workspace_root,
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -499,6 +596,7 @@ fn build_project_at(
|
||||
exclude_dirs: &[std::path::PathBuf],
|
||||
force: bool,
|
||||
verbose: bool,
|
||||
workspace_root: Option<&Path>,
|
||||
) -> Result<(), String> {
|
||||
with_dir(project_root, || {
|
||||
check_interrupted()?;
|
||||
@@ -506,7 +604,22 @@ fn build_project_at(
|
||||
if !items.contains(&"dcr.toml".to_string()) {
|
||||
return Err("dcr.toml file not found".to_string());
|
||||
}
|
||||
let config = Config::open("./dcr.toml").map_err(|err| err.to_string())?;
|
||||
let mut config = Config::open("./dcr.toml").map_err(|err| err.to_string())?;
|
||||
// Inherit build fields from workspace root if configured
|
||||
if let Some(root) = workspace_root {
|
||||
let has_inherit = config
|
||||
.get("build.inherit")
|
||||
.and_then(|v| v.as_bool())
|
||||
.unwrap_or(false);
|
||||
if has_inherit {
|
||||
let root_path = root.join("dcr.toml");
|
||||
if root_path.is_file() {
|
||||
let parent_config =
|
||||
Config::open(&root_path.to_string_lossy()).map_err(|e| e.to_string())?;
|
||||
config.merge_parent(&parent_config);
|
||||
}
|
||||
}
|
||||
}
|
||||
let project_name = get_config_str(&config, "package.name");
|
||||
let project_version = get_config_str(&config, "package.version");
|
||||
let build_target_config = get_build_string_with_profile(&config, "target", profile);
|
||||
@@ -548,17 +661,6 @@ fn build_project_at(
|
||||
.or_else(|| get_config_opt(&config, "toolchain.rcc"));
|
||||
let mut build_cflags =
|
||||
get_list_with_profile_and_target(&config, "cflags", profile, build_target)?;
|
||||
if let Some(t) = build_target
|
||||
&& !t.trim().is_empty()
|
||||
{
|
||||
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 mut build_ldflags =
|
||||
get_list_with_profile_and_target(&config, "ldflags", profile, build_target)?;
|
||||
let build_ldscript =
|
||||
@@ -595,11 +697,48 @@ 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());
|
||||
let resolved_archiver = resolve_tool("DCR_AR", tc_ar.as_deref());
|
||||
|
||||
let target_dir = build_target.map(|t| format!("target/{t}/{profile}"));
|
||||
ensure_target_dirs(&items, profile, target_dir);
|
||||
let target_dir_binding = match workspace_root {
|
||||
Some(root) => {
|
||||
let target_str = build_target
|
||||
.map(normalize_target_os)
|
||||
.filter(|t| !t.is_empty());
|
||||
let rel: PathBuf = match target_str {
|
||||
Some(ref t) => Path::new("target").join(t).join(profile),
|
||||
None => {
|
||||
let default_dir = if cfg!(target_os = "linux") {
|
||||
let arch = std::env::consts::ARCH;
|
||||
format!("{arch}-unknown-linux-gnu/{profile}")
|
||||
} else {
|
||||
profile.to_string()
|
||||
};
|
||||
Path::new("target").join(&default_dir)
|
||||
}
|
||||
};
|
||||
root.join(&rel).to_string_lossy().to_string()
|
||||
}
|
||||
None => normalize_target(build_target.unwrap_or(""), profile).unwrap_or_default(),
|
||||
};
|
||||
let target_dir = if target_dir_binding.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(target_dir_binding.clone())
|
||||
};
|
||||
ensure_target_dirs(&items, profile, target_dir, workspace_root.is_some());
|
||||
|
||||
let deps_table = config.get("dependencies").and_then(|v| v.as_table());
|
||||
let resolved = resolve_deps(&config, profile, build_target, project_root)?;
|
||||
@@ -635,7 +774,15 @@ fn build_project_at(
|
||||
dep_root.display()
|
||||
));
|
||||
}
|
||||
build_project_at(&dep_root, profile, build_target, &[], force, verbose)?;
|
||||
build_project_at(
|
||||
&dep_root,
|
||||
profile,
|
||||
build_target,
|
||||
&[],
|
||||
force,
|
||||
verbose,
|
||||
None,
|
||||
)?;
|
||||
print!(
|
||||
"\r{:100}\r {} {} v{}",
|
||||
"",
|
||||
@@ -724,7 +871,6 @@ fn build_project_at(
|
||||
}
|
||||
}
|
||||
|
||||
let target_dir_binding = normalize_target(build_target.unwrap_or(""), profile);
|
||||
let version_info = parse_version_info(&project_version);
|
||||
let substitute = |s: &str| -> String {
|
||||
s.replace("{profile}", profile)
|
||||
@@ -749,7 +895,11 @@ fn build_project_at(
|
||||
standard: &build_standard,
|
||||
cxx_standard: &build_cxx_standard,
|
||||
target: build_target,
|
||||
target_dir: target_dir_binding.as_deref(),
|
||||
target_dir: if target_dir_binding.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(target_dir_binding.as_str())
|
||||
},
|
||||
kind: normalize_kind(&build_kind),
|
||||
platform: normalize_platform(&build_platform),
|
||||
linker: resolved_linker.as_deref(),
|
||||
|
||||
@@ -120,11 +120,22 @@ fn clean_from_root(root: &Path, flags: &CleanFlags) -> Result<(), String> {
|
||||
})
|
||||
.or_else(|| {
|
||||
Some(if cfg!(target_os = "linux") {
|
||||
"x86_64-unknown-linux-gnu".to_string()
|
||||
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()
|
||||
})
|
||||
|
||||
@@ -21,6 +21,7 @@ use crate::utils::log::warn;
|
||||
pub struct BuildRunFlags {
|
||||
pub profile: String,
|
||||
pub target: Option<String>,
|
||||
pub workspace: Option<String>,
|
||||
pub force: bool,
|
||||
pub clean: bool,
|
||||
pub verbose: bool,
|
||||
@@ -29,6 +30,7 @@ pub struct BuildRunFlags {
|
||||
pub fn parse_build_run_flags(args: &[String]) -> Result<BuildRunFlags, i32> {
|
||||
let mut profile = PROFILE.to_string();
|
||||
let mut target = None;
|
||||
let mut workspace = None;
|
||||
let mut force = false;
|
||||
let mut clean = false;
|
||||
let mut verbose = false;
|
||||
@@ -52,6 +54,15 @@ pub fn parse_build_run_flags(args: &[String]) -> Result<BuildRunFlags, i32> {
|
||||
verbose = true;
|
||||
continue;
|
||||
}
|
||||
if candidate == "workspace" {
|
||||
if let Some(w) = iter.next() {
|
||||
workspace = Some(w.clone());
|
||||
} else {
|
||||
warn("--workspace requires a value");
|
||||
return Err(1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if candidate == "target" {
|
||||
if let Some(t) = iter.next() {
|
||||
target = Some(t.clone());
|
||||
@@ -76,6 +87,7 @@ pub fn parse_build_run_flags(args: &[String]) -> Result<BuildRunFlags, i32> {
|
||||
Ok(BuildRunFlags {
|
||||
profile,
|
||||
target,
|
||||
workspace,
|
||||
force,
|
||||
clean,
|
||||
verbose,
|
||||
|
||||
56
src/cli/fmt.rs
Normal file
56
src/cli/fmt.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
use crate::utils::log::error;
|
||||
use crate::utils::text::{BOLD_GREEN, colored};
|
||||
use glob::glob;
|
||||
use std::process::Command;
|
||||
|
||||
pub fn fmt(_args: &[String]) -> i32 {
|
||||
let patterns = [
|
||||
"src/**/*.c",
|
||||
"src/**/*.cpp",
|
||||
"src/**/*.h",
|
||||
"src/**/*.hpp",
|
||||
"tests/**/*.c",
|
||||
"tests/**/*.cpp",
|
||||
"tests/**/*.h",
|
||||
"tests/**/*.hpp",
|
||||
];
|
||||
|
||||
let mut files = Vec::new();
|
||||
for pattern in patterns {
|
||||
if let Ok(paths) = glob(pattern) {
|
||||
for path in paths.flatten() {
|
||||
if let Some(s) = path.to_str() {
|
||||
files.push(s.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if files.is_empty() {
|
||||
println!(" {} No files to format", colored("Format", BOLD_GREEN));
|
||||
return 0;
|
||||
}
|
||||
|
||||
println!(
|
||||
" {} {} files",
|
||||
colored("Formatting", BOLD_GREEN),
|
||||
files.len()
|
||||
);
|
||||
|
||||
let status = Command::new("clang-format").arg("-i").args(&files).status();
|
||||
|
||||
match status {
|
||||
Ok(s) if s.success() => {
|
||||
println!(" {} successful", colored("Format", BOLD_GREEN));
|
||||
0
|
||||
}
|
||||
Ok(s) => {
|
||||
error(&format!("clang-format failed with status: {}", s));
|
||||
1
|
||||
}
|
||||
Err(e) => {
|
||||
error(&format!("Failed to execute clang-format: {}", e));
|
||||
1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ pub fn help() -> i32 {
|
||||
println!(" run [--profile] Build and run the project (default: --debug)");
|
||||
println!(" tree Display the dependency tree");
|
||||
println!(" test Run project tests (alias: tests)");
|
||||
println!(" fmt Format all C/C++ source files using clang-format");
|
||||
println!(" clean Remove the target directory");
|
||||
println!(" gen <subcommand> Generate IDE integration files");
|
||||
printc("FLAGS:", BOLD_GREEN);
|
||||
|
||||
@@ -20,6 +20,7 @@ pub mod build;
|
||||
pub mod clean;
|
||||
pub mod flag_update;
|
||||
pub mod flags;
|
||||
pub mod fmt;
|
||||
pub mod r#gen;
|
||||
pub mod help;
|
||||
pub mod init;
|
||||
|
||||
147
src/cli/run.rs
147
src/cli/run.rs
@@ -24,6 +24,7 @@ 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 std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
fn get_run_cmd(
|
||||
@@ -82,28 +83,103 @@ pub fn run(args: &[String]) -> i32 {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
let flags = match parse_build_run_flags(args) {
|
||||
Ok(v) => v,
|
||||
Err(_) => return 1,
|
||||
};
|
||||
|
||||
// Handle workspace-only root: delegate to workspace member
|
||||
if config.is_workspace_only() {
|
||||
let ws = match crate::core::workspace::parse_workspace(
|
||||
&config,
|
||||
&flags.profile,
|
||||
flags.target.as_deref(),
|
||||
&root,
|
||||
) {
|
||||
Ok(Some(ws)) => ws,
|
||||
Ok(None) => {
|
||||
error("Workspace root has no members defined");
|
||||
return 1;
|
||||
}
|
||||
Err(e) => {
|
||||
error(&e);
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
let member = match &flags.workspace {
|
||||
Some(name) => ws.members.iter().find(|m| m.name == *name),
|
||||
None => ws.main_member(),
|
||||
};
|
||||
let member = match member {
|
||||
Some(m) => m,
|
||||
None => {
|
||||
if let Some(name) = &flags.workspace {
|
||||
error(&format!("Workspace member '{name}' not found"));
|
||||
} else {
|
||||
error("No workspace member to run (set `main = true` on one member)");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
// Build and run from the member's directory
|
||||
return match with_dir(&member.path, || {
|
||||
run_project(&member.path, &flags, Some(root.as_path()))
|
||||
}) {
|
||||
Ok(code) => code,
|
||||
Err(e) => {
|
||||
error(&e);
|
||||
1
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
match run_project(&root, &flags, None) {
|
||||
Ok(code) => code,
|
||||
Err(e) => {
|
||||
error(&e);
|
||||
1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn run_project(
|
||||
root: &Path,
|
||||
flags: &crate::cli::flags::BuildRunFlags,
|
||||
workspace_root: Option<&Path>,
|
||||
) -> Result<i32, String> {
|
||||
let config =
|
||||
Config::open(root.join("dcr.toml").to_str().unwrap()).map_err(|err| err.to_string())?;
|
||||
|
||||
let project_name: &str = config
|
||||
.get("package.name")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("");
|
||||
|
||||
let mut flags = match parse_build_run_flags(args) {
|
||||
Ok(v) => v,
|
||||
Err(_) => return 1,
|
||||
};
|
||||
|
||||
// If no target specified, use default host target for target-specific config
|
||||
if flags.target.is_none() {
|
||||
let mut target = flags.target.clone();
|
||||
if target.is_none() {
|
||||
let default_target = if cfg!(target_os = "linux") {
|
||||
"x86_64-unknown-linux-gnu"
|
||||
format!("{}-unknown-linux-gnu", std::env::consts::ARCH)
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"x86_64-apple-darwin"
|
||||
"x86_64-apple-darwin".to_string()
|
||||
} else if cfg!(target_os = "windows") {
|
||||
"x86_64-pc-windows-msvc"
|
||||
"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"
|
||||
"unknown".to_string()
|
||||
};
|
||||
flags.target = Some(default_target.to_string());
|
||||
target = Some(default_target);
|
||||
}
|
||||
|
||||
let build_kind = config
|
||||
@@ -112,25 +188,30 @@ pub fn run(args: &[String]) -> i32 {
|
||||
.or_else(|| config.get("build.kind").and_then(|v| v.as_str()))
|
||||
.unwrap_or("");
|
||||
|
||||
let normalized_target_dir = flags
|
||||
.target
|
||||
.as_ref()
|
||||
.and_then(|t| crate::cli::build::normalize_target(t, &flags.profile));
|
||||
let normalized_target_dir = match workspace_root {
|
||||
Some(wr) => target
|
||||
.as_ref()
|
||||
.and_then(|t| crate::cli::build::normalize_target(t, &flags.profile))
|
||||
.map(|rel| wr.join(&rel).to_string_lossy().to_string()),
|
||||
None => target
|
||||
.as_ref()
|
||||
.and_then(|t| crate::cli::build::normalize_target(t, &flags.profile)),
|
||||
};
|
||||
|
||||
let version = config
|
||||
.get("package.version")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("");
|
||||
let run_cmd = get_run_cmd(&config, &flags.profile, flags.target.as_deref(), version);
|
||||
let run_cmd = get_run_cmd(&config, &flags.profile, target.as_deref(), version);
|
||||
|
||||
let kind = build_kind.trim();
|
||||
if run_cmd.is_none()
|
||||
&& (kind == "staticlib" || kind == "sharedlib" || kind == "efi" || kind == "elf")
|
||||
{
|
||||
error("Cannot run library build");
|
||||
return 1;
|
||||
return Err("Cannot run library build".to_string());
|
||||
}
|
||||
let build_status = build(args);
|
||||
|
||||
let build_status = build(&args_for_build(flags));
|
||||
let bin_path = crate::platform::bin_path(
|
||||
&flags.profile,
|
||||
project_name,
|
||||
@@ -140,15 +221,15 @@ pub fn run(args: &[String]) -> i32 {
|
||||
if let Some(cmd) = run_cmd {
|
||||
println!("\n {} {}", colored("Running", BOLD_GREEN), cmd);
|
||||
println!("--------------------------------");
|
||||
return run_shell(&cmd);
|
||||
return Ok(run_shell(&cmd));
|
||||
}
|
||||
println!("\n {} {}", colored("Running", BOLD_GREEN), bin_path);
|
||||
println!("--------------------------------");
|
||||
return run_binary(
|
||||
return Ok(run_binary(
|
||||
project_name,
|
||||
&flags.profile,
|
||||
normalized_target_dir.as_deref(),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
let fallback_code = if let Some(cmd) = run_cmd {
|
||||
@@ -161,11 +242,27 @@ pub fn run(args: &[String]) -> i32 {
|
||||
)
|
||||
};
|
||||
if fallback_code != 1 {
|
||||
return fallback_code;
|
||||
return Ok(fallback_code);
|
||||
}
|
||||
|
||||
error("Fix errors in the code to run the project");
|
||||
1
|
||||
Err("Fix errors in the code to run the project".to_string())
|
||||
}
|
||||
|
||||
fn args_for_build(flags: &crate::cli::flags::BuildRunFlags) -> Vec<String> {
|
||||
let mut args = Vec::new();
|
||||
args.push(format!("--{}", flags.profile));
|
||||
if let Some(ref target) = flags.target {
|
||||
args.push("--target".to_string());
|
||||
args.push(target.clone());
|
||||
}
|
||||
if let Some(ref name) = flags.workspace {
|
||||
args.push("--workspace".to_string());
|
||||
args.push(name.clone());
|
||||
}
|
||||
if flags.verbose {
|
||||
args.push("--verbose".to_string());
|
||||
}
|
||||
args
|
||||
}
|
||||
|
||||
fn run_shell(cmd: &str) -> i32 {
|
||||
|
||||
@@ -316,6 +316,31 @@ pub fn needs_rebuild(source: &str, object: &str) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn needs_link(objects: &[String], output_path: &str) -> bool {
|
||||
let out_meta = match fs::metadata(output_path) {
|
||||
Ok(m) => m,
|
||||
Err(_) => return true,
|
||||
};
|
||||
let out_time = match out_meta.modified() {
|
||||
Ok(t) => t,
|
||||
Err(_) => return true,
|
||||
};
|
||||
for obj in objects {
|
||||
let obj_meta = match fs::metadata(obj) {
|
||||
Ok(m) => m,
|
||||
Err(_) => return true,
|
||||
};
|
||||
let obj_time = match obj_meta.modified() {
|
||||
Ok(t) => t,
|
||||
Err(_) => return true,
|
||||
};
|
||||
if obj_time > out_time {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn parse_d_file(content: &str) -> Vec<String> {
|
||||
let mut deps = Vec::new();
|
||||
let text = content.replace("\\\n", " ").replace("\\\r\n", " ");
|
||||
@@ -418,6 +443,55 @@ mod tests {
|
||||
assert_eq!(result, "target/debug/obj/main.c.obj");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn needs_link_no_output() {
|
||||
let dir = temp_dir("link_no_out");
|
||||
let obj1 = dir.join("test1.o");
|
||||
let obj2 = dir.join("test2.o");
|
||||
let out = dir.join("app");
|
||||
fs::write(&obj1, "").unwrap();
|
||||
fs::write(&obj2, "").unwrap();
|
||||
let objs = vec![
|
||||
obj1.to_string_lossy().to_string(),
|
||||
obj2.to_string_lossy().to_string(),
|
||||
];
|
||||
assert!(needs_link(&objs, &out.to_string_lossy()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn needs_link_fresh() {
|
||||
let dir = temp_dir("link_fresh");
|
||||
let obj1 = dir.join("test1.o");
|
||||
let obj2 = dir.join("test2.o");
|
||||
let out = dir.join("app");
|
||||
fs::write(&obj1, "").unwrap();
|
||||
fs::write(&obj2, "").unwrap();
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
fs::write(&out, "").unwrap();
|
||||
let objs = vec![
|
||||
obj1.to_string_lossy().to_string(),
|
||||
obj2.to_string_lossy().to_string(),
|
||||
];
|
||||
assert!(!needs_link(&objs, &out.to_string_lossy()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn needs_link_stale() {
|
||||
let dir = temp_dir("link_stale");
|
||||
let obj1 = dir.join("test1.o");
|
||||
let obj2 = dir.join("test2.o");
|
||||
let out = dir.join("app");
|
||||
fs::write(&obj1, "").unwrap();
|
||||
fs::write(&out, "").unwrap();
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
fs::write(&obj2, "").unwrap();
|
||||
let objs = vec![
|
||||
obj1.to_string_lossy().to_string(),
|
||||
obj2.to_string_lossy().to_string(),
|
||||
];
|
||||
assert!(needs_link(&objs, &out.to_string_lossy()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn needs_rebuild_no_object() {
|
||||
let dir = temp_dir("rebuild_no_obj");
|
||||
|
||||
@@ -43,6 +43,10 @@ pub fn build(ctx: &BuildContext) -> Result<f64, String> {
|
||||
|
||||
if ctx.kind == "staticlib" {
|
||||
let lib_path = platform::lib_path(ctx.profile, ctx.project_name, ctx.target_dir);
|
||||
if !common::needs_link(&objects, &lib_path) {
|
||||
let elapsed = ((start_time.elapsed().as_secs_f64() * 100.0).trunc()) / 100.0;
|
||||
return Ok(elapsed);
|
||||
}
|
||||
let archiver = ctx.archiver.unwrap_or(if cfg!(target_os = "windows") {
|
||||
"lib"
|
||||
} else {
|
||||
@@ -105,6 +109,11 @@ pub fn build(ctx: &BuildContext) -> Result<f64, String> {
|
||||
} else {
|
||||
platform::bin_path(ctx.profile, &final_name, ctx.target_dir)
|
||||
};
|
||||
|
||||
if !common::needs_link(&objects, &out_path) {
|
||||
let elapsed = ((start_time.elapsed().as_secs_f64() * 100.0).trunc()) / 100.0;
|
||||
return Ok(elapsed);
|
||||
}
|
||||
cmd.arg("-o").arg(out_path);
|
||||
|
||||
if ctx.verbose || std::env::var("DCR_DEBUG").is_ok() {
|
||||
|
||||
@@ -43,6 +43,10 @@ pub fn build(ctx: &BuildContext) -> Result<f64, String> {
|
||||
|
||||
if ctx.kind == "staticlib" {
|
||||
let lib_path = platform::lib_path(ctx.profile, ctx.project_name, ctx.target_dir);
|
||||
if !common::needs_link(&objects, &lib_path) {
|
||||
let elapsed = ((start_time.elapsed().as_secs_f64() * 100.0).trunc()) / 100.0;
|
||||
return Ok(elapsed);
|
||||
}
|
||||
let mut cmd = Command::new(ctx.archiver.unwrap_or("lib"));
|
||||
cmd.arg("/nologo").arg(format!("/OUT:{lib_path}"));
|
||||
for obj in &objects {
|
||||
@@ -117,6 +121,11 @@ pub fn build(ctx: &BuildContext) -> Result<f64, String> {
|
||||
} else {
|
||||
platform::bin_path(ctx.profile, ctx.project_name, ctx.target_dir)
|
||||
};
|
||||
|
||||
if !common::needs_link(&objects, &out_path) {
|
||||
let elapsed = ((start_time.elapsed().as_secs_f64() * 100.0).trunc()) / 100.0;
|
||||
return Ok(elapsed);
|
||||
}
|
||||
cmd.arg(format!("/Fe:{out_path}"));
|
||||
|
||||
if ctx.verbose || std::env::var("DCR_DEBUG").is_ok() {
|
||||
|
||||
@@ -43,6 +43,10 @@ pub fn build(ctx: &BuildContext) -> Result<f64, String> {
|
||||
|
||||
if ctx.kind == "staticlib" {
|
||||
let lib_path = platform::lib_path(ctx.profile, ctx.project_name, ctx.target_dir);
|
||||
if !common::needs_link(&objects, &lib_path) {
|
||||
let elapsed = ((start_time.elapsed().as_secs_f64() * 100.0).trunc()) / 100.0;
|
||||
return Ok(elapsed);
|
||||
}
|
||||
let archiver = ctx.archiver.unwrap_or(if cfg!(target_os = "windows") {
|
||||
"lib"
|
||||
} else {
|
||||
@@ -105,6 +109,11 @@ pub fn build(ctx: &BuildContext) -> Result<f64, String> {
|
||||
} else {
|
||||
platform::bin_path(ctx.profile, &final_name, ctx.target_dir)
|
||||
};
|
||||
|
||||
if !common::needs_link(&objects, &out_path) {
|
||||
let elapsed = ((start_time.elapsed().as_secs_f64() * 100.0).trunc()) / 100.0;
|
||||
return Ok(elapsed);
|
||||
}
|
||||
cmd.arg("-o").arg(out_path);
|
||||
|
||||
if ctx.verbose || std::env::var("DCR_DEBUG").is_ok() {
|
||||
|
||||
@@ -45,6 +45,10 @@ pub fn build(ctx: &BuildContext) -> Result<f64, String> {
|
||||
|
||||
if ctx.kind == "staticlib" {
|
||||
let lib_path = platform::lib_path(ctx.profile, ctx.project_name, ctx.target_dir);
|
||||
if !common::needs_link(&objects, &lib_path) {
|
||||
let elapsed = ((start_time.elapsed().as_secs_f64() * 100.0).trunc()) / 100.0;
|
||||
return Ok(elapsed);
|
||||
}
|
||||
let mut cmd = Command::new(ctx.archiver.unwrap_or("ar"));
|
||||
cmd.arg("rcs").arg(&lib_path);
|
||||
for obj in &objects {
|
||||
@@ -106,6 +110,11 @@ pub fn build(ctx: &BuildContext) -> Result<f64, String> {
|
||||
} else {
|
||||
platform::bin_path(ctx.profile, &final_name, ctx.target_dir)
|
||||
};
|
||||
|
||||
if !common::needs_link(&objects, &out_path) {
|
||||
let elapsed = ((start_time.elapsed().as_secs_f64() * 100.0).trunc()) / 100.0;
|
||||
return Ok(elapsed);
|
||||
}
|
||||
cmd.arg("-o").arg(out_path);
|
||||
|
||||
if ctx.verbose || std::env::var("DCR_DEBUG").is_ok() {
|
||||
|
||||
@@ -77,8 +77,10 @@ pub struct Config {
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct DcrConfig {
|
||||
pub package: PackageConfig,
|
||||
pub build: BuildConfig,
|
||||
#[serde(default)]
|
||||
pub package: Option<PackageConfig>,
|
||||
#[serde(default)]
|
||||
pub build: Option<BuildConfig>,
|
||||
#[serde(default)]
|
||||
pub dependencies: BTreeMap<String, DependencyConfig>,
|
||||
#[serde(default)]
|
||||
@@ -123,6 +125,8 @@ pub struct BuildConfig {
|
||||
pub clean: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub src_disable: Option<bool>,
|
||||
#[serde(default)]
|
||||
pub workspace_only: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
@@ -201,13 +205,100 @@ impl Config {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn package(&self) -> &PackageConfig {
|
||||
&self.typed.package
|
||||
pub fn package(&self) -> Option<&PackageConfig> {
|
||||
self.typed.package.as_ref()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn build_config(&self) -> &BuildConfig {
|
||||
&self.typed.build
|
||||
pub fn build_config(&self) -> Option<&BuildConfig> {
|
||||
self.typed.build.as_ref()
|
||||
}
|
||||
|
||||
pub fn is_workspace_only(&self) -> bool {
|
||||
self.typed
|
||||
.build
|
||||
.as_ref()
|
||||
.map(|b| b.workspace_only)
|
||||
.unwrap_or(false)
|
||||
&& !self.typed.workspace.is_empty()
|
||||
}
|
||||
|
||||
/// Merge build fields from parent config into self where self has empty/default values.
|
||||
/// Used for workspace member inheritance (build.inherit = true).
|
||||
pub fn merge_parent(&mut self, parent: &Config) {
|
||||
let fields: &[&str] = &[
|
||||
"language",
|
||||
"standard",
|
||||
"cxx_standard",
|
||||
"compiler",
|
||||
"kind",
|
||||
"target",
|
||||
"platform",
|
||||
"cflags",
|
||||
"ldflags",
|
||||
"exclude",
|
||||
"include",
|
||||
"roots",
|
||||
"clean",
|
||||
"src_disable",
|
||||
];
|
||||
let parent_build = match parent.data.get("build").and_then(|v| v.as_table()) {
|
||||
Some(t) => t.clone(),
|
||||
None => return,
|
||||
};
|
||||
|
||||
let self_build = self
|
||||
.data
|
||||
.get("build")
|
||||
.and_then(|v| v.as_table())
|
||||
.cloned()
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut changes: Vec<(String, toml::Value)> = Vec::new();
|
||||
|
||||
for field in fields {
|
||||
let val = match parent_build.get(*field) {
|
||||
Some(v) => v,
|
||||
None => continue,
|
||||
};
|
||||
|
||||
let self_val = self_build.get(*field);
|
||||
let should_inherit = match val {
|
||||
toml::Value::Array(_) => self_val.is_none(),
|
||||
toml::Value::String(_) => self_val
|
||||
.and_then(|v| v.as_str())
|
||||
.map(|s| s.trim().is_empty())
|
||||
.unwrap_or(true),
|
||||
_ => self_val.is_none(),
|
||||
};
|
||||
if should_inherit {
|
||||
changes.push((field.to_string(), val.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
if changes.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
if !self.data.is_table() {
|
||||
let mut m = Map::new();
|
||||
m.insert("build".to_string(), toml::Value::Table(Map::new()));
|
||||
self.data = toml::Value::Table(m);
|
||||
}
|
||||
|
||||
let tbl = self.data.as_table_mut().unwrap();
|
||||
let build_tbl = tbl
|
||||
.entry("build".to_string())
|
||||
.or_insert_with(|| toml::Value::Table(Map::new()));
|
||||
if let Some(build_tbl) = build_tbl.as_table_mut() {
|
||||
for (key, val) in changes {
|
||||
build_tbl.entry(key).or_insert(val);
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(typed) = parse_typed_config(&self.data) {
|
||||
self.typed = typed;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get(&self, key: &str) -> Option<&Value> {
|
||||
@@ -229,15 +320,29 @@ impl Config {
|
||||
}
|
||||
|
||||
pub fn validate(&self) -> Result<(), ConfigError> {
|
||||
if self.typed.package.name.trim().is_empty() {
|
||||
if self.is_workspace_only() {
|
||||
return self.validate_workspace();
|
||||
}
|
||||
|
||||
let pkg =
|
||||
self.typed.package.as_ref().ok_or_else(|| {
|
||||
ConfigError::Invalid("missing [package] section (required)".into())
|
||||
})?;
|
||||
let build = self
|
||||
.typed
|
||||
.build
|
||||
.as_ref()
|
||||
.ok_or_else(|| ConfigError::Invalid("missing [build] section (required)".into()))?;
|
||||
|
||||
if pkg.name.trim().is_empty() {
|
||||
return Err(ConfigError::Invalid("package.name is empty".into()));
|
||||
}
|
||||
if self.typed.package.version.trim().is_empty() {
|
||||
if pkg.version.trim().is_empty() {
|
||||
return Err(ConfigError::Invalid("package.version is empty".into()));
|
||||
}
|
||||
validate_package_name(&self.typed.package.name)?;
|
||||
validate_package_name(&pkg.name)?;
|
||||
|
||||
if let Some(pkg_type) = &self.typed.package.pkg_type {
|
||||
if let Some(pkg_type) = &pkg.pkg_type {
|
||||
let pkg_type = pkg_type.trim();
|
||||
if !pkg_type.is_empty() && pkg_type != "lib" && pkg_type != "app" && pkg_type != "none"
|
||||
{
|
||||
@@ -247,32 +352,32 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
validate_language_config(&self.typed.build.language, "build.language")?;
|
||||
if self.typed.build.standard.trim().is_empty() {
|
||||
validate_language_config(&build.language, "build.language")?;
|
||||
if build.standard.trim().is_empty() {
|
||||
return Err(ConfigError::Invalid("build.standard is empty".into()));
|
||||
}
|
||||
if self.typed.build.compiler.trim().is_empty() {
|
||||
if build.compiler.trim().is_empty() {
|
||||
return Err(ConfigError::Invalid("build.compiler is empty".into()));
|
||||
}
|
||||
if let Some(platform) = &self.typed.build.platform
|
||||
if let Some(platform) = &build.platform
|
||||
&& platform.trim().is_empty()
|
||||
{
|
||||
return Err(ConfigError::Invalid("build.platform is empty".into()));
|
||||
}
|
||||
validate_toolchain(self.typed.toolchain.as_ref())?;
|
||||
if let Some(kind) = &self.typed.build.kind {
|
||||
if let Some(kind) = &build.kind {
|
||||
let kind = kind.trim();
|
||||
if !kind.is_empty() && !VALID_KINDS.contains(&kind) {
|
||||
return Err(ConfigError::Invalid("build.kind is invalid".into()));
|
||||
}
|
||||
}
|
||||
validate_string_list(&self.typed.build.exclude, "build.exclude")?;
|
||||
validate_string_list(&self.typed.build.include, "build.include")?;
|
||||
validate_string_list(&self.typed.build.roots, "build.roots")?;
|
||||
validate_string_list(&self.typed.build.clean, "build.clean")?;
|
||||
validate_string_list(&self.typed.build.cflags, "build.cflags")?;
|
||||
validate_string_list(&self.typed.build.ldflags, "build.ldflags")?;
|
||||
if let Some(target) = &self.typed.build.target {
|
||||
validate_string_list(&build.exclude, "build.exclude")?;
|
||||
validate_string_list(&build.include, "build.include")?;
|
||||
validate_string_list(&build.roots, "build.roots")?;
|
||||
validate_string_list(&build.clean, "build.clean")?;
|
||||
validate_string_list(&build.cflags, "build.cflags")?;
|
||||
validate_string_list(&build.ldflags, "build.ldflags")?;
|
||||
if let Some(target) = &build.target {
|
||||
validate_non_empty_string(target, "build.target")?;
|
||||
}
|
||||
for profile in ["release", "debug"] {
|
||||
@@ -824,10 +929,10 @@ mod tests {
|
||||
"[package]\nname = \"typed\"\nversion = \"1.2.3\"\ntype = \"lib\"\n\n[build]\nlanguage = [\"c\", \"c++\"]\nstandard = \"c11\"\ncompiler = \"clang\"\nkind = \"staticlib\"\ncflags = [\"-Wall\"]\n\n[dependencies]\nfoo = \"1.0.0\"\n",
|
||||
);
|
||||
let config = Config::open(&path.to_string_lossy()).unwrap();
|
||||
assert_eq!(config.package().name, "typed");
|
||||
assert_eq!(config.typed().package.version, "1.2.3");
|
||||
assert_eq!(config.build_config().compiler, "clang");
|
||||
assert_eq!(config.build_config().cflags, ["-Wall"]);
|
||||
assert_eq!(config.package().unwrap().name, "typed");
|
||||
assert_eq!(config.typed().package.as_ref().unwrap().version, "1.2.3");
|
||||
assert_eq!(config.build_config().unwrap().compiler, "clang");
|
||||
assert_eq!(config.build_config().unwrap().cflags, ["-Wall"]);
|
||||
assert!(config.typed().dependencies.contains_key("foo"));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,10 @@ use std::process::Command;
|
||||
pub fn run_binary(project_name: &str, profile: &str, target_dir: Option<&str>) -> i32 {
|
||||
let bin_path = platform::bin_path(profile, project_name, target_dir);
|
||||
if Path::new(&bin_path).exists() {
|
||||
let output = Command::new(&bin_path).output();
|
||||
match output {
|
||||
Ok(o) => {
|
||||
print!("{}", String::from_utf8_lossy(&o.stdout));
|
||||
eprint!("{}", String::from_utf8_lossy(&o.stderr));
|
||||
return o.status.code().unwrap_or(0);
|
||||
let status = Command::new(&bin_path).status();
|
||||
match status {
|
||||
Ok(s) => {
|
||||
return s.code().unwrap_or(0);
|
||||
}
|
||||
Err(_) => {
|
||||
return 1;
|
||||
|
||||
@@ -26,6 +26,7 @@ pub struct WorkspaceMember {
|
||||
pub name: String,
|
||||
pub path: PathBuf,
|
||||
pub deps: Vec<String>,
|
||||
pub main: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -33,6 +34,15 @@ pub struct Workspace {
|
||||
pub members: Vec<WorkspaceMember>,
|
||||
}
|
||||
|
||||
impl Workspace {
|
||||
pub fn main_member(&self) -> Option<&WorkspaceMember> {
|
||||
self.members
|
||||
.iter()
|
||||
.find(|m| m.main)
|
||||
.or_else(|| self.members.first())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_workspace(
|
||||
config: &Config,
|
||||
profile: &str,
|
||||
@@ -85,6 +95,7 @@ pub fn parse_workspace(
|
||||
name: name.to_string(),
|
||||
path,
|
||||
deps,
|
||||
main: tbl.get("main").and_then(|v| v.as_bool()).unwrap_or(false),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::utils::log::error;
|
||||
mod cli;
|
||||
mod config;
|
||||
@@ -41,6 +40,7 @@ fn main() {
|
||||
"run" => cli::run::run(rest),
|
||||
"tree" => cli::tree::tree(rest),
|
||||
"test" | "tests" => cli::test::test(rest),
|
||||
"fmt" => cli::fmt::fmt(rest),
|
||||
"clean" => cli::clean::clean(rest),
|
||||
"gen" => cli::r#gen::r#gen(rest),
|
||||
"--version" => {
|
||||
|
||||
88
src/platform/bsd.rs
Normal file
88
src/platform/bsd.rs
Normal file
@@ -0,0 +1,88 @@
|
||||
pub fn bin_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
|
||||
match target_dir {
|
||||
Some(dir) => format!("{}/{}", dir.trim_end_matches('/'), name),
|
||||
None => {
|
||||
let arch = std::env::consts::ARCH;
|
||||
let os = std::env::consts::OS;
|
||||
let target = format!("{arch}-unknown-{os}");
|
||||
format!("./target/{target}/{profile}/{name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn lib_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
|
||||
match target_dir {
|
||||
Some(dir) => format!("{}/lib{}.a", dir.trim_end_matches('/'), name),
|
||||
None => {
|
||||
let arch = std::env::consts::ARCH;
|
||||
let os = std::env::consts::OS;
|
||||
let target = format!("{arch}-unknown-{os}");
|
||||
format!("./target/{target}/{profile}/lib{name}.a")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn elf_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
|
||||
match target_dir {
|
||||
Some(dir) => format!("{}/{}", dir.trim_end_matches('/'), name),
|
||||
None => {
|
||||
let arch = std::env::consts::ARCH;
|
||||
let os = std::env::consts::OS;
|
||||
let target = format!("{arch}-unknown-{os}");
|
||||
format!("./target/{target}/{profile}/{name}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn efi_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
|
||||
match target_dir {
|
||||
Some(dir) => format!("{}/{}.efi", dir.trim_end_matches('/'), name),
|
||||
None => {
|
||||
let arch = std::env::consts::ARCH;
|
||||
let os = std::env::consts::OS;
|
||||
let target = format!("{arch}-unknown-{os}");
|
||||
format!("./target/{target}/{profile}/{name}.efi")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn shared_lib_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
|
||||
match target_dir {
|
||||
Some(dir) => format!("{}/lib{}.so", dir.trim_end_matches('/'), name),
|
||||
None => {
|
||||
let arch = std::env::consts::ARCH;
|
||||
let os = std::env::consts::OS;
|
||||
let target = format!("{arch}-unknown-{os}");
|
||||
format!("./target/{target}/{profile}/lib{name}.so")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn bin_path_default() {
|
||||
let arch = std::env::consts::ARCH;
|
||||
let os = std::env::consts::OS;
|
||||
let expected = format!("./target/{arch}-unknown-{os}/debug/hello");
|
||||
assert_eq!(bin_path("debug", "hello", None), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lib_path_default() {
|
||||
let arch = std::env::consts::ARCH;
|
||||
let os = std::env::consts::OS;
|
||||
let expected = format!("./target/{arch}-unknown-{os}/debug/libmylib.a");
|
||||
assert_eq!(lib_path("debug", "mylib", None), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shared_lib_path_default() {
|
||||
let arch = std::env::consts::ARCH;
|
||||
let os = std::env::consts::OS;
|
||||
let expected = format!("./target/{arch}-unknown-{os}/debug/libmylib.so");
|
||||
assert_eq!(shared_lib_path("debug", "mylib", None), expected);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
))]
|
||||
pub mod bsd;
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod linux;
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -35,7 +42,24 @@ pub fn bin_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
|
||||
{
|
||||
return windows::bin_path(profile, name, target_dir);
|
||||
}
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
|
||||
#[cfg(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
))]
|
||||
{
|
||||
return bsd::bin_path(profile, name, target_dir);
|
||||
}
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "windows",
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
)))]
|
||||
{
|
||||
match target_dir {
|
||||
Some(dir) => format!("{}/{}", dir.trim_end_matches('/'), name),
|
||||
@@ -57,7 +81,24 @@ pub fn elf_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
|
||||
{
|
||||
return windows::elf_path(profile, name, target_dir);
|
||||
}
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
|
||||
#[cfg(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
))]
|
||||
{
|
||||
return bsd::elf_path(profile, name, target_dir);
|
||||
}
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "windows",
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
)))]
|
||||
{
|
||||
match target_dir {
|
||||
Some(dir) => format!("{}/{}", dir.trim_end_matches('/'), name),
|
||||
@@ -79,7 +120,24 @@ pub fn efi_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
|
||||
{
|
||||
return windows::efi_path(profile, name, target_dir);
|
||||
}
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
|
||||
#[cfg(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
))]
|
||||
{
|
||||
return bsd::efi_path(profile, name, target_dir);
|
||||
}
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "windows",
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
)))]
|
||||
{
|
||||
match target_dir {
|
||||
Some(dir) => format!("{}/{}.efi", dir.trim_end_matches('/'), name),
|
||||
@@ -101,7 +159,24 @@ pub fn lib_path(profile: &str, name: &str, target_dir: Option<&str>) -> String {
|
||||
{
|
||||
return windows::lib_path(profile, name, target_dir);
|
||||
}
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
|
||||
#[cfg(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
))]
|
||||
{
|
||||
return bsd::lib_path(profile, name, target_dir);
|
||||
}
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "windows",
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
)))]
|
||||
{
|
||||
match target_dir {
|
||||
Some(dir) => format!("{}/lib{}.a", dir.trim_end_matches('/'), name),
|
||||
@@ -123,7 +198,24 @@ pub fn shared_lib_path(profile: &str, name: &str, target_dir: Option<&str>) -> S
|
||||
{
|
||||
return windows::shared_lib_path(profile, name, target_dir);
|
||||
}
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
|
||||
#[cfg(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
))]
|
||||
{
|
||||
return bsd::shared_lib_path(profile, name, target_dir);
|
||||
}
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "windows",
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "dragonfly"
|
||||
)))]
|
||||
{
|
||||
match target_dir {
|
||||
Some(dir) => format!("{}/lib{}.so", dir.trim_end_matches('/'), name),
|
||||
|
||||
@@ -198,18 +198,6 @@ fn workspace_build_and_clean_all() {
|
||||
"workspace clean --all --release should succeed"
|
||||
);
|
||||
|
||||
for (name, _) in &members {
|
||||
let member = root.join("src").join(name);
|
||||
let target_dir = "target/x86_64-unknown-linux-gnu";
|
||||
assert!(
|
||||
!member.join(target_dir).join("release").exists(),
|
||||
"member target/x86_64-unknown-linux-gnu/release should be removed"
|
||||
);
|
||||
assert!(
|
||||
member.join(target_dir).join("debug").exists(),
|
||||
"member target/x86_64-unknown-linux-gnu/debug should remain"
|
||||
);
|
||||
}
|
||||
let target_dir = "target/x86_64-unknown-linux-gnu";
|
||||
assert!(
|
||||
!root.join(target_dir).join("release").exists(),
|
||||
|
||||
@@ -280,8 +280,11 @@ fn build_release_profile() {
|
||||
let out = run_dcr_env(&["build", "--release"], &dir, &envs);
|
||||
assert!(out.status.success(), "release build should succeed");
|
||||
assert!(
|
||||
dir.join("target").join("release").is_dir(),
|
||||
"target/release should exist"
|
||||
dir.join("target")
|
||||
.join("x86_64-unknown-linux-gnu")
|
||||
.join("release")
|
||||
.is_dir(),
|
||||
"target/x86_64-unknown-linux-gnu/release should exist"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user