wasm.yml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. # SuperTux
  2. # Copyright (C) 2020-2021 Jacob Burroughs <maths22@gmail.com>
  3. # 2020-2022 A. Semphris <semphris@protonmail.com>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. name: WebAssembly
  18. on:
  19. push:
  20. branches:
  21. - master
  22. tags:
  23. - '*'
  24. pull_request: {}
  25. jobs:
  26. wasm:
  27. strategy:
  28. fail-fast: false
  29. matrix:
  30. build_type: ["Release", "Debug"]
  31. runs-on: ubuntu-20.04
  32. steps:
  33. - uses: actions/checkout@v2
  34. with:
  35. # Fetch the whole tree so git describe works
  36. fetch-depth: 0
  37. submodules: true
  38. - name: Install emscripten tools
  39. run: |
  40. cd ~
  41. sudo apt-get update
  42. sudo apt-get install -y git cmake build-essential curl zip
  43. git clone https://github.com/emscripten-core/emsdk.git
  44. cd emsdk
  45. ./emsdk install 1.40.1
  46. ./emsdk activate 1.40.1
  47. # Fixes a bug in emscripten - see https://github.com/emscripten-core/emscripten/issues/13590
  48. sed -i "s/\#define MALLOC_ALIGNMENT ((size_t)(2 \* sizeof(void \*)))/#define MALLOC_ALIGNMENT 16/g" upstream/emscripten/system/lib/dlmalloc.c
  49. # Fixes a bug with the libjpeg port - see https://github.com/emscripten-core/emscripten/pull/13878
  50. sed -i 's/2b581c60ae401a79bbbe748ff2deeda5acd50bfd2ea22e5926e36d34b9ebcffb6580b0ff48e972c1441583e30e21e1ea821ca0423f9c67ce08a31dffabdbe6b7/b2affe9a1688bd49fc033f4682c4a242d4ee612f1affaef532f5adcb4602efc4433c4a52a4b3d69e7440ff1f6413b1b041b419bc90efd6d697999961a9a6afb7/g' upstream/emscripten/tools/ports/libjpeg.py
  51. sed -i 's/https:\/\/dl.bintray.com\/homebrew\/mirror\/jpeg-9c.tar.gz/https:\/\/storage.googleapis.com\/webassembly\/emscripten-ports\/jpegsrc.v9c.tar.gz/g' upstream/emscripten/tools/ports/libjpeg.py
  52. - name: Install vcpkg and dependencies
  53. run: |
  54. source ~/emsdk/emsdk_env.sh
  55. cd ~
  56. git clone https://github.com/microsoft/vcpkg
  57. ./vcpkg/bootstrap-vcpkg.sh
  58. ./vcpkg/vcpkg integrate install
  59. ./vcpkg/vcpkg install boost-date-time:wasm32-emscripten
  60. ./vcpkg/vcpkg install boost-filesystem:wasm32-emscripten
  61. ./vcpkg/vcpkg install boost-format:wasm32-emscripten
  62. ./vcpkg/vcpkg install boost-locale:wasm32-emscripten
  63. ./vcpkg/vcpkg install boost-optional:wasm32-emscripten
  64. ./vcpkg/vcpkg install boost-system:wasm32-emscripten
  65. ./vcpkg/vcpkg install glbinding:wasm32-emscripten
  66. ./vcpkg/vcpkg install libpng:wasm32-emscripten
  67. ./vcpkg/vcpkg install libogg:wasm32-emscripten
  68. ./vcpkg/vcpkg install libvorbis:wasm32-emscripten
  69. ./vcpkg/vcpkg install glm:wasm32-emscripten
  70. ./vcpkg/vcpkg install zlib:wasm32-emscripten
  71. - name: Patch SDL_ttf
  72. working-directory: external/SDL_ttf
  73. run: git apply ../../mk/emscripten/SDL_ttf.patch
  74. - name: Configure build
  75. env:
  76. BUILD_TYPE: ${{ matrix.build_type }}
  77. run: |
  78. source ~/emsdk/emsdk_env.sh
  79. mkdir build
  80. cd build
  81. emcmake cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_OPENGLES2=ON \
  82. -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake\
  83. -DVCPKG_TARGET_TRIPLET=wasm32-emscripten -DGLBINDING_ENABLED=ON\
  84. -DEMSCRIPTEN=1 -DWARNINGS=ON -DWERROR=ON ..
  85. - name: Sync data folder
  86. working-directory: build
  87. run: |
  88. rsync -aP ../data/ data/
  89. - name: Build
  90. working-directory: build
  91. run: |
  92. source ~/emsdk/emsdk_env.sh
  93. emmake make -j$(nproc)
  94. # Now you can run a local server with: `emrun supertux2.html`
  95. # Or any traditional web server will do the job
  96. # Note: opening the html file manually (file:///) won't work
  97. - name: Setup files for upload
  98. working-directory: build
  99. env:
  100. BUILD_TYPE: ${{ matrix.build_type }}
  101. run: |
  102. rm supertux2.html && cp template.html supertux2.html
  103. mkdir upload/
  104. mv supertux2* upload/
  105. - uses: actions/upload-artifact@v2
  106. with:
  107. name: "wasm32-emscripten-${{ matrix.build_type }}-html"
  108. path: build/upload/*
  109. if-no-files-found: ignore
  110. - name: Upload to server
  111. if: ${{ github.ref == 'refs/heads/master' && matrix.build_type == 'Release' }}
  112. env:
  113. UPLOAD_URL: ${{ secrets.UPLOAD_URL }}
  114. run: |
  115. cd build/upload/
  116. mv supertux2.html index.html
  117. zip supertux2.zip *
  118. curl -F "archive=@$(pwd)/supertux2.zip" -F "message=$(git log --format=%B -n 1 | head -1)" $UPLOAD_URL