]> git.saurik.com Git - wxWidgets.git/blame - utils/projgen/projgen.h
info about removal of wxhtml.rc
[wxWidgets.git] / utils / projgen / projgen.h
CommitLineData
302aa842
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: projgen.h
3// Purpose: Project generator classes.
4// Author: Julian Smart
5// Modified by:
6// Created: 04/12/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12/*
13
14Description
15-----------
16
17The top-level object is wxProjectDatabase, which maintains a list of wxProjectGenerator
18objects. Each wxProjectGenerator object contains a list of wxGeneratorConfiguration objects,
19and each of these in turn stores a list of variants which represent compiler-specific options in that
20configuration. wxProjectDatabase also stores a list of generic options (again variants),
21which may cause compiler-specific options to be stored in configurations.
22
23The usage is like this. The IDE (or other calling application) adds a number of project generators
24at initialization, one for each kind of compiler. For a new project, the app should call InitializeGenerators
25in order to call OnInitializeDefaults for each generator, which will call back into the wxProjectDatabase
26to get user-settable defaults.
27
28The app can then set generic options. When a generic option (such as 'use debug info')
29is set for a particular configuration, all generator objects are notified via OnSetGenericOption and they
30translate the generic option into a specific one (for that configuration).
31
32The wxProjectDatabase object can also be used to set compiler-specific options directly if required,
33but normally this would not be required. Each wxProjectGenerator should also have the opportunity
34to set initial defaults. These defaults should be editable by the user.
35
36Each wxProjectGenerator can access the parent wxProjectDatabase object at any time, since it
37may need to make a judgement about several generic settings in order to know what specific
38compiler options should be set.
39
40TODO: make a list of generic compiler options that each generator should recognise.
41
42*/
43
44#ifndef _PROJGEN_H_
45#define _PROJGEN_H_
46
47#ifdef __GNUG__
48#pragma interface "projgen.h"
49#endif
50
51#include "wx/defs.h"
52#include "wx/string.h"
53#include "wx/hash.h"
54#include "wx/variant.h"
55
56typedef enum {
57 wxPROJECT_CAP_NONE = 0,
58 wxPROJECT_CAP_MAKEFILE = 1,
59 wxPROJECT_CAP_PROJECT = 2,
60} wxProjectCapability;
61
62class wxProjectGenerator;
63class wxGeneratorConfiguration;
64
65/*
66 * wxProjectDatabase
67 * This class maintains a list to all wxProjectGenerator objects, one for
68 * each compiler.
69 * Setting a generic option in wxProjectDatabase causes the individual wxProjectGenerator
70 * objects to set their compiler-specific options for later generation.
71 */
72
73class wxProjectDatabase: public wxObject
74{
75DECLARE_CLASS(wxProjectDatabase)
76public:
77 wxProjectDatabase();
78 ~wxProjectDatabase();
79
80// Operations
81 // Generate project or makefile for a named compiler. Give an optional compiler version.
82 virtual bool GenerateProject(const wxString& compiler, const wxString& filename, bool isMakefile, int compilerVersion = 0);
83
84 // This calls each wxProjectGenerator's OnInitializeDefaults function to fill out the
85 // defaults for each configuration. The generators will probably call back into the wxProjectDatabase
86 // to get the defaults from a file (see GetDefaultCompilerOptions below).
87 virtual bool InitializeGenerators();
88
89// Accessors
90 // Get the capability: can it generate projects, or makefiles, or neither?
91 virtual wxProjectCapability GetCapability(const wxString& compiler) const ;
92
93 // Override this for your app so that when the wxProjectGenerator initializes its defaults, it
94 // can call this to get specific option values that may be setup by the user.
95 virtual wxVariant GetDefaultCompilerOption(const wxString& compiler, const wxString& config, const wxString& option) const ;
96
97 // Gets all the default options for the named compiler/config. Likewise, override this to provide
98 // a list of defaults to the calling wxProjectGenerator.
99 virtual wxStringList GetDefaultCompilerOptionList(const wxString& compiler, const wxString& config) const ;
100
101// Compiler/configuration-specific options
102 // Get a compiler-specific option value from the name.
103 virtual wxVariant GetCompilerOption(const wxString& compiler, const wxString& config, const wxString& name) const;
104
105 // Set the compiler-specific option
106 virtual void SetCompilerOption(const wxString& compiler, const wxString& config, const wxString& name, const wxVariant& value);
107
108 // Removes the compiler-specific option
109 virtual void RemoveCompilerOption(const wxString& compiler, const wxString& config, const wxString& name);
110
111 // Does this option exist?
112 virtual bool HasCompilerOption(const wxString& compiler, const wxString& config, const wxString& name) const;
113
114// Generic options
115 // Get a generic option value from the name.
116 virtual wxVariant GetGenericOption(const wxString& config, const wxString& name) const;
117
118 // Set the generic option value. This calls SetGenericOption for each wxProjectGenerator,
119 // which will cause compiler-specific values to be placed in the relevant config
120 virtual void SetGenericOption(const wxString& config, const wxString& name, const wxVariant& value);
121
122 // Removes the generic option.
123 virtual void RemoveGenericOption(const wxString& config, const wxString& name);
124
125 // Does this option exist?
126 virtual bool HasGenericOption(const wxString& config, const wxString& name) const;
127
128// Project path
129 inline void SetProjectPath(const wxString& path) { m_projectPath = path; };
130 inline wxString GetProjectPath() const { return m_projectPath; };
131
132// Project name
133 inline void SetProjectName(const wxString& name) { m_projectName = name; };
134 inline wxString GetProjectName() const { return m_projectName; };
135
136// The source files in the project
137 // Add a file to the project. Normally this will be relative to the project path.
138 // TODO: Files are managed within the wxProjectDatabase, but what about extra files
139 // for specific platforms? Well, let's assume that even on Unix, you'd create a .rc
140 // file, even if this isn't used in the resulting project/makefile on Unix.
141 virtual void AddFile(const wxString& filename);
142 virtual void RemoveFile(const wxString& filename);
143 virtual bool FileExists(const wxString& filename) const;
144
145// TODO: management of include paths, library paths, libraries
146
147// Generator management
148 virtual void AddGenerator(wxProjectGenerator* generator) ;
149 virtual void RemoveGenerator(wxProjectGenerator* generator) ; // Doesn't delete it, just removes it
150 virtual wxProjectGenerator* FindGenerator(const wxString& compiler) const ;
151 virtual void ClearGenerators();
152
153protected:
154 // List of wxProjectGenerator objects
155 wxList m_generators;
156
157 // List of compiler-independent configurations, such as "debug".
158 wxList m_genericConfigurations;
159
160 // List of source files
161 wxStringList m_sourceFiles;
162
163 // List of library paths
164 wxStringList m_libraryPaths;
165
166 // List of libraries: TODO this should be compiler-specific, surely?
167 wxStringList m_libraries;
168
169 // List of include paths
170 wxStringList m_includePaths;
171
172 // Project path
173 wxString m_projectPath;
174
175 // Project name
176 wxString m_projectName;
177};
178
179/*
180 * wxGeneratorConfiguration
181 * A configuration, e.g. "debug", "release"
182 */
183
184class wxGeneratorConfiguration: public wxObject
185{
186DECLARE_CLASS(wxGeneratorConfiguration)
187public:
188 wxGeneratorConfiguration(const wxString& name);
189 ~wxGeneratorConfiguration();
190
191 // Does this option exist?
192 virtual bool HasOption(const wxString& name) const;
193
194 // Find option: returns NULL if there is no such option.
195 wxVariant* FindOption(const wxString& name) const;
196
197 // Get an option value
198 virtual wxVariant GetOption(const wxString& name) const;
199
200 // Set the option
201 virtual void SetOption(const wxString& name, const wxVariant& value);
202
203 // Remove the option
204 virtual void RemoveOption(const wxString& name);
205
206 // Does this option exist?
207 virtual bool HasOption(const wxString& name) const;
208
209 // Get the list of options
210 inline const wxList& GetOptions() const { return m_options; }
211
212 inline void SetName(const wxString& name) { m_name = name; }
213 inline wxString GetName() const { return m_name; }
214
215protected:
216 // Configuration name
217 wxString m_name;
218
219 // List of wxVariants
220 wxList m_options;
221};
222
223/*
224 * wxProjectGenerator.
225 * Only derived classes can be instantiated.
226 */
227
228class wxProjectGenerator: public wxObject
229{
230DECLARE_CLASS(wxProjectGenerator)
231public:
232 wxProjectGenerator(const wxString& name, wxProjectDatabase* topLevel);
233 ~wxProjectGenerator();
234
235// Operations
236 // Generate project or makefile. Give an optional compiler version.
237 virtual bool GenerateProject(bool isMakefile, int compilerVersion = 0) = 0;
238
239 // Called when the defaults should be initialized.
240 // It would recognise e.g. the "Debug" configuration name and set specific defaults, possibly
241 // reading them from a database to allow for tailoring.
242 // It is likely to call wxProjectDatabase::GetDefaultCompilerOption.
243 virtual bool OnInitializeDefaults(const wxString& config) = 0;
244
245 // This is called by wxProjectDatabase::SetGenericOption, and it tells this object
246 // to translate it to a specific option. Then this object will (probably) call SetOption.
247 virtual bool OnSetGenericOption(const wxString& config, const wxString& name, const wxVariant& value) = 0;
248
249// Accessors
250 // Get the capability: can it generate projects, or makefiles, or neither?
251 virtual wxProjectCapability GetCapability() const = 0;
252
253 // Name
254 inline void SetName(const wxString& name) { m_name = name; }
255 inline wxString GetName() const { return m_name; }
256
257 // Top-level wxProjectDatabase object
258 inline void SetTopLevel(wxProjectDatabase* topLevel) { m_topLevel = topLevel; }
259 inline wxProjectDatabase* GetTopLevel() const { return m_topLevel; }
260
261// Options
262 // Get an option value
263 virtual wxVariant GetOption(const wxString& config, const wxString& name) const;
264
265 // Set the option
266 virtual void SetOption(const wxString& config, const wxString& name, const wxVariant& value);
267
268 // Remove the option
269 virtual void RemoveOption(const wxString& config, const wxString& name);
270
271 // Does this option exist?
272 virtual bool HasOption(const wxString& name) const;
273
274 // Get the list of options
275 inline const wxList& GetConfigurations() const { return m_configs; }
276
277// Configuration management
278 wxGeneratorConfiguation* FindConfiguration(const wxString& config) const ;
279 void AddConfiguration(wxGeneratorConfiguration* config) ;
280 void RemoveConfiguration(wxGeneratorConfiguration* config) ;
281 void ClearConfigurations() ;
282
283protected:
284 // List of wxGeneratorConfiguration objects
285 wxList m_configs;
286
287 // Compiler name
288 wxString m_name;
289
290 // Top-level object
291 wxProjectDatabase* m_topLevel;
292};
293
294#endif
295 // projgen.h
296