Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / CPack / cmCPackPackageMakerGenerator.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc.
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12
13 #ifndef cmCPackPackageMakerGenerator_h
14 #define cmCPackPackageMakerGenerator_h
15
16
17 #include "cmCPackGenerator.h"
18
19 class cmCPackComponent;
20
21 /** \class cmCPackPackageMakerGenerator
22  * \brief A generator for PackageMaker files
23  *
24  * http://developer.apple.com/documentation/Darwin
25  * /Reference/ManPages/man1/packagemaker.1.html
26  */
27 class cmCPackPackageMakerGenerator : public cmCPackGenerator
28 {
29 public:
30   cmCPackTypeMacro(cmCPackPackageMakerGenerator, cmCPackGenerator);
31
32   /**
33    * Construct generator
34    */
35   cmCPackPackageMakerGenerator();
36   virtual ~cmCPackPackageMakerGenerator();
37
38   virtual bool SupportsComponentInstallation() const;
39
40 protected:
41   int CopyInstallScript(const char* resdir,
42                         const char* script,
43                         const char* name);
44   virtual int InitializeInternal();
45   int PackageFiles();
46   virtual const char* GetOutputExtension() { return ".dmg"; }
47   virtual const char* GetOutputPostfix() { return "darwin"; }
48
49   // Copies or creates the resource file with the given name to the
50   // package or package staging directory dirName. The variable
51   // CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased
52   // version of name) specifies the input file to use for this file,
53   // which will be configured via ConfigureFile.
54   bool CopyCreateResourceFile(const char* name, const char *dirName);
55   bool CopyResourcePlistFile(const char* name, const char* outName = 0);
56
57   // Run PackageMaker with the given command line, which will (if
58   // successful) produce the given package file. Returns true if
59   // PackageMaker succeeds, false otherwise.
60   bool RunPackageMaker(const char *command, const char *packageFile);
61
62   // Retrieve the name of package file that will be generated for this
63   // component. The name is just the file name with extension, and
64   // does not include the subdirectory.
65   std::string GetPackageName(const cmCPackComponent& component);
66
67   // Generate a package in the file packageFile for the given
68   // component.  All of the files within this component are stored in
69   // the directory packageDir. Returns true if successful, false
70   // otherwise. 
71   bool GenerateComponentPackage(const char *packageFile, 
72                                 const char *packageDir,
73                                 const cmCPackComponent& component);
74
75   // Writes a distribution.dist file, which turns a metapackage into a
76   // full-fledged distribution. This file is used to describe
77   // inter-component dependencies. metapackageFile is the name of the
78   // metapackage for the distribution. Only valid for a
79   // component-based install.
80   void WriteDistributionFile(const char* metapackageFile);
81
82   // Subroutine of WriteDistributionFile that writes out the
83   // dependency attributes for inter-component dependencies.
84   void AddDependencyAttributes(const cmCPackComponent& component,
85                                std::set<const cmCPackComponent *>& visited,
86                                cmOStringStream& out);
87
88   // Subroutine of WriteDistributionFile that writes out the
89   // reverse dependency attributes for inter-component dependencies.
90   void 
91   AddReverseDependencyAttributes(const cmCPackComponent& component,
92                                  std::set<const cmCPackComponent *>& visited,
93                                  cmOStringStream& out);
94
95   // Generates XML that encodes the hierarchy of component groups and
96   // their components in a form that can be used by distribution
97   // metapackages. 
98   void CreateChoiceOutline(const cmCPackComponentGroup& group,
99                            cmOStringStream& out);
100
101   /// Create the "choice" XML element to describe a component group
102   /// for the installer GUI.
103   void CreateChoice(const cmCPackComponentGroup& group,
104                     cmOStringStream& out);
105
106   /// Create the "choice" XML element to describe a component for the
107   /// installer GUI.
108   void CreateChoice(const cmCPackComponent& component,
109                     cmOStringStream& out);
110
111   // Escape the given string to make it usable as an XML attribute
112   // value.
113   std::string EscapeForXML(std::string str);
114   
115   double PackageMakerVersion;
116   double PackageCompatibilityVersion;
117 };
118
119 #endif