-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompile.sh
More file actions
executable file
·189 lines (157 loc) · 5.08 KB
/
Copy pathcompile.sh
File metadata and controls
executable file
·189 lines (157 loc) · 5.08 KB
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
177
178
179
180
181
182
183
184
185
186
187
188
189
#! /bin/sh
set -e
## FUNCTIONS
diagnostic()
{
echo "$@" 1>&2;
}
checkfail()
{
if [ ! $? -eq 0 ];then
diagnostic "$1"
exit 1
fi
}
WORK_DIR=$PWD
# Download the portable SDK and uncompress it
if [ ! -d emsdk ]; then
diagnostic "emsdk not found. Fetching it"
git clone http://github.com/emscripten-core/emsdk.git emsdk
cd emsdk && ./emsdk update-tags && ./emsdk install tot-upstream && ./emsdk activate tot-upstream
checkfail "emsdk: fetch failed"
fi
cd $WORK_DIR
TESTED_HASH="7bad2a86"
# Go go go vlc
if [ ! -d vlc ]; then
diagnostic "VLC source not found, cloning"
git clone http://git.videolan.org/git/vlc.git vlc || checkfail "VLC source: git clone failed"
cd vlc
diagnostic "VLC source: resetting to the TESTED_HASH commit (${TESTED_HASH})"
git reset --hard ${TESTED_HASH} || checkfail "VLC source: TESTED_HASH ${TESTED_HASH} not found"
cd ..
checkfail "vlc source: git clone failed"
fi
cd vlc
# Make in //
if [ -z "$MAKEFLAGS" ]; then
UNAMES=$(uname -s)
MAKEFLAGS=
if which nproc >/dev/null; then
MAKEFLAGS=-j`nproc`
elif [ "$UNAMES" == "Darwin" ] && which sysctl >/dev/null; then
MAKEFLAGS=-j`sysctl -n machdep.cpu.thread_count`
fi
fi
# VLC tools
export PATH=`pwd`/extras/tools/build/bin:$PATH
echo "Building tools"
cd extras/tools
./bootstrap
checkfail "buildsystem tools: bootstrap failed"
make $MAKEFLAGS
checkfail "buildsystem tools: make"
cd $WORK_DIR
diagnostic "Setting the environment"
source emsdk/emsdk_env.sh
export PKG_CONFIG_PATH=$EMSDK/emscripten/incoming/system/lib/pkgconfig
export PKG_CONFIG_LIBDIR=$PWD/vlc/contrib/wasm32_unknowm_emscripten/lib/pkgconfig
export PKG_CONFIG_PATH_CUSTOM=$PKG_CONFIG_LIBDIR
# Check that clang is working
clang --version
diagnostic "Patching"
cd vlc
# patching vlc
if [ -d ../vlc_patches ] && [ "$(ls -A ../vlc_patches)" ]; then
# core patches
git am -3 ../vlc_patches/0001-contrib-add-emscripten-target.patch
git am -3 ../vlc_patches/0002-contrib-add-ffmpeg-configuration-options-for-wasm-em.patch
git am -3 ../vlc_patches/0003-contrib-delete-empty-variable.patch
git am -3 ../vlc_patches/0006-configure-Create-a-target-for-emscripten-in-the-conf.patch
git am -3 ../vlc_patches/0007-core-initial-core-build-for-emscripten-based-on-POSI.patch
git am -3 ../vlc_patches/0008-compat-add-sigwait-support-for-emscripten.patch
git am -3 ../vlc_patches/0009-compat-add-clock_nanosleep-support.patch
git am -3 ../vlc_patches/0010-emscripten-add-vlc_getProxyUrl-stub.patch
git am -3 ../vlc_patches/0011-configure-disable-deprecated-GL-functions-for-emscri.patch
git am -3 ../vlc_patches/0012-logger-add-emscripten-module.patch
git am -3 ../vlc_patches/0013-window-add-emscripten-type.patch
git am -3 ../vlc_patches/0014-vout-add-emscripten-gl-es2-and-window-modules.patch
git am -3 ../vlc_patches/0015-vlc_common-add-weak-attribute-support-for-wasm.patch
git am -3 ../vlc_patches/0016-Add-meson_system_name-for-emscripten.patch
# Add OPENAL support
git am -3 ../vlc_patches/openal/*
fi
# BOOTSTRAP
if [ ! -f configure ]; then
echo "Bootstraping"
./bootstrap
checkfail "vlc: bootstrap failed"
fi
############
# Contribs #
############
echo "Building the contribs"
mkdir -p contrib/contrib-emscripten
cd contrib/contrib-emscripten
../bootstrap --disable-disc --disable-gpl --disable-sout \
--disable-network \
--host=wasm32-unknown-emscripten --build=x86_64-linux
checkfail "contribs: bootstrap failed"
emmake make list
emmake make $MAKEFLAGS fetch
checkfail "contribs: make fetch failed"
emmake make $MAKEFLAGS .ffmpeg
checkfail "contribs: make failed"
cd ../../
# Build
mkdir -p build-emscripten && cd build-emscripten
OPTIONS="
--host=wasm32-unknown-emscripten
--enable-debug
--enable-gles2
--disable-lua
--disable-ssp
--disable-nls
--disable-sout
--disable-vlm
--disable-addonmanagermodules
--enable-avcodec
--enable-merge-ffmpeg
--disable-swscale
--disable-a52
--disable-x264
--disable-xcb
--disable-alsa
--disable-macosx
--disable-sparkle
--disable-qt
--disable-screen
--disable-xcb
--disable-pulse
--disable-alsa
--disable-oss
--disable-vlc"
# --disable-xvideo Unknown option
# Note :
# search.h is a blacklisted module
# time.h is a blacklisted module
# shm.h is a blacklisted module
# ssp is not supported on the wasm backend
emconfigure ../configure ${OPTIONS} \
ac_cv_func_sendmsg=yes ac_cv_func_recvmsg=yes ac_cv_func_if_nameindex=yes ac_cv_header_search_h=no ac_cv_header_time_h=no ac_cv_header_sys_shm_h=no
emmake make ${MAKEFLAGS}
diagnostic "Generating module list"
cd ../..
./generate_modules_list.sh
cd vlc/build-emscripten
emcc vlc-modules.c -o vlc-modules.bc -pthread
cd ../..
url="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
# copy Dolby_Canyon.vob
diagnostic "getting video"
cd vlc/build-emscripten/
curl ${url} -o BigBuckBunny.mp4
cd $WORK_DIR
diagnostic "Generating executable"
cp main.c vlc/build-emscripten/
./create_main.sh