cmCPackArchiveGenerator.h 2.9 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 <iosfwd>
  6. #include <string>
  7. #include "cmArchiveWrite.h"
  8. #include "cmCPackGenerator.h"
  9. class cmCPackComponent;
  10. /** \class cmCPackArchiveGenerator
  11. * \brief A generator base for libarchive generation.
  12. * The generator itself uses the libarchive wrapper
  13. * \ref cmArchiveWrite.
  14. *
  15. */
  16. class cmCPackArchiveGenerator : public cmCPackGenerator
  17. {
  18. public:
  19. using Superclass = cmCPackGenerator;
  20. static cmCPackGenerator* Create7ZGenerator();
  21. static cmCPackGenerator* CreateTBZ2Generator();
  22. static cmCPackGenerator* CreateTGZGenerator();
  23. static cmCPackGenerator* CreateTXZGenerator();
  24. static cmCPackGenerator* CreateTZGenerator();
  25. static cmCPackGenerator* CreateTZSTGenerator();
  26. static cmCPackGenerator* CreateTarGenerator();
  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. std::string GetArchiveFileName();
  40. // get archive component filename
  41. std::string GetArchiveComponentFileName(std::string const& component,
  42. bool isGroupName);
  43. class Deduplicator;
  44. protected:
  45. int InitializeInternal() override;
  46. /**
  47. * Add the files belonging to the specified component
  48. * to the provided (already opened) archive.
  49. * @param[in,out] archive the archive object
  50. * @param[in] component the component whose file will be added to archive
  51. * @param[in] deduplicator file deduplicator utility.
  52. */
  53. int addOneComponentToArchive(cmArchiveWrite& archive,
  54. cmCPackComponent* component,
  55. Deduplicator* deduplicator);
  56. /**
  57. * The main package file method.
  58. * If component install was required this
  59. * method will call either PackageComponents or
  60. * PackageComponentsAllInOne.
  61. */
  62. int PackageFiles() override;
  63. /**
  64. * The method used to package files when component
  65. * install is used. This will create one
  66. * archive for each component group.
  67. */
  68. int PackageComponents(bool ignoreGroup);
  69. /**
  70. * Special case of component install where all
  71. * components will be put in a single installer.
  72. */
  73. int PackageComponentsAllInOne();
  74. private:
  75. char const* GetNameOfClass() override { return "cmCPackArchiveGenerator"; }
  76. char const* GetOutputExtension() override
  77. {
  78. return this->OutputExtension.c_str();
  79. }
  80. int GetThreadCount() const;
  81. private:
  82. cmArchiveWrite::Compress Compress;
  83. std::string ArchiveFormat;
  84. std::string OutputExtension;
  85. };