Compare commits

...

2 Commits

Author SHA1 Message Date
652e210bfb cross-compile 2022-05-23 21:07:30 +02:00
a1117c58ac [WIP] build deps 2022-05-23 21:06:52 +02:00
3 changed files with 122 additions and 0 deletions

2
app/deps/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/data
/target-*

64
app/deps/src/build-ffmpeg.sh Executable file
View File

@ -0,0 +1,64 @@
#!/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"
--arch="$ARCH"
--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
)
case "$HOST_SYSTEM" in
linux)
params+=(--enable-libv4l2)
;;
windows)
params+=(--target-os=mingw32)
params+=(--cross-prefix="$HOST-")
;;
*)
fail "Unsupported platform: $HOST"
;;
esac
../configure "${params[@]}"
make -j $NJOBS
make install

56
app/deps/src/init_deps Normal file
View File

@ -0,0 +1,56 @@
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'
if [[ "$HOST" == *linux* ]]
then
HOST_SYSTEM='linux'
elif [[ "$HOST" == *mingw* ]]
then
HOST_SYSTEM='windows'
else
fail "Host system could not be deduced from '$HOST'"
fi
ARCH="${HOST%%-*}"
[[ -z "$ARCH" ]] && fail "Arch could not be deduced from '$HOST'"
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"
}