-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwasi_ffmpeg.sh
executable file
·115 lines (94 loc) · 2.54 KB
/
wasi_ffmpeg.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
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
#!/bin/bash
set -e
source env.sh
ffmpeg_build=${build_dir}/ffmpeg
fate_samples=${DIR}/ffmpeg-fate-sample
# default path of ffmpeg source code
ffmpeg_src=${DIR}/../ffmpeg
do_install=1
enable_opt=0
while [ $# -gt 0 ]; do
case $1 in
--help)
echo "Use --path to specify ffmpeg source directory"
echo "Use --install to install after build"
exit 1
;;
--path)
ffmpeg_src=$2
shift
;;
--config_opt)
enable_opt=$2
echo "enable_opt $enable_opt"
shift
;;
esac
shift
done
if ! [ -d ${ffmpeg_src} ]; then
echo "Directory $ffmpeg_src not found"
exit 1
fi
extra_config=" "
if [ -z "${WASI_SDK_PREFIX}" ]; then
echo "Please set WASI_SDK_PREFIX env"
exit 1
fi
TOOLCHAIN="${WASI_SDK_PREFIX}"
TARGET=wasm32-wasi
ffmpeg_build="${ffmpeg_build}-wasi"
install_dir="${install_dir}-wasi"
export AR=$TOOLCHAIN/bin/llvm-ar
export CC=$TOOLCHAIN/bin/wasm32-wasi-threads-clang
export CXX=$TOOLCHAIN/bin/wasm32-wasi-threads-clang++
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
export NM=$TOOLCHAIN/bin/llvm-nm
export STRINGS=$TOOLCHAIN/bin/llvm-strings
export CROSS_PREFIX=${TARGET}-
export HOST=${TARGET}
export PKG_CONFIG_PATH="${install_dir}/lib/pkgconfig"
mkdir -p $build_dir
pushd $build_dir
rm -Rf ${ffmpeg_build}
mkdir -p ${ffmpeg_build}
pushd ${ffmpeg_build}
if [ "$enable_opt" -eq 0 ]; then
extra_config="${extra_config} --disable-optimizations"
fi
$ffmpeg_src/configure \
--prefix=$install_dir \
--enable-debug \
--enable-nonfree \
--enable-gpl \
--enable-version3 \
--target-os=none \
--arch=wasm32 \
--cross-prefix=${TARGET}- \
--cc=$CC \
--cxx=$CXX \
--ld=$CXX \
--as=$CC \
--nm=$NM \
--ranlib=$RANLIB \
--ar=$AR \
--enable-static --disable-shared \
--disable-stripping \
--disable-doc \
--disable-network \
--disable-protocol=fd \
--disable-protocol=pipe \
--disable-autodetect \
--extra-cflags='-D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS -mllvm -wasm-enable-sjlj -msimd128 -pthread' \
--extra-ldflags='-Wl,--import-memory,--export-memory,--max-memory=4294967296 -Wl,-z,stack-size=10485760' \
--extra-libs='-lwasi-emulated-signal -lwasi-emulated-process-clocks ' \
--pkg-config=pkg-config \
--samples=${fate_samples} \
--target-exec='wasmtime --wasi threads --dir=/ ' \
${extra_config} \
make -j $(nproc)
if [ "$do_install" -eq 1 ]; then
make install
fi
popd # ${ffmpeg_build}
popd