Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

VSNETGenerator Class Reference

#include <cmt_generators.h>

Inheritance diagram for VSNETGenerator:

Inheritance graph
[legend]
Collaboration diagram for VSNETGenerator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 VSNETGenerator ()
int build_workspace (const Constituent::ConstituentVector &constituents)
int build_project (const Constituent &constituent)

Private Member Functions

void reset ()
void pseudoGUID (const cmt_string &a, const cmt_string &b, const cmt_string &c, cmt_string &d)

Private Attributes

cmt_string vsnetdir
FragmentHandle sln_header_fragment
FragmentHandle sln_project_fragment
FragmentHandle sln_dependency_header_fragment
FragmentHandle sln_dependency_project_fragment
FragmentHandle sln_dependency_trailer_fragment
FragmentHandle sln_project_config_fragment
FragmentHandle sln_trailer_fragment
FragmentHandle vcproj_all_fragment
FragmentHandle vcproj_library_header_fragment
FragmentHandle vcproj_application_header_fragment
FragmentHandle vcproj_windows_header_fragment
FragmentHandle vcproj_contents_fragment
FragmentHandle vcproj_directory_header_fragment
FragmentHandle vcproj_directory_trailer_fragment
FragmentHandle vcproj_trailer_fragment

Constructor & Destructor Documentation

VSNETGenerator::VSNETGenerator  ) 
 

Definition at line 1817 of file cmt_generators.cxx.

References FragmentHandle::set(), sln_dependency_header_fragment, sln_dependency_project_fragment, sln_dependency_trailer_fragment, sln_header_fragment, sln_project_config_fragment, sln_project_fragment, sln_trailer_fragment, vcproj_all_fragment, vcproj_application_header_fragment, vcproj_contents_fragment, vcproj_directory_header_fragment, vcproj_directory_trailer_fragment, vcproj_library_header_fragment, vcproj_trailer_fragment, and vcproj_windows_header_fragment.

01818 {
01819   sln_header_fragment.set ("sln_header");
01820   sln_project_fragment.set ("sln_project");
01821   sln_dependency_header_fragment.set ("sln_dependency_header");
01822   sln_dependency_project_fragment.set ("sln_dependency_project");
01823   sln_dependency_trailer_fragment.set ("sln_dependency_trailer");
01824   sln_project_config_fragment.set ("sln_project_config");
01825   sln_trailer_fragment.set ("sln_trailer");
01826 
01827   vcproj_all_fragment.set ("vcproj_all");
01828   vcproj_library_header_fragment.set ("vcproj_library_header");
01829   vcproj_application_header_fragment.set ("vcproj_application_header");
01830   vcproj_windows_header_fragment.set ("vcproj_windows_header");
01831   vcproj_contents_fragment.set ("vcproj_contents");
01832   vcproj_directory_header_fragment.set ("vcproj_directory_header");
01833   vcproj_directory_trailer_fragment.set ("vcproj_directory_trailer");
01834   vcproj_trailer_fragment.set ("vcproj_trailer");
01835 }


Member Function Documentation

int VSNETGenerator::build_project const Constituent constituent  ) 
 

Definition at line 2038 of file cmt_generators.cxx.

References Application, CmtSystem::cmt_string_vector, Document, Constituent::exclude_exprs, cmt_string::find(), Constituent::generator, CmtGenerator::get_all_files(), Constituent::includes, Library, Constituent::modules, Constituent::name, Constituent::need_OS9, Constituent::no_share, pseudoGUID(), reset(), Constituent::select_exprs, CmtGenerator::set_full_name(), cmt_vector< T >::size(), CmtGenerator::terminate(), Constituent::type, Constituent::variables, and Constituent::windows.

Referenced by Generator::build_vsnet().

02039 {
02040   reset ();
02041   
02042   const cmt_string& package = Cmt::get_current_package();
02043   static cmt_string file;
02044   static cmt_string full_name;
02045   static cmt_string suffix;
02046   
02047   static Variable GUID("GUID");
02048   int i;
02049   
02050   // Directory Support
02051   int dir_pos;
02052   int file_pos;
02053   int src_pos;
02054   int iSFFilter = 0;
02055   cmt_string directory;
02056   cmt_string new_dir;
02057   bool need_trailer = false;
02058 
02059   m_CONSTITUENT = constituent.name;
02060   // make up a pseudo-GUID from the constituent-pacakge-version combination
02061   
02062   cmt_string guid;
02063   pseudoGUID (package, Cmt::get_current_version(), constituent.name, guid);
02064   
02065   GUID = guid;
02066   
02067   for (i = 0; i < constituent.includes.size (); i++)
02068     {
02069       const cmt_string& include = constituent.includes[i];
02070       m_PACKINCLUDES += " -I" + include;
02071     }
02072   
02073   switch (constituent.type)
02074     {
02075     case Application:
02076       is_application = true;
02077       m_TITLE = "Application";
02078       break;
02079     case Library:
02080       is_library = true;
02081       m_TITLE = "Library";
02082       break;
02083     case Document:
02084       m_GENERATOR = constituent.generator;
02085       m_TITLE = "Document";
02086       break;
02087     }
02088   
02089   m_PACKOS9 = constituent.need_OS9;
02090   
02091   const CmtSystem::cmt_string_vector& sources = constituent.modules;
02092   const cmt_vector<cmt_regexp>& excludes = constituent.exclude_exprs;
02093   const cmt_vector<cmt_regexp>& selects = constituent.select_exprs;
02094   
02095   //--- Build the constituents fragment -----
02096   cmt_string output;
02097   
02098   m_output_file_name = vsnetdir + m_CONSTITUENT + ".vcprojnew";
02099   m_output_file = fopen (m_output_file_name.c_str (), "wb");
02100   
02101   if (m_output_file == NULL) return (0);
02102   
02103   m_PACKAGE = package;
02104   
02105   if (is_library)
02106     {
02107       if (constituent.no_share)
02108         {
02109           m_LIBRARYSUFFIX = "lib";
02110         }
02111       else
02112         {
02113           m_LIBRARYSUFFIX = "arc";
02114         }
02115       
02116       vcproj_library_header_fragment.wincopy (m_output_file, constituent.variables, 4,
02117                                               &m_PACKAGE,
02118                                               &m_CONSTITUENT,
02119                                               &GUID,
02120                                               &m_LIBRARYSUFFIX);
02121     }
02122   else
02123     {
02124       if (constituent.windows)
02125         {
02126           vcproj_windows_header_fragment.wincopy (m_output_file, constituent.variables, 3,
02127                                                   &m_PACKAGE,
02128                                                   &m_CONSTITUENT,
02129                                                   &GUID);
02130         }
02131       else
02132         {
02133           vcproj_application_header_fragment.wincopy (m_output_file, constituent.variables, 3,
02134                                                       &m_PACKAGE,
02135                                                       &m_CONSTITUENT,
02136                                                       &GUID);
02137         }
02138     }
02139   
02140   for (i = 0; i < sources.size (); i++)
02141     {
02142       file = sources[i];
02143       
02144       set_full_name (full_name, file);
02145       if (full_name == "") continue;
02146       
02147       static CmtSystem::cmt_string_vector files;
02148       
02149       get_all_files (full_name, excludes, selects, files);
02150       
02151       for (int j = 0; j < files.size (); j++)
02152         {
02153           const cmt_string& name = files[j];
02154           
02155           if (name != "")
02156             {
02157               m_FULLNAME = name;
02158 
02159               // Add Directory Support here
02160               // Step 1: Parse into "..\src\" "directory" "\filename.cxx"
02161 
02162               // find ..\ ;
02163               src_pos = name.find('\\');
02164               // Finds ..\src\ ;
02165               dir_pos = name.find(src_pos+1, '\\') + 1;
02166               // Finds ..\src\..\astro\ ;
02167               file_pos = name.find_last_of('\\');
02168               
02169               // Debug only
02170               //printf("%40s, %i, %i, %i;\n", name src_pos, dir_pos, file_pos);
02171               // If dir_pos == file_pos, then we have ../src/filename.cxx
02172               // If dir_pos >  file_pos, then we have ../filename.cxx or something odd.
02173                            
02174               // Step 2: see if it is or is not a ../src/ directory.
02175               if ((dir_pos < file_pos) && (dir_pos > src_pos))
02176                 {
02177                   new_dir = name.substr (dir_pos, file_pos-dir_pos);
02178                   new_dir.replace( "..\\", ""); // All names are relative to package/Visual,
02179                                                 // so we want to ditch the prevailing ..\ ;
02180                                                 // which all of them have.
02181                 }
02182               else
02183                 {
02184                   new_dir = "Source Files NN";
02185                 }
02186 
02187               // Step 3: Add directory structure to vcproj file.
02188               if (new_dir != directory) // Detects a change in directory
02189                 {
02190                   directory = new_dir;
02191                   // Step 3a: Add a </Filter> when neccessary.
02192                   if (need_trailer == false)
02193                     {
02194                       // Ensure that no trailing </Filter> is placed incorrectly.
02195                       need_trailer = true;
02196                     }
02197                   else
02198                     {
02199                       vcproj_directory_trailer_fragment.wincopy (m_output_file,
02200                                                                  constituent.variables, 1,
02201                                                                  &m_PACKAGE);
02202                     }
02203 
02204                   // Step 3b: Add a <Filter> when neccessary.
02205                   if ((dir_pos < file_pos) && (dir_pos > src_pos))
02206                     {
02207                       // Add <Filter Name="directory">
02208                       m_DIRNAME = new_dir;
02209                       vcproj_directory_header_fragment.wincopy (m_output_file, constituent.variables, 2,
02210                                                                 &m_PACKAGE,
02211                                                                 &m_DIRNAME);
02212                     }
02213                   else
02214                     {
02215                       // Ensure that no </Filter> is placed incorrectly.
02216                       // This is the case of the file being in ../src 
02217                       // which requires no directory. Thus no filter start or end tag is needed.
02218 
02219                       need_trailer = false;
02220                     }
02221                 }
02222 
02223               if (m_output_file != NULL)
02224                 {
02225                   vcproj_contents_fragment.wincopy (m_output_file, constituent.variables, 2,
02226                                                     &m_PACKAGE,
02227                                                     &m_FULLNAME);
02228                 }
02229             }
02230         }
02231     }
02232 
02233   if (need_trailer == true)
02234     {
02235       // Add a trailing </Filter> for directory support.
02236       vcproj_directory_trailer_fragment.wincopy (m_output_file, constituent.variables, 1,
02237                                                  &m_PACKAGE);
02238     }
02239 
02240   if (m_output_file != NULL)
02241     {
02242       vcproj_trailer_fragment.wincopy (m_output_file, constituent.variables, 3,
02243                                        &m_PACKAGE,
02244                                        &m_CONSTITUENT,
02245                                        &m_CONSTITUENTSUFFIX);
02246 
02247       terminate ();
02248     }
02249 
02250   return (0);
02251 }

int VSNETGenerator::build_workspace const Constituent::ConstituentVector constituents  ) 
 

Definition at line 1896 of file cmt_generators.cxx.

References Constituent::ConstituentVector, Library, Constituent::name, pseudoGUID(), reset(), cmt_vector< T >::size(), Constituent::suffix, CmtGenerator::terminate(), Constituent::type, and Constituent::variables.

Referenced by Generator::build_vsnet_workspace().

01897 {
01898   reset ();
01899 
01900   const cmt_string& package = Cmt::get_current_package ();
01901   
01902   m_output_file_name = vsnetdir + package + ".slnnew";
01903   
01904   Variable PACKAGE_GUID ("PACKAGE_GUID");
01905   Variable CONSTITUENT_GUID ("CONSTITUENT_GUID");
01906   Variable NUMBER ("NUMBER");
01907   
01908   cmt_string guid;
01909   pseudoGUID (package, Cmt::get_current_version(), "", guid);
01910   PACKAGE_GUID = guid;
01911   
01912   m_output_file = fopen (m_output_file_name.c_str (), "wb");
01913   
01914   if (m_output_file != NULL)
01915     {
01916       m_PACKAGE = package;
01917       sln_header_fragment.wincopy (m_output_file, 2, 
01918                                    &m_PACKAGE,
01919                                    &PACKAGE_GUID);
01920       
01921       int i;
01922       
01923       for (i = 0; i < constituents.size (); i++)
01924         {
01925           const Constituent& constituent = constituents[i];
01926           
01927           pseudoGUID (package, Cmt::get_current_version(), constituent.name, guid);
01928           CONSTITUENT_GUID = guid;
01929           
01930           if (constituent.type == Library)
01931             {
01932               m_CONSTITUENT = constituent.name;
01933               m_CONSTITUENTSUFFIX = constituent.suffix;
01934               sln_project_fragment.wincopy (m_output_file,
01935                                             constituent.variables, 4,
01936                                             &m_PACKAGE,
01937                                             &m_CONSTITUENT,
01938                                             &PACKAGE_GUID,
01939                                             &CONSTITUENT_GUID);
01940             }
01941           else
01942             {
01943               m_CONSTITUENT = constituent.name;
01944               m_CONSTITUENTSUFFIX = constituent.suffix;
01945               sln_project_fragment.wincopy (m_output_file, constituent.variables, 4,
01946                                             &m_PACKAGE,
01947                                             &m_CONSTITUENT,
01948                                             &PACKAGE_GUID,
01949                                             &CONSTITUENT_GUID);
01950             }
01951         }
01952       
01953       sln_dependency_header_fragment.wincopy (m_output_file,
01954                                               1, &m_PACKAGE);
01955       
01956       for (i = 0; i < constituents.size (); i++)
01957         {
01958           const Constituent& constituent = constituents[i];
01959           pseudoGUID (package, Cmt::get_current_version(), constituent.name, guid);
01960           CONSTITUENT_GUID = guid;
01961           
01962           cmt_string num;
01963           num = (char)('0' + i);
01964           NUMBER = num;
01965           if (constituent.type == Library)
01966             {
01967               m_CONSTITUENT = constituent.name;
01968               m_CONSTITUENTSUFFIX = constituent.suffix;
01969               
01970               sln_dependency_project_fragment.wincopy (m_output_file, constituent.variables, 5,
01971                                                        &m_PACKAGE,
01972                                                        &m_CONSTITUENT,
01973                                                        &PACKAGE_GUID,
01974                                                        &CONSTITUENT_GUID,
01975                                                        &NUMBER);
01976             }
01977           else
01978             {
01979               m_CONSTITUENT = constituent.name;
01980               m_CONSTITUENTSUFFIX = constituent.suffix;
01981               sln_dependency_project_fragment.wincopy (m_output_file, constituent.variables, 5,
01982                                                        &m_PACKAGE,
01983                                                        &m_CONSTITUENT,
01984                                                        &PACKAGE_GUID,
01985                                                        &CONSTITUENT_GUID, 
01986                                                        &NUMBER);
01987             }
01988         }
01989       
01990       sln_dependency_trailer_fragment.wincopy (m_output_file,
01991                                                1, &m_PACKAGE);
01992       
01993       for (i = 0; i < constituents.size (); i++)
01994         {
01995           const Constituent& constituent = constituents[i];
01996           pseudoGUID (package, Cmt::get_current_version(), constituent.name, guid);
01997           CONSTITUENT_GUID = guid;
01998           
01999           if (constituent.type == Library)
02000             {
02001               m_CONSTITUENT = constituent.name;
02002               m_CONSTITUENTSUFFIX = constituent.suffix;
02003               sln_project_config_fragment.wincopy (m_output_file,
02004                                                    constituent.variables, 3,
02005                                                    &m_PACKAGE,
02006                                                    &m_CONSTITUENT,
02007                                                    &CONSTITUENT_GUID);
02008             }
02009           else
02010             {
02011               m_CONSTITUENT = constituent.name;
02012               m_CONSTITUENTSUFFIX = constituent.suffix;
02013               sln_project_config_fragment.wincopy (m_output_file, constituent.variables, 3,
02014                                                    &m_PACKAGE,
02015                                                    &m_CONSTITUENT,
02016                                                    &CONSTITUENT_GUID);
02017             }
02018         }
02019       
02020       sln_trailer_fragment.wincopy (m_output_file, 1, &m_PACKAGE);
02021 
02022       terminate ();
02023     }
02024   
02025   m_output_file_name = vsnetdir + "all.vcprojnew";
02026   
02027   m_output_file = fopen (m_output_file_name.c_str (), "wb");
02028   if (m_output_file != NULL)
02029     {
02030       vcproj_all_fragment.wincopy (m_output_file, 1, &m_PACKAGE);
02031 
02032       terminate ();
02033     }
02034   
02035   return (0);
02036 }

void VSNETGenerator::pseudoGUID const cmt_string a,
const cmt_string b,
const cmt_string c,
cmt_string d
[private]
 

Definition at line 1869 of file cmt_generators.cxx.

References cmt_string::size().

Referenced by build_project(), and build_workspace().

01873 {
01874   char buf[64]; // make the guid in here
01875   static char hex[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
01876   int k = 0;
01877   int i;
01878 
01879   for (i = 0; (i < c.size()) && (k < sizeof(buf)); ++i, ++k) buf[k] = c[i];
01880   for (i = 0; (i < a.size()) && (k < sizeof(buf)); ++i, ++k) buf[k] = a[i];
01881   for (i = 0; (i < b.size()) && (k < sizeof(buf)); ++i, ++k) buf[k] = b[i];
01882   for (; k < sizeof(buf); ++k) buf[k] = 0;
01883 
01884   // now use the buffer to format the output string
01885   // example: {3FE091FC-3738-4F2E-9723-E846B43F77AB}
01886   d = '{';
01887   k = 0;
01888 
01889   for (i = 0; i < 4; ++i, ++k) { d += hex[buf[k]&15]; d += hex[buf[k] >> 4]; } d += '-';
01890   for (i = 0; i < 2; ++i, ++k) { d += hex[buf[k]&15]; d += hex[buf[k] >> 4]; } d += '-';
01891   for (i = 0; i < 2; ++i, ++k) { d += hex[buf[k]&15]; d += hex[buf[k] >> 4]; } d += '-';
01892   for (i = 0; i < 2; ++i, ++k) { d += hex[buf[k]&15]; d += hex[buf[k] >> 4]; } d += '-';
01893   for (i = 0; i < 6; ++i, ++k) { d += hex[buf[k]&15]; d += hex[buf[k] >> 4]; } d += '}';
01894 }

void VSNETGenerator::reset  )  [private]
 

Reimplemented from CmtGenerator.

Definition at line 1837 of file cmt_generators.cxx.

References CmtSystem::cd(), CmtSystem::current_branch(), CmtSystem::file_separator(), CmtSystem::mkdir(), CmtGenerator::reset(), CmtSystem::test_directory(), and vsnetdir.

Referenced by build_project(), and build_workspace().

01838 {
01839   CmtGenerator::reset ();
01840 
01841   CmtSystem::cd (Cmt::get_current_dir ());
01842 
01843   cmt_string branch = CmtSystem::current_branch ();
01844 
01845   if ((branch == "mgr") || (branch == "cmt"))
01846     {
01847 #ifdef WIN32
01848       vsnetdir = "..";
01849       vsnetdir += CmtSystem::file_separator ();
01850       vsnetdir += "Visual";
01851       
01852       if (!CmtSystem::test_directory (vsnetdir))
01853         {
01854           CmtSystem::mkdir (vsnetdir);
01855         }
01856       
01857       vsnetdir += CmtSystem::file_separator ();
01858 #endif
01859     }
01860   else
01861     {
01862 #ifdef WIN32
01863       vsnetdir = ".";
01864       vsnetdir += CmtSystem::file_separator ();
01865 #endif
01866     }
01867 }


Member Data Documentation

FragmentHandle VSNETGenerator::sln_dependency_header_fragment [private]
 

Definition at line 164 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::sln_dependency_project_fragment [private]
 

Definition at line 165 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::sln_dependency_trailer_fragment [private]
 

Definition at line 166 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::sln_header_fragment [private]
 

Definition at line 162 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::sln_project_config_fragment [private]
 

Definition at line 167 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::sln_project_fragment [private]
 

Definition at line 163 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::sln_trailer_fragment [private]
 

Definition at line 168 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::vcproj_all_fragment [private]
 

Definition at line 170 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::vcproj_application_header_fragment [private]
 

Definition at line 172 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::vcproj_contents_fragment [private]
 

Definition at line 174 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::vcproj_directory_header_fragment [private]
 

Definition at line 175 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::vcproj_directory_trailer_fragment [private]
 

Definition at line 176 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::vcproj_library_header_fragment [private]
 

Definition at line 171 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::vcproj_trailer_fragment [private]
 

Definition at line 177 of file cmt_generators.h.

Referenced by VSNETGenerator().

FragmentHandle VSNETGenerator::vcproj_windows_header_fragment [private]
 

Definition at line 173 of file cmt_generators.h.

Referenced by VSNETGenerator().

cmt_string VSNETGenerator::vsnetdir [private]
 

Definition at line 159 of file cmt_generators.h.

Referenced by reset().


The documentation for this class was generated from the following files:
Generated on Mon May 2 10:26:06 2005 for CMT by doxygen 1.3.5