cmake-wasm.yml 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. name: CMake WebAssembly
  2. on:
  3. push:
  4. branches: [ "master" ]
  5. pull_request:
  6. branches: [ "master" ]
  7. env:
  8. wasmtime_version: v7.0.0
  9. wasmer_version: v3.1.1
  10. jobs:
  11. build_wasi_sdk:
  12. strategy:
  13. matrix:
  14. BUILD_TYPE: [Release, Debug, RelWithDebInfo, MinSizeRel]
  15. C_FLAGS: ['', '-msimd128']
  16. wasi_sdk_version: [19, 20]
  17. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  18. # You can convert this to a matrix build if you need cross-platform coverage.
  19. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  20. runs-on: ubuntu-latest
  21. steps:
  22. - uses: actions/checkout@v4
  23. - name: Downloading wasi-sdk
  24. run: |
  25. cd ${{github.workspace}}
  26. wget --no-verbose https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{matrix.wasi_sdk_version}}/wasi-sdk-${{matrix.wasi_sdk_version}}.0-linux.tar.gz
  27. tar xf wasi-sdk-${{matrix.wasi_sdk_version}}.0-linux.tar.gz
  28. - name: Configure CMake
  29. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  30. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  31. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} -DCMAKE_C_FLAGS="${{matrix.C_FLAGS}}" -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/wasi-sdk-${{matrix.wasi_sdk_version}}.0/share/cmake/wasi-sdk.cmake -DWASI_SDK_PREFIX=${{github.workspace}}/wasi-sdk-${{matrix.wasi_sdk_version}}.0 -DCGLM_USE_TEST=ON
  32. - name: Build
  33. # Build your program with the given configuration
  34. run: cmake --build ${{github.workspace}}/build --config ${{matrix.BUILD_TYPE}}
  35. - name: Test with wasmtime
  36. run: |
  37. cd ${{github.workspace}}
  38. ls -lh ${{github.workspace}}/build/
  39. wget --no-verbose https://github.com/bytecodealliance/wasmtime/releases/download/${{env.wasmtime_version}}/wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
  40. tar xf wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
  41. ./wasmtime-${{env.wasmtime_version}}-x86_64-linux/wasmtime run --wasm-features simd ${{github.workspace}}/build/tests
  42. - name: Test with wasmer
  43. run: |
  44. cd ${{github.workspace}}
  45. mkdir wasmer
  46. cd wasmer
  47. wget --no-verbose https://github.com/wasmerio/wasmer/releases/download/${{env.wasmer_version}}/wasmer-linux-amd64.tar.gz
  48. tar xf wasmer-linux-amd64.tar.gz
  49. ./bin/wasmer run --enable-simd ${{github.workspace}}/build/tests
  50. build_emsdk:
  51. strategy:
  52. matrix:
  53. BUILD_TYPE: [Release, Debug, RelWithDebInfo, MinSizeRel]
  54. C_FLAGS: ['', '-msimd128', '-msse -msse2 -msimd128', '-msse -msse2 -msse3 -msse4 -msimd128']
  55. runs-on: ubuntu-latest
  56. steps:
  57. - uses: actions/checkout@v4
  58. - name: Setup emsdk
  59. uses: mymindstorm/setup-emsdk@v12
  60. - name: Verify emsdk
  61. run: emcc -v
  62. - name: Configure CMake
  63. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  64. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  65. run: emcmake cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} -DCMAKE_C_FLAGS="${{matrix.C_FLAGS}}" -DCMAKE_EXE_LINKER_FLAGS="-s STANDALONE_WASM" -DCGLM_STATIC=ON -DCGLM_USE_TEST=ON
  66. - name: Build
  67. # Build your program with the given configuration
  68. run: cmake --build ${{github.workspace}}/build --config ${{matrix.BUILD_TYPE}}
  69. - name: Test with wasmtime
  70. run: |
  71. cd ${{github.workspace}}
  72. ls -lh ${{github.workspace}}/build/
  73. wget --no-verbose https://github.com/bytecodealliance/wasmtime/releases/download/${{env.wasmtime_version}}/wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
  74. tar xf wasmtime-${{env.wasmtime_version}}-x86_64-linux.tar.xz
  75. ./wasmtime-${{env.wasmtime_version}}-x86_64-linux/wasmtime run --wasm-features simd ${{github.workspace}}/build/tests.wasm
  76. - name: Test with wasmer
  77. run: |
  78. cd ${{github.workspace}}
  79. mkdir wasmer
  80. cd wasmer
  81. wget --no-verbose https://github.com/wasmerio/wasmer/releases/download/${{env.wasmer_version}}/wasmer-linux-amd64.tar.gz
  82. tar xf wasmer-linux-amd64.tar.gz
  83. ./bin/wasmer run --enable-simd ${{github.workspace}}/build/tests.wasm