1 | //-----------------------------------------------------------
|
---|
2 | // Copyright Christian Arnault LAL-Orsay CNRS
|
---|
3 | // arnault@lal.in2p3.fr
|
---|
4 | // See the complete license in cmt_license.txt "http://www.cecill.info".
|
---|
5 | //-----------------------------------------------------------
|
---|
6 |
|
---|
7 | #ifndef __cmt_generator_h__
|
---|
8 | #define __cmt_generator_h__
|
---|
9 |
|
---|
10 | #include "cmt_parser.h"
|
---|
11 | #include "cmt_constituent.h"
|
---|
12 | #include "cmt_language.h"
|
---|
13 | #include "cmt_awk.h"
|
---|
14 |
|
---|
15 | class Packager : public FAwk
|
---|
16 | {
|
---|
17 | public:
|
---|
18 | void begin ();
|
---|
19 | void filter (const cmt_string& line);
|
---|
20 | cmt_string& package_name ();
|
---|
21 | private:
|
---|
22 | cmt_string m_package_name;
|
---|
23 | };
|
---|
24 |
|
---|
25 | class SourceFile
|
---|
26 | {
|
---|
27 | public:
|
---|
28 | void set (const cmt_string name, Language& language, const cmt_string output);
|
---|
29 | cmt_string name () const;
|
---|
30 | Language& language () const;
|
---|
31 | cmt_string output () const;
|
---|
32 |
|
---|
33 | private:
|
---|
34 | cmt_string m_name;
|
---|
35 | Language* m_language;
|
---|
36 | cmt_string m_output;
|
---|
37 | };
|
---|
38 |
|
---|
39 | /**
|
---|
40 | Base class for all specific generators.
|
---|
41 | The Generator command driver will operate on specialized classes of CmtGenerator
|
---|
42 | */
|
---|
43 | class CmtGenerator
|
---|
44 | {
|
---|
45 | public:
|
---|
46 |
|
---|
47 | CmtGenerator ();
|
---|
48 |
|
---|
49 | void reset ();
|
---|
50 | bool prepare_output (const cmt_string& package,
|
---|
51 | const Constituent& constituent,
|
---|
52 | const cmt_string& file = "");
|
---|
53 | void commit (const cmt_string& name);
|
---|
54 | static void check (const cmt_string& name);
|
---|
55 | void terminate ();
|
---|
56 |
|
---|
57 | void fill_names_outputs ();
|
---|
58 | void fill_outputs ();
|
---|
59 |
|
---|
60 | // void prepare_use_context ();
|
---|
61 |
|
---|
62 | void set_full_name (cmt_string& full_name, cmt_string& file);
|
---|
63 | void filter_path (cmt_string& text);
|
---|
64 | int get_all_files (const cmt_string& full_name,
|
---|
65 | const cmt_vector<cmt_regexp>& exclude_exprs,
|
---|
66 | const cmt_vector<cmt_regexp>& select_exprs,
|
---|
67 | CmtSystem::cmt_string_vector& files);
|
---|
68 |
|
---|
69 |
|
---|
70 | public:
|
---|
71 | cmt_string m_PACKINCLUDES;
|
---|
72 | bool m_PACKOS9;
|
---|
73 |
|
---|
74 | cmt_string m_GENERATOR;
|
---|
75 |
|
---|
76 | bool is_library;
|
---|
77 | bool is_application;
|
---|
78 |
|
---|
79 | cmt_string srcdir;
|
---|
80 | cmt_string docdir;
|
---|
81 | cmt_string cmtdir;
|
---|
82 | cmt_string incdir;
|
---|
83 | cmt_string src;
|
---|
84 | cmt_string doc;
|
---|
85 | cmt_string inc;
|
---|
86 | cmt_string mgr;
|
---|
87 | cmt_string cmt;
|
---|
88 | cmt_string protos;
|
---|
89 | cmt_string protonames;
|
---|
90 | cmt_string os9sources;
|
---|
91 |
|
---|
92 | cmt_vector<SourceFile> m_source_files;
|
---|
93 |
|
---|
94 | cmt_string m_bin;
|
---|
95 | cmt_string m_output_file_name;
|
---|
96 | FILE* m_output_file;
|
---|
97 |
|
---|
98 | Constituent* m_constituent;
|
---|
99 |
|
---|
100 | Variable m_CONSTITUENT;
|
---|
101 | Variable m_LINKMACRO;
|
---|
102 | Variable m_DEPENDENCIESOPTS;
|
---|
103 | Variable m_DOCPATH;
|
---|
104 | Variable m_PACKAGEPATH;
|
---|
105 | Variable m_PACKAGEPREFIX;
|
---|
106 | Variable m_PACKAGE;
|
---|
107 | Variable m_VERSION;
|
---|
108 | Variable m_MGRSTYLE;
|
---|
109 | Variable m_TITLE;
|
---|
110 | Variable m_GROUP;
|
---|
111 | Variable m_CONSTITUENTSUFFIX;
|
---|
112 | Variable m_LIBRARYSUFFIX;
|
---|
113 | Variable m_USER;
|
---|
114 | Variable m_DATE;
|
---|
115 | Variable m_PROTOTARGET;
|
---|
116 | Variable m_OBJS;
|
---|
117 | Variable m_CLASSES;
|
---|
118 | Variable m_PROTOSTAMPS;
|
---|
119 | Variable m_NAME;
|
---|
120 | Variable m_FILEPATH;
|
---|
121 | Variable m_FILESUFFIX;
|
---|
122 | Variable m_SUFFIX;
|
---|
123 | Variable m_FILENAME;
|
---|
124 | Variable m_LINE;
|
---|
125 | Variable m_ADDINCLUDE;
|
---|
126 | Variable m_FULLNAME;
|
---|
127 | Variable m_DIRNAME;
|
---|
128 | Variable m_OUTPUTNAME;
|
---|
129 | Variable m_ALLOS9SOURCES;
|
---|
130 | Variable m_NODEBUGUSELINKOPTS;
|
---|
131 | Variable m_DEBUGUSELINKOPTS;
|
---|
132 | Variable m_USEINCLUDES;
|
---|
133 | Variable m_HASTARGETTAG;
|
---|
134 | Variable m_HASDEPENDENCIES;
|
---|
135 | Variable m_ISCHECKGROUP;
|
---|
136 | };
|
---|
137 |
|
---|
138 | class InGenerator
|
---|
139 | {
|
---|
140 | public:
|
---|
141 | InGenerator (bool usecmt, bool pedantic);
|
---|
142 | int build (const Constituent& constituent, ostream& out = cout);
|
---|
143 |
|
---|
144 | private:
|
---|
145 | InGenerator ();
|
---|
146 |
|
---|
147 | private:
|
---|
148 | class Buffer
|
---|
149 | {
|
---|
150 | public:
|
---|
151 | Buffer ();
|
---|
152 | void set_names (const CmtSystem::cmt_string_vector& names);
|
---|
153 | int print (ostream& s);
|
---|
154 | void set_uses (bool usecmt);
|
---|
155 | void set_pedantic (bool pedantic);
|
---|
156 | private:
|
---|
157 | virtual int initialize () = 0;
|
---|
158 |
|
---|
159 | protected:
|
---|
160 | CmtSystem::cmt_string_vector m_names;
|
---|
161 | ostringstream m_buffer;
|
---|
162 | bool m_initialized;
|
---|
163 | bool m_usecmt;
|
---|
164 | bool m_pedantic;
|
---|
165 | };
|
---|
166 |
|
---|
167 | class Languages : public Buffer
|
---|
168 | {
|
---|
169 | private:
|
---|
170 | int initialize ();
|
---|
171 | };
|
---|
172 |
|
---|
173 | class Fragments : public Buffer
|
---|
174 | {
|
---|
175 | private:
|
---|
176 | int initialize ();
|
---|
177 | };
|
---|
178 |
|
---|
179 | private:
|
---|
180 | Fragments m_common;
|
---|
181 | Fragments m_application;
|
---|
182 | Fragments m_application_library;
|
---|
183 | Fragments m_library;
|
---|
184 | Fragments m_document;
|
---|
185 | Languages m_languages;
|
---|
186 | bool m_usecmt;
|
---|
187 | bool m_pedantic;
|
---|
188 | };
|
---|
189 |
|
---|
190 | /**
|
---|
191 | Generic command interface to be used by the cmt command driver.
|
---|
192 | */
|
---|
193 | class Generator
|
---|
194 | {
|
---|
195 | public:
|
---|
196 | // Build the MSDEV workspace file
|
---|
197 | static int build_msdev_workspace (const Constituent::ConstituentVector& constituents);
|
---|
198 |
|
---|
199 | // Build the MSDEV project file (one per constituent)
|
---|
200 | static int build_msdev (const Constituent& constituent);
|
---|
201 |
|
---|
202 | // Build the VSNET workspace file
|
---|
203 | static int build_vsnet_workspace (const Constituent::ConstituentVector& constituents);
|
---|
204 |
|
---|
205 | // Build the VSNET project file (one per constituent)
|
---|
206 | static int build_vsnet (const Constituent& constituent);
|
---|
207 |
|
---|
208 | // Build the Make setup file
|
---|
209 | static void build_make_setup (const cmt_string& package);
|
---|
210 |
|
---|
211 | // Build the constituents.make file
|
---|
212 | static void build_constituents_makefile (const cmt_string& package,
|
---|
213 | const cmt_string& file = "");
|
---|
214 | // const CmtSystem::cmt_string_vector& arguments);
|
---|
215 |
|
---|
216 | // Build the makefile fragment for one constituent
|
---|
217 | static int build_constituent_makefile (const Constituent& constituent,
|
---|
218 | bool& dependencies,
|
---|
219 | const cmt_string& file = "");
|
---|
220 | static void build_constituent_makefile (const CmtSystem::cmt_string_vector& arguments);
|
---|
221 | static int build_constituent_infile (const Constituent& constituent,
|
---|
222 | const cmt_string& outdir = "",
|
---|
223 | bool usecmt = true);
|
---|
224 |
|
---|
225 | static int build_library_links_infile (const cmt_string& outdir = "");
|
---|
226 |
|
---|
227 | static int build_dependencies_infile (const Constituent* constituent,
|
---|
228 | const cmt_string& outdir = "",
|
---|
229 | bool usecmt = true);
|
---|
230 |
|
---|
231 | static void build_default_makefile ();
|
---|
232 |
|
---|
233 | // Build the packages (N)Make file
|
---|
234 | static void build_packages_makefile (const cmt_string& package,
|
---|
235 | const cmt_string& file = "");
|
---|
236 |
|
---|
237 | // Build the dependencies for one module
|
---|
238 | static void build_dependencies (const CmtSystem::cmt_string_vector& arguments);
|
---|
239 |
|
---|
240 | // Build prototype file for one module
|
---|
241 | static void build_prototype (const cmt_string& file_name);
|
---|
242 |
|
---|
243 | // Build README.html file
|
---|
244 | static void build_readme (const CmtSystem::cmt_string_vector& arguments);
|
---|
245 |
|
---|
246 | // Build def files for Windows shared libraries
|
---|
247 | // static void build_windefs (const cmt_string& library_name);
|
---|
248 | static void build_windefs (const CmtSystem::cmt_string_vector& arguments);
|
---|
249 | };
|
---|
250 |
|
---|
251 | #endif
|
---|