Add support for win32 builds

Closes #3
This commit is contained in:
BtbN 2020-09-27 22:10:05 +02:00
parent 0e104d9662
commit 77b3030134
17 changed files with 123 additions and 19 deletions

View file

@ -0,0 +1,26 @@
ARG GH_REPO=btbn/ffmpeg-builds
FROM docker.pkg.github.com/$GH_REPO/base:latest
ENV DEBIAN_FRONTEND noninteractive
RUN \
apt-get -y install mingw-w64 && \
apt-get -y clean && \
rm /usr/lib/gcc/*-w64-mingw32/*/libstdc++*.dll* && \
rm /usr/lib/gcc/*-w64-mingw32/*/libgcc_s* && \
rm /usr/lib/gcc/*-w64-mingw32/*/*.dll.a && \
rm /usr/*-w64-mingw32/lib/*.dll.a && \
mkdir /opt/ffbuild
ADD toolchain.cmake /toolchain.cmake
ADD cross.meson /cross.meson
ENV FFBUILD_TARGET_FLAGS="--pkg-config=pkg-config --cross-prefix=i686-w64-mingw32- --arch=i686 --target-os=mingw32" \
FFBUILD_TOOLCHAIN=i686-w64-mingw32 \
FFBUILD_CROSS_PREFIX=i686-w64-mingw32- \
FFBUILD_PREFIX=/opt/ffbuild \
FFBUILD_CMAKE_TOOLCHAIN=/toolchain.cmake \
PKG_CONFIG_LIBDIR=/opt/ffbuild/lib/pkgconfig \
CFLAGS="-static-libgcc -static-libstdc++ -I/opt/ffbuild/include -O2 -pipe -D_FORTIFY_SOURCE=2 -fstack-protector-strong" \
CXXFLAGS="-static-libgcc -static-libstdc++ -I/opt/ffbuild/include -O2 -pipe -D_FORTIFY_SOURCE=2 -fstack-protector-strong" \
LDFLAGS="-static-libgcc -static-libstdc++ -L/opt/ffbuild/lib -O2 -pipe -fstack-protector-strong"

View file

@ -0,0 +1,18 @@
[binaries]
c = 'i686-w64-mingw32-gcc'
cpp = 'i686-w64-mingw32-g++'
ar = 'i686-w64-mingw32-ar'
strip = 'i686-w64-mingw32-strip'
windres = 'i686-w64-mingw32-windres'
exe_wrapper = ['wine']
[properties]
c_link_args = ['-static-libgcc']
cpp_link_args = ['-static-libgcc', '-static-libstdc++']
needs_exe_wrapper = true
[host_machine]
system = 'windows'
cpu_family = 'i686'
cpu = 'i686'
endian = 'little'

View file

@ -0,0 +1,13 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR i686)
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
set(CMAKE_RANLIB i686-w64-mingw32-ranlib)
set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32 /opt/ffbuild)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

View file

@ -26,11 +26,16 @@ ffbuild_dockerbuild() {
--prefix="$FFBUILD_PREFIX" --prefix="$FFBUILD_PREFIX"
) )
if [[ $TARGET == win* ]]; then if [[ $TARGET == win64 ]]; then
myconf+=( myconf+=(
--cross-compile-prefix="$FFBUILD_CROSS_PREFIX" --cross-compile-prefix="$FFBUILD_CROSS_PREFIX"
mingw64 mingw64
) )
elif [[ $TARGET == win32 ]]; then
myconf+=(
--cross-compile-prefix="$FFBUILD_CROSS_PREFIX"
mingw
)
else else
echo "Unknown target" echo "Unknown target"
return -1 return -1

View file

@ -24,9 +24,9 @@ ffbuild_dockerbuild() {
--default-library=static --default-library=static
) )
if [[ $TARGET == win64 ]]; then if [[ $TARGET == win* ]]; then
myconf+=( myconf+=(
--cross-file=../package/crossfiles/x86_64-w64-mingw32.meson --cross-file=/cross.meson
) )
else else
echo "Unknown target" echo "Unknown target"

View file

@ -26,11 +26,16 @@ ffbuild_dockerbuild() {
--prefix="$FFBUILD_PREFIX" --prefix="$FFBUILD_PREFIX"
) )
if [[ $TARGET == win* ]]; then if [[ $TARGET == win64 ]]; then
myconf+=( myconf+=(
--target=x86_64-win64-gcc --target=x86_64-win64-gcc
) )
export CROSS="$FFBUILD_CROSS_PREFIX" export CROSS="$FFBUILD_CROSS_PREFIX"
elif [[ $TARGET == win32 ]]; then
myconf+=(
--target=x86-win32-gcc
)
export CROSS="$FFBUILD_CROSS_PREFIX"
else else
echo "Unknown target" echo "Unknown target"
return -1 return -1

View file

@ -4,6 +4,7 @@ SVTAV1_REPO="https://github.com/OpenVisualCloud/SVT-AV1.git"
SVTAV1_COMMIT="0dc2297715861b78577b3790e361af74b6c4bfef" SVTAV1_COMMIT="0dc2297715861b78577b3790e361af74b6c4bfef"
ffbuild_enabled() { ffbuild_enabled() {
[[ $TARGET == win32 ]] && return -1
[[ $VARIANT == *4.3* ]] && return -1 [[ $VARIANT == *4.3* ]] && return -1
return 0 return 0
} }

View file

@ -18,21 +18,22 @@ ffbuild_dockerbuild() {
cd x265 cd x265
git checkout "$X265_COMMIT" git checkout "$X265_COMMIT"
if [[ $TARGET != *32 ]]; then
mkdir 8bit 10bit 12bit mkdir 8bit 10bit 12bit
cd 12bit cd 12bit
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON ../source || return -1 cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON ../source
make -j$(nproc) || return -1 make -j$(nproc)
cp libx265.a ../8bit/libx265_main12.a cp libx265.a ../8bit/libx265_main12.a
cd ../10bit cd ../10bit
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF ../source || return -1 cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF ../source
make -j$(nproc) || return -1 make -j$(nproc)
cp libx265.a ../8bit/libx265_main10.a cp libx265.a ../8bit/libx265_main10.a
cd ../8bit cd ../8bit
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON -DENABLE_SHARED=OFF -DENABLE_CLI=OFF ../source || return -1 cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON -DENABLE_SHARED=OFF -DENABLE_CLI=OFF ../source
make -j$(nproc) || return -1 make -j$(nproc)
mv libx265.a libx265_main.a mv libx265.a libx265_main.a
${FFBUILD_CROSS_PREFIX}ar -M <<EOF ${FFBUILD_CROSS_PREFIX}ar -M <<EOF
@ -43,6 +44,12 @@ ADDLIB libx265_main12.a
SAVE SAVE
END END
EOF EOF
else
mkdir 8bit
cd 8bit
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DENABLE_SHARED=OFF -DENABLE_CLI=OFF ../source
make -j$(nproc)
fi
make install || return -1 make install || return -1

View file

@ -14,6 +14,11 @@ BASE_IMAGE="${REGISTRY}/${REPO}/base:latest"
TARGET_IMAGE="${REGISTRY}/${REPO}/base-${TARGET}:latest" TARGET_IMAGE="${REGISTRY}/${REPO}/base-${TARGET}:latest"
IMAGE="${REGISTRY}/${REPO}/${TARGET}-${VARIANT}:latest" IMAGE="${REGISTRY}/${REPO}/${TARGET}-${VARIANT}:latest"
if ! [[ -f "variants/${TARGET}-${VARIANT}.sh" ]]; then
echo "Invalid target/variant"
exit -1
fi
ffbuild_configure() { ffbuild_configure() {
return 0 return 0
} }

View file

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/win32-gpl-shared.sh
GIT_BRANCH="release/4.3"

View file

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/win32-gpl.sh
GIT_BRANCH="release/4.3"

View file

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/default-install-shared.sh
source "$(dirname "$BASH_SOURCE")"/defaults-gpl-shared.sh

3
variants/win32-gpl.sh Normal file
View file

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/default-install.sh
source "$(dirname "$BASH_SOURCE")"/defaults-gpl.sh

View file

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/win32-lgpl-shared.sh
GIT_BRANCH="release/4.3"

View file

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/win32-lgpl.sh
GIT_BRANCH="release/4.3"

View file

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/default-install-shared.sh
source "$(dirname "$BASH_SOURCE")"/defaults-lgpl-shared.sh

3
variants/win32-lgpl.sh Normal file
View file

@ -0,0 +1,3 @@
#!/bin/bash
source "$(dirname "$BASH_SOURCE")"/default-install.sh
source "$(dirname "$BASH_SOURCE")"/defaults-lgpl.sh