From 3ac51f325a5af3639a4e120a07352f57613d3acd Mon Sep 17 00:00:00 2001
From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com>
Date: Mon, 15 Nov 2021 15:10:39 -0500
Subject: [PATCH] build: add command option to generate installer directly

Change-Id: I663f4c7d736d62063f897d9551fc2e97ad5360ef
---
 JamiInstaller/JamiInstaller.wixproj |  1 +
 make-client.py                      | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/JamiInstaller/JamiInstaller.wixproj b/JamiInstaller/JamiInstaller.wixproj
index 9c64ca6ee..fee475ae7 100644
--- a/JamiInstaller/JamiInstaller.wixproj
+++ b/JamiInstaller/JamiInstaller.wixproj
@@ -11,6 +11,7 @@
     <OutputType>Package</OutputType>
     <Name>JamiInstaller</Name>
     <InstallerPlatform>x64</InstallerPlatform>
+    <DefineSolutionProperties>false</DefineSolutionProperties>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
     <OutputPath>bin\$(Configuration)\</OutputPath>
diff --git a/make-client.py b/make-client.py
index 0bc78cda9..54a773591 100644
--- a/make-client.py
+++ b/make-client.py
@@ -29,6 +29,7 @@ qt_kit_path = 'msvc2019_64'
 qt_root_path = os.getenv('QT_ROOT_DIRECTORY', qt_path)
 
 # project path
+installer_project = os.path.join(this_dir, 'JamiInstaller', 'JamiInstaller.wixproj')
 unit_test_project = os.path.join(build_dir, 'tests', 'unittests.vcxproj')
 qml_test_project = os.path.join(build_dir, 'tests', 'qml_tests.vcxproj')
 
@@ -261,6 +262,17 @@ def run_tests(mute_jamid, output_to_files):
             test_result_code = 1
     sys.exit(test_result_code)
 
+def generate_msi_installer():
+    print('Generating application installer...')
+
+    vs_env_vars = {}
+    vs_env_vars.update(getVSEnv())
+    msbuild = findMSBuild()
+    if not os.path.isfile(msbuild):
+        raise IOError('msbuild.exe not found. path=' + msbuild)
+    msbuild_args = getMSBuildArgs('x64', 'Release')
+
+    build_project(msbuild, msbuild_args, installer_project, vs_env_vars)
 
 def parse_args():
     ap = argparse.ArgumentParser(description="Client qt build tool")
@@ -287,6 +299,8 @@ def parse_args():
         '-l', '--logtests', action='store_true', default=False,
         help='Output tests log to files')
 
+    subparser.add_parser('msi')
+
     parsed_args = ap.parse_args()
 
     return parsed_args
@@ -315,6 +329,9 @@ def main():
         if parsed_args.runtests:
             run_tests(parsed_args.mutejamid, parsed_args.outputtofiles)
 
+    if parsed_args.subparser_name == 'msi':
+        generate_msi_installer()
+
 
 if __name__ == '__main__':
     main()
-- 
GitLab