Merge pull request #1727 from shimat/fix1725 #358
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: | |
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 |