diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml new file mode 100644 index 000000000..fd923d18d --- /dev/null +++ b/.github/workflows/wasm.yml @@ -0,0 +1,24 @@ +name: wasm +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: emscripten-core/emsdk + path: extern/emsdk + - name: Build + run: | + ./build-utils/em-build.sh + - name: Uploads artifacts + uses: actions/upload-artifact@v4 + with: + name: samples + path: | + build-wasm/samples/**/*.html + build-wasm/samples/**/*.js + build-wasm/samples/**/*.wasm diff --git a/CHANGES.md b/CHANGES.md index ef43f8dbd..a037b7fdc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +Next release +---------------------- + +* Build pipeline + - Adds CI for WebAssembly. + Release version 0.14.3 ---------------------- diff --git a/README.md b/README.md index 8d0a8a468..e1688cec3 100644 --- a/README.md +++ b/README.md @@ -18,17 +18,17 @@ Documentation and samples are available from [ozz-animation website](http://guil Supported platforms ------------------- -Ozz is tested on Linux, Mac OS and Windows, for x86, x86-64 and ARM architectures. The run-time code (ozz_base, ozz_animation, ozz_geometry) depends only on c++11, on the C and the C++ standard libraries, and has no OS specific code. Portability to any other platform shouldn't be an issue. +ozz-animation is tested on WebAssembly, Linux, macOS and Windows, for x86, x86-64 and ARM architectures. The run-time code (ozz_base, ozz_animation, ozz_geometry) depends only on c++11, on the C and the C++ standard libraries, and has no OS specific code. Portability to any other platform shouldn't be an issue. Samples, tools and tests depend on external libraries (glfw, tinygltf, Fbx SDK, jsoncpp, gtest, ...), which could limit portability. Build status ------------ -| | Linux | macOS | Windows | -| ------- | ------ | ------ | ------- | -| master | [![Linux](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml) | [![macOS](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml) | [![Windows](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml) | -| develop | [![Linux](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml) | [![macOS](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml) | [![Windows](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml) | +| | Linux | macOS | Windows | WebAssembly | +| ------- | ------ | ------ | ------- | ------- | +| master | [![Linux](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml) | [![macOS](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml) | [![Windows](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml) | [![WASM](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/wasm.yml/badge.svg?branch=master)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/wasm.yml) | +| develop | [![Linux](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/linux.yml) | [![macOS](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/macos.yml) | [![Windows](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/windows.yml) | [![WASM](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/wasm.yml/badge.svg?branch=develop)](https://github.com/guillaumeblanc/ozz-animation/actions/workflows/wasm.yml) | The dashboard for all branches is available [here](http://guillaumeblanc.github.io/ozz-animation/documentation/dashboard/). diff --git a/build-utils/em-build.sh b/build-utils/em-build.sh new file mode 100755 index 000000000..8ce1ba3b6 --- /dev/null +++ b/build-utils/em-build.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Setup emscripten +cd extern/emsdk +./emsdk install latest +./emsdk activate latest +source ./emsdk_env.sh +cd ../.. + + +# Setup cmake +mkdir build-wasm +cd build-wasm + +if [[ $# -eq 0 ]] ; then + emcmake cmake -DCMAKE_BUILD_TYPE=Release .. +else + emcmake cmake -DCMAKE_BUILD_TYPE=$1 .. +fi + +# Build +cmake --build . diff --git a/samples/framework/CMakeLists.txt b/samples/framework/CMakeLists.txt index cf0f361d4..98d81f8da 100644 --- a/samples/framework/CMakeLists.txt +++ b/samples/framework/CMakeLists.txt @@ -30,6 +30,8 @@ add_library(sample_framework STATIC if(NOT EMSCRIPTEN) add_subdirectory(${PROJECT_SOURCE_DIR}/extern/glfw glfw) target_link_libraries(sample_framework glfw) +else() + target_link_options(sample_framework PUBLIC -sUSE_GLFW=2) endif() target_link_libraries(sample_framework diff --git a/samples/framework/application.cc b/samples/framework/application.cc index a5c155a0d..43dfc57d7 100644 --- a/samples/framework/application.cc +++ b/samples/framework/application.cc @@ -278,7 +278,7 @@ Application::LoopStatus Application::OneLoop(int _loops) { } #else int width, height; - if (emscripten_get_canvas_element_size(nullptr, &width, &height) != + if (emscripten_get_canvas_element_size("#canvas", &width, &height) != EMSCRIPTEN_RESULT_SUCCESS) { return kBreakFailure; }