This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  7f61763a42b466927d4711d4ad6830c88c1c248f (commit)
       via  b807cd9b54e4a9324ddd64281254b6fe80be5b24 (commit)
      from  6119bd7af7dab090ba153cb1752e848282e9c47e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7f61763a42b466927d4711d4ad6830c88c1c248f
commit 7f61763a42b466927d4711d4ad6830c88c1c248f
Merge: 6119bd7 b807cd9
Author:     Brad King <brad.k...@kitware.com>
AuthorDate: Mon Sep 19 13:21:13 2016 -0400
Commit:     CMake Topic Stage <kwro...@kitware.com>
CommitDate: Mon Sep 19 13:21:13 2016 -0400

    Merge topic 'ifw-package-resources' into next
    
    b807cd9b CPackIFW: Add 'cpack_ifw_add_package_resources' command


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b807cd9b54e4a9324ddd64281254b6fe80be5b24
commit b807cd9b54e4a9324ddd64281254b6fe80be5b24
Author:     Konstantin Podsvirov <konstan...@podsvirov.pro>
AuthorDate: Mon Sep 19 18:48:27 2016 +0300
Commit:     Brad King <brad.k...@kitware.com>
CommitDate: Mon Sep 19 13:17:59 2016 -0400

    CPackIFW: Add 'cpack_ifw_add_package_resources' command

diff --git a/Help/release/dev/ifw-package-resources.rst 
b/Help/release/dev/ifw-package-resources.rst
new file mode 100644
index 0000000..28ea5c4
--- /dev/null
+++ b/Help/release/dev/ifw-package-resources.rst
@@ -0,0 +1,6 @@
+ifw-package-resources
+---------------------
+
+* The :module:`CPackIFW` module gained a new
+  :command:`cpack_ifw_add_package_resources` command to include additional
+  resources in the installer binary.
diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake
index 36fc276..bb1285d 100644
--- a/Modules/CPackIFW.cmake
+++ b/Modules/CPackIFW.cmake
@@ -131,6 +131,14 @@
 #
 #  Filename for a custom installer control script.
 #
+# .. variable:: CPACK_IFW_PACKAGE_RESOURCES
+#
+#  List of additional resources ('.qrc' files) to include in the installer
+#  binary.
+#
+#  You can use :command:`cpack_ifw_add_package_resources` command to resolve
+#  relative paths.
+#
 # .. variable:: CPACK_IFW_REPOSITORIES_ALL
 #
 #  The list of remote repositories.
@@ -337,6 +345,19 @@
 #   ``DISPLAY_NAME``
 #     is string to display instead of the URL.
 #
+#
+# .. command:: cpack_ifw_add_package_resources
+#
+#   Add additional resources in the installer binary.
+#
+#   ::
+#
+#     cpack_ifw_add_package_resources(<file_path> <file_path> ...)
+#
+#   This command will also add the specified files
+#   to a variable :variable:`CPACK_IFW_PACKAGE_RESOURCES`.
+#
+#
 # Example usage
 # ^^^^^^^^^^^^^
 #
@@ -741,6 +762,17 @@ macro(cpack_ifw_update_repository reponame)
 
 endmacro()
 
+# Macro for adding resources
+macro(cpack_ifw_add_package_resources)
+  set(_CPACK_IFW_PACKAGE_RESOURCES ${ARGV})
+  _cpack_ifw_resolve_file_list(_CPACK_IFW_PACKAGE_RESOURCES)
+  list(APPEND CPACK_IFW_PACKAGE_RESOURCES ${_CPACK_IFW_PACKAGE_RESOURCES})
+  set(_CPACK_IFWQRC_STR "list(APPEND CPACK_IFW_PACKAGE_RESOURCES 
\"${_CPACK_IFW_PACKAGE_RESOURCES}\")\n")
+  if(CPack_CMake_INCLUDED)
+    file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWQRC_STR}")
+  endif()
+endmacro()
+
 # Resolve package control script
 _cpack_ifw_resolve_script(CPACK_IFW_PACKAGE_CONTROL_SCRIPT)
 
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx 
b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
index a6f1585..fa7e0aa 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
@@ -130,6 +130,19 @@ int cmCPackIFWGenerator::PackageFiles()
   {
     std::string ifwCmd = BinCreator;
     ifwCmd += " -c " + this->toplevel + "/config/config.xml";
+
+    if (!Installer.Resources.empty()) {
+      ifwCmd += " -r ";
+      std::vector<std::string>::iterator it = Installer.Resources.begin();
+      std::string path = this->toplevel + "/resources/";
+      ifwCmd += path + *it;
+      ++it;
+      while (it != Installer.Resources.end()) {
+        ifwCmd += "," + path + *it;
+        ++it;
+      }
+    }
+
     ifwCmd += " -p " + this->toplevel + "/packages";
 
     if (!PkgsDirsVector.empty()) {
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx 
b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
index 5a3efc9..aa609e2 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
@@ -13,11 +13,13 @@
 #include "cmCPackIFWInstaller.h"
 
 #include "CPack/cmCPackGenerator.h"
+#include "CPack/cmCPackLog.h"
 #include "cmCPackIFWGenerator.h"
 #include "cmCPackIFWPackage.h"
 #include "cmCPackIFWRepository.h"
 #include "cmGeneratedFileStream.h"
 #include "cmSystemTools.h"
+#include "cmXMLParser.h"
 #include "cmXMLWriter.h"
 
 #include <cmConfigure.h>
@@ -198,8 +200,70 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
         this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT")) {
     ControlScript = optIFW_CONTROL_SCRIPT;
   }
+
+  // Resources
+  if (const char* optIFW_PACKAGE_RESOURCES =
+        this->GetOption("CPACK_IFW_PACKAGE_RESOURCES")) {
+    Resources.clear();
+    cmSystemTools::ExpandListArgument(optIFW_PACKAGE_RESOURCES, Resources);
+  }
 }
 
+/** \class cmCPackIFWResourcesParser
+ * \brief Helper class that parse resources form .qrc (Qt)
+ */
+class cmCPackIFWResourcesParser : public cmXMLParser
+{
+public:
+  cmCPackIFWResourcesParser(cmCPackIFWInstaller* i)
+    : installer(i)
+    , file(false)
+  {
+    path = i->Directory + "/resources";
+  }
+
+  bool ParseResource(size_t r)
+  {
+    hasFiles = false;
+    hasErrors = false;
+
+    basePath = cmSystemTools::GetFilenamePath(installer->Resources[r].data());
+
+    ParseFile(installer->Resources[r].data());
+
+    return hasFiles && !hasErrors;
+  }
+
+  cmCPackIFWInstaller* installer;
+  bool file, hasFiles, hasErrors;
+  std::string path, basePath;
+
+protected:
+  void StartElement(const std::string& name, const char** /*atts*/) CM_OVERRIDE
+  {
+    file = name == "file" ? true : false;
+    if (file) {
+      hasFiles = true;
+    }
+  }
+
+  void CharacterDataHandler(const char* data, int length) CM_OVERRIDE
+  {
+    if (file) {
+      std::string content(data, data + length);
+      content = cmSystemTools::TrimWhitespace(content);
+      std::string source = basePath + "/" + content;
+      std::string destination = path + "/" + content;
+      if (!cmSystemTools::CopyFileIfDifferent(source.data(),
+                                              destination.data())) {
+        hasErrors = true;
+      }
+    }
+  }
+
+  void EndElement(const std::string& /*name*/) CM_OVERRIDE {}
+};
+
 void cmCPackIFWInstaller::GenerateInstallerFile()
 {
   // Lazy directory initialization
@@ -315,6 +379,26 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
     xout.Element("ControlScript", name);
   }
 
+  // Resources (copy to resources dir)
+  if (!Resources.empty()) {
+    std::vector<std::string> resources;
+    cmCPackIFWResourcesParser parser(this);
+    for (size_t i = 0; i < Resources.size(); i++) {
+      if (parser.ParseResource(i)) {
+        std::string name = cmSystemTools::GetFilenameName(Resources[i]);
+        std::string path = Directory + "/resources/" + name;
+        cmsys::SystemTools::CopyFileIfDifferent(Resources[i].data(),
+                                                path.data());
+        resources.push_back(name);
+      } else {
+        cmCPackLogger(cmCPackLog::LOG_WARNING, "Can't copy resources from \""
+                        << Resources[i] << "\". Resource will be skipped."
+                        << std::endl);
+      }
+    }
+    Resources = resources;
+  }
+
   xout.EndElement();
   xout.EndDocument();
 }
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h 
b/Source/CPack/IFW/cmCPackIFWInstaller.h
index f72d379..c9265ec 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.h
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.h
@@ -94,6 +94,9 @@ public:
   /// Filename for a custom installer control script
   std::string ControlScript;
 
+  /// List of resources to include in the installer binary
+  std::vector<std::string> Resources;
+
 public:
   // Internal implementation
 

-----------------------------------------------------------------------

Summary of changes:
 Help/release/dev/ifw-package-resources.rst |    6 ++
 Modules/CPackIFW.cmake                     |   32 +++++++++++
 Source/CPack/IFW/cmCPackIFWGenerator.cxx   |   13 +++++
 Source/CPack/IFW/cmCPackIFWInstaller.cxx   |   84 ++++++++++++++++++++++++++++
 Source/CPack/IFW/cmCPackIFWInstaller.h     |    3 +
 5 files changed, 138 insertions(+)
 create mode 100644 Help/release/dev/ifw-package-resources.rst


hooks/post-receive
-- 
CMake
_______________________________________________
Cmake-commits mailing list
Cmake-commits@cmake.org
http://public.kitware.com/mailman/listinfo/cmake-commits

Reply via email to