#!/bin/mkpkg
# description: Cargo helper to build and install C-ABI compatible libraries
# url: https://github.com/lu-zero/cargo-c

name=cargo-c
version=0.10.21
release=1
depends=(rust)
makedepends=(cargo-audit)
source=(https://github.com/lu-zero/$name/archive/refs/tags/v$version.tar.gz)
renames=($name-$version.tar.gz)
sha256sums=(
    "819b62a61e5271924dffd122b7c713e446e5d65f3e630bbe9b90d4d46513d8fa"
)

patch() {
    cd $name-$version
    cargo vendor ../vendor
    mkdir -p .cargo
    printf '%s\n' \
        '[source.crates-io]' \
        'replace-with = "vendored-sources"' \
        '' \
        '[source.vendored-sources]' \
        'directory = "../vendor"' \
        > .cargo/config.toml
    cargo audit
}

build() {
    export CARGO_HTTP_CAINFO=/etc/ssl/cert.pem
    export RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=lld -C target-feature=-crt-static"
    cd $name-$version
    cargo build --release --offline
    install -Dm755 target/release/cargo-capi     $PKG/usr/bin/cargo-capi
    install -Dm755 target/release/cargo-cbuild   $PKG/usr/bin/cargo-cbuild
    install -Dm755 target/release/cargo-cinstall $PKG/usr/bin/cargo-cinstall
    install -Dm755 target/release/cargo-ctest    $PKG/usr/bin/cargo-ctest
}

signify() {
    untrusted comment: public key
    RWTZ9IduCSQ/mL8337TEUinPwT92xFEUpD92hkS7IxcOnzTt9QdpohT3
}

# vim: filetype=sh

