-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
176 lines (161 loc) · 5.94 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Wasm
on:
pull_request:
types: [synchronize, opened]
push:
branches:
- main
env:
DEBIAN_FRONTEND: noninteractive
OPENCV_VERSION: 4.10.0
EM_VERSION: 3.1.32
EM_CACHE_FOLDER: 'emsdk-cache'
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install dependencies
run: |
pwd
echo ${GITHUB_WORKSPACE}
current_path=$(pwd)
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends \
apt-transport-https \
software-properties-common \
wget \
unzip \
ca-certificates \
g++ \
make \
cmake \
libtbb-dev \
libatlas-base-dev \
libgtk2.0-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libdc1394-dev \
libxine2-dev \
libv4l-dev \
libtheora-dev \
libvorbis-dev \
libxvidcore-dev \
libopencore-amrnb-dev \
libopencore-amrwb-dev \
x264 \
libtesseract-dev
- name: Cache OpenCV
id: opencv-cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/opencv_wasm/
key: opencv-${{ env.OPENCV_VERSION }}-wasm
- name: Setup Emscripten cache
id: cache-system-libraries
uses: actions/cache@v3
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{ runner.os }}
- uses: mymindstorm/setup-emsdk@v10
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
- name: Build OpenCV
if: steps.opencv-cache.outputs.cache-hit != 'true'
run: |
wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -Oopencv-${OPENCV_VERSION}.zip && unzip opencv-${OPENCV_VERSION}.zip
wget https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip -Oopencv_contrib-${OPENCV_VERSION}.zip && unzip opencv_contrib-${OPENCV_VERSION}.zip
cd opencv-${OPENCV_VERSION} && mkdir build && cd build
emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${OPENCV_VERSION}/modules \
-DBUILD_SHARED_LIBS=OFF \
-DENABLE_CXX11=ON -DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_DOCS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_JAVA=OFF \
-DBUILD_opencv_java_bindings_generator=OFF \
-DBUILD_opencv_python_bindings_generator=OFF \
-DBUILD_opencv_python_tests=OFF \
-DBUILD_opencv_ts=OFF \
-DBUILD_opencv_js=OFF \
-DBUILD_opencv_js_bindings_generator=OFF \
-DBUILD_opencv_apps=OFF \
-DBUILD_opencv_barcode=OFF \
-DBUILD_opencv_bioinspired=OFF \
-DBUILD_opencv_ccalib=OFF \
-DBUILD_opencv_datasets=OFF \
-DBUILD_opencv_dnn_objdetect=OFF \
-DBUILD_opencv_dpm=OFF \
-DBUILD_opencv_fuzzy=OFF \
-DBUILD_opencv_gapi=ON \
-DBUILD_opencv_intensity_transform=OFF \
-DBUILD_opencv_mcc=OFF \
-DBUILD_opencv_objc_bindings_generator=OFF \
-DBUILD_opencv_rapid=OFF \
-DBUILD_opencv_reg=OFF \
-DBUILD_opencv_stereo=OFF \
-DBUILD_opencv_structured_light=OFF \
-DBUILD_opencv_surface_matching=OFF \
-DBUILD_opencv_wechat_qrcode=ON \
-DBUILD_opencv_videostab=OFF \
-DWITH_GSTREAMER=OFF \
-DWITH_EIGEN=OFF \
-DWITH_ADE=OFF \
-DOPENCV_ENABLE_NONFREE=ON \
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/opencv_wasm \
-DCMAKE_C_FLAGS='-s WASM=1' -DCMAKE_CXX_FLAGS='-s WASM=1' \
-DWITH_ITT=OFF \
-DWITH_JPEG=OFF \
-DWITH_TIFF=OFF \
-DWITH_PNG=OFF \
-DWITH_IPP=OFF \
-DWITH_LAPACK=OFF \
-DCV_ENABLE_INTRINSICS=OFF \
-DBUILD_opencv_dnn=ON \
..
make -j2
make install
em++ -r -o ${GITHUB_WORKSPACE}/opencv_wasm/libopencv.o \
-Wl,--whole-archive ${GITHUB_WORKSPACE}/opencv_wasm/lib/*.a \
${GITHUB_WORKSPACE}/opencv_wasm/lib/opencv4/3rdparty/*.a
cd ${GITHUB_WORKSPACE}
ls
- name: Build OpenCvSharpExtern
run: |
ls ${GITHUB_WORKSPACE}/opencv_wasm
echo "-----"
mkdir src/build && cd $_
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DOpenCV_DIR=${GITHUB_WORKSPACE}/opencv_wasm/lib/cmake/opencv4 -DWASM_LIB=${GITHUB_WORKSPACE}/opencv_wasm/libopencv.o ..
make -j2
ls OpenCvSharpExtern
cp OpenCvSharpExtern/libOpenCvSharpExtern.a ${GITHUB_WORKSPACE}/nuget/
- name: Check OpenCvSharpExtern
run: |
echo TODO
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: Create NuGet package
env:
BETA: ""
run: |
yyyymmdd=`date '+%Y%m%d'`
echo $yyyymmdd
sed -E --in-place=.bak "s/<version>[0-9]\.[0-9]{1,2}\.[0-9]{1,2}.[0-9]{8}(-beta[0-9]*)?<\/version>/<version>${OPENCV_VERSION}.${yyyymmdd}${BETA}<\/version>/" ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.wasm.nuspec
cat ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.wasm.nuspec
dotnet pack ${GITHUB_WORKSPACE}/nuget/OpenCvSharp4.runtime.wasm.csproj -o ${GITHUB_WORKSPACE}/artifacts_wasm
ls ${GITHUB_WORKSPACE}/artifacts_wasm
- uses: actions/upload-artifact@v3
with:
name: artifacts_wasm
path: artifacts_wasm
- name: Test
run: |
echo TODO