diff --git a/scripts/build.sh b/scripts/build.sh index 885a71e..dfc7167 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,5 +1,50 @@ #!/bin/bash +usage() { + echo "./scripts/build.sh [-h] [-p] [-o] [r] [-a]" + echo -e "\th: display this help output" + echo -e "\tp: build svt-av1-psy with dovi library" + echo -e "\to: build other encoders x264/5 and vpx" + echo -e "\tr: build rockchip media libraries" +} + +update_git() { + git config pull.rebase false + git stash && git stash drop + git pull +} + +OPTS='hpao:' +NUM_OPTS=$(echo $OPTS | tr ':' '\n' | wc -l) +MIN_OPT=0 +# using all +MAX_OPT=$(( NUM_OPTS )) +test "$#" -lt $MIN_OPT && echo "not enough arguments" && usage && exit 1 +test "$#" -gt $MAX_OPT && echo "too many arguments" && usage && exit 1 +while getopts "$OPTS" flag; do + case "${flag}" in + h) + usage + exit 0 + ;; + p) + export BUILD_PSY="true" + echo "building psy" + ;; + o) + export BUILD_OTHERS="true" + echo "building other encoders" + ;; + r) + export BUILD_ROCKCHIP="true" + echo "building rockchip media platform" + ;; + *) + echo "building default" + ;; + esac +done + BASE_DIR=$(pwd) SVT_DIR="$BASE_DIR/svt" RAV1E_DIR="$BASE_DIR/rav1e" @@ -13,9 +58,6 @@ RKRGA_DIR="$BASE_DIR/rkrga" DOVI_DIR="$BASE_DIR/dovi" SVT_PSY_DIR="$BASE_DIR/svt-psy" -# build svt-psy + dovi_tool -BUILD_PSY="true" - # clone git clone --depth 1 https://gitlab.com/AOMediaCodec/SVT-AV1.git "$SVT_DIR" git clone --depth 1 https://github.com/quietvoid/dovi_tool "$DOVI_DIR" @@ -43,10 +85,8 @@ export PATH="/usr/lib/ccache/:$PATH" # rockchip ffmpeg libs FFMPEG_ROCKCHIP="" -IS_ROCKCHIP=$(uname -r | grep "rockchip" > /dev/null && echo "yes" || echo "no") -# disabling due to decode errors -IS_ROCKCHIP="no" -if [[ "$IS_ROCKCHIP" == "yes" ]] +# IS_ROCKCHIP=$(uname -r | grep "rockchip" > /dev/null && echo "yes" || echo "no") +if [[ "$BUILD_ROCKCHIP" == "true" ]] then FFMPEG_ROCKCHIP="--enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga" FFMPEG_DIR="$BASE_DIR/ffmpeg-rkmpp" @@ -58,8 +98,7 @@ then # build mpp cd "$RKMPP_DIR/" || exit - git stash && git stash drop - git pull + update_git rm -rf mpp_build.user mkdir mpp_build.user cd mpp_build.user || exit @@ -74,8 +113,7 @@ then # build rga cd "$RKRGA_DIR" || exit - git stash && git stash drop - git pull + update_git rm -rf rga_build.user mkdir rga_build.user cd rga_build.user || exit @@ -90,8 +128,7 @@ if [[ "$BUILD_PSY" == "true" ]]; then # build dovi_tool cd "$DOVI_DIR/" || exit - git stash && git stash drop - git pull + update_git rm -rf ffmpeg_build.user && mkdir ffmpeg_build.user || exit source "$HOME/.cargo/env" # for good measure cargo clean @@ -110,7 +147,7 @@ then # build svt-avt-psy cd "$SVT_PSY_DIR/" || exit - git pull + update_git rm -rf build_svt.user mkdir build_svt.user cd build_svt.user || exit @@ -125,7 +162,7 @@ then else # build svt-av1 cd "$SVT_DIR/" || exit - git pull + update_git rm -rf build_svt.user mkdir build_svt.user cd build_svt.user || exit @@ -141,8 +178,7 @@ fi # build rav1e cd "$RAV1E_DIR/" || exit -git stash && git stash drop -git pull +update_git rm -rf ffmpeg_build.user && mkdir ffmpeg_build.user || exit source "$HOME/.cargo/env" # for good measure cargo clean @@ -156,8 +192,7 @@ sudo cp ./include/* /usr/local/include/ -r || exit # build aom cd "$AOM_DIR/" || exit -git stash && git stash drop -git pull +update_git rm -rf build_aom.user mkdir build_aom.user cd build_aom.user || exit @@ -171,8 +206,7 @@ sudo make install || exit # build libvmaf cd "$VMAF_DIR/libvmaf" || exit -git stash && git stash drop -git pull +update_git python3 -m virtualenv .venv source .venv/bin/activate rm -rf build.user @@ -186,8 +220,7 @@ sudo ninja -vC build.user install || exit # build dav1d cd "$DAV1D_DIR" || exit -git stash && git stash drop -git pull +update_git rm -rf build.user mkdir build.user cd build.user || exit @@ -198,8 +231,7 @@ sudo ninja -vC build.user install || exit # build opus cd "$OPUS_DIR" || exit -git stash && git stash drop -git pull +update_git ./autogen.sh || exit export CFLAGS="-O3 -flto $COMP_FLAGS" ./configure || exit @@ -214,8 +246,7 @@ sudo ldconfig # build ffmpeg cd "$FFMPEG_DIR/" || exit -git stash && git stash drop -git pull +update_git export PKG_CONFIG_PATH+=":/usr/local/lib/pkgconfig" make clean ./configure --enable-libsvtav1 --enable-librav1e \ @@ -237,3 +268,4 @@ source ~/.profile ffmpeg -encoders 2>&1 | grep "av1" ffmpeg -encoders 2>&1 | grep "rkmpp" ffmpeg -decoders 2>&1 | grep "rkmpp" +exit 0