From cff189090b645ec9a88e15f77e62b74229eab930 Mon Sep 17 00:00:00 2001
From: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
Date: Fri, 9 Dec 2022 11:19:52 -0300
Subject: [PATCH] windows: add support for Visual Studio 2022

Change-Id: I83e4fa98444bf4d025cce66aa8297b2d2b14ef01
---
 INSTALL.md                              | 17 +++++++++--------
 build.py                                |  5 +----
 daemon                                  |  2 +-
 extras/scripts/build-windows.py         |  4 ++--
 extras/scripts/install-deps-windows.ps1 |  4 ++--
 qrencode-win32.patch                    |  2 +-
 6 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/INSTALL.md b/INSTALL.md
index b834f175b..a54595fa7 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -150,6 +150,7 @@ Only 64-bit MSVC build can be compiled.
 
 - Using the online installer, install the following Qt 6.2.3 components:
 
+  - Git 2.10.2
   - MSVC 2019 64-bit
   - Qt 5 Compatibility Module
   - Additional Libraries
@@ -160,11 +161,11 @@ Only 64-bit MSVC build can be compiled.
     - Qt WebSockets
     - Qt WebView
 
-- Download [Visual Studio](https://visualstudio.microsoft.com/) (version == 2019). Note: version 2022 does not work. _See the SDK and Toolset notes below._
+- Download [Visual Studio](https://visualstudio.microsoft.com/) (versions 2019 or 2022). _See the SDK notes below._
 
-  |              | SDK          | Toolset | MFC    |
-  | ------------ | ------------ | ------- | ------ |
-  | Requirement: | 10.0.18362.0 | V142    | latest |
+  |              | SDK          | Toolset                                              | MFC              |
+  | ------------ | ------------ | ---------------------------------------------------- | ---------------- |
+  | Requirement: | 10.0.18362.0 | V142 (VisualStudio 2019) / V143 (VisualStudio 2022)  | matching Toolset |
 
 - Install Qt Vs Tools under extensions, and configure msvc2017_64 path under Qt Options. _See the Qt notes below._
 
@@ -199,11 +200,11 @@ Only 64-bit MSVC build can be compiled.
     python build.py --install
 ```
 
-> **SDK and Toolset** Note:
-> Jami can be build with more recent Windows SDK and Toolset than the ones specified in the table above. However, if your have another version than SDK 10.0.18362.0 and/or Toolset v142 installed, you need to identify it according to the example below. For the SDK, you still need to have the required version in addition to the one you chose.
+> **SDK** Note:
+> Jami can be build with more recent Windows SDK than the one specified in the table above. However, if your have another version than SDK 10.0.18362.0 installed, you need to identify it according to the example below. And you still need to have the required version in addition to the one you chose.
 
 ```bash
-    python build.py --install --sdk <your-sdk-version> --toolset <your-toolset-version>
+    python build.py --install --sdk <your-sdk-version>
 ```
 
 > **Qt** Note: If you have another version than qt 6.2.3 installed this step will build daemon correctly but will fail for the client.
@@ -227,7 +228,7 @@ Only 64-bit MSVC build can be compiled.
 - On MSVC folder (daemon\MSVC):
 
 ```sh
-    cmake -DCMAKE_CONFIGURATION_TYPES="ReleaseLib_win32" -DCMAKE_VS_PLATFORM_NAME="x64" -G "Visual Studio 16 2019" -A x64 -T '$(DefaultPlatformToolset)' ..
+    cmake -DCMAKE_CONFIGURATION_TYPES="ReleaseLib_win32" -DCMAKE_VS_PLATFORM_NAME="x64" -G "Visual Studio 17 2022" -A x64 -T '$(DefaultPlatformToolset)' ..
     python winmake.py -b daemon
 ```
 
diff --git a/build.py b/build.py
index 1ea2feb35..1555504b2 100755
--- a/build.py
+++ b/build.py
@@ -33,7 +33,6 @@ WIN32_DISTRIBUTION_NAME = "win32"
 
 # vs vars
 win_sdk_default = '10.0.18362.0'
-win_toolset_default = '142'
 
 APT_BASED_DISTROS = [
     'debian',
@@ -358,7 +357,7 @@ def run_install(args):
         winmake = 'daemon/compat/msvc/winmake.py'
         with cwd(os.path.dirname(winmake)):
             execute_script(
-                f'python {winmake} -iv -t {args.toolset} -s {args.sdk} -b daemon')
+                f'python {winmake} -iv -s {args.sdk} -b daemon')
         build_windows = 'extras/scripts/build-windows.py'
         execute_script(f'python {build_windows} init')
         execute_script(f'python {build_windows}')
@@ -615,8 +614,6 @@ def parse_args():
     dist = choose_distribution()
 
     if dist == WIN32_DISTRIBUTION_NAME:
-        ap.add_argument('--toolset', default=win_toolset_default, type=str,
-                        help='Windows use only, specify Visual Studio toolset version')
         ap.add_argument('--sdk', default=win_sdk_default, type=str,
                         help='Windows use only, specify Windows SDK version')
 
diff --git a/daemon b/daemon
index 3d3a8f67c..f18278a87 160000
--- a/daemon
+++ b/daemon
@@ -1 +1 @@
-Subproject commit 3d3a8f67ce572bbc57b99b328df36e6b2efb5d26
+Subproject commit f18278a87633dd71582f819d9ea8d4dd34365050
diff --git a/extras/scripts/build-windows.py b/extras/scripts/build-windows.py
index d00df385a..8d0c2047c 100644
--- a/extras/scripts/build-windows.py
+++ b/extras/scripts/build-windows.py
@@ -320,8 +320,8 @@ def main():
         print('These scripts will only run on a 64-bit Windows system for now!')
         sys.exit(1)
 
-    if int(getLatestVSVersion()) < 15:
-        print('These scripts require at least Visual Studio v15 2017!')
+    if int(getLatestVSVersion()) < 16:
+        print('These scripts require at least Visual Studio v16 2019!')
         sys.exit(1)
 
     parsed_args = parse_args()
diff --git a/extras/scripts/install-deps-windows.ps1 b/extras/scripts/install-deps-windows.ps1
index 6955b613c..68c228024 100644
--- a/extras/scripts/install-deps-windows.ps1
+++ b/extras/scripts/install-deps-windows.ps1
@@ -214,13 +214,13 @@ install_choco_packages $choco_packages
 install_msys2_packages $msys_packages
 
 # Install VSNASM
-download_file_to_temp 'VSNASM' "https://github.com/ShiftMediaProject/VSNASM/releases/download/0.5/VSNASM.zip" 'VSNASM.zip'
+download_file_to_temp 'VSNASM' "https://github.com/ShiftMediaProject/VSNASM/releases/download/0.8/VSNASM.zip" 'VSNASM.zip'
 unzip_file_from_temp 'VSNASM' 'VSNASM.zip' 'VSNASM_UNZIP'
 $batch_path = "/c set ISINSTANCE=1 &&" + $env:TEMP + "\VSNASM_UNZIP\install_script.bat"
 run_batch $batch_path "Install VSNASM"
 
 # Install VSYASM
-download_file_to_temp 'VSYASM' "https://github.com/ShiftMediaProject/VSYASM/releases/download/0.4/VSYASM.zip" 'VSYASM.zip'
+download_file_to_temp 'VSYASM' "https://github.com/ShiftMediaProject/VSYASM/releases/download/0.7/VSYASM.zip" 'VSYASM.zip'
 unzip_file_from_temp 'VSYASM' 'VSYASM.zip' 'VSYASM_UNZIP'
 $batch_path = "/c set ISINSTANCE=1 &&" + $env:TEMP + "\VSYASM_UNZIP\install_script.bat"
 run_batch $batch_path "Install VSYASM"
diff --git a/qrencode-win32.patch b/qrencode-win32.patch
index efeb29674..6cfd8fb31 100644
--- a/qrencode-win32.patch
+++ b/qrencode-win32.patch
@@ -48,7 +48,7 @@ index aabc6b6..8d8293b 100644
      <ProjectGuid>{9A90BF5C-84B0-41F6-B83C-C20EADC1F46C}</ProjectGuid>
      <RootNamespace>qrcodelib</RootNamespace>
      <Keyword>Win32Proj</Keyword>
-+    <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
++    <WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
    </PropertyGroup>
    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|Win32'" Label="Configuration">
-- 
GitLab