From 281ab2941762729eb5b2677a727b70ed5fde524f Mon Sep 17 00:00:00 2001 From: BtbN Date: Thu, 14 Mar 2024 22:54:42 +0100 Subject: [PATCH] Move configure flags into each respective image --- build.sh | 36 +++--------------------------------- generate.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 35 deletions(-) diff --git a/build.sh b/build.sh index ed69d1c..ddd0604 100755 --- a/build.sh +++ b/build.sh @@ -4,42 +4,12 @@ shopt -s globstar cd "$(dirname "$0")" source util/vars.sh -get_output() { - ( - SELF="$1" - source $1 - if ffbuild_enabled; then - ffbuild_$2 || exit 0 - else - ffbuild_un$2 || exit 0 - fi - ) -} - source "variants/${TARGET}-${VARIANT}.sh" for addin in ${ADDINS[*]}; do source "addins/${addin}.sh" done -export FFBUILD_PREFIX="$(docker run --rm "$IMAGE" bash -c 'echo $FFBUILD_PREFIX')" - -for script in scripts.d/**/*.sh; do - FF_CONFIGURE+=" $(get_output $script configure)" - FF_CFLAGS+=" $(get_output $script cflags)" - FF_CXXFLAGS+=" $(get_output $script cxxflags)" - FF_LDFLAGS+=" $(get_output $script ldflags)" - FF_LDEXEFLAGS+=" $(get_output $script ldexeflags)" - FF_LIBS+=" $(get_output $script libs)" -done - -FF_CONFIGURE="$(xargs <<< "$FF_CONFIGURE")" -FF_CFLAGS="$(xargs <<< "$FF_CFLAGS")" -FF_CXXFLAGS="$(xargs <<< "$FF_CXXFLAGS")" -FF_LDFLAGS="$(xargs <<< "$FF_LDFLAGS")" -FF_LDEXEFLAGS="$(xargs <<< "$FF_LDEXEFLAGS")" -FF_LIBS="$(xargs <<< "$FF_LIBS")" - TESTFILE="uidtestfile" rm -f "$TESTFILE" docker run --rm -v "$PWD:/uidtestdir" "$IMAGE" touch "/uidtestdir/$TESTFILE" @@ -67,9 +37,9 @@ cat <"$BUILD_SCRIPT" git clone --filter=blob:none --branch='$GIT_BRANCH' '$FFMPEG_REPO' ffmpeg cd ffmpeg - ./configure --prefix=/ffbuild/prefix --pkg-config-flags="--static" \$FFBUILD_TARGET_FLAGS $FF_CONFIGURE \ - --extra-cflags='$FF_CFLAGS' --extra-cxxflags='$FF_CXXFLAGS' \ - --extra-ldflags='$FF_LDFLAGS' --extra-ldexeflags='$FF_LDEXEFLAGS' --extra-libs='$FF_LIBS' \ + ./configure --prefix=/ffbuild/prefix --pkg-config-flags="--static" \$FFBUILD_TARGET_FLAGS \$FF_CONFIGURE \ + --extra-cflags='\$FF_CFLAGS' --extra-cxxflags='\$FF_CXXFLAGS' \ + --extra-ldflags='\$FF_LDFLAGS' --extra-ldexeflags='\$FF_LDEXEFLAGS' --extra-libs='\$FF_LIBS' \ --extra-version="\$(date +%Y%m%d)" make -j\$(nproc) V=1 make install install-doc diff --git a/generate.sh b/generate.sh index 7b3173f..41ed9e5 100755 --- a/generate.sh +++ b/generate.sh @@ -1,5 +1,6 @@ #!/bin/bash set -e +shopt -s globstar cd "$(dirname "$0")" source util/vars.sh @@ -34,8 +35,6 @@ exec_dockerstage() { to_df "ENV SELF=\"$SELF\" STAGENAME=\"$STAGENAME\"" - set -x - STG="$(ffbuild_dockerdl)" if [[ -n "$STG" ]]; then HASH="$(sha256sum <<<"$STG" | cut -d" " -f1)" @@ -101,3 +100,51 @@ done to_df "FROM base" sed "s/__PREVLAYER__/$PREVLAYER/g" Dockerfile.final | sort -u >> Dockerfile rm Dockerfile.final + +### +### Compile list of configure arguments and add them to the final Dockerfile +### + +get_output() { + ( + SELF="$1" + source $1 + if ffbuild_enabled; then + ffbuild_$2 || exit 0 + else + ffbuild_un$2 || exit 0 + fi + ) +} + +source "variants/${TARGET}-${VARIANT}.sh" + +for addin in ${ADDINS[*]}; do + source "addins/${addin}.sh" +done + +export FFBUILD_PREFIX="$(docker run --rm "$IMAGE" bash -c 'echo $FFBUILD_PREFIX')" + +for script in scripts.d/**/*.sh; do + FF_CONFIGURE+=" $(get_output $script configure)" + FF_CFLAGS+=" $(get_output $script cflags)" + FF_CXXFLAGS+=" $(get_output $script cxxflags)" + FF_LDFLAGS+=" $(get_output $script ldflags)" + FF_LDEXEFLAGS+=" $(get_output $script ldexeflags)" + FF_LIBS+=" $(get_output $script libs)" +done + +FF_CONFIGURE="$(xargs <<< "$FF_CONFIGURE")" +FF_CFLAGS="$(xargs <<< "$FF_CFLAGS")" +FF_CXXFLAGS="$(xargs <<< "$FF_CXXFLAGS")" +FF_LDFLAGS="$(xargs <<< "$FF_LDFLAGS")" +FF_LDEXEFLAGS="$(xargs <<< "$FF_LDEXEFLAGS")" +FF_LIBS="$(xargs <<< "$FF_LIBS")" + +to_df "ENV \\" +to_df " FF_CONFIGURE=\"$FF_CONFIGURE\" \\" +to_df " FF_CFLAGS=\"$FF_CFLAGS\" \\" +to_df " FF_CXXFLAGS=\"$FF_CXXFLAGS\" \\" +to_df " FF_LDFLAGS=\"$FF_LDFLAGS\" \\" +to_df " FF_LDEXEFLAGS=\"$FF_LDEXEFLAGS\" \\" +to_df " FF_LIBS=\"$FF_LIBS\""