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 | #include "cmt_deps_builder.h" |
---|
15 | |
---|
16 | class Packager : public FAwk |
---|
17 | { |
---|
18 | public: |
---|
19 | void begin (); |
---|
20 | void filter (const cmt_string& line); |
---|
21 | cmt_string& package_name (); |
---|
22 | private: |
---|
23 | cmt_string m_package_name; |
---|
24 | }; |
---|
25 | |
---|
26 | class SourceFile |
---|
27 | { |
---|
28 | public: |
---|
29 | void set (const cmt_string name, Language& language, const cmt_string output); |
---|
30 | cmt_string name () const; |
---|
31 | Language& language () const; |
---|
32 | cmt_string output () const; |
---|
33 | |
---|
34 | private: |
---|
35 | cmt_string m_name; |
---|
36 | Language* m_language; |
---|
37 | cmt_string m_output; |
---|
38 | }; |
---|
39 | |
---|
40 | /** |
---|
41 | Base class for all specific generators. |
---|
42 | The Generator command driver will operate on specialized classes of CmtGenerator |
---|
43 | */ |
---|
44 | class CmtGenerator |
---|
45 | { |
---|
46 | public: |
---|
47 | |
---|
48 | CmtGenerator (); |
---|
49 | |
---|
50 | void reset (); |
---|
51 | bool prepare_output (const cmt_string& package, |
---|
52 | const Constituent& constituent, |
---|
53 | const cmt_string& file = ""); |
---|
54 | void commit (const cmt_string& name); |
---|
55 | static void check (const cmt_string& name); |
---|
56 | void terminate (); |
---|
57 | |
---|
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 | DepsBuilder m_deps_builder; |
---|
99 | |
---|
100 | Constituent* m_constituent; |
---|
101 | |
---|
102 | Variable m_CONSTITUENT; |
---|
103 | Variable m_LINKMACRO; |
---|
104 | Variable m_DOCPATH; |
---|
105 | Variable m_PACKAGEPATH; |
---|
106 | Variable m_PACKAGEPREFIX; |
---|
107 | Variable m_PACKAGE; |
---|
108 | Variable m_VERSION; |
---|
109 | Variable m_MGRSTYLE; |
---|
110 | Variable m_TITLE; |
---|
111 | Variable m_GROUP; |
---|
112 | Variable m_CONSTITUENTSUFFIX; |
---|
113 | Variable m_LIBRARYSUFFIX; |
---|
114 | Variable m_USER; |
---|
115 | Variable m_DATE; |
---|
116 | Variable m_PROTOTARGET; |
---|
117 | Variable m_OBJS; |
---|
118 | Variable m_CLASSES; |
---|
119 | Variable m_PROTOSTAMPS; |
---|
120 | Variable m_NAME; |
---|
121 | Variable m_FILEPATH; |
---|
122 | Variable m_FILESUFFIX; |
---|
123 | Variable m_SUFFIX; |
---|
124 | Variable m_FILENAME; |
---|
125 | Variable m_LINE; |
---|
126 | Variable m_ADDINCLUDE; |
---|
127 | Variable m_FULLNAME; |
---|
128 | Variable m_DIRNAME; |
---|
129 | Variable m_OUTPUTNAME; |
---|
130 | Variable m_ALLOS9SOURCES; |
---|
131 | Variable m_NODEBUGUSELINKOPTS; |
---|
132 | Variable m_DEBUGUSELINKOPTS; |
---|
133 | Variable m_USEINCLUDES; |
---|
134 | Variable m_HASTARGETTAG; |
---|
135 | }; |
---|
136 | |
---|
137 | /** |
---|
138 | Generic command interface to be used by the cmt command driver. |
---|
139 | */ |
---|
140 | class Generator |
---|
141 | { |
---|
142 | public: |
---|
143 | // Build the MSDEV workspace file |
---|
144 | static int build_msdev_workspace (const Constituent::ConstituentVector& constituents); |
---|
145 | |
---|
146 | // Build the MSDEV project file (one per constituent) |
---|
147 | static int build_msdev (const Constituent& constituent); |
---|
148 | |
---|
149 | // Build the VSNET workspace file |
---|
150 | static int build_vsnet_workspace (const Constituent::ConstituentVector& constituents); |
---|
151 | |
---|
152 | // Build the VSNET project file (one per constituent) |
---|
153 | static int build_vsnet (const Constituent& constituent); |
---|
154 | |
---|
155 | // Build the Make setup file |
---|
156 | static void build_make_setup (const cmt_string& package); |
---|
157 | |
---|
158 | // Build the constituents.make file |
---|
159 | static void build_constituents_makefile (const cmt_string& package, |
---|
160 | const CmtSystem::cmt_string_vector& arguments); |
---|
161 | |
---|
162 | // Build the makefile fragment for one constituent |
---|
163 | static int build_constituent_makefile (const Constituent& constituent, |
---|
164 | const cmt_string& file = ""); |
---|
165 | static void build_constituent_makefile (const CmtSystem::cmt_string_vector& arguments); |
---|
166 | |
---|
167 | static void build_default_makefile (); |
---|
168 | |
---|
169 | // Build the dependencies for one module |
---|
170 | static void build_dependencies (const CmtSystem::cmt_string_vector& arguments); |
---|
171 | |
---|
172 | // Build prototype file for one module |
---|
173 | static void build_prototype (const cmt_string& file_name); |
---|
174 | |
---|
175 | // Build README.html file |
---|
176 | static void build_readme (const CmtSystem::cmt_string_vector& arguments); |
---|
177 | |
---|
178 | // Build def files for Windows shared libraries |
---|
179 | static void build_windefs (const cmt_string& library_name); |
---|
180 | }; |
---|
181 | |
---|
182 | #endif |
---|