add cygwin cross build support

Put shared code for linux cross builds and cygwin cross builds into
builder/mingw-cross.sh .

Call wxrc when the build platform is cygwin with files resolved via
`cygpath -m` in case the wxrc is a native binary.

Add -fpermissive to CXX/OBJCXX flags.

Reenable libzvbi support for ffmpeg.

Stop building ffmpeg and related dists by default until we fix game
recording.

Set CMAKE_PREFIX_PATH in cmake args as a FILEPATH type variable.

Support xml catalog made with native libxml2 using cygpath in related
commands, make cygpath a noop on non-cygwin platforms.

Remove gdb and zip from msys2 deps.

Add a cygwin installdeps routine using a copy of cyg-apt that it
fetches.

When creating symlinks in install_dist() fully resolve all symlinks in
path parts for the source file, so that host and target binaries are
correctly linked.

When cp -af fails to preserve permission related data, fall back to cp
-rf.

When installing libs with a cross suffix, make a symlink for the lib
without the cross suffix.

Make sure cygwin runs with CYGWIN=winsymlinks:native .

Add paths to host gettext executables to cmake args, otherwise it tries
to use the target executables and fails on paths.

For the pkgconfig bundled glib, turn off win32 platform for the cygwin
host build.

For gettext, remove --disable-auto-import from link flags.

Compile target freetype on cygwin with cmake and manually install the
pkgconfig .pc file using sed.

Add a relocation type 'aggressive', when a dist is marked with this
type, rewrite all '/usr' prefixes to the build root. By default only
files that exist in the dist are matched and rewritten.

Fix regression in linux build by adding some iconv related flags to the
cmake invocation for doxygen and disabling -Werror for xorg dists.

When relocating scripts, use the actual resolved root path for host or
target.

Build libxslt --without-python so that it doesn't try to pick up the
msys2 python.

Other misc. minor tweaks and cleanups.
This commit is contained in:
Rafael Kitover 2018-05-01 04:09:41 -04:00
parent 8638c76923
commit 85dea8a57b
8 changed files with 360 additions and 133 deletions

View File

@ -399,7 +399,7 @@ SET(XRC_SOURCES
)
# wxrc does not support xrs files in -c output (> 10x compression)
# we do it using the bin2.c utility
# we do it using the bin2c.c utility
SET(BIN2C ${CMAKE_BINARY_DIR}/bin2c)
@ -413,6 +413,19 @@ else()
set(WXRC wxrc)
endif()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL CYGWIN)
# pass xrc sources through cygpath in case we only have native wxrc
set(new_xrc_sources)
foreach(xrc ${XRC_SOURCES})
execute_process(COMMAND cygpath -m ${xrc} OUTPUT_VARIABLE win_path OUTPUT_STRIP_TRAILING_WHITESPACE)
list(APPEND new_xrc_sources ${win_path})
endforeach()
set(XRC_SOURCES ${new_xrc_sources})
endif()
ADD_CUSTOM_COMMAND(OUTPUT wxvbam.xrs
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${WXRC} ${XRC_SOURCES} "--output=wxvbam.xrs"

View File

@ -31,8 +31,8 @@ esac
export CPPFLAGS="$CPPFLAGS -I$BUILD_ROOT/root/include"
export CFLAGS="$CFLAGS -fPIC -I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -Wno-error=all"
export CXXFLAGS="$CXXFLAGS -fPIC -I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -std=gnu++11 -Wno-error=all"
export OBJCXXFLAGS="$OBJCXXFLAGS -fPIC -I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -std=gnu++11 -Wno-error=all"
export CXXFLAGS="$CXXFLAGS -fPIC -I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -std=gnu++11 -Wno-error=all -fpermissive"
export OBJCXXFLAGS="$OBJCXXFLAGS -fPIC -I$BUILD_ROOT/root/include -L$BUILD_ROOT/root/lib -std=gnu++11 -Wno-error=all -fpermissive"
export LDFLAGS="$LDFLAGS -fPIC -L$BUILD_ROOT/root/lib -Wno-error=all"
if [ -z "\$OPENMP" ] && echo "\$CC" | grep -Eq gcc; then
@ -195,24 +195,34 @@ DISTS=$DISTS'
libx265 https://bitbucket.org/multicoreware/x265/downloads/x265_2.5.tar.gz lib/libx265.a
libxavs https://github.com/Distrotech/xavs/archive/distrotech-xavs-git.tar.gz lib/libxavs.a
libzmq https://github.com/zeromq/libzmq/releases/download/v4.2.2/zeromq-4.2.2.tar.gz lib/libzmq.a
# libzvbi https://downloads.sourceforge.net/project/zapping/zvbi/0.2.35/zvbi-0.2.35.tar.bz2 lib/libzvbi.a
libzvbi https://downloads.sourceforge.net/project/zapping/zvbi/0.2.35/zvbi-0.2.35.tar.bz2 lib/libzvbi.a
ffmpeg https://github.com/ffmpeg/ffmpeg/archive/0c78b6a416c661afed745d44495b5194f714fb96.tar.gz lib/libavformat.a
'
# for now we don't build ffmpeg because game recording is broken
BUILD_FFMPEG=
PROJECT_ARGS="$PROJECT_ARGS -DENABLE_FFMPEG=NO"
FFMPEG_DISTS='
graphite2 xvidcore fribidi libgsm libmodplug libopencore-amrnb opus snappy
libsoxr speex libtheora vidstab libvo-amrwbenc mp3lame libass libbluray
libvpx libwavpack libx264 libx265 libxavs libzmq libzvbi ffmpeg
'
: ${PATH_SEP:=':'}
# these two can be set to always be included regardless of overrides
REQUIRED_CONFIGURE_ARGS="$REQUIRED_CONFIGURE_ARGS"
REQUIRED_CMAKE_ARGS="$REQUIRED_CMAKE_ARGS"
CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-shared --enable-static --prefix=/usr"
CMAKE_BASE_ARGS="$CMAKE_BASE_ARGS -DBUILD_SHARED_LIBS=NO -DENABLE_SHARED=NO -DCMAKE_PREFIX_PATH=\"\$CMAKE_PREFIX_PATH\" -DCMAKE_BUILD_TYPE=Release"
CMAKE_BASE_ARGS="$CMAKE_BASE_ARGS -DBUILD_SHARED_LIBS=NO -DENABLE_SHARED=NO -DCMAKE_PREFIX_PATH:FILEPATH=\"\$CMAKE_PREFIX_PATH\" -DCMAKE_BUILD_TYPE=Release"
CMAKE_ARGS="$CMAKE_BASE_ARGS $CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=/usr"
MESON_ARGS="--prefix /usr --buildtype release --default-library static -Dintrospection=false"
PROJECT_ARGS="$PROJECT_ARGS"
DIST_PATCHES=$DIST_PATCHES'
docbook2x https://gist.githubusercontent.com/rkitover/0b5dcc95a0703a9b0e0e7eb6d325a98e/raw/e256d2fad8d19633ac8abe02a0d1e119063d1fd9/docbook2x.patch
graphite2 https://gist.githubusercontent.com/rkitover/418600634d7cf19e2bf1c3708b50c042/raw/839b72d9cda545f2e3b640d743c1bd44b89861b9/graphite2-1.3.10-static.patch
@ -236,6 +246,10 @@ DIST_CONFIGURE_TYPES="$DIST_CONFIGURE_TYPES
docbook2x autoreconf
"
DIST_RELOCATION_TYPES="$DIST_RELOCATION_TYPES
texinfo aggressive
"
DIST_PRE_BUILD="$DIST_PRE_BUILD
# xz mkdir -p build-aux; touch build-aux/config.rpath; mkdir -p po; touch po/Makefile.in.in; sed -i.bak 's/ po / /g' Makefile.am;
getopt sed -i.bak 's/\\\$(LDFLAGS)\\(.*\\)\$/\\1 \$(LDFLAGS)/' Makefile;
@ -247,6 +261,7 @@ DIST_PRE_BUILD="$DIST_PRE_BUILD
bakefile sed -i.bak '/SUBDIRS = doc/d' Makefile.am;
unzip rm -f unix/Contents; ln -sf \$(find unix -mindepth 1 -maxdepth 1) .;
zip rm -f unix/Contents; ln -sf \$(find unix -mindepth 1 -maxdepth 1) .;
gettext sed -i.bak 's/-Wl,--disable-auto-import//' m4/woe32-dll.m4;
expat cd expat; \
sed -i.bak '/doc\\/Makefile/d' configure.ac; \
sed -i.bak '/SUBDIRS/{; s/ doc//; }' Makefile.am; \
@ -269,12 +284,12 @@ DIST_PRE_BUILD="$DIST_PRE_BUILD
"
DIST_POST_BUILD="$DIST_POST_BUILD
harfbuzz rebuild_dist freetype --with-harfbuzz=yes;
harfbuzz rebuild_dist freetype;
flex-2.6.3 build_dist flex || :;
glib rebuild_dist gettext --without-included-glib --without-included-libxml;
graphviz (cd '$BUILD_ROOT/root/bin'; path_exists dot_static && ! path_exists dot && ln -sf '$BUILD_ROOT/root/bin/dot_static' ./dot || :)
libxml2 mkdir -p '$BUILD_ROOT/root/etc/xml'; \
xmlcatalog --noout --create '$BUILD_ROOT/root/etc/xml/catalog.xml' || :;
xmlcatalog --noout --create \"\$(cygpath -m \"$BUILD_ROOT/root/etc/xml/catalog.xml\")\" || :;
python2 pip2 install six;
python3 pip3 install six;
fontconfig mkdir -p '$BUILD_ROOT/root/etc/fonts'; \
@ -318,9 +333,10 @@ DIST_BUILD_OVERRIDES="$DIST_BUILD_OVERRIDES
"
DIST_ARGS="$DIST_ARGS
gettext --with-included-gettext --with-included-glib --with-included-libcroco --with-included-libunistring --with-included-libxml CPPFLAGS=\"\$CPPFLAGS -DLIBXML_STATIC\"
gettext --with-included-gettext --with-included-glib --with-included-libcroco --with-included-libunistring --with-included-libxml --disable-curses CPPFLAGS=\"\$CPPFLAGS -DLIBXML_STATIC\"
pkgconfig --with-internal-glib --with-libiconv=gnu
pcre --enable-utf8 --enable-pcre8 --enable-pcre16 --enable-pcre32 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-jit
libxslt --without-python
libgd --without-xpm
fontconfig --with-baseconfigdir=/etc/fonts
graphviz --disable-ltdl --without-x CFLAGS=\"-include \$PWD/declspec.h $CFLAGS\"
@ -329,6 +345,7 @@ DIST_ARGS="$DIST_ARGS
glib --with-libiconv=gnu
bakefile --enable-shared
XML-Parser EXPATINCPATH='$BUILD_ROOT/root/include' EXPATLIBPATH='$BUILD_ROOT/root/lib'
doxygen -DICONV_ACCEPTS_NONCONST_INPUT:BOOL=FALSE -DICONV_ACCEPTS_CONST_INPUT:BOOL=TRUE
sfml -DSFML_USE_SYSTEM_DEPS=TRUE
freetype --with-harfbuzz=no
harfbuzz --with-cairo=no --with-icu=no
@ -343,14 +360,11 @@ DIST_ARGS="$DIST_ARGS
libx264 --enable-pic
libx265 -DHIGH_BIT_DEPTH=ON -DENABLE_ASSEMBLY=OFF -DENABLE_CLI=OFF
ffmpeg --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 --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-libzvbi --enable-openssl --enable-lzma --extra-cflags='-DMODPLUG_STATIC -DZMQ_STATIC' --extra-cxxflags='-DMODPLUG_STATIC -DZMQ_STATIC' --extra-objcflags='-DMODPLUG_STATIC -DZMQ_STATIC'
#
# TODO: add these if possible (from brew) --enable-indev=qtkit --enable-securetransport --enable-chromaprint --enable-ffplay --enable-frei0r --enable-libbs2b --enable-libcaca --enable-libfdk-aac --enable-libgme --enable-libgsm --enable-librtmp --enable-librubberband --enable-libssh --enable-libtesseract --enable-libtwolame --enable-webp --enable-libzimg
#
# Possibly also: --enable-libzvbi
# I could not get libzvbi to build
#
# these require > 10.7:
# --enable-opencl # requires 10.8
# --enable-videotoolbox # requires 10.8
@ -455,6 +469,12 @@ setup() {
done
cd "$OPWD"
if [ -z "$BUILD_FFMPEG" ]; then
for dist in $FFMPEG_DISTS; do
table_line_remove DISTS $dist
done
fi
DIST_NAMES=$( table_column DISTS 0 3)
DIST_URLS=$( table_column DISTS 1 3)
DIST_TARGETS=$(table_column DISTS 2 3)
@ -622,10 +642,6 @@ windows_install_core_deps() {
fi
}
cygwin_install_core_deps() {
:
}
msys2_install_core_deps() {
case "$MSYSTEM" in
MINGW32)
@ -642,13 +658,12 @@ msys2_install_core_deps() {
pacman -Sy
set --
for p in binutils curl crt-git gcc gcc-libs gdb headers-git tools-git windows-default-manifest libmangle-git; do
for p in binutils curl crt-git gcc gcc-libs headers-git tools-git windows-default-manifest libmangle-git; do
set -- "$@" "${target}-${p}"
done
# install
# TODO: remove zip and add to dists
pacman --noconfirm --needed -S make tar patch diffutils ccache zip perl m4 msys2-w32api-headers msys2-runtime-devel gcc gcc-libs mpfr windows-default-manifest python2 "$@"
pacman --noconfirm --needed -S make tar patch diffutils ccache perl msys2-w32api-headers msys2-runtime-devel gcc gcc-libs mpfr windows-default-manifest python2 "$@"
# make sure msys perl takes precedence over mingw perl if the latter is installed
mkdir -p "$BUILD_ROOT/root/bin"
@ -663,6 +678,34 @@ msys2_install_core_deps() {
done_msg
}
cygwin_install_core_deps() {
installing_core_deps
target="mingw64-${target_cpu}"
curl -L rawgit.com/transcode-open/apt-cyg/master/apt-cyg > "$BUILD_ROOT/root/bin/apt-cyg"
chmod +x "$BUILD_ROOT/root/bin/apt-cyg"
hash -r
apt-cyg update
set --
for p in binutils gcc-core gcc-g++ headers windows-default-manifest; do
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 "$@"
# alias python2 to python
ln -sf /usr/bin/python2.exe "$BUILD_ROOT/root/bin/python.exe"
# activate ccache
eval "$BUILD_ENV"
done_msg
}
mac_install_core_deps() {
if ! xcode-select -p >/dev/null 2>&1 && \
! pkgutil --pkg-info=com.apple.pkg.CLTools_Executables >/dev/null 2>&1 && \
@ -1540,6 +1583,9 @@ install_dist() {
# check that key file was built
path_exists "destdir/usr/$(install_artifact_relative "$current_dist")"
# when cross compiling, resolve build root to host or target
inst_root=$(resolve_link "$BUILD_ROOT/root")
# build file list and sed script to replace file paths in text files and
# scripts
@ -1589,18 +1635,18 @@ install_dist() {
usr/*)
f=${f#usr/}
cat >>"$sed_scr_usr" <<EOF
s|^/usr/\\($f/*\\)\$|$BUILD_ROOT/root/\\1|
s|^/usr/\\($f[^a-zA-Z0-9]\\)|$BUILD_ROOT/root/\\1|
s|\\([^a-zA-Z0-9]\\)/usr/\\($f/*\\)\$|\\1$BUILD_ROOT/root/\\2|
s|\\([^a-zA-Z0-9]\\)/usr/\\($f[^a-zA-Z0-9]\\)|\\1$BUILD_ROOT/root/\\2|g
s|^/usr/\\($f/*\\)\$|$inst_root/\\1|
s|^/usr/\\($f[^a-zA-Z0-9]\\)|$inst_root/\\1|
s|\\([^a-zA-Z0-9]\\)/usr/\\($f/*\\)\$|\\1$inst_root/\\2|
s|\\([^a-zA-Z0-9]\\)/usr/\\($f[^a-zA-Z0-9]\\)|\\1$inst_root/\\2|g
EOF
;;
*)
cat >>"$sed_scr_usr" <<EOF
s|^/\\($f/*\\)\$|$BUILD_ROOT/root/\\1|
s|^/\\($f[^a-zA-Z0-9]\\)|$BUILD_ROOT/root/\\1|
s|\\([^a-zA-Z0-9]\\)\\($f/*\\)\$|\\1$BUILD_ROOT/root/\\2|
s|\\([^a-zA-Z0-9]\\)/\\($f[^a-zA-Z0-9]\\)|\\1$BUILD_ROOT/root/\\2|g
s|^/\\($f/*\\)\$|$inst_root/\\1|
s|^/\\($f[^a-zA-Z0-9]\\)|$inst_root/\\1|
s|\\([^a-zA-Z0-9]\\)\\($f/*\\)\$|\\1$inst_root/\\2|
s|\\([^a-zA-Z0-9]\\)/\\($f[^a-zA-Z0-9]\\)|\\1$inst_root/\\2|g
EOF
;;
esac
@ -1610,14 +1656,29 @@ EOF
# group sed script under a /usr/ and /etc/ pattern addresses to speed it up
#
# also add a special rule to rewrite 'prefix' variables in scripts
cat >"${sed_scr}.work" <<EOF
/\/usr/{
s|\([Pp][Rr][Ee][Ff][Ii][Xx].*=.*['"]\)/usr\(/*['"]\)|\1$BUILD_ROOT/root\2|g
EOF
# also add special rules to rewrite 'prefix' variables in scripts
cat >>"${sed_scr}.work" <<EOF
s|\([Pp][Rr][Ee][Ff][Ii][Xx].*=.*['"]\)/usr\(/*['"]\)|\1$inst_root\2|g
EOF
# if the relocation mode for the dist is 'aggressive', rewrite all '/usr'
# prefixes everywhere except for the shebang on the first line.
if [ "$(dist_relocation_type "$current_dist")" = aggressive ]; then
cat >>"${sed_scr}.work" <<EOF
2,\${
s|/usr|$inst_root|g
}
EOF
fi
cat >>"${sed_scr}.work" <<EOF
$(cat "$sed_scr_usr")
}
EOF
if [ -f "${sed_scr_etc}" ]; then
cat >>"${sed_scr}.work" <<EOF
/\/etc\//{
@ -1639,7 +1700,7 @@ EOF
defer_cmds=
OLDPWD=$PWD
cd "$BUILD_ROOT/root"
cd "$inst_root"
IFS=$NL
for f in $(cat "$file_list"); do
IFS=$OIFS
@ -1670,7 +1731,7 @@ EOF
# rewrite symlinks pointing to /usr/*
if [ -h "$tmp_prefix/$f" ]; then
link_dest=$(expr "$(ls -l "$tmp_prefix/$f")" : '.* -> \(.*\)$' | sed 's|^/usr/|'"$BUILD_ROOT/root/|")
link_dest=$(expr "$(ls -l "$tmp_prefix/$f")" : '.* -> \(.*\)$' | sed 's|^/usr/|'"$inst_root/|")
# rewrite relative links to absolute ones
case "$link_dest" in
@ -1681,6 +1742,8 @@ EOF
;;
esac
link_dest=$(fully_resolve_link "$link_dest")
if [ -e "$link_dest" ]; then
echo_run ln -sf "$link_dest" "$dest_f"
else
@ -1696,7 +1759,7 @@ ln -sf \"$link_dest\" \"$dest_f\"
# don''t relocate headers, man and info pages and docs
case "$dest_f" in
share/doc/*|share/man/*|share/info/*|include/*)
echo_run cp -af "$tmp_prefix/$f" "$dest_f"
echo_run cp -af "$tmp_prefix/$f" "$dest_f" || echo_run cp -rf "$tmp_prefix/$f" "$dest_f"
continue
;;
esac
@ -1722,9 +1785,9 @@ ln -sf \"$link_dest\" \"$dest_f\"
cp "$dest_f" "${dest_f}.work"
LANG=C sed '
/\/usr/{
s|\([^a-zA-Z0-9]\)/usr$|\1'"$BUILD_ROOT/root"'|
s|\([^a-zA-Z0-9]\)/usr/|\1'"$BUILD_ROOT/root/"'|g
s|\(-[IL]\)/usr/|\1'"$BUILD_ROOT/root/"'|g
s|\([^a-zA-Z0-9]\)/usr$|\1'"$inst_root"'|
s|\([^a-zA-Z0-9]\)/usr/|\1'"$inst_root/"'|g
s|\(-[IL]\)/usr/|\1'"$inst_root/"'|g
}
' "${dest_f}.work" > "$dest_f"
rm -f "${dest_f}.work"
@ -1742,7 +1805,16 @@ ln -sf \"$link_dest\" \"$dest_f\"
continue
fi
echo_run cp -af "$tmp_prefix/$f" "$dest_f"
echo_run cp -af "$tmp_prefix/$f" "$dest_f" || echo_run cp -rf "$tmp_prefix/$f" "$dest_f"
# when cross-compiling, link arch-suffixed libs to their normal names
if [ -n "$target_arch" ]; then
case "$f" in
*/lib/*-${target_arch}.a)
echo_run ln -sf "$PWD/$dest_f" "${dest_f%%-${target_arch}.a}.a"
;;
esac
fi
done
IFS=$OIFS
@ -1940,6 +2012,13 @@ dist_configure_type() {
puts "$(table_line DIST_CONFIGURE_TYPES $current_dist)" || :
}
dist_relocation_type() {
current_dist=$1
[ -n "$current_dist" ] || die 'dist_relocation_type: dist name required'
puts "$(table_line DIST_RELOCATION_TYPES $current_dist)" || :
}
dist_make_args() {
current_dist=$1
[ -n "$current_dist" ] || die 'dist_make_args: dist name required'
@ -2050,17 +2129,15 @@ install_docbook_dist() {
_dir="$BUILD_ROOT/root/share/xml/docbook/$_dir"
# on cygwin/msys write native POSIX paths to catalog
if command -v cygpath >/dev/null; then
_dir=$(cygpath -m "$_dir")
fi
echo_run mkdir -p "$_dir"
echo_run cp -af * "$_dir"
echo_run cp -af * "$_dir" || echo_run cp -rf * "$_dir"
# on cygwin/msys write native POSIX paths to catalog
_dir=$(cygpath -m "$_dir")
if [ -f "$_dir/catalog.xml" ]; then
echo_run xmlcatalog --noout --del "file://$_dir/catalog.xml" "$BUILD_ROOT/root/etc/xml/catalog.xml" || :
echo_run xmlcatalog --noout --add nextCatalog '' "file://$_dir/catalog.xml" "$BUILD_ROOT/root/etc/xml/catalog.xml"
echo_run xmlcatalog --noout --del "file://$_dir/catalog.xml" "$(cygpath -m "$BUILD_ROOT/root/etc/xml/catalog.xml")" || :
echo_run xmlcatalog --noout --add nextCatalog '' "file://$_dir/catalog.xml" "$(cygpath -m "$BUILD_ROOT/root/etc/xml/catalog.xml")"
fi
}
@ -2296,7 +2373,7 @@ build_project() {
cd "$BUILD_ROOT/project"
# FIXME: turn LTO back on when everything works
echo_eval_run cmake "'$CHECKOUT'" $REQUIRED_CMAKE_ARGS -DVBAM_STATIC=ON -DENABLE_FFMPEG=OFF -DENABLE_LTO=OFF $PROJECT_ARGS $CMAKE_BASE_ARGS $@
echo_eval_run cmake "'$CHECKOUT'" $REQUIRED_CMAKE_ARGS -DVBAM_STATIC=ON -DENABLE_LTO=OFF $PROJECT_ARGS $CMAKE_BASE_ARGS $@
echo_run make -j$NUM_CPUS
if [ "$os" = mac ]; then
@ -2471,5 +2548,69 @@ ln() {
command ln "$@"
}
cygpath() {
if sh -c 'command -v cygpath' >/dev/null; then
command cygpath "$@"
else
case "$1" in
-*)
shift
;;
esac
echo "$@"
fi
}
fully_resolve_link() {
file=$1
# get initial part for non-absolute path, or blank for absolute
path=${file%%/*}
# and set $file to the rest
file=${file#*/}
OLDIFS=$IFS
IFS='/'
for part in $file; do
[ ! -z "$part" ] && path=$(resolve_link "$path/$part")
done
IFS=$OLDIFS
# remove 'foo/..' path parts
while :; do
case "$path" in
*/../*|*/..)
path=$(echo "$path" | sed 's,//*[^/][^/]*//*\.\./*,/,g')
;;
*)
break
;;
esac
done
# remove trailing /s
while [ "$path" != "${path%/}" ]; do
path=${path%/}
done
echo "$path"
}
resolve_link() {
file=$1
while [ -h "$file" ]; do
ls0=$(ls -ld "$file")
new_link=$(expr "$ls0" : '.* -> \(.*\)$')
if expr "$new_link" : '/.*' > /dev/null; then
file="$new_link"
else
file="${file%/*}"/"$new_link"
fi
done
echo "$file"
}
# this needs to run on source, not just after entry
setup

View File

@ -0,0 +1,79 @@
#!/bin/sh
set -e
target_bits=64
target_cpu=x86_64
case "$1" in
-64)
shift
;;
-32)
target_bits=32
target_cpu=i686
shift
;;
esac
target_arch="${target_cpu}-w64-mingw32"
export BUILD_ROOT="$HOME/vbam-build-mingw${target_bits}"
do_not_remove_dists=
host_dists='
unzip zip cmake autoconf autoconf-archive automake m4 gsed bison flex-2.6.3
flex c2man docbook2x libtool help2man texinfo xmlto pkgconfig nasm yasm
xorg-macros dejavu liberation urw graphviz docbook4.2 docbook4.1.2
docbook4.3 docbook4.4 docbook4.5 docbook5.0 docbook-xsl docbook-xsl-ns
python2 python3 swig doxygen bakefile setuptools pip intltool ninja meson
shared-mime-info gperf
'
both_dists='
openssl zlib bzip2 libiconv gettext xz libxml2 expat libpng freetype
fontconfig
'
[ -n "$BUILD_ENV" ] && eval "$BUILD_ENV"
BUILD_ENV=$BUILD_ENV$(cat <<EOF
export CC='ccache ${target_arch}-gcc'
export CXX='ccache ${target_arch}-g++'
EOF
)
REQUIRED_CONFIGURE_ARGS="--host=${target_arch}"
REQUIRED_CMAKE_ARGS="$REQUIRED_CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE='$(readlink -f "${0%/*}/../../cmake/Toolchain-cross-MinGW-w64-${target_cpu}.cmake")'"
. "${0%/*}/../builder/mingw.sh"
openssl_host=mingw
[ "$target_bits" -eq 64 ] && openssl_host=mingw64
table_line_replace DIST_CONFIGURE_OVERRIDES openssl-target "./Configure $openssl_host no-shared --prefix=/usr --openssldir=/etc/ssl --cross-compile-prefix=${target_arch}-"
table_line_append DIST_PRE_BUILD bzip2-target ':; sed -i.bak '\''s,include <sys\\stat.h>,include <sys/stat.h>,g'\'' *.c;'
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 libsoxr '-DHAVE_WORDS_BIGENDIAN_EXITCODE=0'
vpx_target=x86-win32-gcc
[ "$target_bits" -eq 64 ] && vpx_target=x86_64-win64-gcc
table_line_replace DIST_CONFIGURE_OVERRIDES libvpx "./configure --target=$vpx_target $CONFIGURE_ARGS $(table_line DIST_ARGS libvpx)"
table_line_remove DIST_ARGS libvpx
table_line_replace DIST_CONFIGURE_OVERRIDES ffmpeg "\
./configure --arch=$target_cpu --target-os=mingw32 --cross-prefix=${target_arch}- \
--pkg-config='$BUILD_ROOT/host/bin/pkg-config' \
$CONFIGURE_ARGS $(table_line DIST_ARGS ffmpeg) \
"
table_line_remove DIST_ARGS ffmpeg

View File

@ -180,6 +180,12 @@ table_line_append DIST_ARGS openal '-DLIBTYPE=STATIC -DALSOFT_UTILS=OFF -DALSOFT
table_line_replace DIST_ARGS mp3lame "LDFLAGS='$LDFLAGS $BUILD_ROOT/root/lib/libcatgets.a'"
table_line_append DIST_PRE_BUILD zlib ":; \
sed -i.bak ' \
s/defined(_WIN32) *|| *defined(__CYGWIN__)/defined(_WIN32)/ \
' gzguts.h; \
"
table_line_append DIST_POST_BUILD zlib-target ":; \
rm -f \$BUILD_ROOT/root/lib/libz.dll.a \$BUILD_ROOT/root/bin/libz.dll; \
"

View File

@ -58,7 +58,7 @@ table_insert_before DISTS sfml '
# we build and link Xorg libs as dynamic because there is no point in making
# them static, since they are required for the resulting binary to run
for dist in $XORG_DISTS; do
table_line_append DIST_ARGS $dist '--enable-shared --disable-static'
table_line_append DIST_ARGS $dist '--enable-shared --disable-static --disable-selective-werror'
done
# and Wayland now that that's a thing

65
tools/win/cygwin-cross-builder Executable file
View File

@ -0,0 +1,65 @@
#!/bin/sh
set -e
# turn on real symlinks on cygwin
if [ "$(uname -o 2>/dev/null || :)" = Cygwin ]; then
new_cygwin= replaced=
for part in $CYGWIN; do
case "$part" in
winsymlinks:*)
new_cygwin="$new_cygwin winsymlinks:native"
replaced=1
;;
*)
new_cygwin="$new_cygwin $part"
;;
esac
done
if [ -n "$replaced" ]; then
export CYGWIN=$new_cygwin
else
export CYGWIN="winsymlinks:native $new_cygwin"
fi
fi
REQUIRED_CMAKE_ARGS="-DGETTEXT_MSGFMT_EXECUTABLE:FILEPATH=\"\$BUILD_ROOT/host/bin/msgfmt\" -DGETTEXT_MSGMERGE_EXECUTABLE=\"\$BUILD_ROOT/host/bin/msgmerge\""
. "${0%/*}/../builder/mingw-cross.sh"
table_line_append DIST_MAKE_ARGS unzip 'CFLAGS="$CFLAGS -DNO_LCHMOD"'
# FIXME: problems with autopoint that need to be sorted
table_line_remove DISTS flex
table_line_append DIST_PRE_BUILD pkgconfig ":; \
sed -i.bak ' \
s/platform_win32=yes/platform_win32=no/; \
s/#define G_PLATFORM_WIN32//; \
s/PLATFORMDEP=gwin32\\.lo/PLATFORMDEP=/ \
' glib/configure; \
"
table_line_append DIST_PRE_BUILD c2man ":; \
sed -i.bak '/test -d c:\\//,/^fi\$/d' Configure; \
"
table_line_replace DIST_CONFIGURE_TYPES freetype-target cmake
table_line_remove DIST_ARGS freetype-target
table_line_append DIST_POST_BUILD freetype-target ":; \
sed ' \
s,%prefix%,$BUILD_ROOT/root,g; \
s,%exec_prefix%,$BUILD_ROOT/root,g; \
s,%libdir%,$BUILD_ROOT/root/lib,g; \
s,%includedir%,$BUILD_ROOT/root/include,g; \
s,%ft_version%,20.0.14,g; \
s|%REQUIRES_PRIVATE%|zlib, bzip2, libpng|; \
s,%LIBS_PRIVATE%,-lpng -lz -lbz2 -llzma -lharfbuzz,; \
s/-lfreetype/-lfreetype -lpng -lz -lbz2 -llzma/; \
' ../builds/unix/freetype2.in > "$BUILD_ROOT"/root/lib/pkgconfig/freetype2.pc; \
"
table_line_append DIST_EXTRA_LIBS fontconfig-target '-lpng -lz -lbz2 -llzma'
builder "$@"

View File

@ -2,56 +2,12 @@
set -e
case "$1" in
-32)
target_bits=32
target_cpu=i686
;;
-64)
target_bits=64
target_cpu=x86_64
;;
*)
echo >&2 'First parameter must be -32 or -64 for 32 bit or 64 bit target respectively.'
exit 1
;;
esac
shift
. "${0%/*}/../builder/mingw-cross.sh"
target_arch="${target_cpu}-w64-mingw32"
# install cross deps on fedora
if [ $# -eq 0 ] && [ -f /etc/fedora-release ]; then
puts "${NL}Installing cross dependencies for your OS...${NL}${NL}"
export BUILD_ROOT="$HOME/vbam-build-mingw${target_bits}"
do_not_remove_dists=
host_dists='
unzip zip cmake autoconf autoconf-archive automake m4 gsed bison flex-2.6.3
flex c2man docbook2x libtool help2man texinfo xmlto pkgconfig nasm yasm
xorg-macros dejavu liberation urw graphviz docbook4.2 docbook4.1.2
docbook4.3 docbook4.4 docbook4.5 docbook5.0 docbook-xsl docbook-xsl-ns
python2 python3 swig doxygen bakefile setuptools pip intltool ninja meson
shared-mime-info gperf
'
both_dists='openssl zlib bzip2 libiconv xz expat libpng freetype fontconfig'
[ -n "$BUILD_ENV" ] && eval "$BUILD_ENV"
BUILD_ENV=$BUILD_ENV$(cat <<EOF
export CC='ccache ${target_arch}-gcc'
export CXX='ccache ${target_arch}-g++'
EOF
)
REQUIRED_CONFIGURE_ARGS="--host=${target_arch}"
REQUIRED_CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE='$(readlink -f "${0%/*}/../../cmake/Toolchain-cross-MinGW-w64-${target_cpu}.cmake")'"
. "${0%/*}/../builder/mingw.sh"
fedora_installdeps() {
pkg_prefix="mingw${target_bits}"
set --
@ -60,37 +16,8 @@ fedora_installdeps() {
done
sudo dnf install -y --nogpgcheck --best --allowerasing "$@" gettext-devel wxGTK3-devel python
}
if [ $# -eq 0 ] && [ -f /etc/fedora-release ]; then
puts "${NL}Installing cross dependencies for your OS...${NL}${NL}"
fedora_installdeps
set --
fi
openssl_host=mingw
[ "$target_bits" -eq 64 ] && openssl_host=mingw64
table_line_replace DIST_CONFIGURE_OVERRIDES openssl-target "./Configure $openssl_host no-shared --prefix=/usr --openssldir=/etc/ssl --cross-compile-prefix=${target_arch}-"
table_line_append DIST_PRE_BUILD bzip2-target ':; sed -i.bak '\''s,include <sys\\stat.h>,include <sys/stat.h>,g'\'' *.c;'
table_line_replace DIST_POST_BUILD harfbuzz "$(table_line DIST_POST_BUILD harfbuzz | sed 's/build_dist freetype /build_dist freetype-target /')"
table_line_append DIST_ARGS libsoxr '-DHAVE_WORDS_BIGENDIAN_EXITCODE=0'
vpx_target=x86-win32-gcc
[ "$target_bits" -eq 64 ] && vpx_target=x86_64-win64-gcc
table_line_replace DIST_CONFIGURE_OVERRIDES libvpx "./configure --target=$vpx_target $CONFIGURE_ARGS $(table_line DIST_ARGS libvpx)"
table_line_remove DIST_ARGS libvpx
table_line_replace DIST_CONFIGURE_OVERRIDES ffmpeg "\
./configure --arch=$target_cpu --target-os=mingw32 --cross-prefix=${target_arch}- \
--pkg-config='$BUILD_ROOT/host/bin/pkg-config' \
$CONFIGURE_ARGS $(table_line DIST_ARGS ffmpeg) \
"
table_line_remove DIST_ARGS ffmpeg
builder "$@"

View File

@ -65,6 +65,8 @@ else
export MSYS="winsymlinks:nativestrict $new_msys"
fi
PATH_SEP=';'
CMAKE_PREFIX_PATH=
for dir in /lib /bin "$HOST_SYSTEM/lib" "$HOST_SYSTEM/bin"; do
CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$(cygpath -m "$sys_base/$dir")"
@ -98,7 +100,7 @@ DIST_TAR_ARGS="
graphviz --exclude COPYING --exclude graphviz.spec
"
. "$(dirname "$0")/../builder/mingw.sh"
. "${0%/*}/../builder/mingw.sh"
set_host_env() {
ln -sf "$BUILD_ROOT/host" "$BUILD_ROOT/root"
@ -163,10 +165,4 @@ table_line_replace DIST_POST_BUILD unzip ":; \
table_line_replace DIST_CONFIGURE_OVERRIDES openssl "$(table_line DIST_CONFIGURE_OVERRIDES openssl | sed 's,^./config ,./Configure Cygwin-x86_64 ,')"
table_line_append DIST_PRE_BUILD zlib ":; \
sed -i.bak ' \
s/defined(_WIN32) *|| *defined(__CYGWIN__)/defined(_WIN32)/ \
' gzguts.h; \
"
builder "$@"