cmCPackPKGGenerator.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <set>
  6. #include <sstream>
  7. #include <string>
  8. #include <cm/string_view>
  9. #include "cmCPackComponentGroup.h"
  10. #include "cmCPackGenerator.h"
  11. class cmXMLWriter;
  12. /** \class cmCPackPKGGenerator
  13. * \brief A generator for pkg files
  14. *
  15. */
  16. class cmCPackPKGGenerator : public cmCPackGenerator
  17. {
  18. public:
  19. cmCPackTypeMacro(cmCPackPKGGenerator, cmCPackGenerator);
  20. /**
  21. * Construct generator
  22. */
  23. cmCPackPKGGenerator();
  24. ~cmCPackPKGGenerator() override;
  25. bool SupportsComponentInstallation() const override;
  26. protected:
  27. int InitializeInternal() override;
  28. const char* GetOutputPostfix() override { return "darwin"; }
  29. // Copies or creates the resource file with the given name to the
  30. // package or package staging directory dirName. The variable
  31. // CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased
  32. // version of name) specifies the input file to use for this file,
  33. // which will be configured via ConfigureFile.
  34. bool CopyCreateResourceFile(const std::string& name,
  35. const std::string& dirName);
  36. bool CopyResourcePlistFile(const std::string& name,
  37. const char* outName = nullptr);
  38. int CopyInstallScript(const std::string& resdir, const std::string& script,
  39. const std::string& name);
  40. // Retrieve the name of package file that will be generated for this
  41. // component. The name is just the file name with extension, and
  42. // does not include the subdirectory.
  43. std::string GetPackageName(const cmCPackComponent& component);
  44. // Writes a distribution.dist file, which turns a metapackage into a
  45. // full-fledged distribution. This file is used to describe
  46. // inter-component dependencies. metapackageFile is the name of the
  47. // metapackage for the distribution. Only valid for a
  48. // component-based install.
  49. void WriteDistributionFile(const char* metapackageFile, const char* genName);
  50. // Subroutine of WriteDistributionFile that writes out the
  51. // dependency attributes for inter-component dependencies.
  52. void AddDependencyAttributes(const cmCPackComponent& component,
  53. std::set<const cmCPackComponent*>& visited,
  54. std::ostringstream& out);
  55. // Subroutine of WriteDistributionFile that writes out the
  56. // reverse dependency attributes for inter-component dependencies.
  57. void AddReverseDependencyAttributes(
  58. const cmCPackComponent& component,
  59. std::set<const cmCPackComponent*>& visited, std::ostringstream& out);
  60. // Generates XML that encodes the hierarchy of component groups and
  61. // their components in a form that can be used by distribution
  62. // metapackages.
  63. void CreateChoiceOutline(const cmCPackComponentGroup& group,
  64. cmXMLWriter& xout);
  65. /// Create the "choice" XML element to describe a component group
  66. /// for the installer GUI.
  67. void CreateChoice(const cmCPackComponentGroup& group, cmXMLWriter& xout);
  68. /// Create the "choice" XML element to describe a component for the
  69. /// installer GUI.
  70. void CreateChoice(const cmCPackComponent& component, cmXMLWriter& xout);
  71. /// Creates a background in the distribution XML.
  72. void CreateBackground(const char* themeName, const char* metapackageFile,
  73. cm::string_view genName, cmXMLWriter& xout);
  74. /// Create the "domains" XML element to indicate where the product can
  75. /// be installed
  76. void CreateDomains(cmXMLWriter& xout);
  77. // The PostFlight component when creating a metapackage
  78. cmCPackComponent PostFlightComponent;
  79. };