summaryrefslogtreecommitdiffstats
path: root/ci/build-mingw64.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ci/build-mingw64.sh')
-rwxr-xr-xci/build-mingw64.sh274
1 files changed, 187 insertions, 87 deletions
diff --git a/ci/build-mingw64.sh b/ci/build-mingw64.sh
index 46e037b62a..5ca8cf166f 100755
--- a/ci/build-mingw64.sh
+++ b/ci/build-mingw64.sh
@@ -6,14 +6,11 @@ ln -snf . "$prefix_dir/usr"
ln -snf . "$prefix_dir/local"
wget="wget -nc --progress=bar:force"
-gitclone="git clone --depth=10 --recursive"
-commonflags="--disable-static --enable-shared"
-
-export PKG_CONFIG_SYSROOT_DIR="$prefix_dir"
-export PKG_CONFIG_LIBDIR="$PKG_CONFIG_SYSROOT_DIR/lib/pkgconfig"
+gitclone="git clone --depth=1 --recursive --shallow-submodules"
# -posix is Ubuntu's variant with pthreads support
export CC=$TARGET-gcc-posix
+export AS=$TARGET-gcc-posix
export CXX=$TARGET-g++-posix
export AR=$TARGET-ar
export NM=$TARGET-nm
@@ -22,6 +19,14 @@ export RANLIB=$TARGET-ranlib
export CFLAGS="-O2 -pipe -Wall -D_FORTIFY_SOURCE=2"
export LDFLAGS="-fstack-protector-strong"
+# anything that uses pkg-config
+export PKG_CONFIG_SYSROOT_DIR="$prefix_dir"
+export PKG_CONFIG_LIBDIR="$PKG_CONFIG_SYSROOT_DIR/lib/pkgconfig"
+
+# autotools(-like)
+commonflags="--disable-static --enable-shared"
+
+# meson
fam=x86_64
[[ "$TARGET" == "i686-"* ]] && fam=x86
cat >"$prefix_dir/crossfile" <<EOF
@@ -29,12 +34,13 @@ cat >"$prefix_dir/crossfile" <<EOF
buildtype = 'release'
wrap_mode = 'nodownload'
[binaries]
-c = '${CC}'
-cpp = '${CXX}'
+c = ['ccache', '${CC}']
+cpp = ['ccache', '${CXX}']
ar = '${AR}'
strip = '${TARGET}-strip'
pkgconfig = 'pkg-config'
windres = '${TARGET}-windres'
+dlltool = '${TARGET}-dlltool'
[host_machine]
system = 'windows'
cpu_family = '${fam}'
@@ -42,13 +48,27 @@ cpu = '${TARGET%%-*}'
endian = 'little'
EOF
-function builddir () {
+# CMake
+cmake_args=(
+ -Wno-dev
+ -DCMAKE_SYSTEM_PROCESSOR="${fam}"
+ -DCMAKE_SYSTEM_NAME=Windows
+ -DCMAKE_FIND_ROOT_PATH="$PKG_CONFIG_SYSROOT_DIR"
+ -DCMAKE_RC_COMPILER="${TARGET}-windres"
+ -DCMAKE_ASM_COMPILER="$AS"
+ -DCMAKE_BUILD_TYPE=Release
+)
+
+export CC="ccache $CC"
+export CXX="ccache $CXX"
+
+function builddir {
[ -d "$1/builddir" ] && rm -rf "$1/builddir"
mkdir -p "$1/builddir"
pushd "$1/builddir"
}
-function makeplusinstall () {
+function makeplusinstall {
if [ -f build.ninja ]; then
ninja
DESTDIR="$prefix_dir" ninja install
@@ -58,135 +78,205 @@ function makeplusinstall () {
fi
}
-function gettar () {
- name="${1##*/}"
+function gettar {
+ local name="${1##*/}"
[ -d "${name%%.*}" ] && return 0
$wget "$1"
tar -xaf "$name"
}
-## iconv
-if [ ! -e "$prefix_dir/lib/libiconv.dll.a" ]; then
- ver=1.17
+function build_if_missing {
+ local name=${1//-/_}
+ local mark_var=_${name}_mark
+ local mark_file=$prefix_dir/${!mark_var}
+ [ -e "$mark_file" ] && return 0
+ echo "::group::Building $1"
+ _$name
+ echo "::endgroup::"
+ if [ ! -e "$mark_file" ]; then
+ echo "Error: Build of $1 completed but $mark_file was not created."
+ return 2
+ fi
+}
+
+
+## mpv's dependencies
+
+_iconv () {
+ local ver=1.17
gettar "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-${ver}.tar.gz"
builddir libiconv-${ver}
../configure --host=$TARGET $commonflags
makeplusinstall
popd
-fi
+}
+_iconv_mark=lib/libiconv.dll.a
-## zlib
-if [ ! -e "$prefix_dir/lib/libz.dll.a" ]; then
- ver=1.2.12
+_zlib () {
+ local ver=1.3.1
gettar "https://zlib.net/fossils/zlib-${ver}.tar.gz"
pushd zlib-${ver}
make -fwin32/Makefile.gcc clean
- make -fwin32/Makefile.gcc PREFIX=$TARGET- SHARED_MODE=1 \
+ make -fwin32/Makefile.gcc PREFIX=$TARGET- CC="$CC" SHARED_MODE=1 \
DESTDIR="$prefix_dir" install \
BINARY_PATH=/bin INCLUDE_PATH=/include LIBRARY_PATH=/lib
popd
-fi
+}
+_zlib_mark=lib/libz.dll.a
-## ffmpeg
-if [ ! -e "$prefix_dir/lib/libavcodec.dll.a" ]; then
+_dav1d () {
+ [ -d dav1d ] || $gitclone https://code.videolan.org/videolan/dav1d.git
+ builddir dav1d
+ meson setup .. --cross-file "$prefix_dir/crossfile" \
+ -Denable_{tools,tests}=false
+ makeplusinstall
+ popd
+}
+_dav1d_mark=lib/libdav1d.dll.a
+
+_ffmpeg () {
[ -d ffmpeg ] || $gitclone https://github.com/FFmpeg/FFmpeg.git ffmpeg
builddir ffmpeg
- ../configure --pkg-config=pkg-config --target-os=mingw32 \
- --enable-cross-compile --cross-prefix=$TARGET- --arch=${TARGET%%-*} \
- $commonflags \
- --disable-{doc,programs,muxers,encoders,devices}
+ local args=(
+ --pkg-config=pkg-config --target-os=mingw32
+ --enable-cross-compile --cross-prefix=$TARGET- --arch=${TARGET%%-*}
+ --cc="$CC" --cxx="$CXX" $commonflags
+ --disable-{doc,programs,muxers,encoders}
+ --enable-muxer=spdif --enable-encoder=mjpeg,png --enable-libdav1d
+ )
+ pkg-config vulkan && args+=(--enable-vulkan --enable-libshaderc)
+ ../configure "${args[@]}"
makeplusinstall
popd
-fi
+}
+_ffmpeg_mark=lib/libavcodec.dll.a
-## shaderc
-if [ ! -e "$prefix_dir/lib/libshaderc_shared.dll.a" ]; then
+_shaderc () {
if [ ! -d shaderc ]; then
$gitclone https://github.com/google/shaderc.git
(cd shaderc && ./utils/git-sync-deps)
fi
builddir shaderc
- cmake .. -DCMAKE_SYSTEM_NAME=Windows \
- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF \
- -DSHADERC_SKIP_TESTS=ON -DCMAKE_INSTALL_PREFIX=/
+ cmake .. "${cmake_args[@]}" \
+ -DBUILD_SHARED_LIBS=OFF -DSHADERC_SKIP_TESTS=ON
makeplusinstall
popd
-fi
+}
+_shaderc_mark=lib/libshaderc_shared.dll.a
-## spirv-cross
-if [ ! -e "$prefix_dir/lib/libspirv-cross-c-shared.dll.a" ]; then
+_spirv_cross () {
[ -d SPIRV-Cross ] || $gitclone https://github.com/KhronosGroup/SPIRV-Cross
builddir SPIRV-Cross
- cmake .. -DCMAKE_SYSTEM_NAME=Windows \
+ cmake .. "${cmake_args[@]}" \
-DSPIRV_CROSS_SHARED=ON -DSPIRV_CROSS_{CLI,STATIC}=OFF
makeplusinstall
popd
-fi
+}
+_spirv_cross_mark=lib/libspirv-cross-c-shared.dll.a
-## libplacebo
-if [ ! -e "$prefix_dir/lib/libplacebo.dll.a" ]; then
+_nv_headers () {
+ [ -d nv-codec-headers ] || $gitclone https://github.com/FFmpeg/nv-codec-headers
+ pushd nv-codec-headers
+ makeplusinstall
+ popd
+}
+_nv_headers_mark=include/ffnvcodec/dynlink_loader.h
+
+_vulkan_headers () {
+ [ -d Vulkan-Headers ] || $gitclone https://github.com/KhronosGroup/Vulkan-Headers
+ builddir Vulkan-Headers
+ cmake .. "${cmake_args[@]}"
+ makeplusinstall
+ popd
+}
+_vulkan_headers_mark=include/vulkan/vulkan.h
+
+_vulkan_loader () {
+ [ -d Vulkan-Loader ] || $gitclone https://github.com/KhronosGroup/Vulkan-Loader
+ builddir Vulkan-Loader
+ cmake .. "${cmake_args[@]}" \
+ -DENABLE_WERROR=OFF -DUSE_GAS=ON
+ makeplusinstall
+ popd
+}
+_vulkan_loader_mark=lib/libvulkan-1.dll.a
+
+_libplacebo () {
[ -d libplacebo ] || $gitclone https://code.videolan.org/videolan/libplacebo.git
builddir libplacebo
- meson .. --cross-file "$prefix_dir/crossfile"
+ meson setup .. --cross-file "$prefix_dir/crossfile" \
+ -Ddemos=false -D{opengl,d3d11}=enabled
makeplusinstall
popd
-fi
+}
+_libplacebo_mark=lib/libplacebo.dll.a
-## freetype2
-if [ ! -e "$prefix_dir/lib/libfreetype.dll.a" ]; then
- ver=2.12.1
- gettar "https://download.savannah.gnu.org/releases/freetype/freetype-${ver}.tar.xz"
+_freetype () {
+ local ver=2.13.2
+ gettar "https://mirror.netcologne.de/savannah/freetype/freetype-${ver}.tar.xz"
builddir freetype-${ver}
- meson .. --cross-file "$prefix_dir/crossfile"
+ meson setup .. --cross-file "$prefix_dir/crossfile"
makeplusinstall
popd
-fi
+}
+_freetype_mark=lib/libfreetype.dll.a
-## fribidi
-if [ ! -e "$prefix_dir/lib/libfribidi.dll.a" ]; then
- ver=1.0.12
+_fribidi () {
+ local ver=1.0.14
gettar "https://github.com/fribidi/fribidi/releases/download/v${ver}/fribidi-${ver}.tar.xz"
builddir fribidi-${ver}
- meson .. --cross-file "$prefix_dir/crossfile" \
+ meson setup .. --cross-file "$prefix_dir/crossfile" \
-D{tests,docs}=false
makeplusinstall
popd
-fi
+}
+_fribidi_mark=lib/libfribidi.dll.a
-## harfbuzz
-if [ ! -e "$prefix_dir/lib/libharfbuzz.dll.a" ]; then
- ver=5.3.0
+_harfbuzz () {
+ local ver=8.4.0
gettar "https://github.com/harfbuzz/harfbuzz/releases/download/${ver}/harfbuzz-${ver}.tar.xz"
builddir harfbuzz-${ver}
- meson .. --cross-file "$prefix_dir/crossfile" \
+ meson setup .. --cross-file "$prefix_dir/crossfile" \
-Dtests=disabled
makeplusinstall
popd
-fi
+}
+_harfbuzz_mark=lib/libharfbuzz.dll.a
-## libass
-if [ ! -e "$prefix_dir/lib/libass.dll.a" ]; then
+_libass () {
[ -d libass ] || $gitclone https://github.com/libass/libass.git
builddir libass
[ -f ../configure ] || (cd .. && ./autogen.sh)
../configure --host=$TARGET $commonflags
makeplusinstall
popd
-fi
+}
+_libass_mark=lib/libass.dll.a
-## luajit
-if [ ! -e "$prefix_dir/lib/libluajit-5.1.a" ]; then
- ver=2.1.0-beta3
- gettar "http://luajit.org/download/LuaJIT-${ver}.tar.gz"
- pushd LuaJIT-${ver}
- hostcc=cc
- [[ "$TARGET" == "i686-"* ]] && hostcc="$hostcc -m32"
+_luajit () {
+ [ -d LuaJIT ] || $gitclone https://github.com/LuaJIT/LuaJIT.git
+ pushd LuaJIT
+ local hostcc="ccache cc"
+ local flags=
+ [[ "$TARGET" == "i686-"* ]] && { hostcc="$hostcc -m32"; flags=XCFLAGS=-DLUAJIT_NO_UNWIND; }
make TARGET_SYS=Windows clean
- make TARGET_SYS=Windows HOST_CC="$hostcc" CROSS=$TARGET- \
- BUILDMODE=static amalg
+ make TARGET_SYS=Windows HOST_CC="$hostcc" CROSS="ccache $TARGET-" \
+ BUILDMODE=static $flags amalg
make DESTDIR="$prefix_dir" INSTALL_DEP= FILE_T=luajit.exe install
popd
+}
+_luajit_mark=lib/libluajit-5.1.a
+
+for x in iconv zlib shaderc spirv-cross nv-headers dav1d; do
+ build_if_missing $x
+done
+if [[ "$TARGET" != "i686-"* ]]; then
+ build_if_missing vulkan-headers
+ build_if_missing vulkan-loader
fi
+for x in ffmpeg libplacebo freetype fribidi harfbuzz libass luajit; do
+ build_if_missing $x
+done
## mpv
@@ -195,34 +285,44 @@ fi
CFLAGS+=" -I'$prefix_dir/include'"
LDFLAGS+=" -L'$prefix_dir/lib'"
export CFLAGS LDFLAGS
-rm -rf build
+build=mingw_build
+rm -rf $build
-if [ "$1" = "meson" ]; then
- meson setup build --cross-file "$prefix_dir/crossfile" \
- --buildtype debugoptimized \
- -D{libmpv,tests}=true -Dlua=luajit \
- -D{shaderc,spirv-cross,d3d11,libplacebo}=enabled
+meson setup $build --cross-file "$prefix_dir/crossfile" \
+ --werror \
+ -Dc_args="-Wno-error=deprecated -Wno-error=deprecated-declarations" \
+ --buildtype debugoptimized \
+ -Dlibmpv=true -Dlua=luajit \
+ -D{shaderc,spirv-cross,d3d11}=enabled
- ninja -C build --verbose
-elif [ "$1" = "waf" ]; then
- PKG_CONFIG=pkg-config ./waf configure \
- --enable-libmpv-shared --lua=luajit \
- --enable-{shaderc,spirv-cross,d3d11,libplacebo,tests}
-
- ./waf build --verbose
-fi
+meson compile -C $build
if [ "$2" = pack ]; then
- mkdir -p artifact
+ mkdir -p artifact/tmp
echo "Copying:"
- cp -pv build/mpv.{com,exe} "$prefix_dir/bin/"*.dll artifact/
- # ship everything and the kitchen sink
+ cp -pv $build/mpv.com $build/mpv.exe artifact/
+ # copy everything we can get our hands on
+ cp -p "$prefix_dir/bin/"*.dll artifact/tmp/
shopt -s nullglob
for file in /usr/lib/gcc/$TARGET/*-posix/*.dll /usr/$TARGET/lib/*.dll; do
- cp -pv "$file" artifact/
+ cp -p "$file" artifact/tmp/
done
+ # pick DLLs we need
+ pushd artifact/tmp
+ dlls=(
+ libgcc_*.dll lib{ssp,stdc++,winpthread}-[0-9]*.dll # compiler runtime
+ av*.dll sw*.dll lib{ass,freetype,fribidi,harfbuzz,iconv,placebo}-[0-9]*.dll
+ lib{shaderc_shared,spirv-cross-c-shared,dav1d}.dll zlib1.dll
+ )
+ if [[ -f vulkan-1.dll ]]; then
+ dlls+=(vulkan-1.dll)
+ fi
+ mv -v "${dlls[@]}" ..
+ popd
+
echo "Archiving:"
pushd artifact
+ rm -rf tmp
zip -9r "../mpv-git-$(date +%F)-$(git rev-parse --short HEAD)-${TARGET%%-*}.zip" -- *
popd
fi