AppImage-build-debian-inner.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #! /bin/bash
  2. set -e
  3. # Make sure script is called from inside our container
  4. test -e /tmp/torzu-src-ro || (echo "Script MUST NOT be called directly!" ; exit 1)
  5. # Set up environment
  6. export LANG=C.UTF-8
  7. export LC_ALL=C.UTF-8
  8. unset LC_ADDRESS LC_NAME LC_MONETARY LC_PAPER LC_TELEPHONE LC_MEASUREMENT LC_TIME
  9. # Raise max open files count
  10. ulimit -n 50000
  11. # Install dependencies
  12. apt -y install cmake ninja-build build-essential autoconf pkg-config locales wget git file mold libtool lsb-release wget software-properties-common gnupg \
  13. qtbase5-dev qtmultimedia5-dev qtbase5-private-dev glslang-tools libssl-dev libavcodec-dev libavfilter-dev libavutil-dev libswscale-dev libpulse-dev libasound2-dev
  14. if [ ! "$BUILD_USE_CPM" = 1 ]; then
  15. apt -y install libfmt-dev libenet-dev liblz4-dev nlohmann-json3-dev zlib1g-dev libopus-dev libsimpleini-dev libstb-dev libzstd-dev libusb-1.0-0-dev libcubeb-dev libcpp-jwt-dev libvulkan-dev gamemode-dev libasound2-dev libglu1-mesa-dev libxext-dev mesa-common-dev libva-dev
  16. if [ ! -f /usr/local/lib/cmake/Boost-1.88.0/BoostConfigVersion.cmake ]; then
  17. # Install Boost
  18. wget https://archives.boost.io/release/1.88.0/source/boost_1_88_0.tar.bz2
  19. echo "Extracting Boost sources..."
  20. tar xf boost_1_88_0.tar.bz2
  21. cd boost_1_88_0
  22. ./bootstrap.sh
  23. ./b2 install --with-{headers,context,system,fiber,atomic,filesystem} link=static
  24. cd ..
  25. rm -rf boost_1_88_0 boost_1_88_0.tar.bz2
  26. fi
  27. fi
  28. # Install Clang
  29. if ([ "$BUILD_USE_CLANG" = 1 ] && ! clang-19 --version); then
  30. cd /tmp
  31. wget https://apt.llvm.org/llvm.sh
  32. chmod +x llvm.sh
  33. ./llvm.sh 19
  34. rm llvm.sh
  35. fi
  36. # Mount Torzu sources with temporary overlay
  37. cd /tmp
  38. mkdir torzu-src-upper torzu-src-work torzu-src
  39. mount -t overlay overlay -olowerdir=torzu-src-ro,upperdir=torzu-src-upper,workdir=torzu-src-work torzu-src
  40. # Get extra configuration/compilation options
  41. EXTRA_COMPILE_FLAGS=""
  42. EXTRA_CMAKE_FLAGS=""
  43. if [ "$BUILD_USE_CLANG" = 1 ]; then
  44. EXTRA_CMAKE_FLAGS="-DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19"
  45. FATLTO_FLAG="-flto=full"
  46. else
  47. FATLTO_FLAG="-flto"
  48. fi
  49. if [ "$BUILD_USE_THIN_LTO" = 1 ]; then
  50. EXTRA_COMPILE_FLAGS="-flto=thin"
  51. fi
  52. if [ "$BUILD_USE_FAT_LTO" = 1 ]; then
  53. EXTRA_COMPILE_FLAGS="$FATLTO_FLAG"
  54. fi
  55. if [ "$BUILD_USE_CPM" = 1 ]; then
  56. EXTRA_CMAKE_FLAGS="$EXTRA_CMAKE_FLAGS -DYUZU_USE_CPM=ON"
  57. fi
  58. # Build Torzu
  59. cd /tmp
  60. mkdir torzu-build
  61. cd torzu-build
  62. cmake /tmp/torzu-src -GNinja -DCMAKE_BUILD_TYPE=Release -DYUZU_TESTS=OFF -DENABLE_QT_TRANSLATION=OFF -DSPIRV_WERROR=OFF -DCMAKE_FIND_LIBRARY_SUFFIXES=".a;.so" -DSPIRV-Headers_SOURCE_DIR=/tmp/torzu-src/externals/SPIRV-Headers -DCMAKE_{C,CXX}_FLAGS="$EXTRA_COMPILE_FLAGS -fdata-sections -ffunction-sections" -DCMAKE_{EXE,SHARED}_LINKER_FLAGS="-Wl,--gc-sections" $EXTRA_CMAKE_FLAGS
  63. ninja || (
  64. echo "Compilation has failed. Dropping you into a shell so you can inspect the situation. Run 'ninja' to retry and exit shell once compilation has finished successfully."
  65. echo "Note that any changes made here will not be reflected to the host environment, but changes made from the host environment will be reflected here."
  66. bash
  67. )
  68. # Generate AppImage
  69. cp -rv /tmp/torzu-src/AppImageBuilder /tmp/AppImageBuilder
  70. cd /tmp/AppImageBuilder
  71. ./build.sh /tmp/torzu-build /tmp/torzu.AppImage || echo "This error is known. Using workaround..."
  72. cp /lib/$(uname -m)-linux-gnu/libICE.so.6 build/
  73. mv build /tmp/hosttmp/torzu-debian-appimage-rootfs