builder: Fix mingw cross build.

Add meson to core deps because glib requires it to build, and python is
much further in the dependency chain to build meson early enough.

Override the meson command to write and use a cross file for mingw cross
builds.

Add -DFFI_STATIC_BUILD to CPPFLAGS for glib.

Fix --env for the linux mingw cross script.

Add dist make args to the make install invocation.

Add --extra-libs=-liconv to ffmpeg ./configure invocation.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2019-12-01 22:07:41 +00:00
parent b8310538a3
commit b917933013
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
3 changed files with 78 additions and 37 deletions

View File

@ -221,10 +221,6 @@ FFMPEG_DISTS='
: ${PATH_SEP:=':'}
# these two can be set to always be included regardless of overrides
export CONFIGURE_REQUIRED_ARGS="$CONFIGURE_REQUIRED_ARGS"
export CMAKE_REQUIRED_ARGS="$CMAKE_REQUIRED_ARGS"
export CMAKE_BASE_ARGS="$CMAKE_BASE_ARGS -DBUILD_SHARED_LIBS=NO -DENABLE_SHARED=NO -DCMAKE_PREFIX_PATH:FILEPATH=\"\$CMAKE_PREFIX_PATH\" -DCMAKE_BUILD_TYPE=Release"
export CONFIGURE_INSTALL_ARGS="--prefix=/usr --sysconfdir=/etc"
@ -241,7 +237,7 @@ fi
export CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-shared --enable-static $CONFIGURE_INSTALL_ARGS"
export CMAKE_ARGS="$CMAKE_BASE_ARGS $CMAKE_ARGS $CMAKE_INSTALL_ARGS"
export MESON_ARGS="--buildtype release --default-library static -Dintrospection=false $MESON_INSTALL_ARGS"
export MESON_ARGS="$MESON_BASE_ARGS --buildtype release --default-library static -Dintrospection=false $MESON_INSTALL_ARGS"
DIST_PATCHES=$DIST_PATCHES'
m4 https://raw.githubusercontent.com/gentoo/gentoo/master/sys-devel/m4/files/m4-1.4.18-glibc228.patch
@ -334,7 +330,7 @@ DIST_CONFIGURE_OVERRIDES="$DIST_CONFIGURE_OVERRIDES
XML-SAX echo no | PERL_MM_USE_DEFAULT=0 perl Makefile.PL
wxwidgets ./configure \$CONFIGURE_REQUIRED_ARGS --disable-shared --prefix=/usr --enable-stl --disable-precomp-headers --enable-cxx11 --enable-permissive --with-opengl --with-libpng
libvpx ./configure --disable-shared --enable-static --prefix=/usr --disable-unit-tests --disable-tools --disable-docs --disable-examples
ffmpeg ./configure --disable-shared --enable-static --prefix=/usr --pkg-config-flags=--static --enable-nonfree --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-version3 --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-openssl --enable-lzma --extra-cflags='-DMODPLUG_STATIC -DZMQ_STATIC' --extra-cxxflags='-DMODPLUG_STATIC -DZMQ_STATIC' --extra-objcflags='-DMODPLUG_STATIC -DZMQ_STATIC'
ffmpeg ./configure --disable-shared --enable-static --prefix=/usr --pkg-config-flags=--static --enable-nonfree --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-version3 --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzmq --enable-openssl --enable-lzma --extra-cflags='-DMODPLUG_STATIC -DZMQ_STATIC' --extra-cxxflags='-DMODPLUG_STATIC -DZMQ_STATIC' --extra-objcflags='-DMODPLUG_STATIC -DZMQ_STATIC' --extra-libs=-liconv
"
DIST_BUILD_OVERRIDES="$DIST_BUILD_OVERRIDES
@ -483,6 +479,10 @@ pre_build_all() {
setup() {
detect_os
mkdir -p "$BUILD_ROOT/tmp"
rm -rf "$BUILD_ROOT/tmp/"*
mkdir -p "$BUILD_ROOT/root/include"
[ -L "$BUILD_ROOT/root/inc" ] || ln -s "$BUILD_ROOT/root/include" "$BUILD_ROOT/root/inc"
@ -620,7 +620,7 @@ debian_install_core_deps() {
installing_core_deps
sudo apt-get -qq update || :
sudo apt-get -qy install build-essential g++ curl ccache perl
sudo apt-get -qy install build-essential g++ curl ccache perl meson
done_msg
}
@ -628,13 +628,13 @@ debian_install_core_deps() {
fedora_install_core_deps() {
installing_core_deps
sudo dnf install -y --nogpgcheck --best --allowerasing gcc gcc-c++ make redhat-rpm-config curl perl ccache file patch findutils
sudo dnf install -y --nogpgcheck --best --allowerasing gcc gcc-c++ make redhat-rpm-config curl perl ccache file patch findutils meson
}
suse_install_core_deps() {
installing_core_deps
sudo zypper in -y gcc gcc-c++ binutils glibc-devel-static make curl perl ccache file patch
sudo zypper in -y gcc gcc-c++ binutils glibc-devel-static make curl perl ccache file patch meson
}
arch_install_core_deps() {
@ -650,7 +650,7 @@ arch_install_core_deps() {
sudo pacman -Sy
# not using the base-devel group because it can break gcc-multilib
sudo pacman --noconfirm --needed -S $gcc_pkg binutils file grep gawk gzip make patch sed util-linux curl ccache perl
sudo pacman --noconfirm --needed -S $gcc_pkg binutils file grep gawk gzip make patch sed util-linux curl ccache perl meson
done_msg
}
@ -659,7 +659,7 @@ solus_install_core_deps() {
installing_core_deps
sudo eopkg -y update-repo
sudo eopkg -y install -c system.devel curl perl
sudo eopkg -y install -c system.devel curl perl meson
done_msg
}
@ -725,7 +725,7 @@ cygwin_install_core_deps() {
set -- "$@" "${target}-${p}"
done
apt-cyg install make tar patch diffutils ccache perl m4 cygwin32-w32api-headers gcc-core gcc-g++ mpfr windows-default-manifest python2 libncurses-devel "$@"
apt-cyg install make tar patch diffutils ccache perl m4 cygwin32-w32api-headers gcc-core gcc-g++ mpfr windows-default-manifest python2 libncurses-devel meson "$@"
# alias python2 to python
ln -sf /usr/bin/python2.exe "$BUILD_ROOT/root/bin/python.exe"
@ -748,7 +748,7 @@ mac_install_core_deps() {
error 'Please install Mac Homebrew: ;https://brew.sh/'
fi
brew -v install perl
brew -v install perl meson
}
setup_tmp_dir() {
@ -1660,9 +1660,9 @@ make_install() {
cd ..
if grep -Eq 'DESTDIR|cmake_install\.cmake' $(find . -name Makefile -o -name makefile -o -name '*.mk' -o -name '*.mak') 2>/dev/null; then
echo_run make install prefix="${prefix}" PREFIX="${prefix}" DESTDIR="$PWD/destdir" "$@" || :
echo_eval_run make install $(dist_make_args $current_dist) prefix="${prefix}" PREFIX="${prefix}" DESTDIR="$PWD/destdir" "$@" || :
else
echo_run make install prefix="$PWD/destdir${prefix}" PREFIX="$PWD/destdir${prefix}" INSTALL_PREFIX="$PWD/destdir${prefix}" INSTALL_ROOT="$PWD/destdir${prefix}" INSTALLTOP="/..${prefix}/" "$@" || :
echo_eval_run make install $(dist_make_args $current_dist) prefix="$PWD/destdir${prefix}" PREFIX="$PWD/destdir${prefix}" INSTALL_PREFIX="$PWD/destdir${prefix}" INSTALL_ROOT="$PWD/destdir${prefix}" INSTALLTOP="/..${prefix}/" "$@" || :
fi
}

View File

@ -5,6 +5,7 @@ set -e
target_bits=64
target_cpu=x86_64
lib_suffix=64
target_endian=little
case "$1" in
-64)
@ -61,6 +62,40 @@ export CONFIGURE_REQUIRED_ARGS="--host=${target_arch}"
export CMAKE_REQUIRED_ARGS="$CMAKE_REQUIRED_ARGS -DCMAKE_TOOLCHAIN_FILE='$(perl -MCwd=abs_path -le "print abs_path(q{${0%/*}/../../cmake/Toolchain-cross-MinGW-w64-${target_cpu}.cmake})")'"
export MESON_BASE_ARGS=""
lc_build_os=$(uname -s | tr 'A-Z' 'a-z')
meson() {
if [ -z "$HOST_ENV" ]; then
cat >$BUILD_ROOT/tmp/meson_cross_$$.txt <<EOF
[host_machine]
system = 'windows'
cpu_family = '$target_cpu'
cpu = '$target_cpu'
endian = '$target_endian'
[binaries]
c = '${CC#ccache }'
cpp = '${CXX#ccache }'
windres = '${target_arch}-windres'
strip = '$STRIP'
[properties]
c_args = '$CPPFLAGS $CFLAGS'
c_link_args = '$LDFLAGS'
cpp_args = '$CPPFLAGS $CXXFLAGS'
cpp_link_args = '$LDFLAGS'
EOF
# meson is fucking retarded, we set all these in the cross file
CC= CXX= CPPFLAGS= CFLAGS= CXXFLAGS= LDFLAGS= command meson --cross-file $BUILD_ROOT/tmp/meson_cross_$$.txt "$@"
else
# in the host build case, we can use the environment
command meson "$@"
fi
}
. "${0%/*}/../builder/mingw.sh"
installing_cross_deps() {
@ -96,6 +131,8 @@ suse_install_cross_deps() {
sudo zypper in -y "$@" gettext-tools wxGTK3-3_2-devel python3-pip
}
# do not install deps if there are other options like --env
if [ $# -eq 0 ]; then
case "$linux_distribution" in
fedora)
installing_cross_deps
@ -108,6 +145,7 @@ case "$linux_distribution" in
done_msg
;;
esac
fi
openssl_host=mingw
[ "$target_bits" -eq 64 ] && openssl_host=mingw64
@ -123,8 +161,6 @@ table_line_append DIST_PATCHES openal '-p0 https://gist.githubusercontent.com/rk
table_line_replace DIST_POST_BUILD harfbuzz "$(table_line DIST_POST_BUILD harfbuzz | sed 's/rebuild_dist freetype /rebuild_dist freetype-target /')"
table_line_append DIST_ARGS glib --with-python=/usr/bin/python3
table_line_replace DIST_POST_BUILD glib "$(table_line DIST_POST_BUILD glib | sed 's/rebuild_dist gettext /rebuild_dist gettext-target /')"
table_line_append DIST_ARGS libsoxr '-DHAVE_WORDS_BIGENDIAN_EXITCODE=0'

View File

@ -8,11 +8,11 @@ export CROSS_OS=windows
BUILD_ENV=$BUILD_ENV$(cat <<EOF
export CPPFLAGS="$CPPFLAGS${CPPFLAGS:+ }-DMINGW_HAS_SECURE_API"
export CFLAGS="$CFLAGS${CFLAGS:+ }-static-libgcc -static-libstdc++ -static -lpthread -DMINGW_HAS_SECURE_API -lm"
export CXXFLAGS="$CXXFLAGS${CXXFLAGS:+ }-static-libgcc -static-libstdc++ -static -lpthread -DMINGW_HAS_SECURE_API -lm"
export OBJCXXFLAGS="$OBJCXXFLAGS${OBJCXXFLAGS:+ }-static-libgcc -static-libstdc++ -static -lpthread -DMINGW_HAS_SECURE_API -lm"
export LDFLAGS="$LDFLAGS${LDFLAGS:+ }-static-libgcc -static-libstdc++ -static -lpthread -DMINGW_HAS_SECURE_API -lm"
export CPPFLAGS="$CPPFLAGS${CPPFLAGS:+ }-DMINGW_HAS_SECURE_API -DFFI_STATIC_BUILD"
export CFLAGS="$CFLAGS${CFLAGS:+ }-static-libgcc -static-libstdc++ -static -lpthread -DMINGW_HAS_SECURE_API -DFFI_STATIC_BUILD -lm"
export CXXFLAGS="$CXXFLAGS${CXXFLAGS:+ }-static-libgcc -static-libstdc++ -static -lpthread -DMINGW_HAS_SECURE_API -DFFI_STATIC_BUILD -lm"
export OBJCXXFLAGS="$OBJCXXFLAGS${OBJCXXFLAGS:+ }-static-libgcc -static-libstdc++ -static -lpthread -DMINGW_HAS_SECURE_API -DFFI_STATIC_BUILD -lm"
export LDFLAGS="$LDFLAGS${LDFLAGS:+ }-static-libgcc -static-libstdc++ -static -lpthread -DMINGW_HAS_SECURE_API -DFFI_STATIC_BUILD -lm"
export LIBS="-lpthread -lm -lole32"
export UUID_LIBS="-luuid_mingw -luuid"
@ -101,6 +101,9 @@ OUUID_LIBS="\$UUID_LIBS"
OSTRIP="\$STRIP"
OPATH="\$PATH"
OCONFIGURE_REQUIRED_ARGS="\$CONFIGURE_REQUIRED_ARGS"
OCMAKE_REQUIRED_ARGS="\$CMAKE_REQUIRED_ARGS"
$BUILD_ENV
export CC="$HOST_CC"
@ -115,11 +118,11 @@ export UUID_LIBS="$HOST_UUID_LIBS"
export STRIP="$HOST_STRIP"
export PATH="$BUILD_ROOT/host/bin:\$PATH"
OCONFIGURE_REQUIRED_ARGS="\$CONFIGURE_REQUIRED_ARGS"
OCMAKE_REQUIRED_ARGS="\$CMAKE_REQUIRED_ARGS"
CONFIGURE_REQUIRED_ARGS="\$(puts "\$CONFIGURE_REQUIRED_ARGS" | sed 's/--host[^ ]*//g')"
CMAKE_REQUIRED_ARGS="\$(puts "\$CMAKE_REQUIRED_ARGS" | sed 's/-DCMAKE_TOOLCHAIN_FILE=[^ ]*//g')"
unset TARGET_ENV
export HOST_ENV=1
EOF
fi
@ -164,6 +167,8 @@ CONFIGURE_REQUIRED_ARGS="\$OCONFIGURE_REQUIRED_ARGS"
CMAKE_REQUIRED_ARGS="\$OCMAKE_REQUIRED_ARGS"
OCONFIGURE_REQUIRED_ARGS= OCMAKE_REQUIRED_ARGS=
unset HOST_ENV
export TARGET_ENV=1
$BUILD_ENV
EOF
fi