cmCPackArchiveGenerator.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmCPackArchiveGenerator_h
  4. #define cmCPackArchiveGenerator_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <iosfwd>
  7. #include <string>
  8. #include "cmArchiveWrite.h"
  9. #include "cmCPackGenerator.h"
  10. class cmCPackComponent;
  11. /** \class cmCPackArchiveGenerator
  12. * \brief A generator base for libarchive generation.
  13. * The generator itself uses the libarchive wrapper
  14. * \ref cmArchiveWrite.
  15. *
  16. */
  17. class cmCPackArchiveGenerator : public cmCPackGenerator
  18. {
  19. public:
  20. using Superclass = cmCPackGenerator;
  21. static cmCPackGenerator* Create7ZGenerator();
  22. static cmCPackGenerator* CreateTBZ2Generator();
  23. static cmCPackGenerator* CreateTGZGenerator();
  24. static cmCPackGenerator* CreateTXZGenerator();
  25. static cmCPackGenerator* CreateTZGenerator();
  26. static cmCPackGenerator* CreateTZSTGenerator();
  27. static cmCPackGenerator* CreateZIPGenerator();
  28. /**
  29. * Construct generator
  30. */
  31. cmCPackArchiveGenerator(cmArchiveWrite::Compress t, std::string format,
  32. std::string extension);
  33. ~cmCPackArchiveGenerator() override;
  34. // Used to add a header to the archive
  35. virtual int GenerateHeader(std::ostream* os);
  36. // component support
  37. bool SupportsComponentInstallation() const override;
  38. private:
  39. // get archive component filename
  40. std::string GetArchiveComponentFileName(const std::string& component,
  41. bool isGroupName);
  42. protected:
  43. int InitializeInternal() override;
  44. /**
  45. * Add the files belonging to the specified component
  46. * to the provided (already opened) archive.
  47. * @param[in,out] archive the archive object
  48. * @param[in] component the component whose file will be added to archive
  49. */
  50. int addOneComponentToArchive(cmArchiveWrite& archive,
  51. cmCPackComponent* component);
  52. /**
  53. * The main package file method.
  54. * If component install was required this
  55. * method will call either PackageComponents or
  56. * PackageComponentsAllInOne.
  57. */
  58. int PackageFiles() override;
  59. /**
  60. * The method used to package files when component
  61. * install is used. This will create one
  62. * archive for each component group.
  63. */
  64. int PackageComponents(bool ignoreGroup);
  65. /**
  66. * Special case of component install where all
  67. * components will be put in a single installer.
  68. */
  69. int PackageComponentsAllInOne();
  70. private:
  71. const char* GetNameOfClass() override { return "cmCPackArchiveGenerator"; }
  72. const char* GetOutputExtension() override
  73. {
  74. return this->OutputExtension.c_str();
  75. }
  76. private:
  77. cmArchiveWrite::Compress Compress;
  78. std::string ArchiveFormat;
  79. std::string OutputExtension;
  80. };
  81. #endif