# Maintainer: Vladislav Nepogodin <nepogodin.vlad@gmail.com>

pkgname=scx-manager-git
pkgver=1.15.10.r3.g126594c
pkgrel=1
epoch=1
pkgdesc="Simple GUI for managing sched-ext schedulers via scx_loader"
arch=(aarch64 x86_64)
url="https://github.com/cachyos/scx-manager"
license=(GPL-3.0-or-later)
depends=('qt6-base' 'polkit' 'scx-scheds-git' 'scx-tools-git')
makedepends=('cmake' 'ninja' 'git' 'qt6-tools' 'cargo' 'lld' 'clang' 'llvm')
source=("${pkgname}::git+$url.git#branch=develop")
sha256sums=('SKIP')
provides=('scx-manager')
conflicts=('scx-manager')

pkgver() {
  cd "${srcdir}/${pkgname}"
  git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd "${srcdir}/${pkgname}"

  # we are building with llvm stack here, due to rust
  export AR=llvm-ar
  export CC=clang
  export CXX=clang++
  export NM=llvm-nm
  export RANLIB=llvm-ranlib

  export RUSTFLAGS="-Cembed-bitcode -C opt-level=3 -Ccodegen-units=1 -Clinker=clang -C link-arg=-flto -Clink-arg=-fuse-ld=/usr/bin/ld.lld"

  cmake -S . -Bbuild \
        -GNinja \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_INSTALL_LIBDIR=lib
  cmake --build build
}

package() {
  cd "${srcdir}/${pkgname}"

  # we are building with llvm stack here, due to rust
  export AR=llvm-ar
  export CC=clang
  export CXX=clang++
  export NM=llvm-nm
  export RANLIB=llvm-ranlib

  export RUSTFLAGS="-Cembed-bitcode -C opt-level=3 -Ccodegen-units=1 -Clinker=clang -C link-arg=-flto -Clink-arg=-fuse-ld=/usr/bin/ld.lld"

  DESTDIR="${pkgdir}" cmake --build build --target install
}

# vim:set sw=2 sts=2 et:
