summarylogtreecommitdiffstats
path: root/PKGBUILD
diff options
context:
space:
mode:
authorxiota2023-12-28 01:27:14 -0800
committerxiota2023-12-28 01:27:14 -0800
commitc6b6351dfe8889d4a98ded60602d335c532cd260 (patch)
tree3ff346b794c09ddd8b168d0eef2a33033ce84fa3 /PKGBUILD
parentca3b2892cda433e1f9c09e277761cef1c75d8987 (diff)
downloadaur-c6b6351dfe8889d4a98ded60602d335c532cd260.tar.gz
build with clang
Diffstat (limited to 'PKGBUILD')
-rw-r--r--PKGBUILD297
1 files changed, 201 insertions, 96 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 6ff7fc7164cd..a2e529ad8464 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,127 +1,177 @@
# Maintainer: xiota / aur.chaotic.cx
+# options
+: ${_autoupdate:=false}
+
+: ${_build_clang:=true}
+
+: ${_build_avx:=false}
+: ${_build_git:=false}
+
+[[ "${_build_avx::1}" == "t" ]] && _pkgtype+="-avx"
+[[ "${_build_git::1}" == "t" ]] && _pkgtype+="-git"
+
+# basic info
_pkgname=flycast
-pkgname="$_pkgname"
+pkgname="$_pkgname${_pkgtype:-}"
pkgver=2.2
-_tag="v${pkgver%%.r*}"
-pkgrel=1
-pkgdesc='A multi-platform Sega Dreamcast, Naomi and Atomiswave emulator'
-arch=('x86_64' 'i686')
+pkgrel=2
+pkgdesc='Sega Dreamcast, Naomi, and Atomiswave emulator'
url="https://github.com/flyinghead/flycast"
-license=('GPL2')
-
-depends=(
- 'alsa-lib'
- 'hicolor-icon-theme'
- 'libgl'
- 'libzip'
-)
-makedepends=(
- 'cmake'
- 'git'
- 'python'
- 'systemd'
-)
-
-if [ x"$pkgname" == x"$_pkgname" ] ; then
- # normal package
- _pkgsrc="$_pkgname"
- source+=(
- "$_pkgsrc"::"git+$url.git#tag=$_tag"
+license=('GPL-2.0-only')
+arch=('x86_64' 'i686')
+
+# main package
+_main_package() {
+ depends=(
+ 'alsa-lib'
+ 'libgl'
+ 'libzip'
)
- sha256sums+=(
- 'SKIP'
+ makedepends=(
+ 'cmake'
+ 'git'
+ 'python'
)
+ if [[ "${_build_clang::1}" == "t" ]] ; then
+ makedepends+=(
+ 'clang'
+ 'lld'
+ 'llvm'
+ )
+ fi
+
+ if [ "${_build_git::1}" != "t" ] ; then
+ _main_stable
+ else
+ _main_git
+ fi
+
+ source+=("breakpad-disable.patch")
+ sha256sums+=('SKIP')
+
+ _source_flycast
+ #_source_vinniefalco_luabridge
+}
+
+# stable package
+_main_stable() {
+ _update_version
+
+ _pkgsrc="$_pkgname"
+ source+=("$_pkgsrc"::"git+$url.git#tag=v${_pkgver:?}")
+ sha256sums+=('SKIP')
+
pkgver() {
- echo "${pkgver%%.r*}"
+ echo "${_pkgver:?}"
}
+}
- prepare() {
- _prepare_submodules_common
- _prepare_common
- }
-else
- # git package
- provides+=("$_pkgname")
+# git package
+_main_git() {
+ provides+=("$_pkgname=${pkgver%%.r*}")
conflicts+=("$_pkgname")
_pkgsrc="$_pkgname"
+ source+=("$_pkgsrc"::"git+$url.git")
+ sha256sums+=('SKIP')
+
+ pkgver() {
+ cd "$_pkgsrc"
+ git describe --long --tags --abbrev=8 --exclude='*[a-zA-Z][a-zA-Z]*' \
+ | sed -E 's/^[^0-9]*//;s/([^-]*-g)/r\1/;s/-/./g'
+ }
+}
+
+# submodules
+_source_flycast() {
source+=(
- "$_pkgsrc"::"git+$url.git"
+ 'flyinghead.libchdr'::'git+https://github.com/flyinghead/libchdr.git'
+ 'flyinghead.mingw-breakpad'::'git+https://github.com/flyinghead/mingw-breakpad.git'
+ 'google.oboe'::'git+https://github.com/google/oboe.git'
+ 'gpuopen-librariesandsdks.vulkanmemoryallocator'::'git+https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git'
+ 'khronosgroup.glslang'::'git+https://github.com/KhronosGroup/glslang.git'
+ 'khronosgroup.vulkan-headers'::'git+https://github.com/KhronosGroup/Vulkan-Headers.git'
+ 'libsdl-org.sdl'::'git+https://github.com/libsdl-org/SDL.git'
+ 'vinniefalco.luabridge'::'git+https://github.com/vinniefalco/LuaBridge.git'
+ 'vkedwardli.spout2'::'git+https://github.com/vkedwardli/Spout2.git'
+ 'vkedwardli.syphon-framework'::'git+https://github.com/vkedwardli/Syphon-Framework.git'
)
sha256sums+=(
'SKIP'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
+ 'SKIP'
)
- pkgver() {
- cd "$_pkgsrc"
- git describe --long --tags | sed -E 's/^[Vv]//;s/([^-]*-g)/r\1/;s/-/./g'
- }
+ _prepare_flycast() (
+ cd "${srcdir:?}/$_pkgsrc"
+ local -A _submodules=(
+ ['flyinghead.libchdr']='core/deps/libchdr'
+ ['flyinghead.mingw-breakpad']='core/deps/breakpad'
+ ['google.oboe']='core/deps/oboe'
+ ['gpuopen-librariesandsdks.vulkanmemoryallocator']='core/deps/VulkanMemoryAllocator'
+ ['khronosgroup.glslang']='core/deps/glslang'
+ ['khronosgroup.vulkan-headers']='core/deps/Vulkan-Headers'
+ ['libsdl-org.sdl']='core/deps/SDL'
+ ['vinniefalco.luabridge']='core/deps/luabridge'
+ ['vkedwardli.spout2']='core/deps/Spout'
+ ['vkedwardli.syphon-framework']='core/deps/Syphon'
+ )
+ _submodule_update
+ )
+}
- prepare() {
- _prepare_submodules_common
- _prepare_submodules_git
- _prepare_common
- }
-fi
-
-source+=(
- # common submodules
- "SDL"::"git+https://github.com/libsdl-org/SDL"
- "Vulkan-Headers"::"git+https://github.com/KhronosGroup/Vulkan-Headers"
- "VulkanMemoryAllocator"::"git+https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator"
- "breakpad"::"git+https://github.com/flyinghead/mingw-breakpad"
- "glslang"::"git+https://github.com/KhronosGroup/glslang"
- "libchdr"::"git+https://github.com/flyinghead/libchdr"
- "luabridge"::"git+https://github.com/vinniefalco/LuaBridge"
- "oboe"::"git+https://github.com/google/oboe"
- 'Spout'::'git+https://github.com/vkedwardli/Spout2'
- 'Syphon'::'git+https://github.com/vkedwardli/Syphon-Framework'
-)
-sha256sums+=(
- 'SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP'
-)
-
-_prepare_submodules_common() {
- (
- # submodules for flycast
- cd "$_pkgsrc"
+_source_vinniefalco_luabridge() {
+ source+=(
+ 'google.googletest'::'git+https://github.com/google/googletest.git'
+ )
+ sha256sums+=(
+ 'SKIP'
+ )
+
+ _prepare_vinniefalco_luabridge() (
+ cd "${srcdir:?}/$_pkgsrc"
+ cd 'core/deps/luabridge'
local -A _submodules=(
- ['SDL']='core/deps/SDL'
- ['Spout']='core/deps/Spout'
- ['Syphon']='core/deps/Syphon'
- ['Vulkan-Headers']='core/deps/Vulkan-Headers'
- ['VulkanMemoryAllocator']='core/deps/VulkanMemoryAllocator'
- ['breakpad']='core/deps/breakpad'
- ['glslang']='core/deps/glslang'
- ['libchdr']='core/deps/libchdr'
- ['luabridge']='core/deps/luabridge'
- ['oboe']='core/deps/oboe'
+ ['google.googletest']='third_party/gtest'
)
- for key in ${!_submodules[@]} ; do
+ _submodule_update
+ )
+}
+
+# common functions
+prepare() {
+ _submodule_update() {
+ local key;
+ for key in ${!_submodules[@]} ; do
git submodule init "${_submodules[${key}]}"
git submodule set-url "${_submodules[${key}]}" "${srcdir}/${key}"
git -c protocol.file.allow=always submodule update "${_submodules[${key}]}"
done
- )
-}
+ }
-_prepare_submodules_git() {
- : # submodules currently in sync
-}
+ apply-patch() {
+ if patch -Np1 -F100 --dry-run -i "$1" &>/dev/null ; then
+ printf '\nApplying patch: %s\n' "$1"
+ patch -Np1 -F100 -i "$1"
+ else
+ printf '\nPatch already applied: %s\n' "$1"
+ fi
+ }
+
+ _prepare_flycast
+ #_prepare_vinniefalco_luabridge
-_prepare_common() {
- : # not currently needed
+ cd "$_pkgsrc"
+ apply-patch "$srcdir/breakpad-disable.patch"
}
build() {
@@ -129,11 +179,66 @@ build() {
-B build
-S "$_pkgsrc"
-DCMAKE_INSTALL_PREFIX='/usr'
+ -DCMAKE_BUILD_TYPE=Release
+ -Wno-dev
)
+
+ if [[ "${_build_clang::1}" == "t" ]] ; then
+ export AR=llvm-ar
+ export NM=llvm-nm
+
+ _cmake_options+=(
+ -DCMAKE_C_COMPILER=clang
+ -DCMAKE_CXX_COMPILER=clang++
+
+ -DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld"
+ -DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld"
+ -DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld"
+
+ -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
+ -DCMAKE_POLICY_DEFAULT_CMP0069=NEW
+ )
+ fi
+
+ if [[ "${_build_avx::1}" == "t" ]] ; then
+ export CFLAGS="$(echo "$CFLAGS" | sed -E 's@(\s*-(march|mtune)=\S+\s*)@ @g;s@\s*-O[0-9]\s*@ @g;s@\s+@ @g') -march=x86-64-v3 -mtune=skylake -O3"
+ export CXXFLAGS="$(echo "$CXXFLAGS" | sed -E 's@(\s*-(march|mtune)=\S+\s*)@ @g;s@\s*-O[0-9]\s*@ @g;s@\s+@ @g') -march=x86-64-v3 -mtune=skylake -O3"
+ fi
+
cmake "${_cmake_options[@]}"
cmake --build build
}
package() {
- DESTDIR="${pkgdir:?}" cmake --install build
+ depends+=(
+ 'hicolor-icon-theme'
+ )
+
+ DESTDIR="$pkgdir" cmake --install build
}
+
+# update version
+_update_version() {
+ : ${_pkgver:=${pkgver%%.r*}}
+
+ if [[ "${_autoupdate::1}" != "t" ]] ; then
+ return
+ fi
+
+ local _response=$(curl -Ssf "$url/releases.atom")
+ local _tag=$(
+ printf '%s' "$_response" \
+ | grep '/releases/tag/' \
+ | sed -E 's@^.*/releases/tag/(.*)".*$@\1@' \
+ | grep -Ev '[a-z]{2}' | sort -V | tail -1
+ )
+ local _pkgver_new="${_tag#v}"
+
+ # update _pkgver
+ if [ "$_pkgver" != "${_pkgver_new:?}" ] ; then
+ _pkgver="${_pkgver_new:?}"
+ fi
+}
+
+# execute
+_main_package