Просмотр исходного кода

CPackIFW: Add support for RunProgram* config variables

This patch adds support for specifying <RunProgram>,
<RunProgramArguments>, and <RunProgramDescription> in the IFW
configuration file.
Erlend E. Aasland 4 лет назад
Родитель
Сommit
f2f4e66f64

+ 28 - 0
Help/cpack_gen/ifw.rst

@@ -264,6 +264,34 @@ Package
 
  This feature is available for QtIFW 4.0.0 or newer.
 
+.. variable:: CPACK_IFW_PACKAGE_RUN_PROGRAM
+
+ .. versionadded:: 3.23
+
+ Command executed after the installer is done if the user accepts the action.
+ Provide the full path to the application.
+
+ This feature is available for QtIFW 4.0.0 and newer.
+
+.. variable:: CPACK_IFW_PACKAGE_RUN_PROGRAM_ARGUMENTS
+
+ .. versionadded:: 3.23
+
+ List of arguments passed to the program specified in
+ :variable:`CPACK_IFW_PACKAGE_RUN_PROGRAM`.
+
+ This feature is available for QtIFW 4.0.0 and newer.
+
+.. variable:: CPACK_IFW_PACKAGE_RUN_PROGRAM_DESCRIPTION
+
+ .. versionadded:: 3.23
+
+ Text shown next to the check box for running the program after the
+ installation. If :variable:`CPACK_IFW_PACKAGE_RUN_PROGRAM` is set but no
+ description provided, the UI will display ``Run <Name> now``. instead.
+
+ This feature is available for QtIFW 4.0.0 and newer.
+
 Components
 """"""""""
 

+ 10 - 0
Help/release/dev/cpackifw-package-run-program.rst

@@ -0,0 +1,10 @@
+
+cpackifw-package-run-program
+----------------------------
+
+* The :cpack_gen:`CPack IFW Generator` gained the new
+  :variable:`CPACK_IFW_PACKAGE_RUN_PROGRAM`,
+  :variable:`CPACK_IFW_PACKAGE_RUN_PROGRAM_ARGUMENTS`, and
+  :variable:`CPACK_IFW_PACKAGE_RUN_PROGRAM_DESCRIPTION` variables for executing
+  a command after the installer is done if the user accepts the action.
+  This feature is available for QtIFW 4.0 and newer.

+ 33 - 0
Source/CPack/IFW/cmCPackIFWInstaller.cxx

@@ -292,6 +292,20 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
     this->ProductImages.clear();
     cmExpandList(productImages, this->ProductImages);
   }
+
+  // Run program, run program arguments, and run program description
+  if (cmValue program = this->GetOption("CPACK_IFW_PACKAGE_RUN_PROGRAM")) {
+    this->RunProgram = *program;
+  }
+  if (cmValue arguments =
+        this->GetOption("CPACK_IFW_PACKAGE_RUN_PROGRAM_ARGUMENTS")) {
+    this->RunProgramArguments.clear();
+    cmExpandList(arguments, this->RunProgramArguments);
+  }
+  if (cmValue description =
+        this->GetOption("CPACK_IFW_PACKAGE_RUN_PROGRAM_DESCRIPTION")) {
+    this->RunProgramDescription = *description;
+  }
 }
 
 /** \class cmCPackIFWResourcesParser
@@ -542,6 +556,25 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
       xout.Element("DisableCommandLineInterface",
                    this->DisableCommandLineInterface);
     }
+
+    // RunProgram
+    if (!this->RunProgram.empty()) {
+      xout.Element("RunProgram", this->RunProgram);
+    }
+
+    // RunProgramArguments
+    if (!this->RunProgramArguments.empty()) {
+      xout.StartElement("RunProgramArguments");
+      for (const auto& arg : this->RunProgramArguments) {
+        xout.Element("Argument", arg);
+      }
+      xout.EndElement();
+    }
+
+    // RunProgramDescription
+    if (!this->RunProgramDescription.empty()) {
+      xout.Element("RunProgramDescription", this->RunProgramDescription);
+    }
   }
 
   if (!this->RemoveTargetDir.empty()) {

+ 11 - 0
Source/CPack/IFW/cmCPackIFWInstaller.h

@@ -124,6 +124,17 @@ public:
   /// A list of images to be shown on PerformInstallationPage.
   std::vector<std::string> ProductImages;
 
+  /// Command executed after the installer is done if the user accepts the
+  /// action
+  std::string RunProgram;
+
+  /// Arguments passed to the program specified in <RunProgram>
+  std::vector<std::string> RunProgramArguments;
+
+  /// Text shown next to the check box for running the program after the
+  /// installation
+  std::string RunProgramDescription;
+
 public:
   // Internal implementation