[ci,mingw] update build scripts

* update dependency versions
* replace SDL2 with SDL3 client
* update documentation
* add option to do fully static builds
* format script with shfmt -i 2 w scripts/mingw.sh
This commit is contained in:
akallabeth
2025-02-25 09:28:16 +01:00
parent e0ccda667e
commit 418d228d4b
2 changed files with 194 additions and 156 deletions

View File

@@ -3,6 +3,12 @@ Overview
More documentation might be found at https://github.com/FreeRDP/FreeRDP/wiki/Compilation More documentation might be found at https://github.com/FreeRDP/FreeRDP/wiki/Compilation
A sample build script is part of the repository at scripts/mingw.sh
It is periodically run as part of the https://github.com/FreeRDP/FreeRDP/actions/workflows/mingw.yml workflow.
If you want to do your own build, check the script and the dependency versions checked out (we only use it for the ci builder,
so updates are not always done in a timely fashion)
FreeRDP can be built for Windows using llvm-mingw (https://github.com/mstorsjo/llvm-mingw) with both msvcrt and ucrt. FreeRDP can be built for Windows using llvm-mingw (https://github.com/mstorsjo/llvm-mingw) with both msvcrt and ucrt.
MinGW builds are not actively maintained at the moment and every once in a while the build process may stop working. Pull requests to maintain MinGW support are always welcome. MinGW builds are not actively maintained at the moment and every once in a while the build process may stop working. Pull requests to maintain MinGW support are always welcome.

View File

@@ -1,10 +1,10 @@
#!/bin/bash -xe #!/bin/bash -xe
# #
# mingw build script # mingw build script
# #
# TODO: Replace with CMake FetchContent # TODO: Replace with CMake FetchContent
# https://cmake.org/cmake/help/latest/module/FetchContent.html # https://cmake.org/cmake/help/latest/module/FetchContent.html
# #
SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}") SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}")
SCRIPT_PATH=$(realpath "$SCRIPT_PATH") SCRIPT_PATH=$(realpath "$SCRIPT_PATH")
@@ -16,193 +16,225 @@ CLONE=1
DEPS=1 DEPS=1
BUILD=1 BUILD=1
FFMPEG=0 FFMPEG=0
OPENH264=0
for i in "$@" ARG_SHARED=1
do CMAKE_DEFAULT_FLAGS=""
case $i in ARG_SHARED_MESON="-Ddefault_library=shared"
-b|--no-build) ARG_SHARED_FFMPEG="--disable-static --enable-shared"
for i in "$@"; do
case $i in
-b | --no-build)
BUILD=0 BUILD=0
;; ;;
-d|--no-deps) -c | --no-clone)
DEPS=0
;;
-c|--no-clone)
CLONE=0 CLONE=0
;; ;;
-f|--with-ffmpeg) -d | --no-deps)
DEPS=0
;;
-f | --with-ffmpeg)
FFMPEG=1 FFMPEG=1
;; ;;
*) -o | --with-openh264)
# unknown option OPENH264=1
echo "unknown option, quit"
echo "$0 [-d|--no-deps] [-c|--no-clone]"
exit 1
;; ;;
esac -s | --static)
ARG_SHARED=0
CMAKE_DEFAULT_FLAGS="-static -static-libgcc -static-libstdc++"
ARG_SHARED_MESON="-Ddefault_library=static"
ARG_SHARED_FFMPEG=""
;;
*)
# unknown option
echo "unknown option '$i', quit"
echo "usage:\n\t$0 [-b|--no-build] [-c|--no-clone] [-d|--no-deps] [-f|--with-ffmpeg] [-o|--with-openh264] [-s|--static]"
exit 1
;;
esac
done done
function do_clone { ARG_COMPILED_RES=1
version=$1 if [ $ARG_SHARED -ne 0 ]; then
url=$2 ARG_COMPILED_RES=0
dir=$3 fi
if [ -d "$dir" ]; function do_clone {
then version=$1
( url=$2
cd "$dir" dir=$3
git fetch --all
git clean -xdf if [ -d "$dir" ]; then
git reset --hard $version (
git checkout $version cd "$dir"
git submodule update --init --recursive git fetch --all
) git clean -xdf
else git reset --hard $version
git clone --depth 1 --shallow-submodules --recurse-submodules -b $version $url $dir git checkout $version
fi git submodule update --init --recursive
)
else
git clone --depth 1 --shallow-submodules --recurse-submodules -b $version $url $dir
fi
} }
function do_cmake_build { function do_cmake_build {
cmake \ cmake \
-GNinja \ -GNinja \
-DCMAKE_TOOLCHAIN_FILE="$SCRIPT_PATH/mingw64.cmake" \ -DCMAKE_TOOLCHAIN_FILE="$SCRIPT_PATH/mingw64.cmake" \
-DCMAKE_PREFIX_PATH="$INSTALL_BASE/lib/cmake;$INSTALL_BASE/lib;$INSTALL_BASE" \ -DCMAKE_PREFIX_PATH="$INSTALL_BASE/lib/cmake;$INSTALL_BASE/lib;$INSTALL_BASE" \
-DCMAKE_MODULE_PATH="$INSTALL_BASE/lib/cmake;$INSTALL_BASE/lib;$INSTALL_BASE" \ -DCMAKE_MODULE_PATH="$INSTALL_BASE/lib/cmake;$INSTALL_BASE/lib;$INSTALL_BASE" \
-DCMAKE_INSTALL_PREFIX="$INSTALL_BASE" \ -DCMAKE_INSTALL_PREFIX="$INSTALL_BASE" \
-B "$1" \ -DBUILD_SHARED_LIBS=$ARG_SHARED \
${@:2} -DCMAKE_INTERPROZEDURAL_OPTIMIZATION=OFF \
cmake --build "$1" -DCMAKE_EXE_LINKER_FLAGS="$CMAKE_DEFAULT_FLAGS" \
cmake --install "$1" -B "$1" \
${@:2}
cmake --build "$1"
cmake --install "$1"
} }
mkdir -p "$SRC_BASE" mkdir -p "$SRC_BASE"
mkdir -p "$BUILD_BASE" mkdir -p "$BUILD_BASE"
cd "$SRC_BASE" cd "$SRC_BASE"
if [ $CLONE -ne 0 ]; if [ $CLONE -ne 0 ]; then
then do_clone v1.3.1 https://github.com/madler/zlib.git zlib
do_clone v1.3.1 https://github.com/madler/zlib.git zlib do_clone uriparser-0.9.8 https://github.com/uriparser/uriparser.git uriparser
do_clone uriparser-0.9.7 https://github.com/uriparser/uriparser.git uriparser do_clone v1.7.18 https://github.com/DaveGamble/cJSON.git cJSON
do_clone v1.7.17 https://github.com/DaveGamble/cJSON.git cJSON do_clone release-3.2.4 https://github.com/libsdl-org/SDL.git SDL
do_clone release-2.30.0 https://github.com/libsdl-org/SDL.git SDL if [ $FFMPEG -ne 0 ]; then
if [ $FFMPEG -ne 0 ]; do_clone n7.1 https://github.com/FFmpeg/FFmpeg.git FFmpeg
then fi
do_clone n6.1.1 https://github.com/FFmpeg/FFmpeg.git FFmpeg if [ $OPENH264 -ne 0 ]; then
fi do_clone v2.6.0 https://github.com/cisco/openh264.git openh264
do_clone v2.4.1 https://github.com/cisco/openh264.git openh264 fi
do_clone v1.0.27 https://github.com/libusb/libusb-cmake.git libusb-cmake do_clone v1.0.27-1 https://github.com/libusb/libusb-cmake.git libusb-cmake
do_clone release-2.8.2 https://github.com/libsdl-org/SDL_image.git SDL_image do_clone release-3.2.0 https://github.com/libsdl-org/SDL_image.git SDL_image
do_clone release-2.22.0 https://github.com/libsdl-org/SDL_ttf.git SDL_ttf do_clone prerelease-3.1.2 https://github.com/libsdl-org/SDL_ttf.git SDL_ttf
do_clone v3.8.2 https://github.com/libressl/portable.git libressl do_clone v3.9.2 https://github.com/libressl/portable.git libressl
( (
cd libressl cd libressl
./update.sh ./update.sh
) )
fi fi
if [ $BUILD -eq 0 ]; if [ $BUILD -eq 0 ]; then
then exit 0
exit 0
fi fi
if [ $DEPS -ne 0 ]; if [ $DEPS -ne 0 ]; then
then do_cmake_build \
do_cmake_build \ "$BUILD_BASE/libressl" \
"$BUILD_BASE/libressl" \ -S libressl \
-S libressl \ -DLIBRESSL_APPS=OFF \
-DLIBRESSL_APPS=OFF \ -DLIBRESSL_TESTS=OFF
-DLIBRESSL_TESTS=OFF
do_cmake_build \ do_cmake_build \
"$BUILD_BASE/zlib" \ "$BUILD_BASE/zlib" \
-S zlib -S zlib \
-DZLIB_BUILD_EXAMPLES=OFF
do_cmake_build \ do_cmake_build \
"$BUILD_BASE/uriparser" \ "$BUILD_BASE/uriparser" \
-S uriparser \ -S uriparser \
-DURIPARSER_BUILD_DOCS=OFF \ -DURIPARSER_BUILD_TOOLS=OFF \
-DURIPARSER_BUILD_TESTS=OFF -DURIPARSER_BUILD_DOCS=OFF \
-DURIPARSER_BUILD_TESTS=OFF
do_cmake_build \ do_cmake_build \
"$BUILD_BASE/cJSON" \ "$BUILD_BASE/cJSON" \
-S cJSON \ -S cJSON \
-DENABLE_CJSON_TEST=OFF \ -DENABLE_CJSON_TEST=OFF \
-DBUILD_SHARED_AND_STATIC_LIBS=ON -DENABLE_CUSTOM_COMPILER_FLAGS=OFF \
-DENABLE_HIDDEN_SYMBOLS=ON \
-DBUILD_SHARED_AND_STATIC_LIBS=OFF \
-DCJSON_BUILD_SHARED_LIBS=$ARG_SHARED
do_cmake_build \ do_cmake_build \
"$BUILD_BASE/SDL" \ "$BUILD_BASE/SDL" \
-S SDL \ -S SDL \
-DSDL_TEST=OFF \ -DSDL_TEST=OFF \
-DSDL_TESTS=OFF \ -DSDL_TESTS=OFF \
-DSDL_STATIC_PIC=ON -DSDL_STATIC_PIC=ON
do_cmake_build \ do_cmake_build \
"$BUILD_BASE/SDL_ttf" \ "$BUILD_BASE/SDL_ttf" \
-S SDL_ttf \ -S SDL_ttf \
-DSDL2TTF_HARFBUZZ=ON \ -DSDLTTF_HARFBUZZ=ON \
-DSDL2TTF_FREETYPE=ON \ -DSDLTTF_FREETYPE=ON \
-DSDL2TTF_VENDORED=ON \ -DSDLTTF_VENDORED=ON \
-DFT_DISABLE_ZLIB=OFF \ -DFT_DISABLE_ZLIB=OFF \
-DSDL2TTF_SAMPLES=OFF -DSDLTTF_SAMPLES=OFF \
-DSDLTTF_PLUTOSVG=OFF
do_cmake_build \ do_cmake_build \
"$BUILD_BASE/SDL_image" \ "$BUILD_BASE/SDL_image" \
-S SDL_image \ -S SDL_image \
-DSDL2IMAGE_SAMPLES=OFF \ -DSDLIMAGE_SAMPLES=OFF \
-DSDL2IMAGE_DEPS_SHARED=OFF -DSDLIMAGE_DEPS_SHARED=OFF
do_cmake_build \ do_cmake_build \
"$BUILD_BASE/libusb-cmake" \ "$BUILD_BASE/libusb-cmake" \
-S libusb-cmake \ -S libusb-cmake \
-DLIBUSB_BUILD_EXAMPLES=OFF \ -DLIBUSB_BUILD_EXAMPLES=OFF \
-DLIBUSB_BUILD_TESTING=OFF \ -DLIBUSB_BUILD_TESTING=OFF \
-DLIBUSB_ENABLE_DEBUG_LOGGING=OFF -DLIBUSB_ENABLE_DEBUG_LOGGING=OFF
# TODO: This takes ages to compile, disable # TODO: This takes ages to compile, disable
if [ $FFMPEG -ne 0 ]; if [ $FFMPEG -ne 0 ]; then
then (
( cd "$BUILD_BASE"
cd "$BUILD_BASE" mkdir -p FFmpeg
mkdir -p FFmpeg cd FFmpeg
cd FFmpeg "$SRC_BASE/FFmpeg/configure" \
"$SRC_BASE/FFmpeg/configure" \ --arch=x86_64 \
--arch=x86_64 \ --target-os=mingw64 \
--target-os=mingw64 \ --cross-prefix=x86_64-w64-mingw32- \
--cross-prefix=x86_64-w64-mingw32- \ --disable-programs \
--prefix="$INSTALL_BASE" --disable-doc \
make -j --prefix="$INSTALL_BASE" $ARG_SHARED_FFMPEG
make -j install make -j
) make -j install
fi )
fi
meson setup --cross-file "$SCRIPT_PATH/mingw-meson.conf" \ if [ $OPENH264 -ne 0 ]; then
-Dprefix="$INSTALL_BASE" \ (
-Db_pie=true \ meson setup --cross-file "$SCRIPT_PATH/mingw-meson.conf" \
-Db_lto=true \ -Dprefix="$INSTALL_BASE" \
-Dbuildtype=release \ -Db_pie=true \
-Dtests=disabled \ -Db_lto=true \
-Ddefault_library=both \ -Dbuildtype=release \
"$BUILD_BASE/openh264" \ -Dtests=disabled \
openh264 $ARG_SHARED_MESON \
ninja -C "$BUILD_BASE/openh264" -Dcpp_link_args="$CMAKE_DEFAULT_FLAGS" \
ninja -C "$BUILD_BASE/openh264" install -Dcpp_args="$CMAKE_DEFAULT_FLAGS" \
"$BUILD_BASE/openh264" \
openh264
ninja -C "$BUILD_BASE/openh264"
ninja -C "$BUILD_BASE/openh264" install
)
fi
fi fi
do_cmake_build \ do_cmake_build \
"$BUILD_BASE/freerdp" \ "$BUILD_BASE/freerdp" \
-S "$SCRIPT_PATH/.." \ -S "$SCRIPT_PATH/.." \
-DWITH_SERVER=ON \ -DWITH_SERVER=ON \
-DWITH_SHADOW=OFF \ -DWITH_SHADOW=OFF \
-DWITH_PLATFORM_SERVER=OFF \ -DWITH_PLATFORM_SERVER=OFF \
-DWITH_SAMPLE=ON \ -DWITH_SAMPLE=ON \
-DWITH_PLATFORM_SERVER=OFF \ -DWITH_PLATFORM_SERVER=OFF \
-DUSE_UNWIND=OFF \ -DUSE_UNWIND=OFF \
-DSDL_USE_COMPILED_RESOURCES=OFF \ -DSDL_USE_COMPILED_RESOURCES=$ARG_COMPILED_RES \
-DWITH_SWSCALE=OFF \ -DWITH_SDL_IMAGE_DIALOGS=ON \
-DWITH_FFMPEG=OFF \ -DWITH_SDL_LINK_SHARED=$ARG_SHARED \
-DWITH_SIMD=ON \ -DWITH_CLIENT_SDL2=OFF \
-DWITH_OPENH264=ON \ -DWITH_SWSCALE=$FFMPEG \
-DWITH_WEBVIEW=OFF \ -DWITH_FFMPEG=$FFMPEG \
-DWITH_LIBRESSL=ON \ -DWITH_SIMD=ON \
-DWITH_MANPAGES=OFF \ -DWITH_OPENH264=$OPENH264 \
-DZLIB_INCLUDE_DIR="$INSTALL_BASE/include" \ -DWITH_WEBVIEW=OFF \
-DZLIB_LIBRARY="$INSTALL_BASE/lib/libzlibstatic.a" -DWITH_LIBRESSL=ON \
-DWITH_MANPAGES=OFF