[2] | 1 | //-----------------------------------------------------------
|
---|
| 2 | // Copyright Christian Arnault LAL-Orsay CNRS
|
---|
| 3 | // arnault@lal.in2p3.fr
|
---|
[664] | 4 | // Modified by Grigory Rybkin
|
---|
[2] | 5 | // See the complete license in cmt_license.txt "http://www.cecill.info".
|
---|
| 6 | //-----------------------------------------------------------
|
---|
| 7 |
|
---|
| 8 | #ifndef __cmt_generator_h__
|
---|
| 9 | #define __cmt_generator_h__
|
---|
| 10 |
|
---|
| 11 | #include "cmt_parser.h"
|
---|
| 12 | #include "cmt_constituent.h"
|
---|
| 13 | #include "cmt_language.h"
|
---|
| 14 | #include "cmt_awk.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,
|
---|
[428] | 52 | const Constituent& constituent,
|
---|
| 53 | const cmt_string& file = "");
|
---|
[2] | 54 | void commit (const cmt_string& name);
|
---|
| 55 | static void check (const cmt_string& name);
|
---|
| 56 | void terminate ();
|
---|
| 57 |
|
---|
[474] | 58 | void fill_names_outputs ();
|
---|
[2] | 59 | void fill_outputs ();
|
---|
| 60 |
|
---|
[588] | 61 | // void prepare_use_context ();
|
---|
[2] | 62 |
|
---|
| 63 | void set_full_name (cmt_string& full_name, cmt_string& file);
|
---|
| 64 | void filter_path (cmt_string& text);
|
---|
| 65 | int get_all_files (const cmt_string& full_name,
|
---|
| 66 | const cmt_vector<cmt_regexp>& exclude_exprs,
|
---|
| 67 | const cmt_vector<cmt_regexp>& select_exprs,
|
---|
| 68 | CmtSystem::cmt_string_vector& files);
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | public:
|
---|
| 72 | cmt_string m_PACKINCLUDES;
|
---|
| 73 | bool m_PACKOS9;
|
---|
| 74 |
|
---|
| 75 | cmt_string m_GENERATOR;
|
---|
| 76 |
|
---|
| 77 | bool is_library;
|
---|
| 78 | bool is_application;
|
---|
| 79 |
|
---|
| 80 | cmt_string srcdir;
|
---|
| 81 | cmt_string docdir;
|
---|
| 82 | cmt_string cmtdir;
|
---|
| 83 | cmt_string incdir;
|
---|
| 84 | cmt_string src;
|
---|
| 85 | cmt_string doc;
|
---|
| 86 | cmt_string inc;
|
---|
| 87 | cmt_string mgr;
|
---|
| 88 | cmt_string cmt;
|
---|
| 89 | cmt_string protos;
|
---|
| 90 | cmt_string protonames;
|
---|
| 91 | cmt_string os9sources;
|
---|
| 92 |
|
---|
| 93 | cmt_vector<SourceFile> m_source_files;
|
---|
| 94 |
|
---|
| 95 | cmt_string m_bin;
|
---|
| 96 | cmt_string m_output_file_name;
|
---|
| 97 | FILE* m_output_file;
|
---|
| 98 |
|
---|
| 99 | Constituent* m_constituent;
|
---|
| 100 |
|
---|
| 101 | Variable m_CONSTITUENT;
|
---|
| 102 | Variable m_LINKMACRO;
|
---|
[483] | 103 | Variable m_DEPENDENCIESOPTS;
|
---|
[2] | 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;
|
---|
[488] | 135 | Variable m_HASDEPENDENCIES;
|
---|
[637] | 136 | Variable m_ISCHECKGROUP;
|
---|
[2] | 137 | };
|
---|
| 138 |
|
---|
[561] | 139 | class InGenerator
|
---|
| 140 | {
|
---|
| 141 | public:
|
---|
[595] | 142 | InGenerator (bool usecmt, bool pedantic);
|
---|
[561] | 143 | int build (const Constituent& constituent, ostream& out = cout);
|
---|
| 144 |
|
---|
| 145 | private:
|
---|
| 146 | InGenerator ();
|
---|
| 147 |
|
---|
| 148 | private:
|
---|
| 149 | class Buffer
|
---|
| 150 | {
|
---|
| 151 | public:
|
---|
| 152 | Buffer ();
|
---|
| 153 | void set_names (const CmtSystem::cmt_string_vector& names);
|
---|
| 154 | int print (ostream& s);
|
---|
| 155 | void set_uses (bool usecmt);
|
---|
[595] | 156 | void set_pedantic (bool pedantic);
|
---|
[561] | 157 | private:
|
---|
| 158 | virtual int initialize () = 0;
|
---|
| 159 |
|
---|
| 160 | protected:
|
---|
| 161 | CmtSystem::cmt_string_vector m_names;
|
---|
| 162 | ostringstream m_buffer;
|
---|
| 163 | bool m_initialized;
|
---|
| 164 | bool m_usecmt;
|
---|
[595] | 165 | bool m_pedantic;
|
---|
[561] | 166 | };
|
---|
| 167 |
|
---|
| 168 | class Languages : public Buffer
|
---|
| 169 | {
|
---|
| 170 | private:
|
---|
| 171 | int initialize ();
|
---|
| 172 | };
|
---|
| 173 |
|
---|
| 174 | class Fragments : public Buffer
|
---|
| 175 | {
|
---|
| 176 | private:
|
---|
| 177 | int initialize ();
|
---|
| 178 | };
|
---|
| 179 |
|
---|
| 180 | private:
|
---|
| 181 | Fragments m_common;
|
---|
| 182 | Fragments m_application;
|
---|
| 183 | Fragments m_application_library;
|
---|
| 184 | Fragments m_library;
|
---|
| 185 | Fragments m_document;
|
---|
| 186 | Languages m_languages;
|
---|
| 187 | bool m_usecmt;
|
---|
[595] | 188 | bool m_pedantic;
|
---|
[561] | 189 | };
|
---|
| 190 |
|
---|
[2] | 191 | /**
|
---|
| 192 | Generic command interface to be used by the cmt command driver.
|
---|
| 193 | */
|
---|
| 194 | class Generator
|
---|
| 195 | {
|
---|
| 196 | public:
|
---|
| 197 | // Build the MSDEV workspace file
|
---|
| 198 | static int build_msdev_workspace (const Constituent::ConstituentVector& constituents);
|
---|
| 199 |
|
---|
| 200 | // Build the MSDEV project file (one per constituent)
|
---|
| 201 | static int build_msdev (const Constituent& constituent);
|
---|
| 202 |
|
---|
| 203 | // Build the VSNET workspace file
|
---|
| 204 | static int build_vsnet_workspace (const Constituent::ConstituentVector& constituents);
|
---|
| 205 |
|
---|
| 206 | // Build the VSNET project file (one per constituent)
|
---|
| 207 | static int build_vsnet (const Constituent& constituent);
|
---|
| 208 |
|
---|
| 209 | // Build the Make setup file
|
---|
| 210 | static void build_make_setup (const cmt_string& package);
|
---|
| 211 |
|
---|
| 212 | // Build the constituents.make file
|
---|
| 213 | static void build_constituents_makefile (const cmt_string& package,
|
---|
[561] | 214 | const cmt_string& file = "");
|
---|
| 215 | // const CmtSystem::cmt_string_vector& arguments);
|
---|
[2] | 216 |
|
---|
| 217 | // Build the makefile fragment for one constituent
|
---|
[428] | 218 | static int build_constituent_makefile (const Constituent& constituent,
|
---|
[588] | 219 | bool& dependencies,
|
---|
[428] | 220 | const cmt_string& file = "");
|
---|
| 221 | static void build_constituent_makefile (const CmtSystem::cmt_string_vector& arguments);
|
---|
[561] | 222 | static int build_constituent_infile (const Constituent& constituent,
|
---|
| 223 | const cmt_string& outdir = "",
|
---|
| 224 | bool usecmt = true);
|
---|
[2] | 225 |
|
---|
[588] | 226 | static int build_library_links_infile (const cmt_string& outdir = "");
|
---|
| 227 |
|
---|
| 228 | static int build_dependencies_infile (const Constituent* constituent,
|
---|
| 229 | const cmt_string& outdir = "",
|
---|
| 230 | bool usecmt = true);
|
---|
| 231 |
|
---|
[2] | 232 | static void build_default_makefile ();
|
---|
| 233 |
|
---|
[588] | 234 | // Build the packages (N)Make file
|
---|
| 235 | static void build_packages_makefile (const cmt_string& package,
|
---|
| 236 | const cmt_string& file = "");
|
---|
| 237 |
|
---|
[2] | 238 | // Build the dependencies for one module
|
---|
| 239 | static void build_dependencies (const CmtSystem::cmt_string_vector& arguments);
|
---|
| 240 |
|
---|
| 241 | // Build prototype file for one module
|
---|
| 242 | static void build_prototype (const cmt_string& file_name);
|
---|
| 243 |
|
---|
| 244 | // Build README.html file
|
---|
| 245 | static void build_readme (const CmtSystem::cmt_string_vector& arguments);
|
---|
| 246 |
|
---|
| 247 | // Build def files for Windows shared libraries
|
---|
[466] | 248 | // static void build_windefs (const cmt_string& library_name);
|
---|
| 249 | static void build_windefs (const CmtSystem::cmt_string_vector& arguments);
|
---|
[2] | 250 | };
|
---|
| 251 |
|
---|
| 252 | #endif
|
---|