mirror of
https://github.com/levogevo/ffmpeg-builder.git
synced 2026-01-15 19:06:17 +00:00
more packages and testing libc
This commit is contained in:
79
lib/build.sh
79
lib/build.sh
@@ -101,16 +101,19 @@ set_compile_opts() {
|
|||||||
# architecture/cpu compile flags
|
# architecture/cpu compile flags
|
||||||
# arm prefers -mcpu over -march
|
# arm prefers -mcpu over -march
|
||||||
# https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/compiler-flags-across-architectures-march-mtune-and-mcpu
|
# https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/compiler-flags-across-architectures-march-mtune-and-mcpu
|
||||||
arch_flags=""
|
# and can fail static builds with -fpic
|
||||||
test_arch="$(uname -m)"
|
# warning: too many GOT entries for -fpic, please recompile with -fPIC
|
||||||
if [[ ${test_arch} == "x86_64" ]]; then
|
local arch_flags=()
|
||||||
arch_flags="-march=${CPU}"
|
if [[ ${HOSTTYPE} == "x86_64" ]]; then
|
||||||
elif [[ ${test_arch} == "aarch64" ||
|
arch_flags+=("-march=${CPU}")
|
||||||
${test_arch} == "arm64" ]]; then
|
elif [[ ${HOSTTYPE} == "aarch64" ]]; then
|
||||||
arch_flags="-mcpu=${CPU}"
|
arch_flags+=(
|
||||||
|
"-mcpu=${CPU}"
|
||||||
|
"-fPIC"
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
C_FLAGS+=("${arch_flags}")
|
C_FLAGS+=("${arch_flags[@]}")
|
||||||
CXX_FLAGS=("${C_FLAGS[@]}")
|
CXX_FLAGS=("${C_FLAGS[@]}")
|
||||||
CPP_FLAGS=("${C_FLAGS[@]}")
|
CPP_FLAGS=("${C_FLAGS[@]}")
|
||||||
RUSTFLAGS+=("-C target-cpu=${CPU}")
|
RUSTFLAGS+=("-C target-cpu=${CPU}")
|
||||||
@@ -158,6 +161,17 @@ set_compile_opts() {
|
|||||||
get_build_conf() {
|
get_build_conf() {
|
||||||
local getBuild="${1}"
|
local getBuild="${1}"
|
||||||
|
|
||||||
|
local libcVer='X.X'
|
||||||
|
if test "${getBuild}" == 'libc' && has_cmd ldd; then
|
||||||
|
local srcTest="${TMP_DIR}/libc-ver"
|
||||||
|
echo '#include <gnu/libc-version.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
int main() { puts(gnu_get_libc_version()); return 0; }' >"${srcTest}.c"
|
||||||
|
gcc "${srcTest}.c" -o "${srcTest}"
|
||||||
|
libcVer="$("${srcTest}")"
|
||||||
|
fi
|
||||||
|
|
||||||
# name version file-extension url dep1,dep2
|
# name version file-extension url dep1,dep2
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
local BUILDS_CONF='
|
local BUILDS_CONF='
|
||||||
@@ -172,6 +186,9 @@ libvmaf 3.0.0 tar.gz https://github.com/Netflix/vmaf/archive/refs/t
|
|||||||
libopus 1.5.2 tar.gz https://github.com/xiph/opus/releases/download/v${ver}/opus-${ver}.${ext}
|
libopus 1.5.2 tar.gz https://github.com/xiph/opus/releases/download/v${ver}/opus-${ver}.${ext}
|
||||||
libdav1d 1.5.1 tar.xz http://downloads.videolan.org/videolan/dav1d/${ver}/dav1d-${ver}.${ext}
|
libdav1d 1.5.1 tar.xz http://downloads.videolan.org/videolan/dav1d/${ver}/dav1d-${ver}.${ext}
|
||||||
'
|
'
|
||||||
|
BUILDS_CONF+="libc ${libcVer} tar.xz"
|
||||||
|
BUILDS_CONF+=' https://ftpmirror.gnu.org/glibc/glibc-${ver}.${ext}'
|
||||||
|
|
||||||
local supported_builds=()
|
local supported_builds=()
|
||||||
unset ver ext url deps extracted_dir
|
unset ver ext url deps extracted_dir
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
@@ -423,8 +440,14 @@ build_libaom() {
|
|||||||
|
|
||||||
### MESON ###
|
### MESON ###
|
||||||
build_libdav1d() {
|
build_libdav1d() {
|
||||||
|
local enableAsm='true'
|
||||||
|
# arm64 will fail the build at 0 optimization
|
||||||
|
if [[ "${HOSTTYPE}:${OPT_LVL}" == "aarch64:0" ]]; then
|
||||||
|
enableAsm="false"
|
||||||
|
fi
|
||||||
meson \
|
meson \
|
||||||
setup . build.user \
|
setup . build.user \
|
||||||
|
-Denable_asm=${enableAsm} \
|
||||||
"${MESON_FLAGS[@]}" || return 1
|
"${MESON_FLAGS[@]}" || return 1
|
||||||
ccache ninja -vC build.user || return 1
|
ccache ninja -vC build.user || return 1
|
||||||
${SUDO_MODIFY} ninja -vC build.user install || return 1
|
${SUDO_MODIFY} ninja -vC build.user install || return 1
|
||||||
@@ -471,6 +494,46 @@ build_libopus() {
|
|||||||
${SUDO_MODIFY} make -j"${JOBS}" install || return 1
|
${SUDO_MODIFY} make -j"${JOBS}" install || return 1
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
# special function mainly for arm64 builds
|
||||||
|
# since most distros do not compile libc
|
||||||
|
# with -fPIC for some reason
|
||||||
|
build_libc() (
|
||||||
|
# only for arm64
|
||||||
|
test "${HOSTTYPE}" != "aarch64" && exit 0
|
||||||
|
# only for static builds
|
||||||
|
test "${STATIC}" == 'false' && exit 0
|
||||||
|
# only for glibc
|
||||||
|
has_cmd ldd || exit 0
|
||||||
|
# only build once
|
||||||
|
test -f "${LIBDIR}/libc.a" && exit 0
|
||||||
|
|
||||||
|
rm -rf build
|
||||||
|
mkdir build
|
||||||
|
cd build || exit 1
|
||||||
|
|
||||||
|
# manually set flags since these are
|
||||||
|
# not intended to be user-controlled
|
||||||
|
unset CFLAGS CXXFLAGS
|
||||||
|
export CFLAGS='-fPIC -O3 -U_FORTIFY_SOURCE'
|
||||||
|
export CXXFLAGS="${CFLAGS}"
|
||||||
|
libc_prefix="${PWD}/local-install"
|
||||||
|
libc_libdir="${libc_prefix}/lib"
|
||||||
|
./../configure \
|
||||||
|
--prefix="${libc_prefix}" \
|
||||||
|
--libdir="${libc_libdir}" \
|
||||||
|
--disable-werror || exit 1
|
||||||
|
make -j"${JOBS}" all || exit 1
|
||||||
|
|
||||||
|
# install only the -fPIC static libraries
|
||||||
|
for picLib in ./**_pic.a; do
|
||||||
|
echo_warn "${picLib}"
|
||||||
|
done
|
||||||
|
# exit 1
|
||||||
|
# cd "${libc_libdir}" || exit 1
|
||||||
|
# cp ./*.a "${LIBDIR}" || exit 1
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
)
|
||||||
add_project_versioning_to_ffmpeg() {
|
add_project_versioning_to_ffmpeg() {
|
||||||
local optFile
|
local optFile
|
||||||
optFile="$(command ls ./**/ffmpeg_opt.c)"
|
optFile="$(command ls ./**/ffmpeg_opt.c)"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# variables used externally
|
# variables used externally
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
# complete clean before building
|
# clean build directories before building
|
||||||
CLEAN=true
|
CLEAN=true
|
||||||
# enable link time optimization
|
# enable link time optimization
|
||||||
LTO=false
|
LTO=false
|
||||||
@@ -11,7 +11,7 @@ LTO=false
|
|||||||
OPT_LVL=0
|
OPT_LVL=0
|
||||||
# static or shared build
|
# static or shared build
|
||||||
STATIC=true
|
STATIC=true
|
||||||
# CPU type (x86_v{1,2,3}...)
|
# CPU type (amd64/v{1,2,3}...)
|
||||||
CPU=native
|
CPU=native
|
||||||
# architecture type
|
# architecture type
|
||||||
ARCH=native
|
ARCH=native
|
||||||
|
|||||||
@@ -120,17 +120,19 @@ docker_build_image() {
|
|||||||
printf "RUN ${pkg_install} %s\n" "${req_pkgs[@]}"
|
printf "RUN ${pkg_install} %s\n" "${req_pkgs[@]}"
|
||||||
echo 'RUN pipx install virtualenv'
|
echo 'RUN pipx install virtualenv'
|
||||||
echo 'RUN pipx ensurepath'
|
echo 'RUN pipx ensurepath'
|
||||||
echo 'RUN curl https://sh.rustup.rs -sSf | bash -s -- -y'
|
echo 'ENV CARGO_HOME="/root/.cargo"'
|
||||||
echo 'ENV PATH="~/.cargo/bin:$PATH"'
|
echo 'ENV RUSTUP_HOME="/root/.rustup"'
|
||||||
echo 'RUN rustup default stable && rustup update stable'
|
echo 'ENV PATH="/root/.cargo/bin:$PATH"'
|
||||||
echo 'RUN cargo install cargo-c'
|
local cargoInst=''
|
||||||
|
cargoInst+='curl https://sh.rustup.rs -sSf | bash -s -- -y'
|
||||||
|
cargoInst+='&& rustup update stable'
|
||||||
|
cargoInst+='&& cargo install cargo-c'
|
||||||
|
cargoInst+='&& rm -rf "${CARGO_HOME}"/registry "${CARGO_HOME}"/git'
|
||||||
|
echo "RUN ${cargoInst}"
|
||||||
# since any user may run this image,
|
# since any user may run this image,
|
||||||
# open up root tools to everyone
|
# open up root tools to everyone
|
||||||
echo 'RUN chmod 777 -R /root/'
|
|
||||||
echo 'ENV PATH="/root/.cargo/bin:$PATH"'
|
|
||||||
echo 'ENV PATH="/root/.local/bin:$PATH"'
|
echo 'ENV PATH="/root/.local/bin:$PATH"'
|
||||||
echo 'ENV RUSTUP_HOME="/root/.rustup"'
|
echo 'RUN chmod 777 -R /root/'
|
||||||
echo 'ENV CARGO_HOME="/root/.rustup"'
|
|
||||||
echo "WORKDIR ${DOCKER_WORKDIR}"
|
echo "WORKDIR ${DOCKER_WORKDIR}"
|
||||||
|
|
||||||
} >"${dockerfile}"
|
} >"${dockerfile}"
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ print_req_pkgs() {
|
|||||||
local common_pkgs=(
|
local common_pkgs=(
|
||||||
autoconf automake cmake libtool
|
autoconf automake cmake libtool
|
||||||
texinfo nasm yasm python3 wget
|
texinfo nasm yasm python3 wget
|
||||||
meson doxygen jq ccache gawk git
|
meson doxygen jq ccache gawk
|
||||||
|
git gnuplot bison rsync ragel
|
||||||
|
zip unzip gperf itstool
|
||||||
)
|
)
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
local brew_pkgs=(
|
local brew_pkgs=(
|
||||||
@@ -62,7 +64,7 @@ print_req_pkgs() {
|
|||||||
libvorbis-dev libxcb1-dev pipx
|
libvorbis-dev libxcb1-dev pipx
|
||||||
libxcb-shm0-dev libxcb-xfixes0-dev
|
libxcb-shm0-dev libxcb-xfixes0-dev
|
||||||
zlib1g-dev libssl-dev ninja-build
|
zlib1g-dev libssl-dev ninja-build
|
||||||
gobjc++ mawk libnuma-dev
|
gobjc++ mawk libnuma-dev libc6-dev
|
||||||
mediainfo mkvtoolnix libgtest-dev
|
mediainfo mkvtoolnix libgtest-dev
|
||||||
)
|
)
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
@@ -74,12 +76,13 @@ print_req_pkgs() {
|
|||||||
local dnf_pkgs=(
|
local dnf_pkgs=(
|
||||||
"${common_linux_pkgs[@]}" openssl-devel
|
"${common_linux_pkgs[@]}" openssl-devel
|
||||||
pipx ninja-build fontconfig-devel wget2
|
pipx ninja-build fontconfig-devel wget2
|
||||||
cpuinfo-devel glibc-static libstdc++-static
|
cpuinfo-devel glibc-static glibc-devel
|
||||||
|
libstdc++-static libstdc++-devel
|
||||||
)
|
)
|
||||||
|
|
||||||
local req_pkgs_env_name="${pkg_mgr/-/_}_pkgs"
|
local req_pkgs_env_name="${pkg_mgr/-/_}_pkgs"
|
||||||
declare -n req_pkgs="${req_pkgs_env_name}"
|
declare -n req_pkgs="${req_pkgs_env_name}"
|
||||||
local sorted_req_pkgs=($(printf '%s\n' "${req_pkgs[@]}" | sort))
|
local sorted_req_pkgs=($(printf '%s\n' "${req_pkgs[@]}" | sort -u))
|
||||||
echo "${sorted_req_pkgs[@]}"
|
echo "${sorted_req_pkgs[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user