1 | //----------------------------------------------------------- |
---|
2 | // Copyright Christian Arnault LAL-Orsay CNRS |
---|
3 | // arnault@lal.in2p3.fr |
---|
4 | // Modified by garonne@lal.in2p3.fr |
---|
5 | // See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
6 | //----------------------------------------------------------- |
---|
7 | |
---|
8 | #ifndef __cmt_h__ |
---|
9 | #define __cmt_h__ |
---|
10 | |
---|
11 | #include "cmt_parser.h" |
---|
12 | #include "cmt_system.h" |
---|
13 | |
---|
14 | class ArgParser; |
---|
15 | class Symbol; |
---|
16 | class Tag; |
---|
17 | |
---|
18 | class CmtContext |
---|
19 | { |
---|
20 | public: |
---|
21 | |
---|
22 | CmtContext (); |
---|
23 | ~CmtContext (); |
---|
24 | |
---|
25 | void clear (); |
---|
26 | int initialize (); |
---|
27 | |
---|
28 | ActionType m_action; |
---|
29 | bool m_build_nmake; |
---|
30 | cmt_string m_cmt_config; |
---|
31 | cmt_string m_cmt_root; |
---|
32 | cmt_string m_cmt_home; |
---|
33 | cmt_string m_cmt_user_context; |
---|
34 | cmt_string m_cmt_site; |
---|
35 | cmt_string m_cmt_version; |
---|
36 | bool m_use_cmt; |
---|
37 | bool m_use_projects; |
---|
38 | |
---|
39 | cmt_string m_current_dir; |
---|
40 | FilePath m_current_file_path; |
---|
41 | cmt_string m_current_package; |
---|
42 | cmt_string m_current_config; |
---|
43 | cmt_string m_current_path; |
---|
44 | cmt_string m_current_prefix; |
---|
45 | cmt_string m_current_cmtpath; |
---|
46 | cmt_string m_current_offset; |
---|
47 | |
---|
48 | AccessMode m_current_access; |
---|
49 | CmtDirStyle m_current_style; |
---|
50 | CmtStructuringStyle m_current_structuring_style; |
---|
51 | |
---|
52 | cmt_string m_current_tag; |
---|
53 | cmt_string m_current_target; |
---|
54 | cmt_string m_current_version; |
---|
55 | |
---|
56 | // cmt_string m_extra_tags; |
---|
57 | CmtSystem::cmt_string_vector m_extra_tags; |
---|
58 | CmtSystem::cmt_string_vector m_tags; |
---|
59 | CmtSystem::cmt_string_vector m_tags_add; |
---|
60 | CmtSystem::cmt_string_vector m_tags_remove; |
---|
61 | |
---|
62 | cmt_string m_configure_error; |
---|
63 | |
---|
64 | bool m_debug; |
---|
65 | |
---|
66 | cmt_string m_default_path; |
---|
67 | bool m_quiet; |
---|
68 | bool m_disable_warnings; |
---|
69 | bool m_warnings; |
---|
70 | bool m_recursive; |
---|
71 | CmtScopeFilteringMode m_scope_filtering_mode; |
---|
72 | bool m_simulation; |
---|
73 | bool m_standard_macros_done; |
---|
74 | bool m_all_sets_done; |
---|
75 | |
---|
76 | bool m_autoconfigure_cmtpath; |
---|
77 | |
---|
78 | bool m_env_access; |
---|
79 | PrintMode m_print_mode; |
---|
80 | bool m_path_strip; |
---|
81 | |
---|
82 | private: |
---|
83 | |
---|
84 | CmtContext& operator = (const CmtContext& other); |
---|
85 | CmtContext (const CmtContext& other); |
---|
86 | }; |
---|
87 | |
---|
88 | class Cmt |
---|
89 | { |
---|
90 | public: |
---|
91 | static void build_config (const cmt_string& prefix, cmt_string& config); |
---|
92 | static void build_makefile (const cmt_string& target); |
---|
93 | static void build_msdev_file (const cmt_string& target); |
---|
94 | // Visual Studio.Net Support |
---|
95 | static void build_vsnet_file (const cmt_string& target); |
---|
96 | |
---|
97 | static inline bool build_nmake (); |
---|
98 | static void build_OS9_makefile (const cmt_string& target); |
---|
99 | static void build_prefix (const cmt_string& package, cmt_string& prefix); |
---|
100 | static void clear (); |
---|
101 | |
---|
102 | // static void configure (); |
---|
103 | static void configure (const ArgParser& ap); |
---|
104 | static void configure_cmt_path (Use* use); |
---|
105 | static void configure_config_tag (); |
---|
106 | static void configure_current_cmtpath (); |
---|
107 | static void configure_current_dir (); |
---|
108 | static void configure_current_package (); |
---|
109 | // static void configure_current_structuring_style (); |
---|
110 | static void configure_current_structuring_style (const ArgParser& ap); |
---|
111 | static void configure_default_path (); |
---|
112 | static void configure_home (Use* use); |
---|
113 | static void configure_user_context (Use* use); |
---|
114 | static void configure_hosttype_tag (); |
---|
115 | static void configure_site_tag (Use* use); |
---|
116 | static void configure_tags (Use* use); |
---|
117 | static void configure_uname_tag (); |
---|
118 | static void configure_devenv_tag (); |
---|
119 | static void configure_version_tag (); |
---|
120 | // static void configure_cmt_message (); |
---|
121 | static void configure_cmt_message (const ArgParser& ap); |
---|
122 | |
---|
123 | static void do_awk (const ArgParser& ap); |
---|
124 | static void do_broadcast (const ArgParser& ap); |
---|
125 | static void do_build_constituent_makefile (const ArgParser& ap); |
---|
126 | static void do_build_constituent_config (const ArgParser& ap); |
---|
127 | static void do_build_constituents_makefile (const ArgParser& ap); |
---|
128 | static void do_build_constituents_config (const ArgParser& ap); |
---|
129 | static void do_build_broadcast_config (const ArgParser& ap); |
---|
130 | static void do_build_dependencies (const ArgParser& ap, |
---|
131 | int argc, |
---|
132 | char* argv[]); |
---|
133 | static void do_build_library_links (const ArgParser& ap); |
---|
134 | static void do_build_make_setup (const ArgParser& ap); |
---|
135 | static void do_build_msdev (const ArgParser& ap); |
---|
136 | static void do_build_CMT_pacman (const ArgParser& ap); |
---|
137 | // Visual Studio.Net Support |
---|
138 | static void do_build_vsnet (const ArgParser& ap); |
---|
139 | |
---|
140 | static void do_build_os9_makefile (const ArgParser& ap); |
---|
141 | static void do_build_prototype (const ArgParser& ap); |
---|
142 | static void do_build_readme (const ArgParser& ap); |
---|
143 | static void do_build_tag_makefile (const ArgParser& ap); |
---|
144 | static void do_build_temporary_name (const ArgParser& ap); |
---|
145 | static void do_build_triggers (const ArgParser& ap); |
---|
146 | static void do_build_windefs (const ArgParser& ap); |
---|
147 | static void do_check_configuration (const ArgParser& ap); |
---|
148 | static void do_check_files (const ArgParser& ap); |
---|
149 | static void do_check_version (const ArgParser& ap); |
---|
150 | static void do_checkout (const ArgParser& ap); |
---|
151 | static void do_cleanup (const ArgParser& ap); |
---|
152 | static void do_config (const ArgParser& ap); |
---|
153 | static void do_create (const ArgParser& ap); |
---|
154 | static void do_create_project (const ArgParser& ap); |
---|
155 | static void do_cvsbranches (const ArgParser& ap); |
---|
156 | static void do_cvssubpackages (const ArgParser& ap); |
---|
157 | static void do_cvssubprojects (const ArgParser& ap); |
---|
158 | static void do_cvstags (const ArgParser& ap); |
---|
159 | static void do_do (const ArgParser& ap); |
---|
160 | static void do_expand_model (const ArgParser& ap); |
---|
161 | static void do_filter (const ArgParser& ap); |
---|
162 | static void do_help (const ArgParser& ap); |
---|
163 | static void do_lock (const ArgParser& ap); |
---|
164 | static void do_relocate (const ArgParser& ap); |
---|
165 | static void do_remove (const ArgParser& ap); |
---|
166 | static void do_remove_library_links (const ArgParser& ap); |
---|
167 | static void do_run (const ArgParser& ap); |
---|
168 | static void do_run_sequence (const ArgParser& ap); |
---|
169 | |
---|
170 | static void do_set_version (const ArgParser& ap); |
---|
171 | static void do_set_versions (const ArgParser& ap); |
---|
172 | |
---|
173 | static void do_setup (const ArgParser& ap); |
---|
174 | static void do_show_action (const ArgParser& ap); |
---|
175 | static void do_show_action_names (const ArgParser& ap); |
---|
176 | static void do_show_action_value (const ArgParser& ap); |
---|
177 | static void do_show_actions (const ArgParser& ap); |
---|
178 | static void do_show_alias (const ArgParser& ap); |
---|
179 | static void do_show_alias_names (const ArgParser& ap); |
---|
180 | static void do_show_alias_value (const ArgParser& ap); |
---|
181 | static void do_show_aliases (const ArgParser& ap); |
---|
182 | static void do_show_all_tags (const ArgParser& ap); |
---|
183 | static void do_show_applied_patterns (const ArgParser& ap); |
---|
184 | static void do_show_author (const ArgParser& ap); |
---|
185 | static void do_show_branches (const ArgParser& ap); |
---|
186 | static void do_show_clients (const ArgParser& ap); |
---|
187 | static void do_show_cmtpath_patterns (const ArgParser& ap); |
---|
188 | static void do_show_constituent (const ArgParser& ap); |
---|
189 | static void do_show_constituent_names (const ArgParser& ap); |
---|
190 | static void do_show_constituents (const ArgParser& ap); |
---|
191 | static void do_show_container (const ArgParser& ap); |
---|
192 | static void do_show_cycles (const ArgParser& ap); |
---|
193 | static void do_show_fragment (const ArgParser& ap); |
---|
194 | static void do_show_fragments (const ArgParser& ap); |
---|
195 | static void do_show_groups (const ArgParser& ap); |
---|
196 | static void do_show_include_dirs (const ArgParser& ap); |
---|
197 | static void do_show_language (const ArgParser& ap); |
---|
198 | static void do_show_languages (const ArgParser& ap); |
---|
199 | static void do_show_macro (const ArgParser& ap); |
---|
200 | static void do_show_macro_names (const ArgParser& ap); |
---|
201 | static void do_show_macro_value (const ArgParser& ap); |
---|
202 | static void do_show_macros (const ArgParser& ap); |
---|
203 | static void do_show_manager (const ArgParser& ap); |
---|
204 | static void do_show_packages (const ArgParser& ap); |
---|
205 | static void do_show_path (const ArgParser& ap, ostream& out = cout); |
---|
206 | static void do_show_pattern (const ArgParser& ap); |
---|
207 | static void do_show_pattern_names (const ArgParser& ap); |
---|
208 | static void do_show_patterns (const ArgParser& ap); |
---|
209 | static void do_show_projects (const ArgParser& ap); |
---|
210 | static void do_show_project_author (const ArgParser& ap); |
---|
211 | static void do_show_pwd (const ArgParser& ap); |
---|
212 | static void do_show_setup (const ArgParser& ap, ostream& out = cout); |
---|
213 | static void do_show_set (const ArgParser& ap); |
---|
214 | static void do_show_set_names (const ArgParser& ap); |
---|
215 | static void do_show_set_value (const ArgParser& ap); |
---|
216 | static void do_show_sets (const ArgParser& ap); |
---|
217 | static void do_show_strategies (const ArgParser& ap); |
---|
218 | static void do_show_tags (const ArgParser& ap, ostream& out = cout); |
---|
219 | static void do_show_use_paths (const ArgParser& ap); |
---|
220 | static void do_show_uses (const ArgParser& ap, ostream& out = cout); |
---|
221 | static void do_show_version (const ArgParser& ap); |
---|
222 | static void do_show_versions (const ArgParser& ap); |
---|
223 | static void do_show_system (const ArgParser& ap); |
---|
224 | static void do_unlock (const ArgParser& ap); |
---|
225 | static void do_version (const ArgParser& ap); |
---|
226 | |
---|
227 | |
---|
228 | static const cmt_string& filter_dir (const cmt_string& dir); |
---|
229 | |
---|
230 | static inline ActionType get_action (); |
---|
231 | |
---|
232 | static inline const cmt_string& get_cmt_home (); |
---|
233 | static inline const cmt_string& get_cmt_user_context (); |
---|
234 | static inline const cmt_string& get_cmt_version (); |
---|
235 | static inline const cmt_string& get_current_dir (); |
---|
236 | static const cmt_string get_current_dir_real (); |
---|
237 | static inline const cmt_string& get_current_package (); |
---|
238 | static const cmt_string& get_current_path (); |
---|
239 | static const cmt_string& get_current_cmtpath (); |
---|
240 | static const cmt_string& get_current_offset (); |
---|
241 | static inline AccessMode get_current_access (); |
---|
242 | static inline CmtStructuringStyle get_current_structuring_style (); |
---|
243 | static inline CmtDirStyle get_current_style (); |
---|
244 | static const cmt_string& get_current_version (); |
---|
245 | static inline const cmt_string& get_current_target (); |
---|
246 | static inline const CmtSystem::cmt_string_vector& get_tags_remove (); |
---|
247 | static inline bool get_debug (); |
---|
248 | static inline bool get_disable_warnings (); |
---|
249 | static inline bool get_quiet (); |
---|
250 | static inline bool get_warnings (); |
---|
251 | static inline bool get_recursive (); |
---|
252 | static CmtScopeFilteringMode get_scope_filtering_mode (); |
---|
253 | static inline bool get_all_sets_done (); |
---|
254 | |
---|
255 | static void get_cmt_flags (CmtSystem::cmt_string_vector& flags); |
---|
256 | static cmt_string get_cmt_flags (); |
---|
257 | static cmt_string get_cmt_flags (const cmt_string& file_name); |
---|
258 | static bool set_cmt_flags (const cmt_string& flags); |
---|
259 | static bool add_cmt_flag (const cmt_string& flag); |
---|
260 | |
---|
261 | /// If a project file exists above the current directory we don't need CMTPATH |
---|
262 | static void guess_current_project (); |
---|
263 | |
---|
264 | static void install_cleanup_scripts (); |
---|
265 | static void install_setup_scripts (); |
---|
266 | static void install_scripts (ScriptType type, const cmt_string& flags); |
---|
267 | static void install_native_version_file (); |
---|
268 | // static bool load (const cmt_string& path, |
---|
269 | static bool load (const ArgParser& ap, |
---|
270 | const cmt_string& path, |
---|
271 | const cmt_string& package, |
---|
272 | const cmt_string& version, |
---|
273 | const cmt_string& tag_name = ""); |
---|
274 | static bool need_prototypes (); |
---|
275 | static void parse_arguments (ArgParser& ap); |
---|
276 | static int parser (const cmt_string& command_line); |
---|
277 | static int parser (int argc, char* argv[]); |
---|
278 | static void print (PrintMode mode, ostream& out = cout); |
---|
279 | //static void print (PrintMode mode); |
---|
280 | static void print_clean (PrintMode mode); |
---|
281 | static void print_context (Use& use, PrintMode mode, const cmt_string& tag, ostream& out = cout); |
---|
282 | //static void print_context (Use& use, PrintMode mode, const cmt_string& tag); |
---|
283 | static void print_macros (PrintMode mode, const cmt_string& pattern = "", |
---|
284 | ostream& out = cout); |
---|
285 | // static void print_macros (PrintMode mode, const cmt_string& pattern = ""); |
---|
286 | static void print_symbol_names (PrintMode mode, const cmt_string& pattern = ""); |
---|
287 | static void print_tabs (int tabs); |
---|
288 | static void print_xml_prolog (const cmt_string& root = "cmt", ostream& out = cout); |
---|
289 | // static int reach_current_package (); |
---|
290 | static int use_current_package (); |
---|
291 | static int use_extra_file (const cmt_string& file); |
---|
292 | static int apply_globals (); |
---|
293 | static void restore_all_tags (Use* use); |
---|
294 | static inline void set_current_access (AccessMode mode); |
---|
295 | static inline void set_recursive (bool mode); |
---|
296 | static inline void set_scope_filtering_mode (CmtScopeFilteringMode mode); |
---|
297 | static void set_standard_macros (); |
---|
298 | static inline void set_all_sets_done (); |
---|
299 | static inline void reset_all_sets_done (); |
---|
300 | static void use_cmt (); |
---|
301 | static void use_home_requirements (); |
---|
302 | static void use_user_context_requirements (); |
---|
303 | static void use_special_requirements (const cmt_string& path, |
---|
304 | const cmt_string& name, |
---|
305 | const cmt_string& file_name); |
---|
306 | static cmt_string vector_to_string (const CmtSystem::cmt_string_vector& v); |
---|
307 | static void vector_to_string (const CmtSystem::cmt_string_vector& v, |
---|
308 | const cmt_string& separator, |
---|
309 | cmt_string& result); |
---|
310 | |
---|
311 | static inline const bool& get_env_access (); |
---|
312 | static inline void set_env_access (const bool& access); |
---|
313 | static inline const PrintMode& get_print_mode (); |
---|
314 | static inline void set_print_mode (const PrintMode& mode); |
---|
315 | static inline const bool& get_path_strip (); |
---|
316 | |
---|
317 | private: |
---|
318 | static CmtContext& m_cmt_context; |
---|
319 | // static CmtContext * m_cmt_context; |
---|
320 | }; |
---|
321 | |
---|
322 | //---------------------------------------------------------- |
---|
323 | inline bool Cmt::build_nmake () |
---|
324 | { |
---|
325 | return (m_cmt_context.m_build_nmake); |
---|
326 | } |
---|
327 | |
---|
328 | inline ActionType Cmt::get_action () |
---|
329 | { |
---|
330 | return (m_cmt_context.m_action); |
---|
331 | } |
---|
332 | |
---|
333 | inline const cmt_string& Cmt::get_cmt_home () |
---|
334 | { |
---|
335 | return (m_cmt_context.m_cmt_home); |
---|
336 | } |
---|
337 | |
---|
338 | inline const cmt_string& Cmt::get_cmt_user_context () |
---|
339 | { |
---|
340 | return (m_cmt_context.m_cmt_user_context); |
---|
341 | } |
---|
342 | |
---|
343 | inline const cmt_string& Cmt::get_cmt_version () |
---|
344 | { |
---|
345 | return (m_cmt_context.m_cmt_version); |
---|
346 | } |
---|
347 | |
---|
348 | inline const cmt_string& Cmt::get_current_dir () |
---|
349 | { |
---|
350 | return (m_cmt_context.m_current_dir); |
---|
351 | } |
---|
352 | |
---|
353 | inline const cmt_string& Cmt::get_current_package () |
---|
354 | { |
---|
355 | return (m_cmt_context.m_current_package); |
---|
356 | } |
---|
357 | |
---|
358 | inline AccessMode Cmt::get_current_access () |
---|
359 | { |
---|
360 | return (m_cmt_context.m_current_access); |
---|
361 | } |
---|
362 | |
---|
363 | inline CmtStructuringStyle Cmt::get_current_structuring_style () |
---|
364 | { |
---|
365 | return (m_cmt_context.m_current_structuring_style); |
---|
366 | } |
---|
367 | |
---|
368 | inline CmtDirStyle Cmt::get_current_style () |
---|
369 | { |
---|
370 | return (m_cmt_context.m_current_style); |
---|
371 | } |
---|
372 | |
---|
373 | inline const cmt_string& Cmt::get_current_target () |
---|
374 | { |
---|
375 | return (m_cmt_context.m_current_target); |
---|
376 | } |
---|
377 | |
---|
378 | inline const CmtSystem::cmt_string_vector& Cmt::get_tags_remove () |
---|
379 | { |
---|
380 | return m_cmt_context.m_tags_remove; |
---|
381 | } |
---|
382 | |
---|
383 | inline bool Cmt::get_debug () |
---|
384 | { |
---|
385 | return (m_cmt_context.m_debug); |
---|
386 | } |
---|
387 | |
---|
388 | inline bool Cmt::get_quiet () |
---|
389 | { |
---|
390 | return (m_cmt_context.m_quiet); |
---|
391 | } |
---|
392 | |
---|
393 | inline bool Cmt::get_disable_warnings () |
---|
394 | { |
---|
395 | return (m_cmt_context.m_disable_warnings); |
---|
396 | } |
---|
397 | |
---|
398 | inline bool Cmt::get_warnings () |
---|
399 | { |
---|
400 | return (m_cmt_context.m_warnings); |
---|
401 | } |
---|
402 | |
---|
403 | inline bool Cmt::get_recursive () |
---|
404 | { |
---|
405 | return (m_cmt_context.m_recursive); |
---|
406 | } |
---|
407 | |
---|
408 | inline bool Cmt::get_all_sets_done () |
---|
409 | { |
---|
410 | return (m_cmt_context.m_all_sets_done); |
---|
411 | } |
---|
412 | |
---|
413 | inline void Cmt::set_current_access (AccessMode mode) |
---|
414 | { |
---|
415 | m_cmt_context.m_current_access = mode; |
---|
416 | } |
---|
417 | |
---|
418 | //---------------------------------------------------------- |
---|
419 | inline void Cmt::set_recursive (bool mode) |
---|
420 | { |
---|
421 | m_cmt_context.m_recursive = mode; |
---|
422 | } |
---|
423 | |
---|
424 | //---------------------------------------------------------- |
---|
425 | inline void Cmt::set_scope_filtering_mode (CmtScopeFilteringMode mode) |
---|
426 | { |
---|
427 | m_cmt_context.m_scope_filtering_mode = mode; |
---|
428 | } |
---|
429 | |
---|
430 | inline void Cmt::set_all_sets_done () |
---|
431 | { |
---|
432 | m_cmt_context.m_all_sets_done = true; |
---|
433 | } |
---|
434 | |
---|
435 | inline void Cmt::reset_all_sets_done () |
---|
436 | { |
---|
437 | m_cmt_context.m_all_sets_done = false; |
---|
438 | } |
---|
439 | |
---|
440 | inline const bool& Cmt::get_env_access () |
---|
441 | { |
---|
442 | return m_cmt_context.m_env_access; |
---|
443 | } |
---|
444 | |
---|
445 | inline void Cmt::set_env_access (const bool& access) |
---|
446 | { |
---|
447 | m_cmt_context.m_env_access = access; |
---|
448 | } |
---|
449 | |
---|
450 | inline const PrintMode& Cmt::get_print_mode () |
---|
451 | { |
---|
452 | return m_cmt_context.m_print_mode; |
---|
453 | } |
---|
454 | |
---|
455 | inline void Cmt::set_print_mode (const PrintMode& mode) |
---|
456 | { |
---|
457 | m_cmt_context.m_print_mode = mode; |
---|
458 | } |
---|
459 | |
---|
460 | inline const bool& Cmt::get_path_strip () |
---|
461 | { |
---|
462 | return m_cmt_context.m_path_strip; |
---|
463 | } |
---|
464 | //---------------------------------------------------------- |
---|
465 | |
---|
466 | #endif |
---|