TurningWheel / Barony

Barony Open Source Release
http://www.baronygame.com/
Other
487 stars 127 forks source link

Building on Arch Linux #709

Open ThisNekoGuy opened 1 year ago

ThisNekoGuy commented 1 year ago

I'm trying to better understand the Barony build process given some oddities and missing information I've seen around the repo that's made it difficult for me to build the project.

Typically when I do this sort of thing, I use the Arch Build System to break the process into steps (via bash) and potentially package the end-result as a Arch system package; for those unfamiliar, this is how the AUR is driven.

My main issues are that there's discrepancies and/or missing information about how the project is built with that intent and how the project is built with Steamworks and EOS support when somehow encrypted zip files are used (referring to the build-linux_fmod_steam_eos-barony.sh CI) where there are no encryption keys anywhere in this repository to build this thing, as far as I'm aware. That said, the other files that vaguely describe this to me are INSTALL.md and CMakeLists.txt references to EOS environment variables?

Below you can find the steps I've taken; I've made comments in inside of the prepare(), build(), and package() functions in regards to the issues I'm facing and I'm hoping I can get some advice about the right way to go about this. I'm a junior C# dev, so this C/C++ sort of thing doesn't quite immediately make sense to me

PKGBUILD file: ```bash pkgname=barony pkgver=3.3.7 pkgrel=0 pkgdesc='A first-person roguelike RPG featuring permadeath, hunger, and exploration in procedurally generated dungeons.' arch=('any') url=https://github.com/TurningWheel/${pkgname/b/B/} makedepends=('git' 'make' 'cmake' 'sed' 'grep' 'physfs' 'sdl2' 'sdl2_image' 'sdl2_net' 'sdl2_ttf' 'libpng' 'zlib' 'rapidjson' 'base-devel' 'clang' 'llvm' 'llvm-libs' 'lld' 'gold') depends=('glibc' 'libc++abi') optdepends=('') license=('custom:BaronyOpenSource' 'custom:TheFreeTypeProject' 'zlib' 'MIT:RapidJSON') source=("git+${url}.git" "Barony.desktop") sha256sums=('SKIP' 'de79df4e66f127e16609b33d591f9322b4bb11ae42bc3ace2fa97e400385f46b') options=('!strip' 'staticlibs' 'debug') ## Use this if you prefer opendoas; the benefit here is that doas won't time out on you if you wait too long to authenticate after compilation if [ -f /usr/bin/doas ] && [ -f /etc/doas.conf ]; then PACMAN_AUTH=(doas) fi USE_CLANG=1 # Default installation directory. Can be useful if you do not have a lot of space on the default storage drive # DON'T put a "/" at the start of the path!! #_install_dir="opt/${pkgname}" ## This is for detecting your CPU architecture automatically; set to false if you want to enforce your own makepkg.conf file ## Disabled by default as a compromise for those bothered by having it force-enabled ## Note: the resulting package will still be named containing "x86_64" unless the build was done with an "official" Arch distro for that architecture (like Arch ARM - [don't exactly advise using Arch ARM though]) ## or if you manage to trick your Arch installation to accept other architecture extensions by fiddling with the $CARCH variable and /etc/pacman.conf - this method has flaws, namely due to a bug: ## it doesn't work with "makechrootpkg" - though # Valid values are false / disabled / default, auto, and native # "false" means the values for these will respect your /etc/makepkg.conf arch_auto=false if [[ ${arch_auto} == auto ]] then ## Architecture checks and compile flag adjustments - shellcheck throws a fit about the build function but it looks fine to me; checks for the highest available x64 support level and falls back to "native" if either not available if [ "$(uname -m)" == "x86_64" ]; then if [ "$(/lib/ld-linux-x86-64.so.2 --help | grep -w 'x86-64-v4' | cut -d ',' -f 1 | sed 's/^ //' | sed 's/ (/ - /')" == 'x86-64-v4 - supported' ]; then export CFLAGS="${CFLAGS} -march=x86-64-v4 -mtune=x86-64-v4" export LDFLAGS="-Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now" elif [ "$(/lib/ld-linux-x86-64.so.2 --help | grep -w 'x86-64-v3' | cut -d ',' -f 1 | sed 's/^ //' | sed 's/ (/ - /')" == 'x86-64-v3 - supported' ]; then export CFLAGS="${CFLAGS} -march=x86-64-v3 -mtune=x86-64-v3" export LDFLAGS="-Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now" elif [ "$(/lib/ld-linux-x86-64.so.2 --help | grep -w 'x86-64-v2' | cut -d ',' -f 1 | sed 's/^ //' | sed 's/ (/ - /')" == 'x86-64-v2 - supported' ]; then export CFLAGS="${CFLAGS} -march=x86-64-v2 -mtune=x86-64-v2" export LDFLAGS="-Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now" elif [ "$(/lib/ld-linux-x86-64.so.2 --help | grep 'x86_64' | grep 'supported' | cut -d ',' -f 1 | sed 's/^ //' | sed 's/ (/ - /' | grep -w '^x86_64 - supported')" == 'x86_64 - supported' ]; then export CFLAGS="${CFLAGS} -march=x86-64 -mtune=x86-64" fi elif [ "$(uname -m)" == "aarch64" ]; then export CFLAGS="${CFLAGS} -march=aarch64 -mtune=aarch64 -mcpu=native" export LDFLAGS="-Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now" elif [[ "${arch_auto}" == native ]]; then export CFLAGS="${CFLAGS} -march=native -mtune=native -mcpu=native" fi fi CFLAGS="${CFLAGS} -O3 -pipe -fno-plt -pthread -fsanitize=bounds,alignment,object-size -fsanitize-undefined-trap-on-error \ -fexceptions -minline-all-stringops -ftree-vectorize \ -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ -fstack-clash-protection -fstack-protector-strong -fcf-protection" export CXXFLAGS="${CFLAGS} -Wp,-D_GLIBCXX_ASSERTIONS" export LDFLAGS="-unwind=libunwind -lpthread -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now" if [ ! "${USE_CLANG}" -eq 0 ] && [ -f /usr/bin/clang ]; then export CC=clang export CXX=clang++ export LD="" export AR="/usr/bin/llvm-ar" export NM="/usr/bin/llvm-nm" export AS="/usr/bin/llvm-as" export RANLIB="/usr/bin/llvm-ranlib" export STRIP="/usr/bin/llvm-strip" export OBJCOPY="/usr/bin/llvm-objcopy" CLANG_VERSION="$(clang --version | grep 'version' | sed 's|version ||' | cut -f 1 -d ' ' --complement | cut -f 1 -d '.')" if [ "${CLANG_VERSION}" -eq 16 ] || [ "${CLANG_VERSION}" -gt 16 ]; then export CFLAGS="${CFLAGS} -fstrict-flex-arrays" export CXXFLAGS="${CXXFLAGS} -fstrict-flex-arrays" fi export LDFLAGS="-stdlib=libstdc++ -lc++abi -fuse-ld=lld ${LDFLAGS}" ## This value is for Arch users, in case it's not familiar to those who read this export LTOFLAGS="-flto=full" export DEBUG_CFLAGS="-g" else export CC=gcc export CXX=g++ export LD="" export AR="/usr/bin/gcc-ar" export NM="/usr/bin/gcc-nm" export AS="/usr/bin/as" export RANLIB="/usr/bin/gcc-ranlib" export STRIP="/usr/bin/strip" export OBJCOPY="/usr/bin/objcopy" GCC_VERSION="$(gcc --version | grep '(GCC)' | sed 's|gcc (GCC) ||' | cut -f 1 -d ' ' | cut -f 1 -d '.')" if [ "${GCC_VERSION}" -eq 13 ] || [ "${GCC_VERSION}" -gt 13 ]; then export CFLAGS="${CFLAGS} -fstrict-flex-arrays" export CXXFLAGS="${CXXFLAGS} -fstrict-flex-arrays" fi export LDFLAGS="-fuse-ld=gold ${LDFLAGS}" ## This value is for Arch users, in case it's not familiar to those who read this export LTOFLAGS="-flto -fuse-linker-plugin" export DEBUG_CFLAGS="-g -fvar-tracking-assignments" fi export DEBUG_CXXFLAGS="${DEBUG_CFLAGS}" prepare() { cd "${srcdir}/${pkgname}" || return CURRENT_CLONED_VERSION="$(git describe --tags)" if [ "${CURRENT_CLONED_VERSION}" != "${pkgver}" ]; then cd .. rm -rf "${pkgname}" git clone --depth=1 --branch=${pkgver} "${url}" "${pkgname}" cd "${pkgname}" || return else rm -f .git/index.lock git fetch --depth=1 origin tag ${pkgver} git reset --hard ${pkgver} fi ## Official game files are supposedly needed in this directory to build the open-source project # required_files=('sound' 'models' 'maps' 'items' 'images' 'data' 'books' 'music') # # for folder in "${required_files[@]}"; do # if [ ! -d "${srcdir}/${pkgdir}/${folder}" ]; then # echo "ERROR: Required game files for \"${folder}\" are not present in project directory" # exit 1 # fi # done # OpenAL support is deprecated in favor of FMOD cmake -B build \ -DCMAKE_BUILD_TYPE=Release \ -DOPTIMIZATION_LEVEL="-O3" \ -DCMAKE_C_FLAGS_RELEASE="${CFLAGS}" \ -DCMAKE_CXX_FLAGS_RELEASE="${CXXFLAGS}" \ -DCMAKE_C_FLAGS_DEBUG="${DEBUG_CFLAGS}" \ -DCMAKE_CXX_FLAGS_DEBUG="${DEBUG_CXXFLAGS}" \ -DGAME_ENABLED 1 \ -DEDITOR_ENABLED 1 \ -DFMOD_ENABLED=ON \ -DOPENAL_ENABLED=OFF \ -DSTEAMWORKS_ENABLED=1 \ -DEOS_ENABLED=0 ## Unknown variables for EOS that are required to enable it? # BUILD_ENV_PR # BUILD_ENV_SA # BUILD_ENV_DE # BUILD_ENV_CC # BUILD_ENV_CS # BUILD_ENV_GSE ## cmake values I should use? # Binaries: -DCMAKE_INSTALL_BINDIR # Libraries: -DCMAKE_INSTALL_LIBDIR # Data files: -DCMAKE_INSTALL_DATADIR # Documentation: -DCMAKE_INSTALL_DOCDIR # Install prefix: -DCMAKE_INSTALL_PREFIX make } ## Incomplete; needs to be reviewed build() { cd "${srcdir}/${pkgname}" || return make -C build if [ -f "barony.x86_64" ] && [ "$(uname -m)" != "x86_64" ]; then mv "barony.x86_64" "barony.$(uname -m)" fi } ## Incomplete; needs work package() { # Desktop entry cp Barony.desktop Barony.desktop.bak sed -i "5c\Exec=/usr/bin/barony.$(uname -m) %U" Barony.desktop sed -i "12c\Path=/usr/bin/" Barony.desktop install -Dm755 Barony.desktop "${pkgdir}/usr/share/applications/Barony.desktop" chmod +x "${pkgdir}/usr/share/applications/Barony.desktop" cd "${srcdir}/${pkgname}" || return ## Needs to be reviewed to make sure it gets packaged correctly # install -dm755 "/usr/bin" install -dm755 "Barony_Icon256x256.png" "/usr/share/pixmaps/" install -dm755 "BaronyEditor_Icon256x256.png" "/usr/share/pixmaps/" install -dm755 ../../Barony.desktop "/usr/share/applications/" mv ../../Barony.desktop.bak ../../Barony.desktop # License mkdir -p "/usr/share/licenses/${pkgname}/" install -Dm644 LICENSE.txt "/usr/share/licenses/${pkgname}/LICENSE.txt" install -Dm644 README-SDL.txt "/usr/share/licenses/${pkgname}/README-SDL.txt" install -Dm644 LICENSE.SDL2_ttf.txt "/usr/share/licenses/${pkgname}/LICENSE.SDL2_ttf.txt" install -Dm644 LICENSE.freetype.txt "/usr/share/licenses/${pkgname}/LICENSE.freetype.txt" install -Dm644 LICENSE.zlib.txt "/usr/share/licenses/${pkgname}/LICENSE.zlib.txt" ## Not complete; needs advice cd build || return make install "${pkgdir}" } ```
WALLOFJUSTICE commented 1 year ago

Hi, building with EOS isn't possible for other users due to restrictions around the SDK.

If you do get a copy the Steamworks SDK, then the build scripts pass something along the lines of export STEAMWORKS_ROOT="../dependencies" export STEAMWORKS_ENABLED=1 to locate the SDK directory when building.

ThisNekoGuy commented 1 year ago

But why the encrypted zip file(s) and are they necessary? If so, where are the encryption keys...?

SheridanR commented 1 year ago

The encrypted zips are necessary because the Epic SDK is under a restrictive license (and originally the Steamworks SDK was too - but it seems to be publicly available now).

In any case, you don't need it to build a DRM-free build.

If I remember correctly, the libs you need to build are: physfs, SDL2, SDL2_image, SDL2_net, SDL2_ttf, libpng (and thus libz), and ... that may be all.

Use cmake to create a project for your preferred environment, and make sure STEAMWORKS_ENABLED and EOS_ENABLED are both false (easy to configure with an IDE, or I think you can pass -DSTEAMWORKS_ENABLED=0 in a terminal). You may need to finagle things a bit further to get it to build, but I'm happy to answer any additional direct questions here.

Lastly: consider if you want to build off of the latest-and-greatest "quality-of-death" beta version (we keep this code in the develop branch) or whether you just want to build off of the "old" master branch that hasn't been updated in a few years. I would recommend the former personally, but it's your choice.

Best of luck.

ThisNekoGuy commented 1 year ago

@SheridanR

In any case, you don't need it to build a DRM-free build.

To be clear, I was under the impression that Steamworks was necessary for multiplayer compatibility with Steam users (since all my friends use Steam)

I would recommend the former personally, but it's your choice.

I'll do that, thanks for letting me know :ok_hand:

ThisNekoGuy commented 1 year ago

Can I get some helping understanding what the STEAMWORKS_INCLUDE_DIR and STEAMWORKS_LIBRARIES variables are supposed to be set to?

This is what I currently have them set to and it's throwing build errors because Clang can't find the Steam API headers for some reason:

if [ "$(uname -m)" == "x86_64" ] || [ "$(uname -m)" == "x86" ] || [ "$(uname -m)" == "i686" ]; then
    export STEAMWORKS_ENABLED=1
    export STEAMWORKS_ROOT="/opt/steamworks-sdk"
    export STEAMWORKS_INCLUDE_DIR="${STEAMWORKS_ROOT}/public/steam/"
    if [ "$(uname -m)" == "x86_64" ]; then
        export STEAMWORKS_LIBRARIES="${STEAMWORKS_ROOT}/public/steam/lib/linux64"
    elif [ "$(uname -m)" == "x86" ] || [ "$(uname -m)" == "i686" ]; then
        export STEAMWORKS_LIBRARIES="${STEAMWORKS_ROOT}/public/steam/lib/linux32"
    fi
else
    export STEAMWORKS_ENABLED=0
fi
SheridanR commented 1 year ago

The include dir should terminate at the public directory, not steam.

ThisNekoGuy commented 1 year ago

For some reason, building without FMODex (INSTALL.md claims FMOD is deprecated?) and with OpenAL throws FMOD errors at build-time?

OpenAL Build Errors: ```make /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:578:7: error: use of undeclared identifier 'splitscreen' if ( splitscreen ) ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1120:27: error: no member named 'release' in 'OPENAL_BUFFER' introductionmusic->release(); ~~~~~~~~~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1121:35: error: member reference type 'int' is not a pointer fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &introductionmusic); //TODO: FMOD_SOFTWARE -> what now? FMOD_2D? FMOD_LOOP_NORMAL? More things? Something else? ~~~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1121:66: error: use of undeclared identifier 'FMOD_2D' fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &introductionmusic); //TODO: FMOD_SOFTWARE -> what now? FMOD_2D? FMOD_LOOP_NORMAL? More things? Something else? ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1127:27: error: no member named 'release' in 'OPENAL_BUFFER' intermissionmusic->release(); ~~~~~~~~~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1128:35: error: member reference type 'int' is not a pointer fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &intermissionmusic); ~~~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1128:66: error: use of undeclared identifier 'FMOD_2D' fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &intermissionmusic); ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1134:23: error: no member named 'release' in 'OPENAL_BUFFER' minetownmusic->release(); ~~~~~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1135:35: error: member reference type 'int' is not a pointer fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &minetownmusic); ~~~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1135:66: error: use of undeclared identifier 'FMOD_2D' fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &minetownmusic); ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1141:21: error: no member named 'release' in 'OPENAL_BUFFER' splashmusic->release(); ~~~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1142:35: error: member reference type 'int' is not a pointer fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &splashmusic); ~~~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1142:66: error: use of undeclared identifier 'FMOD_2D' fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &splashmusic); ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1148:22: error: no member named 'release' in 'OPENAL_BUFFER' librarymusic->release(); ~~~~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1149:35: error: member reference type 'int' is not a pointer fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &librarymusic); ~~~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1149:66: error: use of undeclared identifier 'FMOD_2D' fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &librarymusic); ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1155:19: error: no member named 'release' in 'OPENAL_BUFFER' shopmusic->release(); ~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1156:35: error: member reference type 'int' is not a pointer fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &shopmusic); ~~~~~~~~~~~ ^ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound.cpp:1156:66: error: use of undeclared identifier 'FMOD_2D' fmod_result = fmod_system->createStream(musicDir.c_str(), FMOD_2D, nullptr, &shopmusic); fatal error: too many errors emitted, stopping now [-ferror-limit=] ```

And building with FMODex produces these errors late in the build:

FMODex Build Errors: ```make /mnt/extraStorage/barony/src/Barony/src/engine/audio/init_audio.cpp:51:82: error: too many arguments to function call, expected 4, have 7 fmod_result = fmod_system->getDriverInfo(i, driverName, driverNameLen, &guid, nullptr, nullptr, nullptr); ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~ /mnt/extraStorage/barony/src/Barony/src/engine/audio/init_audio.cpp:65:66: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat] snprintf(guid_string, sizeof(guid_string), "%.8x%.16llx", _1, _2); ~~~~~~~ ^~ %.16lx /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound_game.cpp:180:39: error: cannot initialize a parameter of type 'FMOD_CHANNELINDEX' with an lvalue of type 'FMOD::Sound *' fmod_result = fmod_system->playSound(sounds[snd], sound_group, true, &channel); ^~~~~~~~~~~ /mnt/extraStorage/barony/src/Barony/src/engine/audio/sound_game.cpp:253:39: error: cannot initialize a parameter of type 'FMOD_CHANNELINDEX' with an lvalue of type 'FMOD::Sound *' fmod_result = fmod_system->playSound(sounds[snd], sound_group, true, &channel); ^~~~~~~~~~~ /mnt/extraStorage/barony/src/Barony/src/engine/audio/music.cpp:225:45: error: cannot initialize a parameter of type 'FMOD_CHANNELINDEX' with an lvalue of type 'FMOD::Sound *' fmod_result = fmod_system->playSound(sound, music_group, true, &music_channel); ^~~~~ /mnt/extraStorage/barony/src/Barony/src/engine/audio/music.cpp:235:44: error: cannot initialize a parameter of type 'FMOD_CHANNELINDEX' with an lvalue of type 'FMOD::Sound *' fmod_result = fmod_system->playSound(sound, music_group, true, &music_channel); ^~~~~ ```
ThisNekoGuy commented 1 year ago

Any idea why these are errors? The last CI didn't seem to indicate these were build issues :/

ThisNekoGuy commented 1 year ago

fmod_patches.zip

~~I made 4 FMOD-build patches to try to address the argument errors as much as I could (considering I'm not exactly familiar with this code-base) but linking seems to fail: build.log~~ Seems I needed the fmodstudioapi package from the site; now I get a confusing issue where cmake just doesn't want to believe me where I tell it the include directory is... :woozy_face: So it fails far earlier now and I have no idea what I'm doing wrong:

PKGBUILD: ```sh pkgname=barony pkgver=3.8.6 pkgrel=0 pkgdesc='A first-person roguelike RPG featuring permadeath, hunger, and exploration in procedurally generated dungeons.' arch=('any') url=https://github.com/TurningWheel/${pkgname/b/B} makedepends=('git' 'make' 'cmake' 'sed' 'grep' 'physfs' 'sdl2' 'sdl2_image' 'sdl2_net' 'sdl2_ttf' 'libpng' 'zlib' 'rapidjson' 'steamworks-sdk' 'base-devel' 'clang' 'llvm' 'llvm-libs' 'lld' 'coreutils' 'findutils') depends=('glibc' 'libc++abi' 'libglvnd' 'libvorbis') optdeps=('openal: Enables OpenAL audio back-end (deprecated?)') license=('custom:BaronyOpenSource' 'custom:TheFreeTypeProject' 'zlib' 'MIT:RapidJSON') source=("git+${url}.git" "Barony.desktop") sha256sums=('SKIP' 'de79df4e66f127e16609b33d591f9322b4bb11ae42bc3ace2fa97e400385f46b') options=('!strip' 'staticlibs' 'debug') ## Use this if you prefer opendoas; the benefit here is that doas won't time out on you if you wait too long to authenticate after compilation if [ -f /usr/bin/doas ] && [ -f /etc/doas.conf ]; then PACMAN_AUTH=(doas) fi ##### ----- THIS PACKAGE REQUIRES THAT THE COMMERCIAL GAME'S FOLDERS ARE PRESENT IN THE PKGBUILD DIRECTORY!!! required_files=('sound' 'models' 'maps' 'items' 'images' 'data' 'books' 'music') USE_CLANG=1 STATICALLY_LINK=0 ## This is for detecting your CPU architecture automatically; set to false if you want to enforce your own makepkg.conf file ## Disabled by default as a compromise for those bothered by having it force-enabled ## Note: the resulting package will still be named containing "x86_64" unless the build was done with an "official" Arch distro for that architecture (like Arch ARM - [don't exactly advise using Arch ARM though]) ## or if you manage to trick your Arch installation to accept other architecture extensions by fiddling with the $CARCH variable and /etc/pacman.conf - this method has flaws, namely due to a bug: ## it doesn't work with "makechrootpkg" - though # Valid values are false / disabled / default, auto, and native # "false" means the values for these will respect your /etc/makepkg.conf arch_auto=false if [[ ${arch_auto} == auto ]] then ## Architecture checks and compile flag adjustments - shellcheck throws a fit about the build function but it looks fine to me; checks for the highest available x64 support level and falls back to "native" if either not available if [ "$(uname -m)" == "x86_64" ]; then if [ "$(/lib/ld-linux-x86-64.so.2 --help | grep -w 'x86-64-v4' | cut -d ',' -f 1 | sed 's/^ //' | sed 's/ (/ - /')" == 'x86-64-v4 - supported' ]; then export CFLAGS="-march=x86-64-v4 -mtune=x86-64-v4" export LDFLAGS="-Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now" elif [ "$(/lib/ld-linux-x86-64.so.2 --help | grep -w 'x86-64-v3' | cut -d ',' -f 1 | sed 's/^ //' | sed 's/ (/ - /')" == 'x86-64-v3 - supported' ]; then export CFLAGS="-march=x86-64-v3 -mtune=x86-64-v3" export LDFLAGS="-Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now" elif [ "$(/lib/ld-linux-x86-64.so.2 --help | grep -w 'x86-64-v2' | cut -d ',' -f 1 | sed 's/^ //' | sed 's/ (/ - /')" == 'x86-64-v2 - supported' ]; then export CFLAGS="-march=x86-64-v2 -mtune=x86-64-v2" export LDFLAGS="-Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now" elif [ "$(/lib/ld-linux-x86-64.so.2 --help | grep 'x86_64' | grep 'supported' | cut -d ',' -f 1 | sed 's/^ //' | sed 's/ (/ - /' | grep -w '^x86_64 - supported')" == 'x86_64 - supported' ]; then export CFLAGS="-march=x86-64 -mtune=x86-64" fi elif [ "$(uname -m)" == "aarch64" ]; then export CFLAGS="-march=aarch64 -mtune=aarch64" elif [[ "${arch_auto}" == native ]]; then export CFLAGS="-march=native -mtune=native" if [ "${USE_CLANG}" -eq 0 ]; then export CFLAGS="-mcpu=native ${CFLAGS}" fi fi fi export CFLAGS="-O3 -pipe -fno-plt -pthread -fexceptions \ -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ -fstack-clash-protection -fstack-protector-strong -fcf-protection \ -Wno-invalid-utf8" export CXXFLAGS="${CFLAGS} -Wp,-D_GLIBCXX_ASSERTIONS" export LDFLAGS="-unwind=libunwind -lpthread -Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now" if [ ! ${STATICALLY_LINK} -eq 0 ]; then export LDFLAGS="-static ${LDFLAGS}" fi if [ ! "${USE_CLANG}" -eq 0 ] && [ -f /usr/bin/clang ]; then export CC=clang export CXX=clang++ export LD="" export AR="/usr/bin/llvm-ar" export NM="/usr/bin/llvm-nm" export AS="/usr/bin/llvm-as" export RANLIB="/usr/bin/llvm-ranlib" export STRIP="/usr/bin/llvm-strip" export OBJCOPY="/usr/bin/llvm-objcopy" CLANG_VERSION="$(clang --version | grep 'version' | sed 's|version ||' | cut -f 1 -d ' ' --complement | cut -f 1 -d '.')" if [ "${CLANG_VERSION}" -eq 16 ] || [ "${CLANG_VERSION}" -gt 16 ]; then export CFLAGS="${CFLAGS} -fstrict-flex-arrays" export CXXFLAGS="${CXXFLAGS} -fstrict-flex-arrays" fi export LDFLAGS="-stdlib=libc++ -lc++abi -fuse-ld=lld ${LDFLAGS}" export LTOFLAGS="-flto=full" export DEBUG_CFLAGS="-g" else export CC=gcc export CXX=g++ export LD="" export AR="/usr/bin/gcc-ar" export NM="/usr/bin/gcc-nm" export AS="/usr/bin/as" export RANLIB="/usr/bin/gcc-ranlib" export STRIP="/usr/bin/strip" export OBJCOPY="/usr/bin/objcopy" GCC_VERSION="$(gcc --version | grep '(GCC)' | sed 's|gcc (GCC) ||' | cut -f 1 -d ' ' | cut -f 1 -d '.')" if [ "${GCC_VERSION}" -eq 13 ] || [ "${GCC_VERSION}" -gt 13 ]; then export CFLAGS="${CFLAGS} -fstrict-flex-arrays" export CXXFLAGS="${CXXFLAGS} -fstrict-flex-arrays" fi export LDFLAGS="-stdlib=libstdc++ -lstdc++ -fuse-ld=gold ${LDFLAGS}" export LTOFLAGS="-flto -fuse-linker-plugin" export DEBUG_CFLAGS="-g -fvar-tracking-assignments" fi export DEBUG_CXXFLAGS="${DEBUG_CFLAGS}" if [ "$(uname -m)" == "x86_64" ] || [ "$(uname -m)" == "x86" ] || [ "$(uname -m)" == "i686" ]; then export STEAMWORKS_ENABLED=1 export STEAMWORKS_ROOT="/opt/steamworks-sdk" export STEAMWORKS_INCLUDE_DIR="${STEAMWORKS_ROOT}/public" if [ "$(uname -m)" == "x86_64" ]; then export STEAMWORKS_LIBRARIES="${STEAMWORKS_ROOT}/redistributable_bin/linux64" elif [ "$(uname -m)" == "x86" ] || [ "$(uname -m)" == "i686" ]; then export STEAMWORKS_LIBRARIES="${STEAMWORKS_ROOT}/redistributable_bin/linux32" fi else export STEAMWORKS_ENABLED=0 fi arm32_values=(arm armeb armhf armel armv5 armv6 armv7) is_arm32=false for val in "${arm32_values[@]}"; do if [[ "$(uname -m)" == "${val}"* ]]; then is_arm32=true break fi done if [ "$(uname -m)" == "x86_64" ] || [ "$(uname -m)" == "x86" ] || [ "$(uname -m)" == "i686" ] || [ "$(uname -m)" == "aarch64" ] || [ "${is_arm32}" == "true" ]; then export FMOD_DIR="${srcdir}/../fmodstudioapi20212linux" export FMOD_INCLUDE_DIR="${FMOD_DIR}/api/core/inc" if [ "$(uname -m)" == "x86_64" ]; then export FMOD_LIBRARY="${srcdir}/../fmodstudioapi20212linux/api/core/lib/x86_64/libfmod.so" elif [ "$(uname -m)" == "x86" ] || [ "$(uname -m)" == "i686" ]; then export FMOD_LIBRARY="${srcdir}/../fmodstudioapi20212linux/api/core/lib/x86/libfmod.so" elif [ "$(uname -m)" == "aarch64" ]; then export FMOD_LIBRARY="${srcdir}/../fmodstudioapi20212linux/api/core/lib/arm64/libfmod.so" elif [ "${is_arm32}" == "true" ]; then export FMOD_LIBRARY="${srcdir}/../fmodstudioapi20212linux/api/core/lib/arm/libfmod.so" fi export FMOD_ENABLED=ON export OPENAL_ENABLED=OFF else export FMOD_ENABLED=OFF export OPENAL_ENABLED=ON fi export EDITOR_ENABLED=1 export GAME_ENABLED=1 export INSTALL_DATADIR="/usr/local/barony" export INSTALL_LIBDIR="/usr/local/barony/lib" prepare() { ## Official game files are supposedly needed in this directory to build/use the open-source project for folder in "${required_files[@]}"; do if [ ! -d "${srcdir}/../${folder}" ]; then echo "ERROR: Required game files for \"${folder}\" are not present in PKGBUILD directory" exit 1 fi done cd "${srcdir}/${pkgname/b/B}" || return # CURRENT_CLONED_VERSION="$(git describe --tags)" # if [ "${CURRENT_CLONED_VERSION}" != "${pkgver}" ]; then # cd .. # rm -rf "${pkgname/b/B}" # git clone --depth=1 --branch=${pkgver} "${url}" "${pkgname/b/B}" # cd "${pkgname/b/B}" || return # else # rm -f .git/index.lock # git fetch --depth=1 origin tag ${pkgver} # git reset --hard ${pkgver} # fi git checkout develop git reset --hard @{upstream} ## EOS builds by 3rd parties (in this case - this open-source project) is prohibited when the original proprietary party accepted Epic's legal agreement(s) ## Therefore, EOS must be disabled to build cmake -B build -G "Unix Makefiles" \ -DCMAKE_BUILD_TYPE=Release \ -DOPTIMIZATION_LEVEL="-O3" \ -DCMAKE_C_FLAGS_RELEASE="${CFLAGS}" \ -DCMAKE_CXX_FLAGS_RELEASE="${CXXFLAGS}" \ -DCMAKE_C_FLAGS_DEBUG="${DEBUG_CFLAGS}" \ -DCMAKE_CXX_FLAGS_DEBUG="${DEBUG_CXXFLAGS}" \ -DGAME_ENABLED=${GAME_ENABLED} \ -DEDITOR_ENABLED=${EDITOR_ENABLED} \ -DFMOD_ENABLED="${FMOD_ENABLED}" \ -DFMOD_INCLUDE_DIR="${FMOD_INCLUDE_DIR}" \ -DFMOD_LIBRARY="${FMOD_LIBRARY}" \ -DOPENAL_ENABLED="${OPENAL_ENABLED}" \ -DOpenGL_GL_PREFERENCE="GLVND" \ -DSTEAMWORKS_ENABLED="${STEAMWORKS_ENABLED}" \ -DSTEAMWORKS_INCLUDE_DIR="${STEAMWORKS_INCLUDE_DIR}" \ -DSTEAMWORKS_LIBRARIES="${STEAMWORKS_LIBRARIES}" \ -DEOS_ENABLED=0 \ -DCMAKE_INSTALL_BINDIR="/usr/bin" \ -DCMAKE_INSTALL_LIBDIR="${INSTALL_LIBDIR}" \ -DCMAKE_INSTALL_DATADIR="${INSTALL_DATADIR}" \ -DCMAKE_INSTALL_PREFIX="${pkgdir}" ## cmake values we should use? # Binaries: -DCMAKE_INSTALL_BINDIR # Libraries: -DCMAKE_INSTALL_LIBDIR # Data files: -DCMAKE_INSTALL_DATADIR # Documentation: -DCMAKE_INSTALL_DOCDIR # Install prefix: -DCMAKE_INSTALL_PREFIX } build() { cd "${srcdir}/${pkgname/b/B}" || return make -C build cd "${srcdir}/${pkgname/b/B}/build" || return if [ -f "barony.x86_64" ] && [ "$(uname -m)" != "x86_64" ]; then mv "barony.x86_64" "barony.$(uname -m)" if [ -f "editor.x86_64" ]; then mv "editor.x86_64" "barony-editor.$(uname -m)" fi fi } ## Incomplete; needs work? package() { ## Not complete; needs advice cd "${srcdir}/${pkgname/b/B}" || return make install chown -R 755 "${pkgdir}" if [ ! -f "${pkgdir}${INSTALL_LIBDIR}libsteam_api.so" ]; then if [ "$(uname -m)" == "x86_64" ]; then install -dm755 "${STEAMWORKS_ROOT}/redistributable_bin/linux64/libsteam_api.so" "${pkgdir}${INSTALL_LIBDIR}" elif [ "$(uname -m)" == "x86" ] || [ "$(uname -m)" == "i686" ]; then install -dm755 "${STEAMWORKS_ROOT}/redistributable_bin/linux32/libsteam_api.so" "${pkgdir}${INSTALL_LIBDIR}" fi fi ln -s "${pkgdir}/usr/bin/barony.$(uname -m)" "${pkgdir}/usr/bin/barony" ln -s "${pkgdir}/usr/bin/barony-editor.$(uname -m)" "${pkgdir}/usr/bin/barony-editor" # Desktop entry cd "${srcdir}/.." || return cp Barony.desktop Barony.desktop.bak sed -i "5c\Exec=/usr/bin/barony.$(uname -m) %U" Barony.desktop sed -i "8c\Icon=/usr/share/pixmaps/Barony_Icon256x256.png" Barony.desktop sed -i "12c\Path=/usr/bin/" Barony.desktop cp Barony.desktop Barony-Editor.desktop sed -i "3c\Comment[en_US]=Map Editor for a First-Person Dungeon-Crawling Roguelike" Barony-Editor.desktop sed -i "4c\Comment=Map Editor for a First-Person Dungeon-Crawling Roguelike" Barony-Editor.desktop sed -i "5c\Exec=/usr/bin/barony-editor.$(uname -m) %U" Barony-Editor.desktop sed -i "6c\GenericName[en_US]=Map Editor" Barony-Editor.desktop sed -i "7c\GenericName=Map Editor" Barony-Editor.desktop sed -i "8c\Icon=/usr/share/pixmaps/BaronyEditor_Icon256x256.png" Barony-Editor.desktop sed -i "10c\Name[en_US]=Barony Map Editor" Barony-Editor.desktop sed -i "11c\Name=Barony Map Editor" Barony-Editor.desktop install -Dm755 Barony.desktop "${pkgdir}/usr/share/applications/" install -Dm755 Barony-Editor.desktop "${pkgdir}/usr/share/applications/" chmod +x "${pkgdir}/usr/share/applications/Barony.desktop" chmod +x "${pkgdir}/usr/share/applications/Barony-Editor.desktop" cd "${srcdir}/${pkgname/b/B}" || return install -dm755 "Barony_Icon256x256.png" "/usr/share/pixmaps/" install -dm755 "BaronyEditor_Icon256x256.png" "/usr/share/pixmaps/" mv ../../Barony.desktop.bak ../../Barony.desktop rm ../../Barony-Editor.desktop install -dm757 playernames-male.txt "${INSTALL_DATADIR}" install -dm757 playernames-female.txt "${INSTALL_DATADIR}" install -dm755 gamecontrollerdb.txt "${INSTALL_DATADIR}" install -dm755 EDITING.txt "${INSTALL_DATADIR}" # Licenses mkdir -p "${pkgdir}/usr/share/licenses/${pkgname}/" install -Dm644 LICENSE.txt "/usr/share/licenses/${pkgname}/LICENSE.txt" install -Dm644 README-SDL.txt "/usr/share/licenses/${pkgname}/README-SDL.txt" install -Dm644 LICENSE.SDL2_ttf.txt "/usr/share/licenses/${pkgname}/LICENSE.SDL2_ttf.txt" install -Dm644 LICENSE.freetype.txt "/usr/share/licenses/${pkgname}/LICENSE.freetype.txt" install -Dm644 LICENSE.zlib.txt "/usr/share/licenses/${pkgname}/LICENSE.zlib.txt" # Move required game files for folder in "${required_files[@]}"; do mv "${srcdir}/../${folder}" "${pkgdir}${INSTALL_DATADIR}" || return done } ```

As for the OpenAL build errors, I imagine what's needed to fix them might be a bit more substancial... I'm not sure when these errors were introduced though, given that I thought that it's supposed to be the same build "tag" (if there was one) as 3.8.6 and the Steam version obviously doesn't lack audio :/

ThisNekoGuy commented 1 year ago

@WALLOFJUSTICE The export and cmake values are correctly set, so I don't see why it wouldn't find fmod.hpp?

damiencarol commented 9 months ago

Faced the same errors and was able to compile in the end with some modifications.

1) compiled without sound by modifying a little bit CMake files and few lines in the source code, I'm testing it by doing real runs, pushing a PR to enable this https://github.com/TurningWheel/Barony/pull/823 2) Tested to compile with OpenAL, it's broken today sadly, 3) will try to get FMOD and try with it

@WALLOFJUSTICE @ThisNekoGuy would appreciate feedback on the PR.