From a1117c58ace73ac3796c98e6f4317dba05076342 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 21 May 2022 14:07:20 +0200 Subject: [PATCH] [WIP] build deps --- app/deps/.gitignore | 2 ++ app/deps/src/build-ffmpeg.sh | 54 ++++++++++++++++++++++++++++++++++++ app/deps/src/init_deps | 44 +++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 app/deps/.gitignore create mode 100755 app/deps/src/build-ffmpeg.sh create mode 100644 app/deps/src/init_deps diff --git a/app/deps/.gitignore b/app/deps/.gitignore new file mode 100644 index 00000000..feeb3363 --- /dev/null +++ b/app/deps/.gitignore @@ -0,0 +1,2 @@ +/data +/target-* diff --git a/app/deps/src/build-ffmpeg.sh b/app/deps/src/build-ffmpeg.sh new file mode 100755 index 00000000..bd679d69 --- /dev/null +++ b/app/deps/src/build-ffmpeg.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +. init_deps + +VERSION=5.0.1 +FILENAME=ffmpeg-$VERSION.tar.xz + +URL=http://ffmpeg.org/releases/ffmpeg-$VERSION.tar.xz +SHA256SUM=ef2efae259ce80a240de48ec85ecb062cecca26e4352ffb3fda562c21a93007b + +DEP_DIR="$DATA_DIR/ffmpeg-$VERSION-$SHA256SUM" + +if [[ ! -d "$DEP_DIR" ]] +then + get_file "$URL" "$FILENAME" "$SHA256SUM" + + mkdir "$DEP_DIR" + cd "$DEP_DIR" + + tar xvf "../$FILENAME" +else + echo "$DEP_DIR found" + cd "$DEP_DIR" +fi + +cd "ffmpeg-$VERSION" +rm -rf "build-$HOST" +mkdir "build-$HOST" +cd "build-$HOST" + +params=( + --prefix="$INSTALL_DIR" + --disable-autodetect + --disable-programs + --disable-everything + --disable-doc + --disable-swresample + --disable-swscale + --disable-avfilter + --disable-postproc + --disable-static + --enable-shared + --enable-decoder=h264 + --enable-decoder=png + --enable-muxer=mp4 + --enable-muxer=matroska +) +if [[ "$HOST_SYSTEM" == 'linux' ]] +then + params+=(--enable-libv4l2) +fi + +../configure "${params[@]}" +make -j $NJOBS +make install diff --git a/app/deps/src/init_deps b/app/deps/src/init_deps new file mode 100644 index 00000000..06baa573 --- /dev/null +++ b/app/deps/src/init_deps @@ -0,0 +1,44 @@ +set -e + +# The caller must set the following environment variable +# - $HOST (e.g. "x86_64-linux-gnu") +# - $HOST_SYSTEM ("linux", "windows", "apple"), for scripts convenience + +fail() { + echo "$1" >&2 + exit 1 +} + +[[ -z "$HOST" ]] && fail '$HOST not defined' +[[ -z "$HOST_SYSTEM" ]] && fail '$HOST_SYSTEM not defined' + +DIR=$(dirname ${BASH_SOURCE[0]}) +cd "$DIR" + +DATA_DIR=$(realpath ../data) +INSTALL_DIR=$(realpath ../target-"$HOST") +NJOBS=$(grep -c ^processor /proc/cpuinfo) + +mkdir -p "$DATA_DIR" +cd "$DATA_DIR" + +checksum() { + local file="$1" + local sum="$2" + echo "$file: verifying checksum..." + echo "$sum $file" | sha256sum -c +} + +get_file() { + local url="$1" + local file="$2" + local sum="$3" + if [[ -f "$file" ]] + then + echo "$file: found" + else + echo "$file: not found, downloading..." + wget "$url" -O "$file" + fi + checksum "$file" "$sum" +}