Wasm #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: wasm | |
# on: pull_request | |
on: | |
push: | |
tags: | |
- '*' | |
pull_request: | |
branches: ["main"] | |
env: | |
EMSCRIPTEN_VERSION: 3.1.69 | |
OPENCV_SUBDIR: lib/cmake/opencv4 | |
jobs: | |
webassembly: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
opencv-version: [4.10.0] | |
env: | |
SOURCE_DIR: ${{ github.workspace}}/opencv-${{ matrix.opencv-version }} | |
CONTRIB_SOURCE_DIR: ${{ github.workspace}}/opencv_contrib-${{ matrix.opencv-version }} | |
PACKAGE_NAME: libopencv-webassembly | |
COMMON_CMAKE_OPTIONS: | | |
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace}}/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ | |
-DCMAKE_INSTALL_PREFIX=install \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DENABLE_PIC=FALSE \ | |
-DCPU_DISPATCH='' \ | |
-DCV_TRACE=OFF \ | |
-DBUILD_SHARED_LIBS=OFF \ | |
-DWITH_1394=OFF \ | |
-DWITH_ADE=OFF \ | |
-DWITH_VTK=OFF \ | |
-DWITH_EIGEN=OFF \ | |
-DWITH_FFMPEG=OFF \ | |
-DWITH_GSTREAMER=OFF \ | |
-DWITH_GTK=OFF \ | |
-DWITH_GTK_2_X=OFF \ | |
-DWITH_IPP=OFF \ | |
-DWITH_JASPER=OFF \ | |
-DWITH_JPEG=ON \ | |
-DWITH_WEBP=ON \ | |
-DWITH_OPENEXR=OFF \ | |
-DWITH_OPENGL=OFF \ | |
-DWITH_OPENVX=OFF \ | |
-DWITH_OPENNI=OFF \ | |
-DWITH_OPENNI2=OFF \ | |
-DWITH_PNG=ON \ | |
-DWITH_TBB=OFF \ | |
-DWITH_TIFF=OFF \ | |
-DWITH_V4L=OFF \ | |
-DWITH_OPENCL=OFF \ | |
-DWITH_OPENCL_SVM=OFF \ | |
-DWITH_OPENCLAMDFFT=OFF \ | |
-DWITH_OPENCLAMDBLAS=OFF \ | |
-DWITH_GPHOTO2=OFF \ | |
-DWITH_LAPACK=OFF \ | |
-DWITH_ITT=OFF \ | |
-DWITH_QUIRC=OFF \ | |
-DWITH_VULKAN=OFF \ | |
-DBUILD_ZLIB=ON \ | |
-DBUILD_opencv_apps=OFF \ | |
-DBUILD_opencv_calib3d=ON \ | |
-DBUILD_opencv_dnn=ON \ | |
-DBUILD_opencv_features2d=ON \ | |
-DBUILD_opencv_flann=ON \ | |
-DBUILD_opencv_gapi=ON \ | |
-DBUILD_opencv_ml=ON \ | |
-DBUILD_opencv_photo=ON \ | |
-DBUILD_opencv_imgcodecs=ON \ | |
-DBUILD_opencv_shape=OFF \ | |
-DBUILD_opencv_videoio=OFF \ | |
-DBUILD_opencv_videostab=OFF \ | |
-DBUILD_opencv_highgui=OFF \ | |
-DBUILD_opencv_superres=ON \ | |
-DBUILD_opencv_stitching=ON \ | |
-DBUILD_opencv_java=OFF \ | |
-DBUILD_opencv_js=ON \ | |
-DBUILD_opencv_python2=OFF \ | |
-DBUILD_opencv_python3=OFF \ | |
-DBUILD_EXAMPLES=OFF \ | |
-DBUILD_PACKAGE=OFF \ | |
-DBUILD_TESTS=OFF \ | |
-DBUILD_PERF_TESTS=OFF \ | |
-DBUILD_DOCS=OFF \ | |
-DWITH_PTHREADS_PF=OFF \ | |
-DCV_ENABLE_INTRINSICS=OFF \ | |
-DBUILD_WASM_INTRIN_TESTS=OFF \ | |
-DCMAKE_C_FLAGS="-s WASM=1 -s SINGLE_FILE=1 -s USE_PTHREADS=0" \ | |
-DCMAKE_CXX_FLAGS="-s WASM=1 -s SINGLE_FILE=1 -s USE_PTHREADS=0" \ | |
steps: | |
- uses: actions/checkout@v4 | |
- name: emsdk | |
run: | | |
git clone https://github.com/emscripten-core/emsdk.git | |
cd emsdk | |
./emsdk install $EMSCRIPTEN_VERSION | |
./emsdk activate $EMSCRIPTEN_VERSION | |
- name: setup-opencv-source | |
run: | | |
git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git ${{ env.SOURCE_DIR }} | |
git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git ${{ env.CONTRIB_SOURCE_DIR }} | |
- name: build | |
run: | | |
source emsdk/emsdk_env.sh | |
cd ${{ env.SOURCE_DIR }} | |
mkdir build && cd build | |
cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ | |
-DOPENCV_EXTRA_MODULES_PATH="${{ env.CONTRIB_SOURCE_DIR }}/modules" | |
cmake --build . --target install | |
- name: package | |
run: | | |
rm -rf ${{ env.PACKAGE_NAME }} | |
cp -rf ${{ env.SOURCE_DIR }}/build/install ${{ env.PACKAGE_NAME }} | |
tar -zcvf ${{ env.PACKAGE_NAME }}.tar.gz -C ${{ env.PACKAGE_NAME }} . | |
- name: upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PACKAGE_NAME }} | |
path: ${{ env.PACKAGE_NAME }} | |
# - name: test | |
# run: | | |
# cd test | |
# mkdir build && cd build | |
# cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \ | |
# -DCMAKE_C_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ | |
# -DCMAKE_CXX_FLAGS="-s WASM=1 -s USE_PTHREADS=0" \ | |
# -DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} | |
- name: release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
draft: true | |
prerelease: false | |
token: ${{ secrets.GITHUB_TOKEN }} | |
files: ${{ env.PACKAGE_NAME }}.tar.gz | |
# release: | |
# permissions: | |
# contents: write # for softprops/action-gh-release to create a release | |
# needs: [webassembly] | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: download | |
# uses: actions/download-artifact@v4 | |
# with: | |
# path: artifacts | |
# - name: create-release | |
# uses: softprops/action-gh-release@v2 | |
# if: startsWith(github.ref, 'refs/tags/') | |
# with: | |
# draft: true | |
# prerelease: false | |
# token: ${{ secrets.GITHUB_TOKEN }} | |
# files: artifacts/*/*.zip |