Fix VS2022 MSMs detection

After commits 42da199753 (more VS2022 integration,
Oct 14 10:58:25 2021 +0200) and 9ea17a6331 (Adapt
to latest VS 2022 MSM versions, Apr 08 09:15:19 2022 +0200), the new 143 version
of MSMs gets detected and passed to SCP, but not used there, so MSIs lack CRT.

Additionally, it may happen that a redist is configured that does not match the
actual CRT used in the build, because it picked a latest available version, and
then an error happens when building MSI, because it expects MSMs in wrong source
directory.

This simplifies the checks, makes sure to look for the correct MSM version, and
adds an error message in SCP in case when the passed version is not handled, to
detect the incomplete support early.

Change-Id: I47d45472309c584314730e7f5f46a9596fc8d21d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142587
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2022-11-11 16:59:31 +03:00
parent dd16101465
commit ab4e40941e
2 changed files with 38 additions and 39 deletions

View File

@@ -6703,36 +6703,24 @@ find_winsdk()
find_msms() find_msms()
{ {
# Return value: $msmdir # Return value: $msmdir
local version="$1"
AC_MSG_CHECKING([for MSVC merge modules directory]) AC_MSG_CHECKING([for MSVC $version merge modules directory])
local my_msm_files local my_msm_file="Microsoft_VC${version}_CRT_x86.msm"
local my_msm_dir local my_msm_dir
dnl Order my_msm_files in increasing order. Then check the directories returned echo "$as_me:$LINENO: searching for $my_msm_file" >&5
dnl by ls in an inner loop; assuming they are also ordered in increasing order,
dnl the result will be the highest MSM version found in the highest directory.
case "$VCVER" in
16.0 | 17.0 | 17.4)
my_msm_files="Microsoft_VC141_CRT_x86.msm Microsoft_VC142_CRT_x86.msm Microsoft_VC143_CRT_x86.msm ${my_msm_files}"
;;
esac
for f in $my_msm_files; do
echo "$as_me:$LINENO: searching for $f" >&5
done
msmdir= msmdir=
case "$VCVER" in case "$VCVER" in
16.0 | 17.0 | 17.4) 16.0 | 17.0 | 17.4)
for f in ${my_msm_files}; do
for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do for l in `ls -1 $VC_PRODUCT_DIR/redist/MSVC/`; do
my_msm_dir="$VC_PRODUCT_DIR/redist/MSVC/$l/MergeModules/" my_msm_dir="$VC_PRODUCT_DIR/redist/MSVC/$l/MergeModules/"
echo "$as_me:$LINENO: looking for $my_msm_dir${f}])" >&5 echo "$as_me:$LINENO: looking for $my_msm_dir${my_msm_file}])" >&5
if test -e "$my_msm_dir${f}"; then if test -e "$my_msm_dir${my_msm_file}"; then
msmdir=$my_msm_dir msmdir=$my_msm_dir
fi fi
done done
done
;; ;;
esac esac
@@ -6744,7 +6732,7 @@ find_msms()
AC_MSG_FAILURE([not found]) AC_MSG_FAILURE([not found])
else else
AC_MSG_WARN([not found (check config.log)]) AC_MSG_WARN([not found (check config.log)])
add_warning "MSM none of ${my_msm_files} found" add_warning "MSM ${my_msm_file} not found"
fi fi
fi fi
} }
@@ -8565,25 +8553,25 @@ AC_ARG_WITH(ucrt-dir,
UCRT_REDISTDIR="$with_ucrt_dir" UCRT_REDISTDIR="$with_ucrt_dir"
if test $_os = "WINNT"; then if test $_os = "WINNT"; then
find_msvc_x64_dlls find_msvc_x64_dlls
MSVC_DLL_PATH=`win_short_path_for_make "$msvcdllpath"`
MSVC_DLLS="$msvcdlls"
if echo "$msvcdllpath" | grep -q "VC143.CRT$"; then
with_redist=143
elif echo "$msvcdllpath" | grep -q "VC142.CRT$"; then
with_redist=142
elif echo "$msvcdllpath" | grep -q "VC141.CRT$"; then
with_redist=141
fi
for i in $PKGFORMAT; do for i in $PKGFORMAT; do
if test "$i" = msi; then if test "$i" = msi; then
find_msms find_msms "$with_redist"
if test -n "$msmdir"; then
MSM_PATH=`win_short_path_for_make "$msmdir"`
SCPDEFS="$SCPDEFS -DWITH_VC_REDIST=$with_redist"
fi
break break
fi fi
done done
MSVC_DLL_PATH=`win_short_path_for_make "$msvcdllpath"`
MSVC_DLLS="$msvcdlls"
test -n "$msmdir" && MSM_PATH=`win_short_path_for_make "$msmdir"`
# MSVC 15.3 changed it to VC141
if echo "$msvcdllpath" | grep -q "VC143.CRT$"; then
SCPDEFS="$SCPDEFS -DWITH_VC143_REDIST"
elif echo "$msvcdllpath" | grep -q "VC142.CRT$"; then
SCPDEFS="$SCPDEFS -DWITH_VC142_REDIST"
elif echo "$msvcdllpath" | grep -q "VC141.CRT$"; then
SCPDEFS="$SCPDEFS -DWITH_VC141_REDIST"
else
SCPDEFS="$SCPDEFS -DWITH_VC${VCVER}_REDIST"
fi
if test "$UCRT_REDISTDIR" = "no"; then if test "$UCRT_REDISTDIR" = "no"; then
dnl explicitly disabled dnl explicitly disabled

View File

@@ -18,16 +18,27 @@
#include "macros.inc" #include "macros.inc"
#if defined(WITH_VC142_REDIST) #if defined(WITH_VC_REDIST)
#if WITH_VC_REDIST == 143
#define WINDOWS_X64_MERGEMODULE gid_MergeModule_Microsoft_VC143_CRT_x64
#define WINDOWS_X64_MERGEMODULE_FILE "Microsoft_VC143_CRT_x64.msm"
#define WINDOWS_X86_MERGEMODULE gid_MergeModule_Microsoft_VC143_CRT_x86
#define WINDOWS_X86_MERGEMODULE_FILE "Microsoft_VC143_CRT_x86.msm"
#elif WITH_VC_REDIST == 142
#define WINDOWS_X64_MERGEMODULE gid_MergeModule_Microsoft_VC142_CRT_x64 #define WINDOWS_X64_MERGEMODULE gid_MergeModule_Microsoft_VC142_CRT_x64
#define WINDOWS_X64_MERGEMODULE_FILE "Microsoft_VC142_CRT_x64.msm" #define WINDOWS_X64_MERGEMODULE_FILE "Microsoft_VC142_CRT_x64.msm"
#define WINDOWS_X86_MERGEMODULE gid_MergeModule_Microsoft_VC142_CRT_x86 #define WINDOWS_X86_MERGEMODULE gid_MergeModule_Microsoft_VC142_CRT_x86
#define WINDOWS_X86_MERGEMODULE_FILE "Microsoft_VC142_CRT_x86.msm" #define WINDOWS_X86_MERGEMODULE_FILE "Microsoft_VC142_CRT_x86.msm"
#elif defined(WITH_VC141_REDIST) #elif WITH_VC_REDIST == 141
#define WINDOWS_X64_MERGEMODULE gid_MergeModule_Microsoft_VC141_CRT_x64 #define WINDOWS_X64_MERGEMODULE gid_MergeModule_Microsoft_VC141_CRT_x64
#define WINDOWS_X64_MERGEMODULE_FILE "Microsoft_VC141_CRT_x64.msm" #define WINDOWS_X64_MERGEMODULE_FILE "Microsoft_VC141_CRT_x64.msm"
#define WINDOWS_X86_MERGEMODULE gid_MergeModule_Microsoft_VC141_CRT_x86 #define WINDOWS_X86_MERGEMODULE gid_MergeModule_Microsoft_VC141_CRT_x86
#define WINDOWS_X86_MERGEMODULE_FILE "Microsoft_VC141_CRT_x86.msm" #define WINDOWS_X86_MERGEMODULE_FILE "Microsoft_VC141_CRT_x86.msm"
#else
// The next string will result in "malformed par file" error, terminating build as expected.
// Possibly a new version of CRT was enabled in configure.ac, but not handled here yet?
error: unknown VC redist version WITH_VC_REDIST. Check configure.ac
#endif
#endif #endif
#if defined(WINDOWS_X86_MERGEMODULE) #if defined(WINDOWS_X86_MERGEMODULE)