-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_script.sh
executable file
·43 lines (34 loc) · 1.05 KB
/
build_script.sh
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
#!/bin/bash
# Exit on error
set -e
# Load the version number from version.env
source ./version.env
# Install dependencies
apt-get update &&
apt-get install -y \
python3 \
python3-pip \
cmake &&
rm -rf /var/lib/apt/lists/*
# Set Python alias
ln -s /usr/bin/python3 /usr/bin/python
export EMSCRIPTEN=/emsdk/upstream/emscripten
# Clone opencv and checkout the version tag
git clone --depth 1 --branch $CV_VERSION https://github.com/opencv/opencv.git
cd ./opencv
# Patch the build script to allow unknown arguments
OLD_LINE="args = parser.parse_args()"
NEW_LINE="args, _ = parser.parse_known_args()"
sed -i "s/$OLD_LINE/$NEW_LINE/g" ./platforms/js/build_js.py
cp ../opencv_js.config.py ./platforms/js/
# Build!
emcmake python ./platforms/js/build_js.py \
./build_wasm \
--build_wasm \
--build_test
# Grab the built JS file and clean up
cp ./build_wasm/bin/opencv_js.js ../index.js
# Delete the opencv source
cd .. && rm -rf opencv
# Copy into ./dist, ignoring error for skipping ./dist itself
mkdir dist && cp ./* ./dist || true