-
Notifications
You must be signed in to change notification settings - Fork 2
157 lines (153 loc) · 5.04 KB
/
wasm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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