00001 //----------------------------------------------------------- 00002 // Copyright Christian Arnault LAL-Orsay CNRS 00003 // arnault@lal.in2p3.fr 00004 // See the complete license in cmt_license.txt "http://www.cecill.info". 00005 //----------------------------------------------------------- 00006 00007 #ifndef __cmt_generator_h__ 00008 #define __cmt_generator_h__ 00009 00010 #include "cmt_parser.h" 00011 #include "cmt_constituent.h" 00012 #include "cmt_language.h" 00013 #include "cmt_awk.h" 00014 #include "cmt_deps_builder.h" 00015 00016 class Packager : public FAwk 00017 { 00018 public: 00019 void begin (); 00020 void filter (const cmt_string& line); 00021 cmt_string& package_name (); 00022 private: 00023 cmt_string m_package_name; 00024 }; 00025 00026 class SourceFile 00027 { 00028 public: 00029 void set (const cmt_string name, Language& language, const cmt_string output); 00030 cmt_string name () const; 00031 Language& language () const; 00032 cmt_string output () const; 00033 00034 private: 00035 cmt_string m_name; 00036 Language* m_language; 00037 cmt_string m_output; 00038 }; 00039 00044 class CmtGenerator 00045 { 00046 public: 00047 00048 CmtGenerator (); 00049 00050 void reset (); 00051 bool prepare_output (const cmt_string& package, 00052 const Constituent& constituent); 00053 void commit (const cmt_string& name); 00054 static void check (const cmt_string& name); 00055 void terminate (); 00056 00057 void fill_outputs (); 00058 00059 void prepare_use_context (); 00060 00061 void set_full_name (cmt_string& full_name, cmt_string& file); 00062 void filter_path (cmt_string& text); 00063 int get_all_files (const cmt_string& full_name, 00064 const cmt_vector<cmt_regexp>& exclude_exprs, 00065 const cmt_vector<cmt_regexp>& select_exprs, 00066 CmtSystem::cmt_string_vector& files); 00067 00068 00069 public: 00070 cmt_string m_PACKINCLUDES; 00071 bool m_PACKOS9; 00072 00073 cmt_string m_GENERATOR; 00074 00075 bool is_library; 00076 bool is_application; 00077 00078 cmt_string srcdir; 00079 cmt_string docdir; 00080 cmt_string cmtdir; 00081 cmt_string incdir; 00082 cmt_string src; 00083 cmt_string doc; 00084 cmt_string inc; 00085 cmt_string mgr; 00086 cmt_string cmt; 00087 cmt_string protos; 00088 cmt_string protonames; 00089 cmt_string os9sources; 00090 00091 cmt_vector<SourceFile> m_source_files; 00092 00093 cmt_string m_bin; 00094 cmt_string m_output_file_name; 00095 FILE* m_output_file; 00096 00097 DepsBuilder m_deps_builder; 00098 00099 Constituent* m_constituent; 00100 00101 Variable m_CONSTITUENT; 00102 Variable m_LINKMACRO; 00103 Variable m_DOCPATH; 00104 Variable m_PACKAGEPATH; 00105 Variable m_PACKAGEPREFIX; 00106 Variable m_PACKAGE; 00107 Variable m_VERSION; 00108 Variable m_MGRSTYLE; 00109 Variable m_TITLE; 00110 Variable m_GROUP; 00111 Variable m_CONSTITUENTSUFFIX; 00112 Variable m_LIBRARYSUFFIX; 00113 Variable m_USER; 00114 Variable m_DATE; 00115 Variable m_PROTOTARGET; 00116 Variable m_OBJS; 00117 Variable m_CLASSES; 00118 Variable m_PROTOSTAMPS; 00119 Variable m_NAME; 00120 Variable m_FILEPATH; 00121 Variable m_FILESUFFIX; 00122 Variable m_SUFFIX; 00123 Variable m_FILENAME; 00124 Variable m_LINE; 00125 Variable m_ADDINCLUDE; 00126 Variable m_FULLNAME; 00127 Variable m_DIRNAME; 00128 Variable m_OUTPUTNAME; 00129 Variable m_ALLOS9SOURCES; 00130 Variable m_NODEBUGUSELINKOPTS; 00131 Variable m_DEBUGUSELINKOPTS; 00132 Variable m_USEINCLUDES; 00133 Variable m_HASTARGETTAG; 00134 }; 00135 00139 class Generator 00140 { 00141 public: 00142 // Build the MSDEV workspace file 00143 static int build_msdev_workspace (const Constituent::ConstituentVector& constituents); 00144 00145 // Build the MSDEV project file (one per constituent) 00146 static int build_msdev (const Constituent& constituent); 00147 00148 // Build the VSNET workspace file 00149 static int build_vsnet_workspace (const Constituent::ConstituentVector& constituents); 00150 00151 // Build the VSNET project file (one per constituent) 00152 static int build_vsnet (const Constituent& constituent); 00153 00154 // Build the Make setup file 00155 static void build_make_setup (const cmt_string& package); 00156 00157 // Build the constituents.make file 00158 static void build_constituents_makefile (const cmt_string& package, 00159 const CmtSystem::cmt_string_vector& arguments); 00160 00161 // Build the makefile fragment for one constituent 00162 static int build_constituent_makefile (const Constituent& constituent); 00163 static void build_constituent_makefile (const cmt_string& name); 00164 00165 static void build_default_makefile (); 00166 00167 // Build the dependencies for one module 00168 static void build_dependencies (const CmtSystem::cmt_string_vector& arguments); 00169 00170 // Build prototype file for one module 00171 static void build_prototype (const cmt_string& file_name); 00172 00173 // Build README.html file 00174 static void build_readme (const CmtSystem::cmt_string_vector& arguments); 00175 00176 // Build def files for Windows shared libraries 00177 static void build_windefs (const cmt_string& library_name); 00178 }; 00179 00180 #endif