add ucrt support to windows build script (#399)

This commit is contained in:
Cyano Hao 2024-04-27 21:55:09 +08:00 committed by GitHub
parent 9ef7d45640
commit ec6222ddb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 41 additions and 0 deletions

View File

@ -14,6 +14,8 @@ function fn_print_help() {
--mingw Alias for --mingw32 (x86 app) or --mingw64 (x64 app). --mingw Alias for --mingw32 (x86 app) or --mingw64 (x64 app).
--mingw32 Build mingw32 integrated compiler. --mingw32 Build mingw32 integrated compiler.
--mingw64 Build mingw64 integrated compiler. --mingw64 Build mingw64 integrated compiler.
--ucrt <build> Include UCRT in the package. Windows SDK required.
e.g. '--ucrt 22621' for Windows 11 SDK 22H2.
-nd, --no-deps Skip dependency check. -nd, --no-deps Skip dependency check.
-t, --target-dir <dir> Set target directory for the packages." -t, --target-dir <dir> Set target directory for the packages."
} }
@ -68,6 +70,7 @@ compilers=()
COMPILER_MINGW32=0 COMPILER_MINGW32=0
COMPILER_MINGW64=0 COMPILER_MINGW64=0
TARGET_DIR="$(pwd)/dist" TARGET_DIR="$(pwd)/dist"
UCRT=""
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
-h|--help) -h|--help)
@ -106,6 +109,22 @@ while [[ $# -gt 0 ]]; do
COMPILER_MINGW64=1 COMPILER_MINGW64=1
shift shift
;; ;;
--ucrt)
case "${MSYSTEM}" in
CLANG32|UCRT64|CLANG64)
UCRT="$2"
shift 2
;;
MINGW32|MINGW64)
echo "Error: Red Panda C++ is not built against UCRT."
exit 1
;;
CLANGARM64)
echo "Error: UCRT is a system component on arm64, local deployment is not supported."
exit 1
;;
esac
;;
-nd|--no-deps) -nd|--no-deps)
CHECK_DEPS=0 CHECK_DEPS=0
shift shift
@ -129,6 +148,7 @@ QMAKE="${MINGW_PREFIX}/qt5-static/bin/qmake"
NSIS="/mingw32/bin/makensis" NSIS="/mingw32/bin/makensis"
SOURCE_DIR="$(pwd)" SOURCE_DIR="$(pwd)"
ASSETS_DIR="${SOURCE_DIR}/assets" ASSETS_DIR="${SOURCE_DIR}/assets"
UCRT_DIR="/c/Program Files (x86)/Windows Kits/10/Redist/10.0.${UCRT}.0/ucrt/DLLs/${NSIS_ARCH}"
MINGW32_ARCHIVE="mingw32.7z" MINGW32_ARCHIVE="mingw32.7z"
MINGW32_COMPILER_NAME="MinGW-w64 i686 GCC 8.1" MINGW32_COMPILER_NAME="MinGW-w64 i686 GCC 8.1"
@ -181,6 +201,10 @@ if [[ ${COMPILER_MINGW64} -eq 1 && ! -f "${SOURCE_DIR}/assets/${MINGW64_ARCHIVE}
echo "Missing MinGW archive: assets/${MINGW64_ARCHIVE}" echo "Missing MinGW archive: assets/${MINGW64_ARCHIVE}"
exit 1 exit 1
fi fi
if [[ -n "${UCRT}" && ! -f "${UCRT_DIR}/ucrtbase.dll" ]]; then
echo "Missing Windows SDK, UCRT cannot be included."
exit 1
fi
## prepare dirs ## prepare dirs
@ -263,6 +287,13 @@ if [[ ${COMPILER_MINGW64} -eq 1 ]]; then
nsis_flags+=(-DHAVE_MINGW64) nsis_flags+=(-DHAVE_MINGW64)
[[ -d "mingw64" ]] || 7z x "${SOURCE_DIR}/assets/${MINGW64_ARCHIVE}" -o"${PACKAGE_DIR}" [[ -d "mingw64" ]] || 7z x "${SOURCE_DIR}/assets/${MINGW64_ARCHIVE}" -o"${PACKAGE_DIR}"
fi fi
if [[ -n "${UCRT}" ]]; then
nsis_flags+=(-DHAVE_UCRT)
if [[ ! -f ucrt/ucrtbase.dll ]]; then
mkdir -p ucrt
cp "${UCRT_DIR}"/*.dll ucrt
fi
fi
"${NSIS}" "${nsis_flags[@]}" redpanda.nsi "${NSIS}" "${nsis_flags[@]}" redpanda.nsi
fn_print_progress "Making Portable Package..." fn_print_progress "Making Portable Package..."

View File

@ -129,6 +129,13 @@ Section "$(SectionMainName)" SectionMain
!ifdef HAVE_COMPILER_HINT !ifdef HAVE_COMPILER_HINT
File "compiler_hint.lua" File "compiler_hint.lua"
!endif !endif
!ifdef HAVE_UCRT
${IfNot} ${AtLeastWin10}
File "ucrt\ucrtbase.dll"
File "ucrt\api-ms-win-core-*.dll"
File "ucrt\api-ms-win-crt-*.dll"
${EndIf}
!endif
; Write required paths ; Write required paths
SetOutPath $INSTDIR\templates SetOutPath $INSTDIR\templates
@ -439,6 +446,9 @@ Section "Uninstall"
Delete "$INSTDIR\qt.conf" Delete "$INSTDIR\qt.conf"
Delete "$INSTDIR\OpenConsole.exe" Delete "$INSTDIR\OpenConsole.exe"
Delete "$INSTDIR\compiler_hint.lua" Delete "$INSTDIR\compiler_hint.lua"
Delete "$INSTDIR\ucrtbase.dll"
Delete "$INSTDIR\api-ms-win-core-*.dll"
Delete "$INSTDIR\api-ms-win-crt-*.dll"
RMDir /r "$INSTDIR\templates" RMDir /r "$INSTDIR\templates"
RMDir /r "$INSTDIR\mingw32" RMDir /r "$INSTDIR\mingw32"