Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make build_lgpl.sh work with emscripten 1.31.0 #30

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 32 additions & 26 deletions build/build_all_codecs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Current build uses emscripten at commit df11c6f1fd1636a355b83a1c48b3a890596e6a32
# Current build uses emscripten 1.32.0 (commit b3efd9328f940034e1cab45af23bf29541e0d8ff)
echo "Beginning Build:"

rm -r dist
Expand All @@ -18,54 +18,59 @@ mkdir -p dist
# emmake make install
# cd ..


cd zlib
make clean
emconfigure ./configure --prefix=$(pwd)/../dist --64
emmake make
# --static should be enforced because current emcc can't handle .lo files
emconfigure ./configure --prefix=$(pwd)/../dist --64 --static
emmake make -j2 CFLAGS="-O3" SHELL="/bin/bash -x"
emmake make install

cd ..

cd libvpx
## Try some of these options: ./configure --target=js1-none-clang_emscripten --disable-examples --disable-docs --disable-multithread --disable-runtime-cpu-detect --disable-optimizations --disable-vp8-decoder --disable-vp9-decoder --extra-cflags="-O2"

make clean

emconfigure ./configure --prefix=$(pwd)/../dist --disable-examples --disable-docs \
--disable-runtime-cpu-detect --disable-multithread --disable-optimizations \
--target=generic-gnu
emmake make
--target=generic-gnu --extra-cflags="-O3"

emmake make -j2 SHELL="/bin/bash -x"
emmake make install

cd ..

# x264-snapshot-20140501-2245
cd x264
make clean

# x264 has .c files with same names, which causes linking problem if built as static library, so --enable-shared.
emconfigure ./configure --disable-thread --disable-asm \
--host=i686-pc-linux-gnu \
--disable-cli --enable-static --disable-gpl --prefix=$(pwd)/../dist
emmake make
--disable-cli --enable-shared --disable-gpl --prefix=$(pwd)/../dist

emmake make -j2 SHELL="/bin/bash -x"
emmake make install

cd ..

cd ffmpeg

make clean
emconfigure ./configure --cc="emcc" --prefix=$(pwd)/../dist --extra-cflags="-I$(pwd)/../dist/include -v" --enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic \

# ffmpeg's configure doesn't correctly set CPPFLAGS="-D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600" when built by emcc, so we add them.
emconfigure ./configure --cc="emcc" --prefix=$(pwd)/../dist \
--optflags="-O3" --extra-cflags="-I$(pwd)/../dist/include -v -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600" \
--enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic \
--disable-ffplay --disable-ffprobe --disable-ffserver --disable-asm --disable-doc --disable-devices --disable-pthreads --disable-w32threads --disable-network \
--disable-hwaccels --disable-parsers --disable-bsfs --disable-debug --disable-protocols --disable-indevs --disable-outdevs --enable-protocol=file \
--enable-libvpx --enable-gpl --extra-libs="$(pwd)/../dist/lib/libx264.a $(pwd)/../dist/lib/libvpx.a"

# If we --enable-libx264 there is an error. Instead just act like it is there, extra-libs seems to work.
sed -i '' 's/define CONFIG_LIBX264 0/define CONFIG_LIBX264 1/' config.h
sed -i '' 's/define CONFIG_LIBX264_ENCODER 0/define CONFIG_LIBX264_ENCODER 1/' config.h
sed -i '' 's/define CONFIG_LIBX264RGB_ENCODER 0/define CONFIG_LIBX264RGB_ENCODER 1/' config.h
sed -i '' 's/define CONFIG_H264_PARSER 0/define CONFIG_H264_PARSER 1/' config.h

sed -i '' 's/\!CONFIG_LIBX264=yes/CONFIG_LIBX264=yes/' config.mak
sed -i '' 's/\!CONFIG_LIBX264_ENCODER=yes/CONFIG_LIBX264_ENCODER=yes/' config.mak
sed -i '' 's/\!CONFIG_LIBX264RGB_ENCODER=yes/CONFIG_LIBX264RGB_ENCODER=yes/' config.mak
sed -i '' 's/\!CONFIG_H264_PARSER=yes/CONFIG_H264_PARSER=yes/' config.mak
--enable-libvpx --enable-libx264 --enable-gpl \
--extra-ldflags="-L$(pwd)/../dist/lib/ -lx264 -lvpx -lz"

make
make install
emmake make -j2
emmake make install

cd ..

Expand All @@ -74,14 +79,15 @@ rm dist/*.bc
# cp dist/lib/libogg.a dist/libogg.bc
# cp dist/lib/libvorbis.a dist/libvorbis.bc

cp dist/lib/libvpx.a dist/libvpx.bc
cp dist/lib/libz.a dist/libz.bc
cp dist/lib/libx264.a dist/libx264.bc
cp ffmpeg/ffmpeg dist/ffmpeg.bc

cd dist
emcc -s OUTLINING_LIMIT=100000 -s VERBOSE=1 -s TOTAL_MEMORY=33554432 -O2 -v ffmpeg.bc libx264.bc libvpx.bc libz.bc -o ../ffmpeg-all-codecs.js --pre-js ../ffmpeg_pre.js --post-js ../ffmpeg_post.js

emcc -s OUTLINING_LIMIT=100000 -s VERBOSE=1 -s TOTAL_MEMORY=33554432 -O3 -v ffmpeg.bc lib/libx264.so -o ../ffmpeg-all-codecs.js --pre-js ../ffmpeg_pre.js --post-js ../ffmpeg_post.js

cd ..

cp ffmpeg-all-codecs.js ../demo/ffmpeg.js
cp ffmpeg-all-codecs.js.mem ../demo/ffmpeg.js.mem

echo "Finished Build"
20 changes: 13 additions & 7 deletions build/build_lgpl.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Current build uses emscripten at commit df11c6f1fd1636a355b83a1c48b3a890596e6a32
# Current build uses emscripten 1.32.0 (commit b3efd9328f940034e1cab45af23bf29541e0d8ff)

echo "Beginning Build:"

Expand All @@ -7,8 +7,10 @@ mkdir -p dist

cd zlib
make clean
emconfigure ./configure --prefix=$(pwd)/../dist --64
emmake make

# --static should be enforced because current emcc can't handle .lo files
emconfigure ./configure --prefix=$(pwd)/../dist --64 --static
emmake make -j2 CFLAGS="-O3"
emmake make install
cd ..

Expand All @@ -17,12 +19,15 @@ cd ffmpeg
#--enable-small

make clean

# ffmpeg's configure doesn't correctly set CPPFLAGS="-D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600" when built by emcc, so we add them.
emconfigure ./configure --cc="emcc" --prefix=$(pwd)/../dist --enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic \
--optflags="-O3" --extra-cflags="-D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600" \
--disable-ffplay --disable-ffprobe --disable-ffserver --disable-asm --disable-doc --disable-devices --disable-pthreads --disable-w32threads --disable-network \
--disable-hwaccels --disable-parsers --disable-bsfs --disable-debug --disable-protocols --disable-indevs --disable-outdevs --enable-protocol=file \
--disable-hwaccels --disable-parsers --disable-bsfs --disable-debug --disable-protocols --disable-indevs --disable-outdevs --enable-protocol=file

make
make install
emmake make -j2
emmake make install


cd ..
Expand All @@ -34,9 +39,10 @@ rm *.bc
cp lib/libz.a dist/libz.bc
cp ../ffmpeg/ffmpeg ffmpeg.bc

emcc -s OUTLINING_LIMIT=100000 -s VERBOSE=1 -s TOTAL_MEMORY=33554432 -O2 -v ffmpeg.bc -o ../ffmpeg.js --pre-js ../ffmpeg_pre.js --post-js ../ffmpeg_post.js
emcc -s OUTLINING_LIMIT=100000 -s VERBOSE=1 -s TOTAL_MEMORY=33554432 -O3 -v ffmpeg.bc -o ../ffmpeg.js --pre-js ../ffmpeg_pre.js --post-js ../ffmpeg_post.js

cd ..

cp ffmpeg.js ffmpeg.js.mem ../demo/

echo "Finished Build"
8 changes: 5 additions & 3 deletions build/ffmpeg/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4780,9 +4780,11 @@ enabled libvpx && {
enabled libvpx_vp9_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_vp9_cx VP9E_SET_SVC" -lvpx || disable libvpx_vp9_encoder; } }
enabled libwavpack && require libwavpack wavpack/wavpack.h WavpackOpenFileOutput -lwavpack
enabled libwebp && require_pkg_config libwebp webp/encode.h WebPGetEncoderVersion
enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
{ check_cpp_condition x264.h "X264_BUILD >= 118" ||
die "ERROR: libx264 must be installed and version must be >= 0.118."; }

# test of libx264 always fails when built by emcc, so skip this test
# enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
# { check_cpp_condition x264.h "X264_BUILD >= 118" ||
# die "ERROR: libx264 must be installed and version must be >= 0.118."; }
enabled libx265 && require_pkg_config x265 x265.h x265_encoder_encode &&
{ check_cpp_condition x265.h "X265_BUILD >= 17" ||
die "ERROR: libx265 version must be >= 17."; }
Expand Down
3 changes: 1 addition & 2 deletions build/ffmpeg_post.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

return Module['return'];
}

if (typeof(exports) !== 'undefined') {
ffmpeg_run.call(this);
}
}
13 changes: 7 additions & 6 deletions build/ffmpeg_pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function ffmpeg_run(opts) {
if (Module['arguments'].length > 2 && outputFilePath && outputFilePath.indexOf(".") > -1) {
Module['arguments'][Module['arguments'].length - 1] = "output/" + outputFilePath;
}
Module['preRun'] = function() {
Module['preRun'] = [ function() {
FS.createFolder('/', Module['outputDirectory'], true, true);
/* fileData / fileName is deprecated - please use file.name and file.data instead */
if (Module['fileData']) {
Expand All @@ -32,11 +32,12 @@ function ffmpeg_run(opts) {
FS.createDataFile('/', file.name, file.data, true, true);
});
}
};
Module['postRun'] = function() {
} ];
Module['postRun'] = [ function() {
var handle = FS.analyzePath(Module['outputDirectory']);
Module['return'] = getAllBuffers(handle);
};
if (Module['return'])
Module['return'](getAllBuffers(handle));
} ];
function getAllBuffers(result) {
var buffers = [];
if (result && result.object && result.object.contents) {
Expand All @@ -51,4 +52,4 @@ function ffmpeg_run(opts) {
}
return buffers;
}
}
}
3 changes: 2 additions & 1 deletion build/x264/configure
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,8 @@ define STACK_ALIGNMENT $stack_alignment
ASFLAGS="$ASFLAGS -DSTACK_ALIGNMENT=$stack_alignment"

# skip endianness check for Intel Compiler, as all supported platforms are little. the -ipo flag will also cause the check to fail
if [ $compiler = GNU ]; then
# emcc always fails in this check, also skip
if [ $compiler = GNU -a `basename "$CC"` != emcc ]; then
echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c
$CC $CFLAGS conftest.c -c -o conftest.o 2>/dev/null || die "endian test failed"
if (${cross_prefix}strings -a conftest.o | grep -q BIGE) && (${cross_prefix}strings -a conftest.o | grep -q FPendian) ; then
Expand Down
167 changes: 167 additions & 0 deletions build_edge/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#!/bin/sh
# Current build uses emscripten 1.31.0 (commit 01d531a5fabc58d9f83a628df5c5b43ecc5950d5)
echo "Beginning Build:"

PREFIX=$(pwd)/dist

clean_prefix() {
echo clean_prefix
rm -r $PREFIX
mkdir -p $PREFIX
}

build_zlib() {
echo build_zlib
cd zlib
emconfigure ./configure --prefix=$PREFIX --64 --static
emmake make CFLAGS="-O3" SHELL="/bin/bash -x"
emmake make install
cd ..
}

build_libvpx() {
echo build_libvpx
cd libvpx
## Try some of these options: ./configure --target=js1-none-clang_emscripten --disable-examples --disable-docs --disable-multithread --disable-runtime-cpu-detect --disable-optimizations --disable-vp8-decoder --disable-vp9-decoder --extra-cflags="-O2"

emconfigure ./configure --prefix=$PREFIX --disable-examples --disable-docs \
--disable-runtime-cpu-detect --disable-multithread \
--target=generic-gnu --extra-cflags=-O3

#make clean
emmake make -j4 SHELL="/bin/bash -x"
emmake make install
cd ..
}

build_x264() {
echo build_x264
# x264
cd x264

# x264 has .c files with same names, which causes linking problem if built as static library, so --enable-shared.
emconfigure ./configure --disable-thread --disable-asm --disable-opencl \
--host=i686-pc-linux-gnu \
--disable-cli --enable-shared --disable-gpl --prefix=$PREFIX

#make clean
emmake make -j4 SHELL="/bin/bash -x"
emmake make install
cd ..
}

build_openh264() {
echo build_openh264
# openh264
cd openh264
# use mips to avoid compiling ASM codes
emmake make -j4 ARCH=mips CFLAGS_OPT=-O3
# use shared library becuase openh264 has object files with same name
emmake make ARCH=mips PREFIX=$PREFIX install-headers install-shared
cd ..
}

build_lame() {
echo build_lame
cd lame
emconfigure ./configure CFLAGS=-O3 --prefix=$PREFIX --enable-shared=no --disable-gtktest --disable-decoder --disable-cpml --without-iconv
emmake make -j4
emmake make install
cd ..
}

build_opus() {
echo build_opus
cd opus
./autogen.sh
emconfigure ./configure CFLAGS=-O3 --prefix=$PREFIX --enable-shared=no --disable-asm --disable-rtcd \
# --enable-fixed-point --enable-intrinsics

emmake make -j4
emmake make install
cd ..
}

config_ffmpeg_full() {
echo config_ffmpeg_full
cd ffmpeg

# ffmpeg's configure doesn't correctly set CPPFLAGS="-D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600" when built by emcc, so we add them.
emconfigure ./configure --cc="emcc" --prefix=$PREFIX \
--pkg-config=../pkg_config \
--optflags="-O3" --extra-cflags="-I$PREFIX/include -v -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600" \
--extra-ldflags="-L$PREFIX/lib/" \
--enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic --disable-debug --disable-runtime-cpudetect \
--disable-ffplay --disable-ffprobe --disable-ffserver --disable-asm --disable-doc --disable-pthreads --disable-w32threads --disable-network --disable-iconv --disable-xlib \
--enable-gpl --enable-libvpx --enable-libx264 \
--enable-libmp3lame --enable-libopus --enable-libopenh264 \
--enable-protocol=file

cd ..
}

config_ffmpeg_custom() {
echo config_ffmpeg_custom
cd ffmpeg

# ffmpeg's configure doesn't correctly set CPPFLAGS="-D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600" when built by emcc, so we add them.
emconfigure ./configure --cc="emcc" --prefix=$PREFIX \
--pkg-config=../pkg_config \
--optflags="-O3" --extra-cflags="-I$PREFIX/include -v -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600" \
--extra-ldflags="-L$PREFIX/lib/" \
--enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic --disable-debug --disable-runtime-cpudetect \
--disable-ffplay --disable-ffprobe --disable-ffserver --disable-asm --disable-doc --disable-pthreads --disable-w32threads --disable-network --disable-iconv --disable-xlib \
--enable-gpl --enable-libvpx --enable-libx264 \
--enable-libmp3lame --enable-libopus --enable-libopenh264 \
--disable-everything --enable-protocol=file \
--enable-encoder=libopus --enable-encoder=libmp3lame --enable-encoder=aac --enable-encoder=libvpx_vp8 --enable-encoder=libvpx_vp9 --enable-encoder=libx264 --enable-encoder=libopenh264 --enable-encoder=vorbis \
--enable-demuxer=aac --enable-demuxer=ac3 --enable-demuxer=ogg --enable-demuxer=pcm_alaw --enable-demuxer=pcm_f32be --enable-demuxer=pcm_f32le --enable-demuxer=pcm_f64be --enable-demuxer=pcm_f64le --enable-demuxer=pcm_mulaw --enable-demuxer=pcm_s16be --enable-demuxer=pcm_s16le --enable-demuxer=avi --enable-demuxer=pcm_s24be --enable-demuxer=avisynth --enable-demuxer=pcm_s24le --enable-demuxer=pcm_s32be --enable-demuxer=pcm_s32le --enable-demuxer=pcm_s8 --enable-demuxer=pcm_u16be --enable-demuxer=pcm_u16le --enable-demuxer=pcm_u24be --enable-demuxer=pcm_u24le --enable-demuxer=pcm_u32be --enable-demuxer=pcm_u32le --enable-demuxer=pcm_u8 --enable-demuxer=rm --enable-demuxer=m4v --enable-demuxer=matroska --enable-demuxer=mjpeg --enable-demuxer=mp3 --enable-demuxer=flac --enable-demuxer=mpegps --enable-demuxer=flv --enable-demuxer=mpegts --enable-demuxer=mpegtsraw --enable-demuxer=mpegvideo --enable-demuxer=vc1t --enable-demuxer=vc1 \
--enable-muxer=mp4 --enable-muxer=oga --enable-muxer=ogg --enable-muxer=webm \
--enable-filter=adelay --enable-filter=aresample --enable-filter=pad --enable-filter=aformat --enable-filter=rotate --enable-filter=scale --enable-filter=format --enable-filter=setdar --enable-filter=setsar --enable-filter=ashowinfo --enable-filter=showinfo --enable-filter=ass --enable-filter=atrim --enable-filter=join --enable-filter=trim --enable-filter=vflip --enable-filter=concat --enable-filter=copy --enable-filter=volume --enable-filter=crop --enable-filter=volumedetect --enable-filter=cropdetect \
--enable-decoder=libvpx_vp8 --enable-decoder=libvpx_vp9 --enable-decoder=vorbis \
--enable-decoder=zlib \
#--enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=h263 --enable-decoder=ac3 --enable-decoder=h263i --enable-decoder=ac3_fixed --enable-decoder=h263p --enable-decoder=h264 --enable-decoder=h264_crystalhd --enable-decoder=h264_vda --enable-decoder=h264_vdpau --enable-decoder=cook --enable-decoder=mjpeg --enable-decoder=mjpegb --enable-decoder=mp2 --enable-decoder=mp2float --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=pcm_u32be --enable-decoder=mp3adufloat --enable-decoder=pcm_u32le --enable-decoder=mp3float --enable-decoder=pcm_u8 --enable-decoder=mp3on4 --enable-decoder=pcm_zork --enable-decoder=mp3on4float --enable-decoder=mpeg1_vdpau --enable-decoder=mpeg1video --enable-decoder=mpeg2_crystalhd --enable-decoder=mpeg2video --enable-decoder=mpeg4 --enable-decoder=mpeg4_crystalhd --enable-decoder=mpeg4_vdpau --enable-decoder=mpeg_vdpau --enable-decoder=mpeg_xvmc --enable-decoder=mpegvideo --enable-decoder=msmpeg4_crystalhd --enable-decoder=vc1 --enable-decoder=msmpeg4v1 --enable-decoder=vc1_crystalhd --enable-decoder=msmpeg4v2 --enable-decoder=vc1_vdpau --enable-decoder=msmpeg4v3 --enable-decoder=ra_144 --enable-decoder=vc1image --enable-decoder=ra_288 --enable-decoder=ralf --enable-decoder=rv10 --enable-decoder=vp6 --enable-decoder=rv20 --enable-decoder=vp6a --enable-decoder=rv30 --enable-decoder=vp6f --enable-decoder=rv40 --enable-decoder=opus --enable-decoder=pcm_alaw --enable-decoder=pcm_bluray --enable-decoder=sipr --enable-decoder=pcm_dvd --enable-decoder=wmalossless --enable-decoder=pcm_f32be --enable-decoder=wmapro --enable-decoder=pcm_f32le --enable-decoder=wmav1 --enable-decoder=pcm_f64be --enable-decoder=wmav2 --enable-decoder=pcm_f64le --enable-decoder=wmavoice --enable-decoder=pcm_lxf --enable-decoder=wmv1 --enable-decoder=pcm_mulaw --enable-decoder=wmv2 --enable-decoder=pcm_s16be --enable-decoder=wmv3 --enable-decoder=pcm_s16be_planar --enable-decoder=wmv3_crystalhd --enable-decoder=pcm_s16le --enable-decoder=wmv3_vdpau --enable-decoder=pcm_s16le_planar --enable-decoder=wmv3image --enable-decoder=pcm_s24be --enable-decoder=pcm_s24daud --enable-decoder=pcm_s24le --enable-decoder=pcm_s24le_planar --enable-decoder=pcm_s32be --enable-decoder=pcm_s32le --enable-decoder=pcm_s32le_planar --enable-decoder=pcm_s8 --enable-decoder=pcm_s8_planar --enable-decoder=pcm_u16be --enable-decoder=pcm_u16le --enable-decoder=pcm_u24be --enable-decoder=pcm_u24le

cd ..
}

make_ffmpeg() {
echo make_ffmpeg
cd ffmpeg

# make clean
emmake make -j4
emmake make install

cd ..
}

build_js() {
echo build_js
cp $PREFIX/bin/ffmpeg $PREFIX/ffmpeg.bc

emcc -s OUTLINING_LIMIT=100000 -s VERBOSE=1 -s TOTAL_MEMORY=33554432 -O3 -v $PREFIX/ffmpeg.bc $PREFIX/lib/libx264.so $PREFIX/lib/libopenh264.so -o ffmpeg.js --pre-js ffmpeg_pre.js --post-js ffmpeg_post.js
}

install_js() {
echo install_js
cp -a ffmpeg.js ffmpeg.js.mem ../demo/
}

clean_prefix
build_zlib
build_libvpx
build_x264
build_openh264
build_lame
build_opus

# select one of the following ffmpeg configure.
# config_ffmpeg_full
config_ffmpeg_custom

make_ffmpeg
build_js
install_js

echo "Finished Build"
Loading