Skip to content

Commit

Permalink
build zlib directly
Browse files Browse the repository at this point in the history
  • Loading branch information
odrling committed Sep 3, 2024
1 parent ba5a231 commit 4d3b8d5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ ARG TARGET=""

RUN export DEBIAN_FRONTEND="noninteractive"
RUN apt-get update && apt-get -y upgrade
RUN apt-get -y install ffmpeg golang-go npm meson git nasm mold
RUN apt-get -y install ffmpeg golang-go npm meson git nasm mold cmake
COPY build/ /build
RUN TARGET=${TARGET} sh /build/build.sh
17 changes: 17 additions & 0 deletions build/aarch64-linux-gnu.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# the name of the target operating system
set(CMAKE_SYSTEM_NAME Linux)

# which compilers to use for C and C++
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc-14)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++-14)

# where is the target environment located
set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)

# adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
8 changes: 6 additions & 2 deletions build/aarch64-linux-gnu.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
CPU = 'aarch64'
TARGET = CPU + '-linux-gnu'
SYSROOT = '/usr/' + TARGET
GCC_VER = '14'

[binaries]
c = TARGET + '-gcc-14'
cpp = TARGET + '-g++-14'
c = TARGET + '-gcc-' + GCC_VER
cpp = TARGET + '-g++-' + GCC_VER
c_ld = 'mold'
cpp_ld = 'mold'
exe_wrapper = ['qemu-' + CPU + '-static', '-L', SYSROOT]
Expand All @@ -16,5 +17,8 @@ cpu_family = CPU
cpu = CPU
endian = 'little'

[properties]
sys_root = SYSROOT

[project options]
prefix = SYSROOT
39 changes: 28 additions & 11 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
#!/bin/sh -ex
#!/bin/sh
set -e
GCC_VER=14
if [ -z "${TARGET}" ]; then
cross_args="--native-file /build/native.ini"
apt-get -y install gcc-14 g++-14
apt-get -y install gcc-${GCC_VER} g++-${GCC_VER}
else
arch=$(echo ${TARGET} | cut -d- -f1)
cmake_args="-DCMAKE_TOOLCHAIN_FILE=/build/${TARGET}.cmake -DCMAKE_INSTALL_PREFIX=/usr/${TARGET}"
ffmpeg_args="--cross-prefix=${TARGET}- --pkg-config=pkg-config --cc=${TARGET}-gcc-${GCC_VER} --prefix=/usr/${TARGET} --arch=${arch} --target-os=linux"
cross_args="--cross-file /build/${TARGET}.ini"
apt-get -y install gcc-14-aarch64-linux-gnu g++-14-aarch64-linux-gnu qemu-user-static
apt-get -y install gcc-${GCC_VER}-${TARGET} g++-${GCC_VER}-${TARGET} qemu-user-static
export PKG_CONFIG_SYSROOT_DIR="/usr/${TARGET}"
fi

if [ ! -d /deps/ffmpeg ]; then
git clone --depth 1 --branch meson-7.0 https://gitlab.freedesktop.org/gstreamer/meson-ports/ffmpeg.git /deps/ffmpeg
if [ ! -d /deps/zlib ]; then
git clone --depth 1 -b master https://github.com/madler/zlib.git /deps/zlib
fi

meson setup /deps/ffmpeg_build /deps/ffmpeg --reconfigure --buildtype release -Db_lto=true -Db_lto_mode=thin -Db_pie=true -Db_sanitize=undefined --auto-features=disabled -Ddefault_library=shared -Dtests=disabled -Dprograms=disabled -Dencoders=disabled -Dmuxers=disabled -Davfilter=disabled -Davdevice=disabled -Dpostproc=disabled -Dswresample=disabled -Dswscale=disabled -Daac_decoder=enabled -Dversion3=enabled $cross_args
meson install -C /deps/ffmpeg_build
mkdir -p /deps/zlib_build
cd /deps/zlib_build
cmake ${cmake_args} /deps/zlib
make -j$(ncproc)
make install

if [ ! -d /deps/libass ]; then
git clone --depth 1 https://github.com/libass/libass.git /deps/libass
ln -s /build/subprojects /deps/libass
fi

cd /deps/libass
cp -r /build/subprojects .
meson setup /deps/libass_build /deps/libass --reconfigure --buildtype release -Db_lto=true -Db_lto_mode=thin -Db_pie=true -Db_sanitize=undefined --auto-features=disabled -Ddefault_library=shared -Dasm=enabled -Dfontconfig=enabled -Dfribidi:bin=false $cross_args
meson setup /deps/libass_build /deps/libass --reconfigure --buildtype release -Db_lto=true -Db_lto_mode=thin -Db_pie=true -Db_sanitize=undefined --auto-features=disabled -Ddefault_library=shared -Dasm=enabled -Dfontconfig=enabled -Dzlib:default_library=shared -Dfribidi:bin=false $cross_args
meson install -C /deps/libass_build

if [ ! -d /deps/ffmpeg ]; then
git clone --depth 1 --branch release/7.0 https://github.com/FFmpeg/FFmpeg.git /deps/ffmpeg
fi

mkdir -p /deps/ffmpeg_build
cd /deps/ffmpeg_build
/deps/ffmpeg/configure --logfile=/dev/stderr --enable-shared --disable-static --disable-autodetect --disable-programs --disable-avdevice --disable-postproc --disable-avfilter --disable-swscale --disable-swresample --disable-doc --disable-muxers --disable-network --disable-encoders --disable-decoders --disable-bsfs --disable-protocols --enable-zlib --enable-decoder=aac --toolchain=hardened --enable-lto=auto ${ffmpeg_args}
make -j$(nproc)
make install

rm -rf /deps /build
apt-get clean
rm -rf /var/lib/apt/lists/*

0 comments on commit 4d3b8d5

Please sign in to comment.