Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Generator Class Reference

#include <cmt_generator.h>

List of all members.

Static Public Methods

int build_msdev_workspace (const Constituent::ConstituentVector& constituents)
int build_msdev (const Constituent& constituent)
void build_make_setup (const cmt_string& package)
void build_constituents_makefile (const cmt_string& package)
int build_constituent_makefile (const Constituent& constituent)
void build_constituent_makefile (const cmt_string& name)
void build_default_makefile ()
cmt_string build_dependencies (const cmt_string& file_name)
void build_dependencies (const cmt_string& name, int argc, char* argv[])
void build_prototype (const cmt_string& file_name)
void build_readme (const CmtSystem::cmt_string_vector& arguments)
void build_windefs (const cmt_string& library_name)
void commit (const cmt_string& name)
void check (const cmt_string& name)


Member Function Documentation

void Generator::build_constituent_makefile ( const cmt_string & name ) [static]
 

Definition at line 2208 of file cmt_generator.cxx.

02209 {
02210   const Constituent* constituent = Constituent::find (name);
02211   if (constituent != 0) build_constituent_makefile (*constituent);
02212 }

int Generator::build_constituent_makefile ( const Constituent & constituent ) [static]
 

Definition at line 2124 of file cmt_generator.cxx.

Referenced by build_constituent_makefile(), Constituent::build_makefile(), and Cmt::do_build_constituent_makefile().

02125 {
02126   Context.reset ();
02127 
02128   const cmt_string& package = Cmt::get_current_package ();
02129 
02130   int i;
02131 
02132   PACKAGE = package;
02133   CONSTITUENT = constituent.name;
02134   CONSTITUENTSUFFIX = constituent.suffix;
02135 
02136   for (i = 0; i < constituent.includes.size (); i++)
02137     {
02138       const cmt_string& include = constituent.includes[i];
02139       Context.PACKINCLUDES += " -I" + include;
02140     }
02141 
02142   switch (constituent.type)
02143     {
02144     case Application:
02145       Context.is_library = false;
02146       Context.is_application = true;
02147       Context.is_document = false;
02148       TITLE = "Application";
02149       break;
02150     case Library:
02151       Context.is_library = true;
02152       Context.is_application = false;
02153       Context.is_document = false;
02154       TITLE = "Library";
02155       break;
02156     case Document:
02157       Context.is_library = false;
02158       Context.is_application = false;
02159       Context.is_document = true;
02160       Context.GENERATOR = constituent.generator;
02161       TITLE = "Document";
02162       break;
02163     }
02164 
02165   Context.PACKOS9 = constituent.need_OS9;
02166 
02167   cmt_string output = Context.cmtdir + CONSTITUENT + ".";
02168 
02169   if (Cmt::build_nmake ())
02170     {
02171       output += "nmake";
02172     }
02173   else
02174     {
02175       output += "make";
02176     }
02177   
02178   output += "new";
02179 
02180 
02181   Context.output_file = fopen (output.c_str (), "wb");
02182   if (Context.output_file != NULL)
02183     {
02184       if (Context.is_library)
02185         {
02186           Context.build_library_makefile (package, constituent);
02187         }
02188       else if (Context.is_application)
02189         {
02190           Context.build_application_makefile (package, constituent);
02191         }
02192       else if (Context.is_document)
02193         {
02194           Context.build_document_makefile (package, constituent);
02195         }
02196 
02197       fclose (Context.output_file);
02198 
02199       //--- Complete the operation --------------
02200 
02201       commit (output);
02202     }
02203 
02204   return (0);
02205 }

void Generator::build_constituents_makefile ( const cmt_string & package ) [static]
 

Definition at line 2041 of file cmt_generator.cxx.

Referenced by Cmt::do_build_constituents_makefile().

02042 {
02043   Context.reset ();
02044   cmt_string file_name = "constituents.";
02045 
02046   //--- Build the constituents fragment -----
02047 
02048   if (Cmt::build_nmake ())
02049     {
02050       file_name += "nmake";
02051     }
02052   else
02053     {
02054       file_name += "make";
02055     }
02056 
02057   cmt_string save_file_name = file_name;
02058   save_file_name += "sav";
02059 
02060   if (CmtSystem::test_file (file_name))
02061     {
02062       rename (file_name, save_file_name);
02063     }
02064 
02065   cmt_string new_file_name = file_name;
02066   new_file_name += "new";
02067 
02068   FILE* output_file = fopen (new_file_name, "wb");
02069   if (output_file != NULL)
02070     {
02071       int number;
02072       const Constituent::ConstituentVector&
02073         constituents = Constituent::constituents ();
02074 
02075       PACKAGE = package;
02076 
02077       constituents_header_fragment.copy (output_file, 1, &PACKAGE);
02078 
02079       GROUP = "all";
02080       group_fragment.copy (output_file, 1, &GROUP);
02081 
02082       const Group::GroupVector& groups = Group::groups ();
02083 
02084       for (number = 0; number < groups.size (); number++)
02085         {
02086           const Group& group = groups[number];
02087 
02088           GROUP = group.name ();
02089 
02090           group_fragment.copy (output_file, 1, &GROUP);
02091         }
02092       
02093       for (number = 0; number < constituents.size (); number++)
02094         {
02095           const Constituent& constituent = constituents[number];
02096 
02097           CONSTITUENT = constituent.name;
02098           CONSTITUENTSUFFIX = constituent.suffix;
02099 
02100           LINE = "";
02101 
02102           const CmtSystem::cmt_string_vector& sources = constituent.modules;
02103 
02104           constituent_fragment.copy (output_file, constituent.variables, 3, 
02105                                      &CONSTITUENT, &CONSTITUENTSUFFIX, &LINE);
02106 
02107           if (constituent.need_check)
02108             {
02109               check_application_header_fragment.copy (output_file, 
02110                                                       constituent.variables, 2,
02111                                                       &CONSTITUENT, &CONSTITUENTSUFFIX);
02112             }
02113         }
02114 
02115       constituents_trailer_fragment.copy (output_file, 0);
02116 
02117       fclose (output_file);
02118 
02119       commit (new_file_name);
02120     }
02121 }

void Generator::build_default_makefile ( ) [static]
 

Definition at line 2215 of file cmt_generator.cxx.

Referenced by Cmt::do_config(), and Cmt::do_create().

02216 {
02217   cmt_string makefile;
02218 
02219   //--- Build a simple Makefile if none is installed
02220 
02221 #ifndef WIN32
02222 
02223   bool need_makefile = false;
02224 
02225   makefile = Context.cmtdir + "Makefile";
02226 
02227   if (!CmtSystem::test_file (makefile))
02228     {
02229       need_makefile = true;
02230     }
02231   else
02232     {
02233       static cmt_string s;
02234 
02235       s.read (makefile);
02236       if ((s.find ("METHODSROOT") != cmt_string::npos) ||
02237           (s.find ("$(CMTROOT)/src/constituents.make") == cmt_string::npos))
02238         {
02239           static cmt_string backup = makefile;
02240           backup += "_backup";
02241 
02242           makefile += ".cmt";
02243 
02244           if (!CmtSystem::test_file (makefile))
02245             {
02246               FILE* file = fopen (backup.c_str (), "wb");
02247               if (file != NULL)
02248                 {
02249                   cout << "# " << endl;
02250                   cout << "#CMT> Warning !!! " << endl;
02251                   cout << "# A Makefile already exists "
02252                     "but it does not provides " << endl;
02253                   cout << "# the recommended features "
02254                     "for a full benefit of CMT" << endl;
02255                   cout << "# " << endl;
02256                   cout << "# CMT is now building "
02257                     "a new 'Makefile.cmt' which you can use" << endl;
02258                   cout << "# to upgrade your current one." << endl;
02259                   cout << "# " << endl;
02260 
02261                   s.write (file);
02262                   fclose (file);
02263 
02264                   need_makefile = true;
02265                 }
02266             }
02267         }
02268     }
02269 
02270   if (need_makefile)
02271     {
02272       FILE* file = fopen (makefile.c_str (), "wb");
02273       if (file != NULL)
02274         {
02275           fprintf (file, "include $(CMTROOT)/src/Makefile.header\n");
02276           fprintf (file, "\n");
02277           fprintf (file, "include $(CMTROOT)/src/constituents.make\n");
02278           fprintf (file, "\n");
02279           fclose (file);
02280         }
02281     }
02282 
02283 #endif
02284 
02285 #ifdef WIN32
02286 
02287   makefile = Context.cmtdir + "NMake";
02288 
02289   if (!CmtSystem::test_file (makefile))
02290     {
02291       FILE* file = fopen (makefile.c_str (), "wb");
02292       if (file != NULL)
02293         {
02294           fprintf (file, "!include $(CMTROOT)\\src\\NMakefile.header\n");
02295           fprintf (file, "\n");
02296           fprintf (file, "!include $(CMTROOT)\\src\\constituents.nmake\n");
02297           fprintf (file, "\n");
02298           fclose (file);
02299         }
02300     }
02301 
02302 #endif
02303 
02304 }

void Generator::build_dependencies ( const cmt_string & name,
int argc,
char * argv[] ) [static]
 

Definition at line 2485 of file cmt_generator.cxx.

02487 {
02488   Context.reset ();
02489   Context.prepare_use_context ();
02490 
02491   const Constituent* constituent_ptr = Constituent::find (name);
02492   if (constituent_ptr == 0)
02493     {
02494       // Error : wrong constituent name...
02495       return;
02496     }
02497 
02498   const Constituent& constituent = *constituent_ptr;
02499 
02500   cmt_string file_name;
02501   cmt_string full_name;
02502   cmt_string compressed_name;
02503   cmt_string suffix;
02504   cmt_string dependencies;
02505 
02506   static cmt_string output_name;
02507 
02508   cmt_string branch = CmtSystem::current_branch ();
02509 
02510   if ((branch == "mgr") || (branch == "cmt"))
02511     {
02512       Use& current_use = Use::current ();
02513 
02514       if (current_use.package == "CMT")
02515         {
02516           output_name = "../";
02517           output_name += CmtSystem::getenv ("CMTBIN");
02518           output_name += CmtSystem::file_separator ();
02519         }
02520       else
02521         {
02522           output_name = "${bin}";
02523         }
02524 
02525       Symbol::expand (output_name);
02526 
02527       //cerr << "output_name=" << output_name << endl;
02528       //cerr << "current_tag=" << Cmt::current_tag << endl;
02529     }
02530 
02531   output_name += name;
02532   output_name += "_";
02533   output_name += "dependencies.";
02534   if (Cmt::build_nmake ())
02535     {
02536       output_name += "nmake";
02537     }
02538   else
02539     {
02540       output_name += "make";
02541     }
02542 
02543   static DependencyFilter filter;
02544 
02545   dependencies.read (output_name);
02546 
02547   filter.run (dependencies);
02548 
02549   //
02550   // Scan the sources.
02551   //
02552 
02553     //
02554     //  We have to rebuild the dependencies for :
02555     //
02556     //   o all sources if the parameter -all_sources has been received
02557     //   o otherwise,
02558     //      + all source names provided in the argument list (if any)
02559     //      + all source names missing from the existing dependency file (if any)
02560     //
02561 
02562   const CmtSystem::cmt_string_vector& sources = constituent.modules;
02563   bool all_sources = false;
02564 
02565   int source_number = argc;
02566   int i;
02567 
02568   for (i = argc-1; i >= 0; i--)
02569     {
02570       file_name = argv[i];
02571 
02572         // Get rid of files that may come from the makefile fragment
02573       if (file_name.find ("requirements") != cmt_string::npos) source_number--;
02574       else if (file_name.find (".make") != cmt_string::npos) source_number--;
02575       else if (file_name == "-all_sources") 
02576         {
02577           source_number = sources.size ();
02578           all_sources = true;
02579         }
02580     }
02581 
02582 
02583   if (all_sources)
02584     {
02585       for (i = 0; i < sources.size (); i++)
02586         {
02587           file_name = sources[i];
02588           
02589           Context.set_full_name (full_name, file_name);
02590           if (full_name == "") continue;
02591 
02592           CmtSystem::compress_path (full_name, compressed_name);
02593           full_name = compressed_name;
02594           
02595           static CmtSystem::cmt_string_vector files;
02596 
02597           get_all_files (full_name, files);
02598 
02599           for (int j = 0; j < files.size (); j++)
02600             {
02601               const cmt_string& name = files[j];
02602               
02603               if (name != "") 
02604                 {
02605                   const cmt_string& line = build_dependencies (name);
02606                   
02607                     //cout << ">>> name1=" << name << endl;
02608                   
02609                   add_line_to_text (line, dependencies);
02610                 }
02611             }
02612         }
02613     }
02614   else
02615     {
02616       for (i = 0; i < source_number; i++)
02617         {
02618           file_name = argv[i];
02619           
02620           Context.set_full_name (full_name, file_name);
02621           if (full_name == "") continue;
02622 
02623           CmtSystem::compress_path (full_name, compressed_name);
02624           full_name = compressed_name;
02625           
02626           const cmt_string& line = build_dependencies (full_name);
02627                   
02628             //cout << ">>> name2=" << full_name << endl;
02629                   
02630           add_line_to_text (line, dependencies);
02631 
02632             //cout << ">>from deps : " << filter.get_sources () << endl;
02633           filter.add_source (full_name);
02634 
02635         }
02636 
02637         //cout << ">>from deps : " << filter.get_sources () << endl;
02638 
02639         // Now : are there still any missing source file in dependencies??
02640 
02641       for (i = 0; i < sources.size (); i++)
02642         {
02643           file_name = sources[i];
02644           
02645           Context.set_full_name (full_name, file_name);
02646           if (full_name == "") continue;
02647           
02648           CmtSystem::compress_path (full_name, compressed_name);
02649           full_name = compressed_name;
02650           
02651           static CmtSystem::cmt_string_vector files;
02652           
02653           get_all_files (full_name, files);
02654 
02655           for (int j = 0; j < files.size (); j++)
02656             {
02657               const cmt_string& name = files[j];
02658               
02659               if (name != "") 
02660                 {
02661                   if (!filter.has_source (name))
02662                     {
02663                       const cmt_string& line = build_dependencies (name);
02664                   
02665                         //cout << ">>> name3=" << name << endl;
02666                   
02667                       add_line_to_text (line, dependencies);
02668                     }
02669                 }
02670             }
02671         }
02672     }
02673 
02674   FILE* f = fopen (output_name.c_str (), "wb");
02675 
02676   if (f == 0)
02677     {
02678       cerr << "Cannot open " << output_name << " for write" << endl;
02679     }
02680   else
02681     {
02682       dependencies.write (f);
02683       fclose (f);
02684     }
02685 }

cmt_string Generator::build_dependencies ( const cmt_string & file_name ) [static]
 

Definition at line 2307 of file cmt_generator.cxx.

Referenced by build_dependencies(), and Cmt::do_build_dependencies().

02308 {
02309   static cmt_string full_name;
02310   static cmt_string suffix;
02311   static cmt_string name;
02312   static cmt_string line;
02313 
02314   full_name = "";
02315   line = "";
02316 
02317   if (!CmtSystem::absolute_path (file_name))
02318     {
02319       full_name = Context.srcdir;
02320     }
02321 
02322   full_name += file_name;
02323 
02324   CmtSystem::get_dot_suffix (full_name, suffix);
02325   CmtSystem::basename (full_name, suffix, name);
02326   CmtSystem::get_suffix (full_name, suffix);
02327 
02328   if (name == "requirements") return (line);
02329 
02330   const CmtSystem::cmt_string_vector& deps = Context.deps_builder.run (full_name);
02331 
02332   line  = name;
02333   line += "_";
02334   line += suffix;
02335   line += "_dependencies = ";
02336   line += full_name;
02337   line += " ";
02338 
02339   for (int j = 0; j < deps.size (); j++)
02340     {
02341       line += deps[j];
02342       line += " ";
02343     }
02344 
02345   filter_paths (line);
02346 
02347   return (line);
02348 }

void Generator::build_make_setup ( const cmt_string & package ) [static]
 

Definition at line 1915 of file cmt_generator.cxx.

Referenced by Cmt::do_build_make_setup().

01916 {
01917   Context.reset ();
01918 
01919   PACKAGE = package;
01920 
01921   FILE* output_file;
01922 
01923   cmt_string file_name = "setup.";
01924 
01925   if (Cmt::build_nmake ())
01926     {
01927       file_name += "nmake";
01928     }
01929   else
01930     {
01931       file_name += "make";
01932     }
01933   
01934   cmt_string new_file_name = file_name;
01935   new_file_name += "new";
01936 
01937   output_file = fopen (new_file_name, "wb");
01938 
01939   if (output_file != NULL)
01940     {
01941       int number;
01942       const Use::UsePtrVector& uses = Use::uses ();
01943       const Constituent::ConstituentVector& constituents =
01944         Constituent::constituents ();
01945       cmt_string temp;
01946 
01947       make_setup_header_fragment.copy (output_file, 1, &PACKAGE);
01948 
01949       for (number = 0; number < uses.size (); number++)
01950         {
01951           const Use* use = uses[number];
01952 
01953           if (use->discarded) continue;
01954 
01955           if (use->real_path != "")
01956             {
01957               temp  = use->prefix;
01958               temp += "ROOT = ";
01959               temp += use->real_path;
01960               temp += SLASH;
01961               temp += use->package;
01962               temp += SLASH;
01963               temp += use->version;
01964 
01965               fprintf (output_file, "%s\n", temp.c_str());
01966             }
01967         }
01968 
01969       temp  = "use_requirements = ";
01970       temp += "requirements ";
01971 
01972       for (number = 0; number < uses.size (); number++)
01973         {
01974           const Use* use = uses[number];
01975 
01976           if (use->discarded) continue;
01977 
01978           if (use->real_path != "")
01979             {
01980               temp += "$(";
01981               temp += use->prefix;
01982               temp += "ROOT)";
01983               temp += CmtSystem::file_separator ();
01984               switch (use->style)
01985                 {
01986                 case cmt_style:
01987                   temp += "cmt";
01988                   break;
01989                 case mgr_style:
01990                   temp += "mgr";
01991                   break;
01992                 }
01993               temp += CmtSystem::file_separator ();
01994               temp += "requirements ";
01995             }
01996         }
01997 
01998       fprintf (output_file, "%s\n", temp.c_str());
01999 
02000       temp  = "constituents = $(constituents)";
02001       Symbol::expand (temp);
02002 
02003       fprintf (output_file, "%s\n", temp.c_str());
02004 
02005       make_setup_fragment.copy (output_file, 1, &PACKAGE);
02006 
02007       fclose (output_file);
02008 
02009       //--- Complete the operation --------------
02010 
02011       commit (new_file_name);
02012     }
02013 
02014   /*
02015     for option in $*
02016     do
02017     case ${option} in
02018     args-tag=*)
02019     tag=${option}
02020     tag=`echo "${tag}" | sed -e 's/args.tag=//'`
02021     ;;
02022     -tag=*)
02023     tag=args${option}
02024     tag=`echo "${tag}" | sed -e 's/args.tag=//'`
02025     ;;
02026     esac
02027     done
02028 
02029     if test "${tag}" = "" ; then
02030     tag=${CMTCONFIG}
02031     fi
02032 
02033     build_shell_setup_files ${tag}
02034 
02035     now=`date`
02036 
02037   */
02038 }

int Generator::build_msdev ( const Constituent & constituent ) [static]
 

Definition at line 1714 of file cmt_generator.cxx.

Referenced by Constituent::build_msdev_file().

01715 {
01716   Context.reset ();
01717 
01718   const cmt_string& package = Cmt::get_current_package ();
01719   static cmt_string file;
01720   static cmt_string full_name;
01721   static cmt_string suffix;
01722 
01723   int i;
01724 
01725   CONSTITUENT = constituent.name;
01726   CONSTITUENTSUFFIX = constituent.suffix;
01727 
01728   for (i = 0; i < constituent.includes.size (); i++)
01729     {
01730       const cmt_string& include = constituent.includes[i];
01731       Context.PACKINCLUDES += " -I" + include;
01732     }
01733 
01734   switch (constituent.type)
01735     {
01736     case Application:
01737       Context.is_application = true;
01738       TITLE = "Application";
01739       break;
01740     case Library:
01741       Context.is_library = true;
01742       TITLE = "Library";
01743       break;
01744     case Document:
01745       Context.is_document = true;
01746       Context.GENERATOR = constituent.generator;
01747       TITLE = "Document";
01748       break;
01749     }
01750 
01751   Context.PACKOS9 = constituent.need_OS9;
01752 
01753   const CmtSystem::cmt_string_vector& sources = constituent.modules;
01754 
01755   //--- Build the constituents fragment -----
01756   cmt_string output;
01757   cmt_string output_s;
01758 
01759   FILE* output_file = NULL;
01760   FILE* output_file_s = NULL;
01761 
01762   output = Context.msdevdir + CONSTITUENT + ".dspnew";
01763   output_file = fopen (output.c_str (), "wb");
01764 
01765   if ((output_file == NULL) && (output_file_s == NULL)) return (0);
01766 
01767   PACKAGE = package;
01768 
01769   if (Context.is_library)
01770     {
01771       if (constituent.no_share)
01772         {
01773           LIBRARYSUFFIX = "lib";
01774         }
01775       else
01776         {
01777           LIBRARYSUFFIX = "arc";
01778         }
01779 
01780       dsp_library_header_fragment.wincopy (output_file, constituent.variables, 4,
01781                                            &PACKAGE,
01782                                            &CONSTITUENT, 
01783                                            &CONSTITUENTSUFFIX, 
01784                                            &LIBRARYSUFFIX);
01785     }
01786   else
01787     {
01788       if (constituent.windows)
01789         {
01790           dsp_windows_header_fragment.wincopy (output_file, constituent.variables, 3,
01791                                                &PACKAGE,
01792                                                &CONSTITUENT, 
01793                                                &CONSTITUENTSUFFIX);
01794         }
01795       else
01796         {
01797           dsp_application_header_fragment.wincopy (output_file, constituent.variables, 3,
01798                                                    &PACKAGE,
01799                                                    &CONSTITUENT, 
01800                                                    &CONSTITUENTSUFFIX);
01801         }
01802     }
01803 
01804   for (i = 0; i < sources.size (); i++)
01805     {
01806       file = sources[i];
01807 
01808       Context.set_full_name (full_name, file);
01809       if (full_name == "") continue;
01810 
01811       static CmtSystem::cmt_string_vector files;
01812 
01813       get_all_files (full_name, files);
01814 
01815       for (int j = 0; j < files.size (); j++)
01816         {
01817           const cmt_string& name = files[j];
01818 
01819           if (name != "") 
01820             {
01821               FULLNAME = name;
01822 
01823               if (output_file != NULL)
01824                 {
01825                   dsp_contents_fragment.wincopy (output_file, constituent.variables, 2, 
01826                                                  &PACKAGE, 
01827                                                  &FULLNAME);
01828                 }
01829               if (output_file_s != NULL)
01830                 {
01831                   dsp_contents_fragment.wincopy (output_file_s, constituent.variables, 2, 
01832                                                  &PACKAGE,
01833                                                  &FULLNAME);
01834                 }
01835             }
01836         }
01837 
01838       /*
01839         CmtSystem::get_suffix (full_name, suffix);
01840 
01841         if (file.find ('*') != cmt_string::npos)
01842         {
01843         static CmtSystem::cmt_string_vector files;
01844 
01845         CmtSystem::scan_dir (full_name, files);
01846 
01847         if (Cmt::get_debug ())
01848         {
01849         cout << "CMT> full_name=" << full_name <<
01850         " pwd=" << CmtSystem::pwd () << endl;
01851         cout << "CMT> files.size=" <<  files.size () << endl;
01852         }
01853 
01854         for (int j = 0; j < files.size (); j++)
01855         {
01856         const cmt_string& nnn = files[j];
01857         static cmt_string sss;
01858 
01859         CmtSystem::get_suffix (nnn, sss);
01860         if (sss == suffix)
01861         {
01862         FULLNAME = nnn;
01863         if (output_file != NULL)
01864         {
01865         dsp_contents_fragment.wincopy (output_file,
01866         constituent.variables, 1, &FULLNAME);
01867         }
01868         if (output_file_s != NULL)
01869         {
01870         dsp_contents_fragment.wincopy (output_file_s,
01871         constituent.variables, 1, &FULLNAME);
01872         }
01873         }
01874         }
01875         }
01876         else
01877         {
01878         FULLNAME = full_name;
01879         if (output_file != NULL)
01880         {
01881         dsp_contents_fragment.wincopy (output_file, constituent.variables, 1, &FULLNAME);
01882         }
01883         if (output_file_s != NULL)
01884         {
01885         dsp_contents_fragment.wincopy (output_file_s, constituent.variables, 1, &FULLNAME);
01886         }
01887         }
01888       */
01889     }
01890 
01891   if (output_file != NULL)
01892     {
01893       dsp_trailer_fragment.wincopy (output_file, constituent.variables, 3,
01894                                     &PACKAGE,
01895                                     &CONSTITUENT, 
01896                                     &CONSTITUENTSUFFIX);
01897       fclose (output_file);
01898       commit (output);
01899     }
01900 
01901   if (output_file_s != NULL)
01902     {
01903       dsp_trailer_fragment.wincopy (output_file_s, constituent.variables, 3,
01904                                     &PACKAGE,
01905                                     &CONSTITUENT, 
01906                                     &CONSTITUENTSUFFIX);
01907       fclose (output_file_s);
01908       commit (output_s);
01909     }
01910 
01911   return (0);
01912 }

int Generator::build_msdev_workspace ( const Constituent::ConstituentVector & constituents ) [static]
 

Definition at line 1616 of file cmt_generator.cxx.

Referenced by Constituent::build_all_msdev_files().

01617 {
01618   Context.reset ();
01619 
01620   const cmt_string& package = Cmt::get_current_package ();
01621 
01622   cmt_string output = Context.msdevdir + package + ".dswnew";
01623 
01624   Context.output_file = fopen (output.c_str (), "wb");
01625   if (Context.output_file != NULL)
01626     {
01627       PACKAGE = package;
01628       dsw_header_fragment.wincopy (Context.output_file, 1, &PACKAGE);
01629 
01630       int i;
01631 
01632       dsw_all_project_header_fragment.wincopy (Context.output_file,
01633                                                1, &PACKAGE);
01634 
01635       for (i = 0; i < constituents.size (); i++)
01636         {
01637           const Constituent& constituent = constituents[i];
01638 
01639           if (constituent.type == Library)
01640             {
01641               CONSTITUENT = constituent.name;
01642               CONSTITUENTSUFFIX = constituent.suffix;
01643               dsw_all_project_dependency_fragment.wincopy (Context.output_file, constituent.variables, 3,
01644                                                            &PACKAGE,
01645                                                            &CONSTITUENT, 
01646                                                            &CONSTITUENTSUFFIX);
01647             }
01648           else
01649             {
01650               CONSTITUENT = constituent.name;
01651               CONSTITUENTSUFFIX = constituent.suffix;
01652               dsw_all_project_dependency_fragment.wincopy (Context.output_file, constituent.variables, 3,
01653                                                            &PACKAGE,
01654                                                            &CONSTITUENT, 
01655                                                            &CONSTITUENTSUFFIX);
01656             }
01657 
01658         }
01659 
01660       dsw_all_project_trailer_fragment.wincopy (Context.output_file,
01661                                                 1, &PACKAGE);
01662 
01663       for (i = 0; i < constituents.size (); i++)
01664         {
01665           const Constituent& constituent = constituents[i];
01666 
01667           if (constituent.type == Library)
01668             {
01669               CONSTITUENT = constituent.name;
01670               CONSTITUENTSUFFIX = constituent.suffix;
01671               dsw_project_fragment.wincopy (Context.output_file,
01672                                             constituent.variables, 3,
01673                                             &PACKAGE,
01674                                             &CONSTITUENT, 
01675                                             &CONSTITUENTSUFFIX);
01676             }
01677           else
01678             {
01679               CONSTITUENT = constituent.name;
01680               CONSTITUENTSUFFIX = constituent.suffix;
01681               dsw_project_fragment.wincopy (Context.output_file, constituent.variables, 3, 
01682                                             &PACKAGE,
01683                                             &CONSTITUENT, 
01684                                             &CONSTITUENTSUFFIX);
01685             }
01686         }
01687 
01688       dsw_trailer_fragment.wincopy (Context.output_file, 1, &PACKAGE);
01689 
01690       fclose (Context.output_file);
01691 
01692       //--- Complete the operation --------------
01693 
01694       commit (output);
01695     }
01696 
01697   output = Context.msdevdir + "all.dspnew";
01698 
01699   Context.output_file = fopen (output.c_str (), "wb");
01700   if (Context.output_file != NULL)
01701     {
01702       dsp_all_fragment.wincopy (Context.output_file, 1, &PACKAGE);
01703       fclose (Context.output_file);
01704 
01705       //--- Complete the operation --------------
01706 
01707       commit (output);
01708     }
01709 
01710   return (0);
01711 }

void Generator::build_prototype ( const cmt_string & file_name ) [static]
 

Definition at line 2849 of file cmt_generator.cxx.

Referenced by Cmt::do_build_prototype().

02850 {
02851   Prototyper prototyper;
02852 
02853   prototyper.run (file_name);
02854   /*
02855     static cmt_string pp;
02856     pp  = incdir;
02857     pp += name;
02858     pp += ".pp";
02859   */
02860 }

void Generator::build_readme ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2863 of file cmt_generator.cxx.

Referenced by Cmt::do_build_readme().

02864 {
02865   Context.reset ();
02866 
02867   PACKAGE = Cmt::get_current_package ();
02868   VERSION = Cmt::get_current_version ();
02869   DATE = CmtSystem::now ();
02870   USER = CmtSystem::user ();
02871 
02872   cmt_string url;
02873   cmt_string doc;
02874 
02875   for (int i = 0; i < arguments.size (); i++)
02876     {
02877       cmt_string arg = arguments[i];
02878 
02879       if (arg.substr (0, 5) == "-url=")
02880         {
02881           arg.substr (5, url);
02882         }
02883       else if (arg.substr (0, 5) == "-doc=")
02884         {
02885           arg.substr (5, doc);
02886         }
02887     }
02888 
02889   cmt_string output = Context.cmtdir + "README.html";
02890 
02891   Context.output_file = fopen (output.c_str (), "wb");
02892   if (Context.output_file != NULL)
02893     {
02894       readme_header_fragment.copy (Context.output_file, 2, &PACKAGE, &VERSION);
02895 
02896       if (doc != "")
02897         {
02898           DOCPATH = doc;
02899           readme_doc_fragment.copy (Context.output_file, 3, &PACKAGE, &VERSION, &DOCPATH);
02900         }
02901 
02902       readme_fragment.copy (Context.output_file, 2, &PACKAGE, &VERSION);
02903 
02904       int number;
02905       const Use::UsePtrVector& uses = Use::uses ();
02906 
02907       for (number = 0; number < uses.size (); number++)
02908         {
02909           const Use* use = uses[number];
02910           if (use->discarded) continue;
02911           if ((use != 0) && (use->package != "CMT"))
02912             {
02913               cmt_string selected_path;
02914 
02915               if (url == "")
02916                 {
02917                   selected_path = use->real_path;
02918 
02919                   if (use->specified_path != "")
02920                     {
02921                       int pos = selected_path.find_last_of (use->specified_path);
02922                       if (pos != cmt_string::npos)
02923                         {
02924                           selected_path.erase (pos);
02925                         }
02926                     }
02927                 }
02928               else
02929                 {
02930                   selected_path = url;
02931 
02932                   if (use->specified_path != "")
02933                     {
02934                       selected_path += CmtSystem::file_separator ();
02935                     }
02936                 }
02937 
02938               PACKAGEPATH = selected_path;
02939               PACKAGEPREFIX = use->specified_path;
02940               PACKAGE = use->package;
02941               VERSION = use->version;
02942               MGRSTYLE = (use->style == mgr_style) ? "mgr" : "cmt";
02943               readme_use_fragment.copy (Context.output_file, 5,
02944                                         &PACKAGEPATH,
02945                                         &PACKAGEPREFIX,
02946                                         &PACKAGE,
02947                                         &VERSION,
02948                                         &MGRSTYLE);
02949             }
02950         }
02951       PACKAGE = Cmt::get_current_package ();
02952       VERSION = Cmt::get_current_version ();
02953       readme_trailer_fragment.copy (Context.output_file, 4, 
02954                                     &PACKAGE, 
02955                                     &VERSION, 
02956                                     &DATE, 
02957                                     &USER);
02958     }
02959 }

void Generator::build_windefs ( const cmt_string & library_name ) [static]
 

Definition at line 3008 of file cmt_generator.cxx.

Referenced by Cmt::do_build_windefs().

03009 {
03010         cmt_string bin;
03011         cmt_string name;
03012         cmt_string suffix;
03013 
03014         CmtSystem::dirname (library_name, bin);
03015         CmtSystem::get_dot_suffix (library_name, suffix);
03016         CmtSystem::basename (library_name, suffix, name);
03017 
03018         if (!CmtSystem::cd (bin)) return;
03019         
03020         cmt_string text;
03021         cmt_string command;
03022         
03023         command = "dumpbin /symbols ";
03024         command += library_name;
03025         
03026         WinDefAwk filter (name);
03027         
03028         filter.run (command, "SECT");
03029 }

void Generator::check ( const cmt_string & name ) [static]
 

Definition at line 1590 of file cmt_generator.cxx.

Referenced by Prototyper::end().

01591 {
01592   static cmt_string old;
01593   static cmt_string backup;
01594 
01595   old = name;
01596 
01597   int pos = old.find_last_of ("new");
01598   old.erase (pos);
01599 
01600   if (!CmtSystem::compare_files (old, name))
01601     {
01602       backup = old;
01603       backup += "sav";
01604 
01605       unlink (backup.c_str ());
01606       rename (old.c_str (), backup.c_str ());
01607       rename (name.c_str (), old.c_str ());
01608     }
01609   else
01610     {
01611       unlink (name);
01612     }
01613 }

void Generator::commit ( const cmt_string & name ) [static]
 

Definition at line 1567 of file cmt_generator.cxx.

Referenced by build_constituent_makefile(), build_constituents_makefile(), build_make_setup(), build_msdev(), and build_msdev_workspace().

01568 {
01569   static cmt_string old;
01570   static cmt_string backup;
01571 
01572   old = name;
01573 
01574   int pos = old.find_last_of ("new");
01575   old.erase (pos);
01576 
01577   if (CmtSystem::test_file (old))
01578     {
01579       backup = old;
01580       backup += "sav";
01581 
01582       unlink (backup.c_str ());
01583       rename (old.c_str (), backup.c_str ());
01584     }
01585 
01586   rename (name.c_str (), old.c_str ());
01587 }


The documentation for this class was generated from the following files:
Generated at Thu Apr 11 16:50:44 2002 for CMT by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000