# Template file for 'voiced'
#
# Canonical Void Linux package definition, to be built with xbps-src from a
# void-packages checkout:
#
#   cp -r packaging/void/template void-packages/srcpkgs/voiced/template
#   cd void-packages && ./xbps-src pkg voiced
#
# Notes:
#  * `distfiles` points at a tagged archive of the (private) source repository.
#    Private repositories require credentials, so either publish a release
#    tarball, mirror it, or drop the sources into the xbps-src masterdir.
#  * `checksum=SKIP` avoids pinning a hash that cannot be computed here; replace
#    it with the real sha256 once the tarball is published.
#  * If the build machine is offline, pre-populate the npm cache and Cargo
#    registry in the masterdir before building.
#
pkgname=voiced
version=0.1.0
revision=1
archs="x86_64*"
hostmakedepends="rust nodejs pkg-config"
makedepends="libwebkit2gtk41-devel libsoup3-devel gtk+3-devel librsvg-devel openssl-devel"
depends="libwebkit2gtk41"
short_desc="Offline invoicing app by Bongbetic"
maintainer="Xavier Karma <xavier@bongbetic.com>"
license="custom:proprietary"
homepage="https://git.bongbetic.com/xavierk/Voiced"
distfiles="https://git.bongbetic.com/xavierk/Voiced/archive/v${version}.tar.gz"
checksum=SKIP
compression="zstd"

do_build() {
    npm install --include=dev --no-audit --no-fund
    npm run build
    cd src-tauri
    # `custom-protocol` embeds the frontend for production; without it the app
    # expects a dev server on localhost:1420.
    cargo build --release --features custom-protocol
}

do_install() {
    vbin "${wrksrc}/src-tauri/target/release/voiced"
    vinstall "${wrksrc}/packaging/void/voiced.desktop" 644 usr/share/applications
    for size in 32 64 128; do
        vinstall "${wrksrc}/src-tauri/icons/${size}x${size}.png" 644 \
            "usr/share/icons/hicolor/${size}x${size}/apps" voiced.png
    done
    vinstall "${wrksrc}/src-tauri/icons/128x128@2x.png" 644 \
        usr/share/icons/hicolor/256x256/apps voiced.png
    vinstall "${wrksrc}/src-tauri/icons/icon.png" 644 \
        usr/share/icons/hicolor/512x512/apps voiced.png
    vdoc "${wrksrc}/README.md"
}
