patch.lua 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. function _unsafe_patch(package)
  2. if package:is_plat("macosx") then
  3. io.replace("CMakeLists.txt", [[set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")]], "", {plain = true})
  4. io.replace("CMakeLists.txt", [[set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")]], "", {plain = true})
  5. end
  6. -- clang unsupported this flag https://github.com/llvm/llvm-project/issues/25059
  7. -- and build failed on ubuntu with libstdc++-13
  8. io.replace("CMakeLists.txt", "add_compile_options(-fabi-version=6)", "", {plain = true})
  9. end
  10. function main(package)
  11. if package:config("abi") then
  12. _unsafe_patch(package)
  13. end
  14. if package:is_plat("windows") and package:is_arch("arm64") then
  15. -- https://github.com/microsoft/vcpkg/blob/218f0d9ad10eb7b56624d3a6de5ad7a44bdf2927/ports/steam-audio/fix-arm64-windows.patch
  16. io.replace("CMakeLists.txt", "set(IPL_CPU_X64 TRUE)", "set(IPL_CPU_ARMV8 TRUE)", {plain = true})
  17. end
  18. if package:is_cross() then
  19. io.replace("CMakeLists.txt", "add_compile_options(-m32 -mfpmath=sse -march=native)", "", {plain = true})
  20. end
  21. if package:is_plat("mingw", "msys") then
  22. io.replace("CMakeLists.txt", "# Windows flags\nif (IPL_OS_WINDOWS)", "if(0)", {plain = true})
  23. else
  24. -- remove ucrt hardcode
  25. io.replace("CMakeLists.txt", "$<$<AND:$<CONFIG:Debug>,$<BOOL:${STEAMAUDIO_STATIC_RUNTIME}>>:/MTd>", "", {plain = true})
  26. io.replace("CMakeLists.txt", "$<$<AND:$<CONFIG:Debug>,$<NOT:$<BOOL:${STEAMAUDIO_STATIC_RUNTIME}>>>:/MDd>", "", {plain = true})
  27. io.replace("CMakeLists.txt", "$<$<AND:$<NOT:$<CONFIG:Debug>>,$<BOOL:${STEAMAUDIO_STATIC_RUNTIME}>>:/MT>", "", {plain = true})
  28. io.replace("CMakeLists.txt", "$<$<AND:$<NOT:$<CONFIG:Debug>>,$<NOT:$<BOOL:${STEAMAUDIO_STATIC_RUNTIME}>>>:/MD>", "", {plain = true})
  29. io.replace("CMakeLists.txt", "$<IF:$<CONFIG:Debug>,_DEBUG,NDEBUG>", "", {plain = true})
  30. -- remove lto hardcode
  31. io.replace("CMakeLists.txt", "$<$<CONFIG:Release>:/GL>", "", {plain = true})
  32. end
  33. -- remove zlib hardcode
  34. io.replace("build/FindMySOFA.cmake", "set(ZLIB_ROOT ${CMAKE_HOME_DIRECTORY}/deps/zlib/lib/${IPL_BIN_SUBDIR}/release)", "", {plain = true})
  35. io.replace("build/FindMySOFA.cmake", "set(ZLIB_INCLUDE_DIR ${CMAKE_HOME_DIRECTORY}/deps/zlib/include)", "", {plain = true})
  36. -- https://github.com/ValveSoftware/steam-audio/pull/399
  37. io.replace("src/core/profiler.h", [[#include "memory_allocator.h"]], [[
  38. #include "memory_allocator.h"
  39. #include <chrono>
  40. ]], {plain = true})
  41. io.replace("src/core/CMakeLists.txt", "get_bin_subdir(IPL_BIN_SUBDIR)", "set(IPL_BIN_SUBDIR )", {plain = true})
  42. -- remove symbol install command
  43. io.replace("src/core/CMakeLists.txt",
  44. [[ install(
  45. FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/phonon.pdb
  46. DESTINATION symbols/${IPL_BIN_SUBDIR}
  47. )]], "", {plain = true})
  48. io.replace("src/core/CMakeLists.txt",
  49. [[ install(
  50. FILES ${CMAKE_CURRENT_BINARY_DIR}/libphonon.so.dbg
  51. DESTINATION symbols/${IPL_BIN_SUBDIR}
  52. )]], "", {plain = true})
  53. -- remove deps dll install command
  54. io.replace("src/core/CMakeLists.txt",
  55. [[ install(
  56. FILES ${CMAKE_HOME_DIRECTORY}/deps/trueaudionext/bin/windows-x64/$<LOWER_CASE:$<CONFIG>>/TrueAudioNext.dll
  57. ${CMAKE_HOME_DIRECTORY}/deps/trueaudionext/bin/windows-x64/$<LOWER_CASE:$<CONFIG>>/GPUUtilities.dll
  58. DESTINATION lib/${IPL_BIN_SUBDIR}
  59. )]], "", {plain = true})
  60. end