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

Cmt Class Reference

#include <cmt.h>

Collaboration diagram for Cmt:

Collaboration graph
[legend]
List of all members.

Static Public Methods

void build_config (const cmt_string& prefix, cmt_string& config)
 Append "CONFIG" to the prefix. More...

void build_makefile (const cmt_string& target)
void build_msdev_file (const cmt_string& target)
bool build_nmake ()
void build_OS9_makefile (const cmt_string& target)
void build_prefix (const cmt_string& package, cmt_string& prefix)
 Convert a package name to its upper case copy. More...

void clear ()
void configure ()
void configure_cmt_path (Use* use)
void configure_config_tag ()
void configure_current_dir ()
void configure_current_package ()
void configure_default_path ()
void configure_home (Use* use)
void configure_user_context (Use* use)
void configure_hosttype_tag ()
void configure_site_tag (Use* use)
void configure_tags (Use* use)
void configure_uname_tag ()
void do_broadcast (const CmtSystem::cmt_string_vector& arguments, int argc, char* argv[])
void do_build_constituent_makefile (const CmtSystem::cmt_string_vector& arguments, int argc, char* argv[])
void do_build_constituents_makefile (const CmtSystem::cmt_string_vector& arguments, int argc, char* argv[])
void do_build_dependencies (const CmtSystem::cmt_string_vector& arguments, int argc, char* argv[])
void do_build_library_links ()
void do_build_make_setup ()
 Here we expect that only the base name of the library is given : ie it should not contain the "lib" prefix, nor the suffix .so, nor any path prefix. More...

void do_build_msdev (const CmtSystem::cmt_string_vector& arguments)
void do_build_os9_makefile (const CmtSystem::cmt_string_vector& arguments)
void do_build_prototype (const CmtSystem::cmt_string_vector& arguments)
void do_build_readme (const CmtSystem::cmt_string_vector& arguments)
void do_build_tag_makefile ()
void do_build_temporary_name ()
void do_build_triggers (const CmtSystem::cmt_string_vector& arguments)
void do_build_windefs (const CmtSystem::cmt_string_vector& arguments)
void do_check_configuration ()
void do_check_files (const CmtSystem::cmt_string_vector& arguments)
void do_check_version (const CmtSystem::cmt_string_vector& arguments)
void do_checkout (const CmtSystem::cmt_string_vector& arguments)
void do_cleanup (PrintMode& mode)
void do_config ()
void do_create (const CmtSystem::cmt_string_vector& arguments)
void do_cvsbranches (const CmtSystem::cmt_string_vector& arguments)
void do_cvssubpackages (const CmtSystem::cmt_string_vector& arguments)
void do_cvstags (const CmtSystem::cmt_string_vector& arguments)
void do_expand_model (const CmtSystem::cmt_string_vector& arguments)
void do_filter (const CmtSystem::cmt_string_vector& arguments)
 Handle free filtering of text files containing or ${xxx} patterns. More...

void do_help ()
void do_lock (const cmt_string& package, const cmt_string& version, const cmt_string& path)
void do_remove (const cmt_string& package, const cmt_string& version, const cmt_string& path)
void do_remove_library_links ()
void do_run (const CmtSystem::cmt_string_vector& arguments)
 Here we expect that only the base name of the library is given : ie it should not contain the "lib" prefix, nor the suffix .so, nor any path prefix. More...

void do_setup (PrintMode& mode)
void do_show_applied_patterns ()
void do_show_author ()
void do_show_branches (PrintMode& mode)
void do_show_clients (const CmtSystem::cmt_string_vector& arguments)
void do_show_constituent (const CmtSystem::cmt_string_vector& arguments)
void do_show_constituent_names ()
void do_show_constituents ()
void do_show_fragment (const CmtSystem::cmt_string_vector& arguments)
void do_show_fragments ()
void do_show_groups ()
void do_show_include_dirs ()
void do_show_language (const CmtSystem::cmt_string_vector& arguments)
void do_show_languages ()
void do_show_macro (const CmtSystem::cmt_string_vector& arguments, PrintMode& mode)
void do_show_macro_value (const CmtSystem::cmt_string_vector& arguments, PrintMode& mode)
void do_show_macros (PrintMode& mode)
void do_show_manager ()
void do_show_packages (const CmtSystem::cmt_string_vector& arguments)
void do_show_path ()
void do_show_pattern (const CmtSystem::cmt_string_vector& arguments)
void do_show_pattern_names ()
void do_show_patterns ()
void do_show_pwd ()
void do_show_set (const CmtSystem::cmt_string_vector& arguments, PrintMode& mode)
void do_show_set_value (const CmtSystem::cmt_string_vector& arguments, PrintMode& mode)
void do_show_sets (PrintMode& mode)
void do_show_strategies ()
void do_show_tags ()
void do_show_uses ()
void do_show_version ()
void do_show_versions (const CmtSystem::cmt_string_vector& arguments)
void do_show_system ()
void do_unlock (const cmt_string& package, const cmt_string& version, const cmt_string& path)
void do_version ()
const cmt_stringfilter_dir (const cmt_string& dir)
ActionType get_action ()
const CmtSystem::cmt_string_vectorget_cmt_path ()
const cmt_stringget_cmt_home ()
const cmt_stringget_cmt_user_context ()
const cmt_stringget_current_dir ()
const cmt_stringget_current_package ()
AccessMode get_current_access ()
VersionStrategy get_current_strategy ()
const cmt_stringget_current_version ()
const cmt_stringget_current_target ()
bool get_debug ()
bool get_quiet ()
bool get_recursive ()
ScopeType get_scope ()
void install_cleanup_scripts ()
void install_setup_scripts ()
void install_test_cleanup_scripts ()
void install_test_setup_scripts ()
bool load (const cmt_string& path, const cmt_string& package, const cmt_string& version, const cmt_string& tag_name = "")
bool need_prototypes ()
 See reach_current_package for an explanation of this call. More...

void parse_arguments (int argc, char* argv[], CmtSystem::cmt_string_vector& arguments, cmt_string& extra_line, cmt_string& extra_file, PrintMode& mode)
void parse_requirements (const cmt_string& file_name, Use* use)
 Parse the input file, rejecting comments and rebuilding complete lines (from sections separated by \ characters. More...

void parse_requirements_line (const cmt_string& line, Use* use, const cmt_string& file_name = "", int line_number = 0)
 Apply the basic parser to one single line :. More...

void parse_requirements_text (const cmt_string& text, const cmt_string& file_name, Use* use)
 Parse a text, rejecting comments and rebuilding complete lines (from sections separated by \ characters. More...

int parser (const cmt_string& command_line)
int parser (int argc, char* argv[])
void print (PrintMode mode)
 Format as one single line a set of 'setenv' statements joined with semi-colons to form one shell command. More...

void print_clean (PrintMode mode)
void print_context (Use& use, PrintMode mode, const cmt_string& tag)
void print_macros (PrintMode mode)
 Format a set of make macro definitions (one per line) Each macro value is provided enclosed in single quotes. More...

void print_tabs (int tabs)
int reach_current_package ()
void restore_all_tags (Use* use)
void select (const CmtSystem::cmt_string_vector& words, Use* use, const cmt_string& file_name, int line_number)
 Parse a line reformatted into a set of words. More...

void set_standard_macros ()
void use_cmt ()
 Macros implied or required to manage constituents. More...

void use_home_requirements ()
void use_user_context_requirements ()
cmt_string vector_to_string (const CmtSystem::cmt_string_vector& v)
void vector_to_string (const CmtSystem::cmt_string_vector& v, const cmt_string& separator, cmt_string& result)

Static Private Attributes

ActionType m_action
 All Attributes are private. More...

bool m_build_nmake
cmt_string m_cmt_config
CmtSystem::cmt_string_vector m_cmt_path
CmtSystem::cmt_string_vector m_cmt_path_pwds
CmtSystem::cmt_string_vector m_cmt_path_sources
cmt_string m_cmt_root
cmt_string m_cmt_home
cmt_string m_cmt_user_context
cmt_string m_cmt_site
cmt_string m_cmt_version
int m_current_build_strategy = DefaultBuildStrategy
cmt_string m_current_dir
cmt_string m_current_package
cmt_string m_current_config
cmt_string m_current_path
cmt_string m_current_prefix
AccessMode m_current_access = UserMode
VersionStrategy m_current_strategy = BestFit
CmtDirStyle m_current_style = cmt_style
cmt_string m_current_tag
cmt_string m_current_target
cmt_string m_current_version
cmt_string m_extra_tags
cmt_string m_configure_error
bool m_debug
cmt_string m_default_path
cmt_string m_filtered_text
bool m_quiet
bool m_recursive
ScopeType m_scope
bool m_simulation
bool m_standard_macros_done

Member Function Documentation

void Cmt::build_OS9_makefile ( const cmt_string & target ) [static]
 

Definition at line 603 of file cmt_parser.cxx.

Referenced by do_build_os9_makefile().

00604 {
00605   build_makefile (target);
00606 }

void Cmt::build_config ( const cmt_string & prefix,
cmt_string & config ) [static]
 

Append "CONFIG" to the prefix.

Definition at line 533 of file cmt_parser.cxx.

Referenced by configure_current_package(), and load().

00535 {
00536   /*
00537     Building the config from <prefix> 
00538   */
00539 
00540   config = prefix;
00541   config += "CONFIG";
00542 }

void Cmt::build_makefile ( const cmt_string & target ) [static]
 

Definition at line 545 of file cmt_parser.cxx.

Referenced by build_OS9_makefile().

00546 {
00547   Constituent* constituent = 0;
00548 
00549   if (target.size () > 0)
00550     {
00551       /*
00552         Do genmake for one specific target.
00553       */
00554       constituent = Constituent::find (target);
00555       if (constituent != 0)
00556         {
00557           constituent->build_makefile (m_simulation);
00558         }
00559     }
00560   else
00561     {
00562       /*
00563         Do genmake for all possible targets.
00564       */
00565       Constituent::build_all_makefiles (m_simulation);
00566     }
00567 }

void Cmt::build_msdev_file ( const cmt_string & target ) [static]
 

Definition at line 570 of file cmt_parser.cxx.

Referenced by do_build_msdev().

00571 {
00572   Constituent* constituent = 0;
00573 
00574   set_standard_macros ();
00575 
00576   if (target != "")
00577     {
00578       /*
00579         Do genmsdev for one specific target.
00580       */
00581       constituent = Constituent::find (target);
00582       if (constituent != 0)
00583         {
00584           constituent->build_msdev_file (m_simulation);
00585         }
00586     }
00587   else
00588     {
00589       /*
00590         Do genmsdev for all possible targets.
00591       */
00592       Constituent::build_all_msdev_files (m_simulation);
00593     }
00594 }

bool Cmt::build_nmake ( ) [static]
 

Definition at line 597 of file cmt_parser.cxx.

Referenced by MakefileGenerator::analyze_file(), Generator::build_constituent_makefile(), Generator::build_constituents_makefile(), Generator::build_dependencies(), Generator::build_make_setup(), and Fragment::locate().

00598 {
00599   return (m_build_nmake);
00600 }

void Cmt::build_prefix ( const cmt_string & package,
cmt_string & prefix ) [static]
 

Convert a package name to its upper case copy.

Definition at line 611 of file cmt_parser.cxx.

Referenced by configure_current_package(), load(), select(), and Use::set().

00612 {
00613   int pos;
00614   char c;
00615 
00616   /*
00617     Building the prefix from <package> 
00618   */
00619 
00620   prefix = package;
00621 
00622   for (pos = 0; pos < package.size (); pos++)
00623     {
00624       c = package[pos];
00625       prefix[pos] = toupper (c);
00626     }
00627 }

void Cmt::clear ( ) [static]
 

Definition at line 630 of file cmt_parser.cxx.

Referenced by do_show_clients(), load(), and parser().

00631 {
00632   m_action         = action_none;
00633   m_build_nmake    = false;
00634   m_cmt_config     = "";
00635   m_cmt_path.clear ();
00636   m_cmt_path_pwds.clear ();
00637   m_cmt_path_sources.clear ();
00638   m_cmt_root       = "";
00639   m_cmt_version    = "";
00640   m_current_build_strategy = DefaultBuildStrategy;
00641   m_current_dir     = "";
00642   m_current_package = "";
00643   m_current_config  = "";
00644   m_current_path    = "";
00645   m_current_prefix  = "";
00646   m_current_access   = DeveloperMode;
00647   m_current_strategy = BestFit;
00648 
00649   m_current_tag      = "";
00650   m_current_target   = "";
00651   m_current_version  = "";
00652   m_default_path     = "";
00653   m_quiet            = false;
00654   m_recursive        = false;
00655 
00656   m_scope            = ScopePublic;
00657   m_simulation       = false;
00658 
00659   m_filtered_text    = "";
00660   m_standard_macros_done = false;
00661 
00662   Database::clear ();
00663   Include::clear_all ();
00664   Script::clear_all ();
00665   CmtError::clear ();
00666 }

void Cmt::configure ( ) [static]
 

Definition at line 669 of file cmt_parser.cxx.

Referenced by do_show_clients(), load(), and parser().

00670 {
00671   static bool configured = false;
00672 
00673   if (configured) return;
00674 
00675   m_cmt_version   = "";
00676   m_current_dir     = "";
00677   m_current_package = "";
00678   m_current_prefix  = "";
00679   m_current_config  = "";
00680   m_current_path    = "";
00681 
00682   m_current_tag     = "";
00683   m_current_version = "";
00684 
00685   m_configure_error = "";
00686 
00687   m_debug = false;
00688   if (getenv ("CMTDEBUG") != 0) m_debug = true;
00689 
00690   m_default_path    = "";
00691 
00692   configure_default_path ();
00693   configure_uname_tag ();
00694   configure_hosttype_tag ();
00695   configure_config_tag ();
00696   configure_site_tag (0);
00697   configure_cmt_path (0);
00698   configure_current_dir ();
00699   configure_current_package ();
00700   configure_home (0);
00701   configure_user_context (0);
00702 
00703   Use& use = Use::current();
00704 
00705   use.set (m_current_package,
00706            m_current_version,
00707            m_current_path,
00708            "",
00709            "");
00710 
00711   use.style = m_current_style;
00712 
00713   use.change_path (m_current_path);
00714 
00715   if (CmtError::has_pending_error ()) 
00716     {
00717       m_configure_error = CmtError::get_last_error ();
00718     }
00719 }

void Cmt::configure_cmt_path ( Use * use ) [static]
 

Definition at line 722 of file cmt_parser.cxx.

Referenced by Symbol::action(), and configure().

00723 {
00724   cmt_string s;
00725 
00726   Symbol* symbol = Symbol::find ("CMTPATH");
00727   if (symbol != 0)
00728     {
00729       bool show_set_hidden = false;
00730 
00731       if (Cmt::m_action == action_show_set)
00732         {
00733           show_set_hidden = true;
00734           Cmt::m_action = action_none;
00735         }
00736 
00737       s = symbol->build_macro_value ();
00738       Symbol::expand (s);
00739 
00740       if (show_set_hidden)
00741         {
00742           show_set_hidden = false;
00743           Cmt::m_action = action_show_set;
00744         }
00745     }
00746 
00747   CmtSystem::get_cmt_paths (m_cmt_path, 
00748                             m_cmt_path_pwds, 
00749                             m_cmt_path_sources, s);
00750 }

void Cmt::configure_config_tag ( ) [static]
 

Definition at line 753 of file cmt_parser.cxx.

Referenced by configure(), and parse_arguments().

00754 {
00755   m_cmt_config = CmtSystem::get_cmt_config ();
00756   if (m_cmt_config != "")
00757     {
00758       Tag* tag;
00759 
00760       tag = Tag::add (m_cmt_config, PriorityConfig, "CMTCONFIG", 0);
00761       tag->mark ();
00762     }
00763 }

void Cmt::configure_current_dir ( ) [static]
 

Definition at line 766 of file cmt_parser.cxx.

Referenced by configure(), load(), and reach_current_package().

00767 {
00768   cmt_string file_name;
00769 
00770   /*
00771     Building current_dir :
00772 
00773     o we first get the physical value (using getwd)
00774     o then this value is possibly filtered using the
00775     cmt_mount_filter file.
00776   */
00777 
00778   m_current_dir.erase (0);
00779 
00780   file_name = m_default_path;
00781   if (file_name != "")
00782     {
00783       file_name += CmtSystem::file_separator ();
00784       file_name += "CMT";
00785       file_name += CmtSystem::file_separator ();
00786       file_name += m_cmt_version;
00787       file_name += CmtSystem::file_separator ();
00788       file_name += "mgr";
00789       file_name += CmtSystem::file_separator ();
00790     }
00791 
00792   file_name += "cmt_mount_filter";
00793 
00794   m_current_dir = CmtSystem::pwd ();
00795 
00796   {
00797     cmt_string text;
00798     cmt_string line;
00799     CmtSystem::cmt_string_vector words;
00800 
00801     text.read (file_name);
00802 
00803     int pos = 0;
00804     int max_pos = text.size ();
00805 
00806     for (pos = 0; pos < max_pos; )
00807       {
00808         int cr = text.find (pos, "\r\n");
00809         int nl = text.find (pos, '\n');
00810         int first = nl;
00811         int length = 1;
00812 
00813         if (cr != cmt_string::npos)
00814           {
00815             if (nl == cmt_string::npos)
00816               {
00817                 first = cr;
00818                 length = 2;
00819               }
00820             else
00821               {
00822                 first = (nl < cr) ? nl : cr;
00823                 length = (nl < cr) ? 1 : 2;
00824               }
00825           }
00826         
00827         if (first == cmt_string::npos)
00828           {
00829             text.substr (pos, line);
00830             pos = max_pos;
00831           }
00832         else if (first > pos)
00833           {
00834             text.substr (pos, first - pos, line);
00835             pos = first + length;
00836           }
00837         else
00838           {
00839             line.erase (0);
00840             pos += length;
00841           }
00842 
00843         CmtSystem::split (line, " \t", words);
00844 
00845         if (words.size () >= 2)
00846           {
00847             cmt_string& path_name = words[0];
00848             cmt_string& replacement = words[1];
00849 
00850             if (m_current_dir.find (path_name) != cmt_string::npos)
00851               {
00852                 m_current_dir.replace (path_name, replacement);
00853                 break;
00854               }
00855           }
00856       }
00857   }
00858 }

void Cmt::configure_current_package ( ) [static]
 

Definition at line 861 of file cmt_parser.cxx.

Referenced by configure().

00862 {
00863   /*
00864     Build current_package and current_prefix.
00865 
00866     This is only possible if we are within the cmt/mgr branch of a
00867     standard directory tree (i.e. <package>/<version>/cmt or mgr)
00868   */
00869 
00870   if (CmtSystem::test_file ("../cmt/requirements"))
00871     {
00872       m_current_style = cmt_style;
00873     }
00874   else if (CmtSystem::test_file ("../mgr/requirements"))
00875     {
00876       m_current_style = mgr_style;
00877     }
00878   else
00879     {
00880       m_current_style = none_style;
00881     }
00882 
00883   if (m_current_style != none_style)
00884     {
00885       CmtSystem::dirname (m_current_dir, m_current_path);
00886       CmtSystem::basename (m_current_path, m_current_version);
00887       CmtSystem::dirname (m_current_path, m_current_path);
00888       CmtSystem::basename (m_current_path, m_current_package);
00889       CmtSystem::dirname (m_current_path, m_current_path);
00890       build_prefix (m_current_package, m_current_prefix);
00891       build_config (m_current_prefix, m_current_config);
00892     }
00893   else
00894     {
00895       m_current_package = "cmt_standalone";
00896       m_current_version = "";
00897       m_current_path = m_current_dir;
00898       build_prefix (m_current_package, m_current_prefix);
00899       build_config (m_current_prefix, m_current_config);
00900     }
00901 
00902   //cout << "configure_current_package> current style=" << m_current_style << endl;
00903 }

void Cmt::configure_default_path ( ) [static]
 

Definition at line 906 of file cmt_parser.cxx.

Referenced by configure().

00907 {
00908   m_default_path = CmtSystem::get_cmt_root ();
00909   CmtSystem::get_cmt_version (m_cmt_version);
00910   m_cmt_root = m_default_path;
00911   m_cmt_root += CmtSystem::file_separator ();
00912   m_cmt_root += "CMT";
00913   m_cmt_root += CmtSystem::file_separator ();
00914   m_cmt_root += m_cmt_version;
00915 }

void Cmt::configure_home ( Use * use ) [static]
 

Definition at line 918 of file cmt_parser.cxx.

Referenced by Symbol::action(), and configure().

00919 {
00920   m_cmt_home = "";
00921 
00922   Symbol* symbol = Symbol::find ("CMTHOME");
00923   if (symbol != 0)
00924     {
00925       m_cmt_home = symbol->build_macro_value ();
00926     }
00927   else if (CmtSystem::testenv ("CMTHOME"))
00928     {
00929       m_cmt_home = CmtSystem::getenv ("CMTHOME");
00930     }
00931 
00932   if ((m_cmt_home != "") && !CmtSystem::test_directory (m_cmt_home))
00933     {
00934       m_cmt_home = "";
00935     }
00936 }

void Cmt::configure_hosttype_tag ( ) [static]
 

Definition at line 960 of file cmt_parser.cxx.

Referenced by configure(), load(), and parse_arguments().

00961 {
00962   cmt_string hosttype;
00963 
00964   CmtSystem::get_hosttype (hosttype);
00965 
00966   if (hosttype != "")
00967     {
00968       Tag* tag;
00969 
00970       tag = Tag::add (hosttype, PriorityUname, "HOSTTYPE", 0);
00971       tag->mark ();
00972     }
00973 }

void Cmt::configure_site_tag ( Use * use ) [static]
 

Definition at line 976 of file cmt_parser.cxx.

Referenced by Symbol::action(), configure(), load(), and parse_arguments().

00977 {
00978   Symbol* symbol = Symbol::find ("CMTSITE");
00979   if (symbol != 0)
00980     {
00981       m_cmt_site = symbol->build_macro_value ();
00982     }
00983   else
00984     {
00985       m_cmt_site = CmtSystem::get_cmt_site ();
00986     }
00987 
00988   if (m_cmt_site != "")
00989     {
00990       cmt_string s = "CMTSITE";
00991 
00992       if (use != 0)
00993         {
00994           s += " in ";
00995         }
00996 
00997       Tag* tag;
00998 
00999       tag = Tag::add (m_cmt_site, PrioritySite, s, use);
01000       tag->mark ();
01001     }
01002 }

void Cmt::configure_tags ( Use * use ) [static]
 

Definition at line 1048 of file cmt_parser.cxx.

Referenced by Symbol::action(), and restore_all_tags().

01049 {
01050   cmt_string config_tag;
01051   
01052   if (m_debug) cerr << "configure_tags0> current_tag=" << m_current_tag << endl;
01053 
01054   Symbol* symbol = Symbol::find ("CMTCONFIG");
01055   if (symbol != 0)
01056     {
01057       bool show_set_hidden = false;
01058 
01059       if (Cmt::m_action == action_show_set)
01060         {
01061           show_set_hidden = true;
01062           Cmt::m_action = action_none;
01063         }
01064 
01065       config_tag = symbol->build_macro_value ();
01066 
01067       if (show_set_hidden)
01068         {
01069           show_set_hidden = false;
01070           Cmt::m_action = action_show_set;
01071         }
01072     }
01073   else if (CmtSystem::testenv ("CMTCONFIG"))
01074     {
01075       config_tag = CmtSystem::getenv ("CMTCONFIG");
01076     }
01077   else if (CmtSystem::testenv ("CMTBIN"))
01078     {
01079       config_tag = CmtSystem::getenv ("CMTBIN");
01080     }
01081 
01082   if (config_tag == "")
01083     {
01084       CmtSystem::get_uname (config_tag);
01085     }
01086 
01087   if (m_debug) cerr << "configure_tags> current_tag=" << m_current_tag << endl;
01088 
01089   cmt_string s = "CMTCONFIG";
01090 
01091   if (use != 0)
01092     {
01093       s += " in ";
01094     }
01095 
01096   Tag* tag;
01097 
01098   tag = Tag::add (config_tag, PriorityConfig, s, use);
01099   tag->mark ();
01100 
01101     //m_current_tag = config_tag;
01102 }

void Cmt::configure_uname_tag ( ) [static]
 

Definition at line 1105 of file cmt_parser.cxx.

Referenced by configure(), load(), and parse_arguments().

01106 {
01107   cmt_string uname;
01108 
01109   CmtSystem::get_uname (uname);
01110 
01111   if (uname != "")
01112     {
01113       Tag* tag;
01114 
01115       tag = Tag::add (uname, PriorityUname, "uname", 0);
01116       tag->mark ();
01117     }
01118 }

void Cmt::configure_user_context ( Use * use ) [static]
 

Definition at line 939 of file cmt_parser.cxx.

Referenced by Symbol::action(), and configure().

00940 {
00941   m_cmt_user_context = "";
00942 
00943   Symbol* symbol = Symbol::find ("CMTUSERCONTEXT");
00944   if (symbol != 0)
00945     {
00946       m_cmt_user_context = symbol->build_macro_value ();
00947     }
00948   else if (CmtSystem::testenv ("CMTUSERCONTEXT"))
00949     {
00950       m_cmt_user_context = CmtSystem::getenv ("CMTUSERCONTEXT");
00951     }
00952 
00953   if ((m_cmt_user_context != "") && !CmtSystem::test_directory (m_cmt_user_context))
00954     {
00955       m_cmt_user_context = "";
00956     }
00957 }

void Cmt::do_broadcast ( const CmtSystem::cmt_string_vector & arguments,
int argc,
char * argv[] ) [static]
 

Definition at line 1127 of file cmt_parser.cxx.

Referenced by parser().

01130 {
01131   Use::UsePtrVector& Uses = Use::uses ();
01132 
01133   CmtSystem::cmt_string_vector uses;
01134   CmtSystem::cmt_string_vector path_selections;
01135   CmtSystem::cmt_string_vector selections;
01136   CmtSystem::cmt_string_vector exclusions;
01137   cmt_string begin;
01138   cmt_string command;
01139   bool is_cmt = false;
01140   int first = 0;
01141   int i;
01142   bool ignore_errors = false;
01143   bool all_packages = false;
01144 
01145   bool local = true;
01146 
01147   for (i = 0; i < arguments.size (); i++)
01148     {
01149       const cmt_string& w = arguments[i];
01150 
01151       if (command == "")
01152         {
01153           if (w.substr (0, 13) == "-all_packages")
01154             {
01155               local = false;
01156               all_packages = true;
01157             }
01158           else if (w.substr (0, 7) == "-depth=")
01159             {
01160               local = false;
01161 
01162               cmt_string depth_str;
01163               int depth_value = 0;
01164                           
01165               w.substr (7, depth_str);
01166               if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) ||
01167                   (depth_value < 1))
01168                 {
01169                   // Syntax error
01170                   //  We shall restrict to packages found within 
01171                   // the <depth_value> first elements of CMTPATH.
01172                   //  If CMTPATH is empty, nothing is selected.
01173                   // depth=1 is equivalent to local
01174                 }
01175 
01176               int i = 0;
01177               while (i < m_cmt_path.size ())
01178                 {
01179                   cmt_string& p = m_cmt_path[i];
01180                   cmt_string& pwd = m_cmt_path_pwds[i];
01181                   cmt_string& src = m_cmt_path_sources[i];
01182 
01183                   if (src == "current package")
01184                     {
01185                       cmt_string& s1 = path_selections.add ();
01186                       s1 = p;
01187                       cmt_string& s2 = path_selections.add ();
01188                       s2 = pwd;
01189                     }
01190                   else if (src != "default path")
01191                     {
01192                       if (depth_value > 0)
01193                         {
01194                           cmt_string& s1 = path_selections.add ();
01195                           s1 = p;
01196                           cmt_string& s2 = path_selections.add ();
01197                           s2 = pwd;
01198                           depth_value--;
01199                         }
01200                     }
01201                   i++;
01202                 }
01203             }
01204           else if (w.substr (0, 9) == "-exclude=")
01205             {
01206               cmt_string exclusion;
01207 
01208               w.substr (9, exclusion);
01209 
01210               int size = exclusion.size ();
01211               
01212               if (size >= 2)
01213                 {
01214                   if (((exclusion[0] == '"') && (exclusion[size - 1] == '"')) ||
01215                       ((exclusion[0] == '\'') && (exclusion[size - 1] == '\'')))
01216                     {
01217                       exclusion.erase (size - 1);
01218                       exclusion.erase (0, 1);
01219                     }
01220 
01221                   CmtSystem::split (exclusion, " \t", exclusions);
01222                 }
01223             }
01224           else if (w.substr (0, 7) == "-global")
01225             {
01226               path_selections.clear ();
01227               local = false;
01228             }
01229           else if (w.substr (0, 6) == "-local")
01230             {
01231               local = true;
01232             }
01233           else if (w.substr (0, 8) == "-select=")
01234             {
01235               cmt_string selection;
01236 
01237               w.substr (8, selection);
01238 
01239               int size = selection.size ();
01240               
01241               if (size >= 2)
01242                 {
01243                   if (((selection[0] == '"') && (selection[size - 1] == '"')) ||
01244                       ((selection[0] == '\'') && (selection[size - 1] == '\'')))
01245                     {
01246                       selection.erase (size - 1);
01247                       selection.erase (0, 1);
01248                     }
01249 
01250                   CmtSystem::split (selection, " \t", selections);
01251                 }
01252             }
01253           else if (w.substr (0, 7) == "-begin=")
01254             {
01255               w.substr (7, begin);
01256             }
01257           else
01258             {
01259               command = w;
01260             }
01261         }
01262       else
01263         {
01264           command += " ";
01265           command += w;
01266         }
01267 
01268     }
01269 
01270   if (local)
01271     {
01272       int depth_value = 1;
01273 
01274       int i = 0;
01275       while (i < m_cmt_path.size ())
01276         {
01277           cmt_string& p = m_cmt_path[i];
01278           cmt_string& pwd = m_cmt_path_pwds[i];
01279           cmt_string& src = m_cmt_path_sources[i];
01280 
01281           if (src == "current package")
01282             {
01283               cmt_string& s1 = path_selections.add ();
01284               s1 = p;
01285               cmt_string& s2 = path_selections.add ();
01286               s2 = pwd;
01287             }
01288           else if (src != "default path")
01289             {
01290               if (depth_value > 0)
01291                 {
01292                   cmt_string& s1 = path_selections.add ();
01293                   s1 = p;
01294                   cmt_string& s2 = path_selections.add ();
01295                   s2 = pwd;
01296                   depth_value--;
01297                 }
01298             }
01299           i++;
01300         }
01301     }
01302 
01303   if (command[0] == '-')
01304     {
01305       ignore_errors = true;
01306       command.erase (0, 1);
01307     }
01308 
01309   //if (command.substr (0, 3) == "cmt") is_cmt = true;
01310 
01311   if (all_packages)
01312     {
01313       PackageSelector selector (uses);
01314       FileScanner scanner;
01315           
01316       for (i = 0; i < m_cmt_path.size (); i++)
01317         {
01318           cmt_string& p = m_cmt_path[i];
01319           scanner.scan_path (p, selector);
01320         }
01321     }
01322   else
01323     {
01324       for (i = Uses.size () - 1; i >= 0; i--)
01325         {
01326           Use* use = Uses[i];
01327                   
01328           if (use->discarded) continue;
01329 
01330           if (!use->located ())
01331             {
01332               if (!Cmt::m_quiet)
01333                 {
01334                   cout << "# package " << use->package <<
01335                       " " << use->version << " " << use->path <<
01336                       " not found" <<
01337                       endl;
01338                 }
01339             }
01340           else
01341             {
01342               if (use->package != "CMT")
01343                 {
01344                   cmt_string& s = uses.add ();
01345                                   
01346                   if (use->real_path == "") s = CmtSystem::pwd ();
01347                   else s = use->real_path;
01348                   s += CmtSystem::file_separator ();
01349                   s += use->package;
01350                   s += CmtSystem::file_separator ();
01351                   s += use->version;
01352                   s += CmtSystem::file_separator ();
01353                                   
01354                   if (use->style == mgr_style) s += "mgr";
01355                   else s += "cmt";
01356 
01357                   //cout << ">>> adding " << s << " to selection" << endl;
01358                 }
01359             }
01360         }
01361           
01362       {
01363         cmt_string& s = uses.add ();
01364                   
01365         Use* use = &(Use::current ());
01366 
01367         if (use->package.find ("cmt_standalone") != cmt_string::npos)
01368           {
01369             s = CmtSystem::pwd ();
01370           }
01371         else
01372           {
01373             if (use->real_path == "") s = CmtSystem::pwd ();
01374             else s = use->real_path;
01375             s += CmtSystem::file_separator ();
01376             s += use->package;
01377             s += CmtSystem::file_separator ();
01378             s += use->version;
01379             s += CmtSystem::file_separator ();
01380                   
01381             if (use->style == mgr_style) s += "mgr";
01382             else s += "cmt";
01383           }
01384 
01385         //cout << ">>> adding current " << s << " to selection" << endl;
01386       }
01387     }
01388 
01389   bool started = false;
01390 
01391   if (begin == "") started = true;
01392 
01393   for (i = 0; i < uses.size (); i++)
01394     {
01395       const cmt_string& s = uses[i];
01396       bool ok = true;
01397       bool selected = true;
01398       bool excluded = false;
01399 
01400       if (path_selections.size () > 0)
01401         {
01402           selected = false;
01403 
01404           for (int j = 0; j < path_selections.size (); j++)
01405             {
01406               const cmt_string& sel = path_selections[j];
01407               
01408               if (s.find (sel) != cmt_string::npos) 
01409                 {
01410                   selected = true;
01411                   break;
01412                 }
01413             }
01414 
01415           ok = selected;
01416         }
01417 
01418       if (ok)
01419         {
01420           if (selections.size () > 0)
01421             {
01422               selected = false;
01423               
01424               for (int j = 0; j < selections.size (); j++)
01425                 {
01426                   const cmt_string& sel = selections[j];
01427                   
01428                   if (s.find (sel) != cmt_string::npos) 
01429                     {
01430                       selected = true;
01431                       break;
01432                     }
01433                 }
01434               
01435               ok = selected;
01436             }
01437         }
01438 
01439       if (ok && !started)
01440         {
01441           if (s.find (begin) != cmt_string::npos)
01442             {
01443               started = true;
01444               ok = true;
01445             }
01446           else
01447             {
01448               ok = false;
01449             }
01450         }
01451 
01452 
01453       if (ok)
01454         {
01455           excluded = false;
01456 
01457           for (int j = 0; j < exclusions.size (); j++)
01458             {
01459               const cmt_string& exc = exclusions[j];
01460               
01461               if (s.find (exc) != cmt_string::npos) 
01462                 {
01463                   excluded = true;
01464                   break;
01465                 }
01466             }
01467 
01468           if (excluded) ok = false;
01469         }
01470 
01471       if (!ok) 
01472         {
01473           continue;
01474         }
01475 
01476 
01477 
01478       if (!CmtSystem::cd (s))
01479         {
01480           if (s.find ("cmt_standalone") != cmt_string::npos)
01481             {
01482               cout << "# Currently not in a CMT package" << endl;
01483             }
01484           else
01485             {
01486               cout << "# Cannot move to the package in " << s << " (" << i+1 << "/" 
01487                    << uses.size () << ")"<< endl;
01488             }
01489 
01490           if (!ignore_errors) break;
01491 
01492           continue;
01493         }
01494 
01495       if (CmtLock::check () == CmtLock::locked_by_another_user)
01496         {
01497           cout << "# Ignore locked package in " << s << " (" << i+1 << "/" 
01498                << uses.size () << ")" << endl;
01499           continue;
01500         }
01501 
01502       cout << "#--------------------------------------------------------------" << endl;
01503       cout << "# Now trying [" << command << "] in " << s << " (" << i+1 << "/" << uses.size () 
01504            << ")" << endl;
01505       cout << "#--------------------------------------------------------------" << endl;
01506 
01507       if (is_cmt)
01508         {
01509           //
01510           //  There is a bug in the recursive use of the parser. Macros are not set correctly.
01511           //  Thus the recursive optimization is now discarded.
01512           //
01513           if (parser (command) != 0)
01514             {
01515               CmtError::set (CmtError::execution_error, command);
01516               break;
01517             }
01518         }
01519       else
01520         {
01521           int status = CmtSystem::execute (command);
01522 
01523           //cerr << "do_broadcast> status=" << status << " ignore_errors=" << ignore_errors << endl;
01524 
01525           if (((status != 0) && !ignore_errors) || (status == 2))
01526               //if ((status != 0) && !ignore_errors)
01527             {
01528               if (status != 2) CmtError::set (CmtError::execution_error, command);
01529               break;
01530             }
01531         }
01532     }
01533 }

void Cmt::do_build_constituent_makefile ( const CmtSystem::cmt_string_vector & arguments,
int argc,
char * argv[] ) [static]
 

Definition at line 1536 of file cmt_parser.cxx.

Referenced by parser().

01539 {
01540   if (CmtLock::check () == CmtLock::locked_by_another_user)
01541     {
01542       CmtError::set (CmtError::conflicting_lock, "build_constituent_makefile>");
01543       return;
01544     }
01545   if (arguments.size () > 0) 
01546     {
01547       set_standard_macros ();
01548       Generator::build_constituent_makefile (arguments[0]);
01549     }
01550 }

void Cmt::do_build_constituents_makefile ( const CmtSystem::cmt_string_vector & arguments,
int argc,
char * argv[] ) [static]
 

Definition at line 1553 of file cmt_parser.cxx.

Referenced by parser().

01556 {
01557   if (CmtLock::check () == CmtLock::locked_by_another_user)
01558     {
01559       CmtError::set (CmtError::conflicting_lock, "build_constituents_makefile>");
01560       return;
01561     }
01562   set_standard_macros ();
01563   Generator::build_constituents_makefile (m_current_package);
01564 }

void Cmt::do_build_dependencies ( const CmtSystem::cmt_string_vector & arguments,
int argc,
char * argv[] ) [static]
 

Definition at line 1567 of file cmt_parser.cxx.

Referenced by parser().

01570 {
01571   if (CmtLock::check () == CmtLock::locked_by_another_user)
01572     {
01573       CmtError::set (CmtError::conflicting_lock, "build_dependencies>");
01574       return;
01575     }
01576   if (arguments.size () > 0)
01577     {
01578       set_standard_macros ();
01579 
01580       while (argc > 0)
01581         {
01582           if (strcmp (argv[0], "dependencies") != 0)
01583             {
01584               argc--;
01585               argv++;
01586             }
01587           else
01588             {
01589               argc--;
01590               argv++;
01591               argc--;
01592               argv++;
01593 
01594               Generator::build_dependencies (arguments[0], argc, argv);
01595 
01596               break;
01597             }
01598         }
01599     }
01600 }

void Cmt::do_build_library_links ( ) [static]
 

Definition at line 1603 of file cmt_parser.cxx.

Referenced by parser().

01604 {
01605   if (CmtLock::check () == CmtLock::locked_by_another_user)
01606     {
01607       CmtError::set (CmtError::conflicting_lock, "build_library_links>");
01608       return;
01609     }
01610 
01611   set_standard_macros ();
01612 
01613   Use::UsePtrVector& Uses = Use::uses ();
01614   Use& current_use = Use::current ();
01615   int i;
01616   cmt_string shlibsuffix;
01617   cmt_string bin;
01618 
01619   {
01620     Symbol* macro = Symbol::find ("shlibsuffix");
01621     if (macro == 0) return;
01622     shlibsuffix = macro->build_macro_value ();
01623   }
01624 
01625   for (i = 0; i < Uses.size (); i++)
01626     {
01627       Use* use = Uses[i];
01628 
01629       if (use->discarded) continue;
01630 
01631       if (!use->located ())
01632         {
01633           if (!m_quiet)
01634             {
01635               cout << "# package " << use->package <<
01636                   " " << use->version << " " << use->path << 
01637                   " not found" <<
01638                   endl;
01639             }
01640         }
01641       else
01642         {
01643           if (use->package == "CMT") continue;
01644           if (use->package == current_use.package) continue;
01645 
01646           cmt_string s;
01647 
01648           s = use->package;
01649           s += "_libraries";
01650 
01651           Symbol* libraries_macro = Symbol::find (s);
01652 
01653           if (libraries_macro == 0) continue;
01654 
01655           cmt_string libraries = libraries_macro->build_macro_value ();
01656           static CmtSystem::cmt_string_vector values;
01657 
01658           CmtSystem::split (libraries, " \t", values);
01659 
01660           for (int j = 0; j < values.size (); j++)
01661             {
01662               const cmt_string& library = values[j];
01663 
01664               static cmt_string libname;
01665               static cmt_string name;
01666 
01667               // Is it a simple name or a complete path?
01668 
01669               libname = library;
01670               Symbol::expand (libname);
01671 
01672               if (CmtSystem::absolute_path (libname))
01673                 {
01679                   cmt_string suffix;
01680                   CmtSystem::basename (library, name);
01681                 }
01682               else
01683                 {
01690                   libname = "${";
01691                   libname += use->prefix;
01692                   libname += "ROOT}/${";
01693                   libname += use->package;
01694                   libname += "_tag}/lib";
01695                   libname += library;
01696                   libname += ".";
01697                   libname += shlibsuffix;
01698 
01699                   name = "lib";
01700                   name += library;
01701                   name += ".";
01702                   name += shlibsuffix;
01703                 }
01704 
01705               Symbol::expand (libname);
01706 
01707               s = "../$(";
01708               s += current_use.package;
01709               s += "_tag)/";
01710               s += name;
01711 
01712               Symbol::expand (s);
01713 
01714               if (!m_quiet) cout << "   Symlinking " << libname << " to " << s << endl;
01715 
01716               if (!CmtSystem::create_symlink (libname, s))
01717                 {
01718                   cout << "Cannot create a symbolic link to " << libname << endl;
01719 
01720                   break;
01721                 }
01722             }
01723         }
01724     }
01725 }

void Cmt::do_build_make_setup ( ) [static]
 

Here we expect that only the base name of the library is given : ie it should not contain the "lib" prefix, nor the suffix .so, nor any path prefix.

This of course should generally correspond to a constituent name.

Definition at line 1728 of file cmt_parser.cxx.

Referenced by parser().

01729 {
01730   if (CmtLock::check () == CmtLock::locked_by_another_user)
01731     {
01732       CmtError::set (CmtError::conflicting_lock, "build_make_setup>");
01733       return;
01734     }
01735   set_standard_macros ();
01736   Generator::build_make_setup (m_current_package);
01737 }

void Cmt::do_build_msdev ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 1740 of file cmt_parser.cxx.

Referenced by parser().

01741 {
01742   if (CmtLock::check () == CmtLock::locked_by_another_user)
01743     {
01744       CmtError::set (CmtError::conflicting_lock, "build_msdev>");
01745       return;
01746     }
01747 
01748   if (true)
01749     {
01750       set_standard_macros ();
01751       if (arguments.size () > 0) build_msdev_file (arguments[0]);
01752       else build_msdev_file ("");
01753     }
01754 }

void Cmt::do_build_os9_makefile ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 1757 of file cmt_parser.cxx.

Referenced by parser().

01758 {
01759   if (CmtLock::check () == CmtLock::locked_by_another_user)
01760     {
01761       CmtError::set (CmtError::conflicting_lock, "build_os9_makefile>");
01762       return;
01763     }
01764 
01765   if (arguments.size () > 0) 
01766     {
01767       set_standard_macros ();
01768       build_OS9_makefile (arguments[0]);
01769     }
01770 }

void Cmt::do_build_prototype ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 1773 of file cmt_parser.cxx.

Referenced by parser().

01774 {
01775   if (CmtLock::check () == CmtLock::locked_by_another_user)
01776     {
01777       CmtError::set (CmtError::conflicting_lock, "build_prototype>");
01778       return;
01779     }
01780 
01781   if (arguments.size () > 0) 
01782     {
01783       set_standard_macros ();
01784       Generator::build_prototype (arguments[0]);
01785     }
01786 }

void Cmt::do_build_readme ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 1789 of file cmt_parser.cxx.

Referenced by parser().

01790 {
01791   if (CmtLock::check () == CmtLock::locked_by_another_user)
01792     {
01793       CmtError::set (CmtError::conflicting_lock, "build_readme>");
01794       return;
01795     }
01796 
01797   set_standard_macros ();
01798   Generator::build_readme (arguments);
01799 }

void Cmt::do_build_tag_makefile ( ) [static]
 

Definition at line 1802 of file cmt_parser.cxx.

Referenced by parser().

01803 {
01804   if (CmtLock::check () == CmtLock::locked_by_another_user)
01805     {
01806       CmtError::set (CmtError::conflicting_lock, "build_tag_makefile>");
01807       return;
01808     }
01809 
01810   print_macros (Make);
01811 }

void Cmt::do_build_temporary_name ( ) [static]
 

Definition at line 1814 of file cmt_parser.cxx.

Referenced by parser().

01815 {
01816   cmt_string name = CmtSystem::get_temporary_name ();
01817   cout << name << endl;
01818 }

void Cmt::do_build_triggers ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 1821 of file cmt_parser.cxx.

Referenced by parser().

01822 {
01823   if (CmtLock::check () == CmtLock::locked_by_another_user)
01824     {
01825       CmtError::set (CmtError::conflicting_lock, "build_tag_makefile>");
01826       return;
01827     }
01828 
01829   if (arguments.size () > 0) 
01830     {
01831       set_standard_macros ();
01832       TriggerGenerator::run (arguments[0]);
01833     }
01834 }

void Cmt::do_build_windefs ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 1837 of file cmt_parser.cxx.

Referenced by parser().

01838 {
01839   if (CmtLock::check () == CmtLock::locked_by_another_user)
01840     {
01841       CmtError::set (CmtError::conflicting_lock, "build_windefs>");
01842       return;
01843     }
01844 
01845   if (arguments.size () > 0) 
01846     {
01847       set_standard_macros ();
01848       Generator::build_windefs (arguments[0]);
01849     }
01850 }

void Cmt::do_check_configuration ( ) [static]
 

Definition at line 1853 of file cmt_parser.cxx.

Referenced by parser().

01854 {
01855 }

void Cmt::do_check_files ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 1858 of file cmt_parser.cxx.

Referenced by parser().

01859 {
01860   if (arguments.size () >= 2) 
01861     {
01862       cmt_string first_file = arguments[0];
01863       cmt_string second_file = arguments[1];
01864           
01865       if (first_file == "") return;
01866       if (second_file == "") return;
01867           
01868       CmtSystem::compare_and_update_files (first_file, second_file);
01869     }
01870 }

void Cmt::do_check_version ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 1873 of file cmt_parser.cxx.

Referenced by parser().

01874 {
01875   if (arguments.size () > 0)
01876     {
01877       cmt_string name = arguments[0];
01878           
01879       if (name == "") return;
01880       int v = 0;
01881       int r = 0;
01882       int p = 0;
01883           
01884       bool ok = CmtSystem::is_version_directory (name, v, r, p);
01885           
01886       if (ok)
01887         {
01888           cout << "# " << name << " is version " << v << " release " << r << " patch " << p << endl;
01889         }
01890       else
01891         {
01892           cout << "# " << name << " is not a version tag" << endl;
01893         }
01894     }
01895 }

void Cmt::do_checkout ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 1898 of file cmt_parser.cxx.

Referenced by parser().

01899 {
01900   Cvs::checkout (arguments);
01901 }

void Cmt::do_cleanup ( PrintMode & mode ) [static]
 

Definition at line 1904 of file cmt_parser.cxx.

Referenced by parser().

01905 {
01906   print_clean (mode);
01907 }

void Cmt::do_config ( ) [static]
 

Definition at line 1910 of file cmt_parser.cxx.

Referenced by do_create(), and parser().

01911 {
01912   if (CmtLock::check () == CmtLock::locked_by_another_user)
01913     {
01914       CmtError::set (CmtError::conflicting_lock, "config>");
01915       return;
01916     }
01917 
01918     //Use::UsePtrVector& Uses = Use::uses ();
01919 
01920   /*
01921     cout << "pwd " << CmtSystem::pwd () << endl;
01922     cout << "current_dir " << m_current_dir << endl;
01923     cout << "default_path " << m_default_path << endl;
01924     cout << "cmt config " <<
01925     m_current_package << " " <<
01926     m_current_version << " " <<
01927     m_current_path << endl;
01928   */
01929 
01930   if (m_current_package == "CMT") return;
01931   if (m_current_package == "methods") return;
01932 
01933   cmt_string branch;
01934 
01935   CmtSystem::basename (m_current_dir, branch);
01936 
01937   if ((branch != "mgr") && (branch != "cmt"))
01938     {
01939       if (CmtSystem::test_file ("requirements"))
01940         {
01941           cout << "------------------------------------------" << endl;
01942           cout << "Configuring environment for standalone package." << endl;
01943           cout << "CMT version " << m_cmt_version << "." << endl;
01944           cout << "System is " << m_cmt_config << endl;
01945           cout << "------------------------------------------" << endl;
01946 
01947           install_test_setup_scripts ();
01948           install_test_cleanup_scripts ();
01949 
01950           Generator::build_default_makefile ();
01951         }
01952       else
01953         {
01954           cout << "==============================================" << endl;
01955           cout << "cmt config must be operated either upon "
01956             "an existing package" << endl;
01957           cout << " (ie. when a requirements file already exists)" << endl;
01958           cout << "   > cd ..." << endl;
01959           cout << "   > cmt config" << endl;
01960           cout << "or to create a new package" << endl;
01961           cout << "   > cmt config <package> <version> [<path>]" << endl;
01962           cout << "==============================================" << endl;
01963         }
01964 
01965       return;
01966     }
01967 
01968   if (branch == "cmt") m_current_style = cmt_style;
01969   else if (branch == "mgr") m_current_style = mgr_style;
01970   else m_current_style = none_style;
01971 
01972   Generator::build_default_makefile ();
01973 
01974   CmtSystem::cmt_string_vector makes;
01975   cmt_regexp expression ("[.]n?make(sav)?$");
01976 
01977   CmtSystem::scan_dir (".", expression, makes);
01978 
01979   if (makes.size () > 0)
01980     {
01981       cout << "Removing all previous make fragments from " << branch << endl;
01982 
01983       for (int i = 0; i < makes.size (); i++)
01984         {
01985           const cmt_string& s = makes[i];
01986           CmtSystem::remove_file (s);
01987         }
01988     }
01989 
01990   CmtSystem::cd ("..");
01991 
01992   CmtSystem::scan_dir (m_cmt_config, expression, makes); 
01993     
01994   if (makes.size () > 0) 
01995     {
01996       cout << "Removing all previous make fragments from "
01997            << m_cmt_config << endl; 
01998 
01999       for (int i = 0; i < makes.size (); i++) 
02000         { 
02001           const cmt_string& s = makes[i]; 
02002           CmtSystem::remove_file (s); 
02003         }    
02004     } 
02005     
02006   CmtSystem::cd (branch); 
02007     
02008 
02009   /*
02010     if (!load (m_current_path, m_current_package, m_current_version))
02011     {
02012     cout << "Cannot read the requirements file" << endl;
02013     return;
02014     }
02015   */
02016 
02017   CmtSystem::dirname (m_current_dir, m_current_path);
02018   CmtSystem::basename (m_current_path, m_current_version);
02019   CmtSystem::dirname (m_current_path, m_current_path);
02020   CmtSystem::basename (m_current_path, m_current_package);
02021   CmtSystem::dirname (m_current_path, m_current_path);
02022 
02023   Use& use = Use::current ();
02024 
02025   use.set (m_current_package,
02026            m_current_version,
02027            m_current_path,
02028            "",
02029            "");
02030 
02031   use.change_path (m_current_path);
02032   use.style     = m_current_style;
02033 
02034   //cout << "do_config> current style=" << m_current_style << endl;
02035 
02036   if (!reach_current_package ())
02037     {
02038       cout << "Cannot read the requirements file" << endl;
02039       return;
02040     }
02041 
02042   install_setup_scripts ();
02043   install_cleanup_scripts ();
02044 
02045   CmtSystem::cd ("..");
02046 
02047   Branch::BranchVector& branches = Branch::branches ();
02048 
02049   int i;
02050 
02051   for (i = 0; i < branches.size (); i++)
02052     {
02053       const Branch& branch = branches[i];
02054       const cmt_string& branch_name = branch.name ();
02055 
02056       if (!CmtSystem::test_directory (branch_name))
02057         {
02058           if (!CmtSystem::mkdir (branch_name))
02059             {
02060               cout << "Cannot create the " << branch_name <<" branch" << endl;
02061             }
02062           else
02063             {
02064               cout << "Installing the " << branch_name << " directory" << endl;
02065             }
02066         }
02067       else
02068         {
02069           cout << branch_name << " directory already installed" << endl;
02070         }
02071     }
02072 }

void Cmt::do_create ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2075 of file cmt_parser.cxx.

Referenced by parser().

02076 {
02077   if (arguments.size () < 2) return;
02078 
02079   const cmt_string& package = arguments[0];
02080   const cmt_string& version = arguments[1];
02081   cmt_string path;
02082   if (arguments.size () >= 3) path = arguments[2];
02083 
02084   if (m_debug)
02085     {
02086       cout << "do_create>m_current_package=" << m_current_package << endl;
02087       cout << "do_create>package=" << package << endl;
02088     }
02089 
02090     //if (m_current_package == "CMT") return;
02091     //if (m_current_package == "methods") return;
02092 
02093   cmt_string the_path;
02094 
02095   //the_path = m_default_path;
02096   the_path = CmtSystem::pwd ();
02097 
02098   if (path != "")
02099     {
02100       if (!CmtSystem::absolute_path (path))
02101         {
02102           // path is just a suffix
02103           the_path += CmtSystem::file_separator ();
02104           the_path += path;
02105         }
02106       else // absolute path
02107         {
02108           the_path = path;
02109         }
02110     }
02111 
02112   CmtSystem::compress_path (the_path);
02113 
02114   cout << "------------------------------------------" << endl;
02115   cout << "Configuring environment for package " << package <<
02116     " version " << version << "." << endl;
02117   cout << "CMT version " << m_cmt_version << "." << endl;
02118   cout << "Root set to " << the_path << "." << endl;
02119   cout << "System is " << m_cmt_config << endl;
02120   cout << "------------------------------------------" << endl;
02121 
02122   if (!CmtSystem::test_directory (the_path))
02123     {
02124       if (!CmtSystem::mkdir (the_path))
02125         {
02126           cout << "Cannot create the path directory" << endl;
02127           return;
02128         }
02129       else
02130         {
02131           cout << "Installing the path directory" << endl;
02132         }
02133     }
02134 
02135   CmtSystem::cd (the_path);
02136 
02137   if (!CmtSystem::test_directory (package))
02138     {
02139       if (!CmtSystem::mkdir (package))
02140         {
02141           cout << "Cannot create the package directory" << endl;
02142           return;
02143         }
02144       else
02145         {
02146           cout << "Installing the package directory" << endl;
02147         }
02148     }
02149   else
02150     {
02151       cout << "Package directory already installed" << endl;
02152     }
02153 
02154   CmtSystem::cd (package);
02155 
02156   if (!CmtSystem::test_directory (version))
02157     {
02158       if (!CmtSystem::mkdir (version))
02159         {
02160           cout << "Cannot create the version directory" << endl;
02161           return;
02162         }
02163       else
02164         {
02165           cout << "Installing the version directory" << endl;
02166         }
02167     }
02168   else
02169     {
02170       cout << "Version directory already installed" << endl;
02171     }
02172 
02173   CmtSystem::cd (version);
02174 
02175   if (!CmtSystem::test_directory ("cmt"))
02176     {
02177       if (!CmtSystem::test_directory ("mgr"))
02178         {
02179           if (!CmtSystem::mkdir ("cmt"))
02180             {
02181               cout << "Cannot create the cmt directory" << endl;
02182               return;
02183             }
02184           else
02185             {
02186               m_current_style = cmt_style;
02187               cout << "Installing the cmt directory" << endl;
02188             }
02189         }
02190       else
02191         {
02192           m_current_style = mgr_style;
02193           cout << "Mgr directory already installed" << endl;
02194         }
02195     }
02196   else
02197     {
02198       m_current_style = cmt_style;
02199       cout << "Cmt directory already installed" << endl;
02200     }
02201 
02202   if (!CmtSystem::test_directory ("src"))
02203     {
02204       if (!CmtSystem::mkdir ("src"))
02205         {
02206           cout << "Cannot create the src directory" << endl;
02207           return;
02208         }
02209       else
02210         {
02211           cout << "Installing the src directory" << endl;
02212         }
02213     }
02214   else
02215     {
02216       cout << "src directory already installed" << endl;
02217     }
02218 
02219   switch (m_current_style)
02220     {
02221     case cmt_style:
02222       CmtSystem::cd ("cmt");
02223       break;
02224     case mgr_style:
02225       CmtSystem::cd ("mgr");
02226       break;
02227     }
02228 
02229   Generator::build_default_makefile ();
02230 
02231   if (!CmtSystem::test_file ("requirements"))
02232     {
02233       // create an empty requirement file.
02234       ofstream f ("requirements");
02235       if (f)
02236         {
02237           f << "package " << package << endl;
02238           f << endl;
02239           f.close ();
02240         }
02241     }
02242 
02243   m_current_package = package;
02244   m_current_version = version;
02245   m_current_path    = the_path;
02246   m_current_dir     = CmtSystem::pwd ();
02247 
02248   do_config ();
02249 }

void Cmt::do_cvsbranches ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2252 of file cmt_parser.cxx.

Referenced by parser().

02253 {
02254   Cvs::branches (arguments[0]);
02255 }

void Cmt::do_cvssubpackages ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2258 of file cmt_parser.cxx.

Referenced by parser().

02259 {
02260   Cvs::subpackages (arguments[0]);
02261 }

void Cmt::do_cvstags ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2264 of file cmt_parser.cxx.

Referenced by parser().

02265 {
02266   Cvs::tags (arguments);
02267 }

void Cmt::do_expand_model ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2270 of file cmt_parser.cxx.

Referenced by parser().

02271 {
02272   set_standard_macros ();
02273   CmtModel::expand (arguments[0]);
02274 }

void Cmt::do_filter ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Handle free filtering of text files containing or ${xxx} patterns.

Substitution is performed against CMT macros and environment variables.

Arguments:

cmt filter input-file-name output-file-name

Definition at line 2286 of file cmt_parser.cxx.

Referenced by parser().

02287 {
02288   if (arguments.size () < 2) return;
02289 
02290   cmt_string& input = arguments[0];
02291   cmt_string& output = arguments[1];
02292 
02293   if (!CmtSystem::test_file (input))
02294     {
02295       cout << "#CMT> File " << input << " not found" << endl;
02296       return;
02297     }
02298 
02299   cmt_string text;
02300 
02301   text.read (input);
02302 
02303   set_standard_macros ();
02304 
02305   Symbol::expand (text);
02306 
02307   FILE* file = fopen (output, "wb");
02308   if (file == NULL)
02309     {
02310       cout << "#CMT> Cannot write filtered file " << output << endl;
02311     }
02312   else
02313     {
02314       text.write (file);
02315       fclose (file);
02316     }
02317 }

void Cmt::do_help ( ) [static]
 

Definition at line 2320 of file cmt_parser.cxx.

Referenced by parser().

02321 {
02322   cout << "> cmt command [option...]" << endl;
02323   cout << " command :" << endl;
02324   cout << "   broadcast [-select=list] [-exclude=list] [-local] [-global] [-begin=pattern] [-depth=n] <command> : apply a command to [some of] the used packages" << endl;
02325   cout << "" << endl;
02326   cout << "   build <key>             : build various components :" << endl;
02327   cout << "         constituent_makefile <constituent>  : generate constituent Makefile fragment" << endl;
02328   cout << "         constituents_makefile : generate constituents.make" << endl;
02329   cout << "         dependencies      : generate dependencies" << endl;
02330   cout << "         library_links     : build symbolic links towards all imported libraries" << endl;
02331   cout << "         make_setup        : build a compiled version of setup scripts" << endl;
02332   cout << "         msdev             : generate MSDEV files" << endl;
02333   cout << "         os9_makefile      : generate Makefile for OS9" << endl;
02334   cout << "         prototype         : generate prototype file" << endl;
02335   cout << "         readme            : generate README.html" << endl;
02336   cout << "         tag_makefile      : generate tag specific Makefile" << endl;
02337   cout << "         triggers <constituent> : generate library trigger file" << endl;
02338   cout << "         windefs <library_name> : generate def file for Windows shared libraries" << endl;
02339   cout << "" << endl;
02340   cout << "   check <key>             : perform various checks" << endl;
02341   cout << "         configuration     : check configuration" << endl;
02342   cout << "         files <old> <new> : compare two files and overrides <old> by <new> if different" << endl;
02343   cout << "         version <name>    : check if a name follows a version tag syntax " << endl;
02344   cout << "   check_files <old> <new> : compare two files and overrides <old> by <new> if different" << endl;
02345   cout << "   checkout                : perform a cvs checkout over a CMT package" << endl;
02346   cout << "   co                      : perform a cvs checkout over a CMT package" << endl;
02347   cout << "   cleanup [-csh|-sh|-bat] : generate a cleanup script" << endl;
02348   cout << "   config                  : generate setup and cleanup scripts" << endl;
02349   cout << "   create <package> <version> [<path>] : create and configure a new package" << endl;
02350   cout << "   filter <in> <out>       : filter a file against CMT macros and env. variables" << endl;
02351   cout << "   help                    : display this help" << endl;
02352   cout << "   lock [<p> <v> [<path>]] : lock a package" << endl;
02353   cout << "   remove <package> <version> [<path>] : remove a package version" << endl;
02354   cout << "   remove library_links    : remove symbolic links towards all imported libraries" << endl;
02355   cout << "   run <command>           : apply a command" << endl;
02356   cout << "   setup [-csh|-sh|-bat]   : generate a setup script" << endl;
02357   cout << "   show <key>              : display various infos on :" << endl;
02358   cout << "         applied_patterns  :  all patterns actually applied" << endl;
02359   cout << "         author            :  package author" << endl;
02360   cout << "         branches          :  added branches" << endl;
02361   cout << "         clients           :  package clients" << endl;
02362   cout << "         constituent_names :  constituent names" << endl;
02363   cout << "         constituents      :  constituent definitions" << endl;
02364   cout << "         uses              :  the use tree" << endl;
02365   cout << "         fragment <name>   :  one fragment definition" << endl;
02366   cout << "         fragments         :  fragment definitions" << endl;
02367   cout << "         groups            :  group definitions" << endl;
02368   cout << "         languages         :  language definitions" << endl;
02369   cout << "         macro <name>      :  a formatted macro definition" << endl;
02370   cout << "         macro_value <name>  :  a raw macro definition" << endl;
02371   cout << "         macros            :  all macro definitions" << endl;
02372   cout << "         manager           :  package manager" << endl;
02373   cout << "         packages          :  packages reachable from the current context" << endl;
02374   cout << "         path              :  the package search list" << endl;
02375   cout << "         pattern <name>    :  the pattern definition and usages" << endl;
02376   cout << "         pattern_names     :  pattern names" << endl;
02377   cout << "         patterns          :  the pattern definitions" << endl;
02378   cout << "         pwd               :  filtered current directory" << endl;
02379   cout << "         set_value <name>  :  a raw set definition" << endl;
02380   cout << "         set <name>        :  a formatted set definition" << endl;
02381   cout << "         sets              :  set definitions" << endl;
02382   cout << "         strategies        :  all strategies (build & version)" << endl;
02383   cout << "         tags              :  all defined tags" << endl;
02384   cout << "         uses              :  used packages" << endl;
02385   cout << "         version           :  version of the current package" << endl;
02386   cout << "         versions <name>   :  visible versions of the selected package" << endl;
02387   cout << "" << endl;
02388   cout << "   system                  : display the system tag" << endl;
02389   cout << "   unlock [<p> <v> [<path>]] : unlock a package" << endl;
02390   cout << "   version                 : version of CMT" << endl;
02391   cout << "" << endl;
02392   cout << "   cvstags <module>         : display the CVS tags for a module" << endl;
02393   cout << "   cvsbranches <module>     : display the subdirectories for a module" << endl;
02394   cout << "   cvssubpackagess <module> : display the subpackages for a module" << endl;
02395 
02396   cout << " global options :" << endl;
02397 
02398   cout << "   -quiet                  : don't print errors" << endl;
02399   cout << "   -use=<p>:<v>:<path>     : set package version path" << endl;
02400   cout << "   -pack=<package>         : set package" << endl;
02401   cout << "   -version=<version>      : set version" << endl;
02402   cout << "   -path=<path>            : set root path" << endl;
02403   cout << "   -f=<requirement-file>   : set input file" << endl;
02404   cout << "   -e=<statement>          : add a one line statement" << endl;
02405   cout << "   -tag=<tag-list>         : select a new tag-set" << endl;
02406   cout << "   -tag_add=<tag-list>     : add specific comma-separated tag(s)" << endl;
02407   cout << "   -tag_remove=<tag-list>  : remove specific comma-separated tag(s)" << endl;
02408 }

void Cmt::do_lock ( const cmt_string & package,
const cmt_string & version,
const cmt_string & path ) [static]
 

Definition at line 2411 of file cmt_parser.cxx.

Referenced by parser().

02414 {
02415   Use& use = Use::current();
02416 
02417   cout << "try to lock package " << package << " in " << CmtSystem::pwd () << endl;
02418 
02419   set_standard_macros ();
02420 
02421   CmtLock::status status = CmtLock::lock ();
02422 }

void Cmt::do_remove ( const cmt_string & package,
const cmt_string & version,
const cmt_string & path ) [static]
 

Definition at line 2425 of file cmt_parser.cxx.

Referenced by parser().

02428 {
02429     //Use::UsePtrVector& Uses = Use::uses ();
02430 
02431   if (m_current_package == "CMT") return;
02432   if (m_current_package == "methods") return;
02433 
02434   cmt_string the_path;
02435 
02436   //the_path = m_default_path;
02437   the_path = CmtSystem::pwd ();
02438 
02439   if (path != "")
02440     {
02441       if (!CmtSystem::absolute_path (path))
02442         {
02443           // path is just a suffix
02444           the_path += CmtSystem::file_separator ();
02445           the_path += path;
02446         }
02447       else // absolute path
02448         {
02449           the_path = path;
02450         }
02451     }
02452 
02453   CmtSystem::compress_path (the_path);
02454 
02455   cout << "------------------------------------------" << endl;
02456   cout << "Removing package " << package <<
02457     " version " << version << "." << endl;
02458   cout << "CMT version " << m_cmt_version << "." << endl;
02459   cout << "Root set to " << the_path << "." << endl;
02460   cout << "System is " << m_cmt_config << endl;
02461   cout << "------------------------------------------" << endl;
02462 
02463   the_path += CmtSystem::file_separator ();
02464   the_path += package;
02465 
02466   if (CmtSystem::cd (the_path) && 
02467       CmtSystem::test_directory (version))
02468     {
02469       if (CmtSystem::remove_directory (version))
02470         {
02471           cout << "Version " << version << " has been removed from " << the_path << endl;
02472           CmtSystem::cmt_string_vector contents;
02473           CmtSystem::scan_dir (".", contents);
02474           if (contents.size () == 0)
02475             {
02476               CmtSystem::cd ("..");
02477               if (CmtSystem::remove_directory (package))
02478                 {
02479                   cout << "Package " << package << " has no more versions. Thus it has been removed."<< endl;
02480                 }
02481             }
02482         }
02483       else
02484         {
02485           cout << "Impossible to remove version " << version << " from " << the_path << endl;
02486         }
02487     }
02488   else
02489     {
02490       cout << "Version " << version << " not found" << endl;
02491     }
02492 }

void Cmt::do_remove_library_links ( ) [static]
 

Definition at line 2495 of file cmt_parser.cxx.

Referenced by parser().

02496 {
02497   if (CmtLock::check () == CmtLock::locked_by_another_user)
02498     {
02499       CmtError::set (CmtError::conflicting_lock, "remove_library_links>");
02500       return;
02501     }
02502 
02503   set_standard_macros ();
02504 
02505   Use::UsePtrVector& Uses = Use::uses ();
02506   Use& current_use = Use::current ();
02507   int i;
02508   cmt_string shlibsuffix;
02509   cmt_string symunlink;
02510 
02511   {
02512     Symbol* macro = Symbol::find ("shlibsuffix");
02513     if (macro == 0) return;
02514     shlibsuffix = macro->build_macro_value ();
02515   }
02516 
02517   {
02518     Symbol* macro = Symbol::find ("symunlink");
02519     if (macro == 0) return;
02520     symunlink = macro->build_macro_value ();
02521   }
02522 
02523   for (i = 0; i < Uses.size (); i++)
02524     {
02525       Use* use = Uses[i];
02526 
02527       if (use->discarded) continue;
02528 
02529       if (!use->located ())
02530         {
02531           if (!m_quiet)
02532             {
02533               cout << "# package " << use->package <<
02534                   " " << use->version << " " << use->path << 
02535                   " not found" <<
02536                   endl;
02537             }
02538         }
02539       else
02540         {
02541           if (use->package == "CMT") continue;
02542           if (use->package == current_use.package) continue;
02543 
02544           cmt_string s;
02545 
02546           s = use->package;
02547           s += "_libraries";
02548 
02549           Symbol* libraries_macro = Symbol::find (s);
02550 
02551           if (libraries_macro == 0) continue;
02552 
02553           cmt_string libraries = libraries_macro->build_macro_value ();
02554           static CmtSystem::cmt_string_vector values;
02555 
02556           CmtSystem::split (libraries, " \t", values);
02557 
02558           for (int j = 0; j < values.size (); j++)
02559             {
02560               const cmt_string& library = values[j];
02561 
02562               static cmt_string libname;
02563               static cmt_string name;
02564 
02565               // Is it a simple name or a complete path?
02566 
02567               libname = library;
02568               Symbol::expand (libname);
02569 
02570               if (CmtSystem::absolute_path (libname))
02571                 {
02577                   cmt_string suffix;
02578                   CmtSystem::basename (library, name);
02579                 }
02580               else
02581                 {
02589                   name = "lib";
02590                   name += libname;
02591                   name += ".";
02592                   name += shlibsuffix;
02593                 }
02594 
02595               s = symunlink;
02596               s += " ../$(";
02597               s += current_use.package;
02598               s += "_tag)/";
02599               s += name;
02600 
02601               Symbol::expand (s);
02602 
02603               if (!m_quiet) cout << s << endl;
02604               int status = CmtSystem::execute (s);
02605 
02606               if (status != 0)
02607                 {
02608                   if (status != 2) CmtError::set (CmtError::execution_error, s);
02609 
02610                   cout << "Cannot remove the symbolic link " << s << endl;
02611 
02612                   break;
02613                 }
02614             }
02615         }
02616     }
02617 }

void Cmt::do_run ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Here we expect that only the base name of the library is given : ie it should not contain the "lib" prefix, nor the suffix .so, nor any path prefix.

This of course should generally correspond to a constituent name.

Definition at line 2620 of file cmt_parser.cxx.

Referenced by parser().

02621 {
02622   if (arguments.size () > 0) CmtSystem::execute (arguments[0]);
02623 }

void Cmt::do_setup ( PrintMode & mode ) [static]
 

Definition at line 2626 of file cmt_parser.cxx.

Referenced by parser().

02627 {
02628   print (mode);
02629 }

void Cmt::do_show_applied_patterns ( ) [static]
 

Definition at line 2632 of file cmt_parser.cxx.

Referenced by parser().

02633 {
02634   Pattern::show_all_applied_patterns ();
02635 }

void Cmt::do_show_author ( ) [static]
 

Definition at line 2638 of file cmt_parser.cxx.

Referenced by parser().

02639 {
02640   Use& use = Use::current();
02641 
02642   cout << use.author << endl;
02643 }

void Cmt::do_show_branches ( PrintMode & mode ) [static]
 

Definition at line 2646 of file cmt_parser.cxx.

Referenced by parser().

02647 {
02648   Branch::print_all (mode);
02649 }

void Cmt::do_show_clients ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2652 of file cmt_parser.cxx.

Referenced by parser().

02653 {
02654   cmt_string package;
02655   cmt_string version;
02656   cmt_string path_name;
02657 
02658   if (arguments.size () >= 1) package = arguments[0];
02659   if (arguments.size () >= 2) version = arguments[1];
02660   if (arguments.size () >= 3) path_name = arguments[2];
02661 
02662   FileScanner scanner;
02663   PackageCollector collector (package, version);
02664 
02665   clear ();
02666   configure ();
02667 
02668   cout << "# ----------- Clients of " << package <<
02669     " " << version <<
02670     " " << path_name <<
02671     endl;
02672 
02673   if (path_name == "")
02674     {
02675       int path_index;
02676 
02677       for (path_index = 0; path_index < m_cmt_path.size (); path_index++)
02678         {
02679           const cmt_string& path = m_cmt_path[path_index];
02680 
02681           scanner.scan_path (path, collector);
02682         }
02683     }
02684   else
02685     {
02686       scanner.scan_path (path_name, collector);
02687     }
02688   cout << "# ----------- " << collector.count () << " clients found." << endl;
02689 }

void Cmt::do_show_constituent ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2692 of file cmt_parser.cxx.

Referenced by parser().

02693 {
02694   if (arguments.size () > 0) 
02695     {
02696       set_standard_macros ();
02697       Constituent::show (arguments[0]);
02698     }
02699 }

void Cmt::do_show_constituent_names ( ) [static]
 

Definition at line 2702 of file cmt_parser.cxx.

Referenced by parser().

02703 {
02704   set_standard_macros ();
02705   Constituent::show_names ();
02706 }

void Cmt::do_show_constituents ( ) [static]
 

Definition at line 2709 of file cmt_parser.cxx.

Referenced by parser().

02710 {
02711   set_standard_macros ();
02712   Constituent::show_all ();
02713 }

void Cmt::do_show_fragment ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2716 of file cmt_parser.cxx.

Referenced by parser().

02717 {
02718   if (arguments.size () > 0) Fragment::show (arguments[0]);
02719 }

void Cmt::do_show_fragments ( ) [static]
 

Definition at line 2722 of file cmt_parser.cxx.

Referenced by parser().

02723 {
02724   Fragment::show_all ();
02725 }

void Cmt::do_show_groups ( ) [static]
 

Definition at line 2728 of file cmt_parser.cxx.

Referenced by parser().

02729 {
02730   Group::show_all ();
02731 }

void Cmt::do_show_include_dirs ( ) [static]
 

Definition at line 2734 of file cmt_parser.cxx.

Referenced by parser().

02735 {
02736   cmt_string temp;
02737 
02738   Use& use = Use::current();
02739 
02740   set_standard_macros ();
02741 
02742   if (use.include_path == "")
02743     {
02744       temp += "$(src) ";
02745     }
02746   else if (use.include_path != "none")
02747     {
02748       temp += use.include_path;
02749       temp += " ";
02750     }
02751 
02752   for (int include_number = 0;
02753        include_number < use.includes.size ();
02754        include_number++)
02755     {
02756       Include& incl = use.includes[include_number];
02757       
02758       temp += incl.name;
02759       temp += " ";
02760     }
02761 
02762   cout << temp << endl;
02763 }

void Cmt::do_show_language ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2766 of file cmt_parser.cxx.

Referenced by parser().

02767 {
02768   if (arguments.size () > 0) 
02769     {
02770       set_standard_macros ();
02771       Language::show (arguments[0]);
02772     }
02773 }

void Cmt::do_show_languages ( ) [static]
 

Definition at line 2776 of file cmt_parser.cxx.

Referenced by parser().

02777 {
02778   set_standard_macros ();
02779   Language::show_all ();
02780 }

void Cmt::do_show_macro ( const CmtSystem::cmt_string_vector & arguments,
PrintMode & mode ) [static]
 

Definition at line 2783 of file cmt_parser.cxx.

Referenced by do_show_macro_value(), do_show_set(), do_show_set_value(), and parser().

02785 {
02786   cmt_string target;
02787 
02788   if (arguments.size () > 0) target = arguments[0];
02789 
02790   Symbol* symbol;
02791 
02792   set_standard_macros ();
02793 
02794   symbol = Symbol::find (target);
02795 
02796   if (symbol == 0) 
02797     {
02798       cmt_string t = " ";
02799       t += target;
02800       t += " is not a ";
02801 
02802       if ((m_action == action_show_macro) ||
02803           (m_action == action_show_macro_value))
02804         {
02805           t += "macro";
02806         }
02807       else if ((m_action == action_show_set) ||
02808                (m_action == action_show_set_value))
02809         {
02810           t += "set";
02811         }
02812 
02813       CmtError::set (CmtError::symbol_not_found, t);
02814 
02815       return;
02816     }
02817   else
02818     {
02819       cmt_string t = " ";
02820       t += target;
02821       t += " is not a ";
02822 
02823       if ((m_action == action_show_macro) ||
02824           (m_action == action_show_macro_value))
02825         {
02826           if ((symbol->command != CommandMacro) &&
02827               (symbol->command != CommandMacroAppend) &&
02828               (symbol->command != CommandMacroPrepend) &&
02829               (symbol->command != CommandMacroRemove) &&
02830               (symbol->command != CommandMacroRemoveAll))
02831             {
02832               t += "macro";
02833 
02834               CmtError::set (CmtError::symbol_not_found, t);
02835 
02836               return;
02837             }
02838         }
02839       else if ((m_action == action_show_set) ||
02840                (m_action == action_show_set_value))
02841         {
02842           if ((symbol->command != CommandSet) &&
02843               (symbol->command != CommandSetAppend) &&
02844               (symbol->command != CommandSetPrepend) &&
02845               (symbol->command != CommandSetRemove) &&
02846               (symbol->command != CommandPath) &&
02847               (symbol->command != CommandPathAppend) &&
02848               (symbol->command != CommandPathPrepend) &&
02849               (symbol->command != CommandPathRemove))
02850             {
02851               t += "set";
02852 
02853               CmtError::set (CmtError::symbol_not_found, t);
02854 
02855               return;
02856             }
02857         }
02858     }
02859 
02860   if (symbol->value_lists.size () < 1) return;
02861 
02862   symbol->show_macro (mode);
02863 }

void Cmt::do_show_macro_value ( const CmtSystem::cmt_string_vector & arguments,
PrintMode & mode ) [static]
 

Definition at line 2866 of file cmt_parser.cxx.

Referenced by parser().

02868 {
02869   do_show_macro (arguments, mode);
02870 }

void Cmt::do_show_macros ( PrintMode & mode ) [static]
 

Definition at line 2873 of file cmt_parser.cxx.

Referenced by parser().

02874 {
02875   print_macros (mode);
02876 }

void Cmt::do_show_manager ( ) [static]
 

Definition at line 2879 of file cmt_parser.cxx.

Referenced by parser().

02880 {
02881   Use& use = Use::current();
02882 
02883   cout << use.manager << endl;
02884 }

void Cmt::do_show_packages ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2887 of file cmt_parser.cxx.

Referenced by parser().

02888 {
02889   cmt_string path_name;
02890 
02891   if (arguments.size () > 0) path_name = arguments[0];
02892 
02893   FileScanner scanner;
02894   PackageViewer viewer;
02895 
02896   if (path_name == "")
02897     {
02898       int path_index;
02899 
02900       for (path_index = 0; path_index < m_cmt_path.size (); path_index++)
02901         {
02902           const cmt_string& path = m_cmt_path[path_index];
02903 
02904           scanner.scan_path (path, viewer);
02905         }
02906     }
02907   else
02908     {
02909       scanner.scan_path (path_name, viewer);
02910     }
02911 }

void Cmt::do_show_path ( ) [static]
 

Definition at line 2914 of file cmt_parser.cxx.

Referenced by parser().

02915 {
02916   int path_index;
02917 
02918   if (!m_quiet)
02919     {
02920       for (path_index = 0; path_index < m_cmt_path.size (); path_index++)
02921         {
02922           const cmt_string& path   = m_cmt_path[path_index];
02923           const cmt_string& source = m_cmt_path_sources[path_index];
02924 
02925           cout << "# Add path " << path << " from " << source << endl;
02926         }
02927 
02928       cout << "#" << endl;
02929     }
02930 
02931   for (path_index = 0; path_index < m_cmt_path.size (); path_index++)
02932     {
02933       const cmt_string& path   = m_cmt_path[path_index];
02934       const cmt_string& source = m_cmt_path_sources[path_index];
02935 
02936       if (path_index > 0) cout << CmtSystem::path_separator ();
02937 
02938       cout << path;
02939     }
02940 
02941   cout << endl;
02942 }

void Cmt::do_show_pattern ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 2945 of file cmt_parser.cxx.

Referenced by parser().

02946 {
02947   cmt_string name;
02948   if (arguments.size () > 0) name = arguments[0];
02949   Pattern::show (name);
02950 }

void Cmt::do_show_pattern_names ( ) [static]
 

Definition at line 2953 of file cmt_parser.cxx.

Referenced by parser().

02954 {
02955   Pattern::show_all_names ();
02956 }

void Cmt::do_show_patterns ( ) [static]
 

Definition at line 2959 of file cmt_parser.cxx.

Referenced by parser().

02960 {
02961   Pattern::show_all ();
02962 }

void Cmt::do_show_pwd ( ) [static]
 

Definition at line 2965 of file cmt_parser.cxx.

Referenced by parser().

02966 {
02967   cout << m_current_dir << endl;
02968 }

void Cmt::do_show_set ( const CmtSystem::cmt_string_vector & arguments,
PrintMode & mode ) [static]
 

Definition at line 2971 of file cmt_parser.cxx.

Referenced by parser().

02973 {
02974   do_show_macro (arguments, mode);
02975 }

void Cmt::do_show_set_value ( const CmtSystem::cmt_string_vector & arguments,
PrintMode & mode ) [static]
 

Definition at line 2978 of file cmt_parser.cxx.

Referenced by parser().

02980 {
02981   do_show_macro (arguments, mode);
02982 }

void Cmt::do_show_sets ( PrintMode & mode ) [static]
 

Definition at line 2985 of file cmt_parser.cxx.

Referenced by parser().

02986 {
02987   print_macros (mode);
02988 }

void Cmt::do_show_strategies ( ) [static]
 

Definition at line 2991 of file cmt_parser.cxx.

Referenced by parser().

02992 {
02993   cout << "Version strategy : ";
02994 
02995   switch (m_current_strategy)
02996     {
02997     case BestFit :
02998       cout << "BestFit";
02999       break;
03000     case BestFitNoCheck :
03001       cout << "BestFitNoCheck";
03002       break;
03003     case FirstChoice :
03004       cout << "FirstChoice";
03005       break;
03006     case LastChoice :
03007       cout << "LastChoice";
03008       break;
03009     case KeepAll :
03010       cout << "KeepAll";
03011       break;
03012     default :
03013       cout << "BestFit";
03014       break;
03015     }
03016   
03017   cout << endl;
03018   
03019   cout << "Build strategy   : ";
03020   
03021   if ((m_current_build_strategy & PrototypesMask) == Prototypes)
03022     {
03023       cout << "prototypes";
03024     }
03025   else
03026     {
03027       cout << "no_prototypes";
03028     }
03029   
03030   if ((m_current_build_strategy & KeepMakefilesMask) == KeepMakefiles)
03031     {
03032       cout << " keep_makefiles";
03033     }
03034   else
03035     {
03036       cout << " rebuild_makefiles";
03037     }
03038   
03039   cout << endl;
03040 }

void Cmt::do_show_system ( ) [static]
 

Definition at line 3121 of file cmt_parser.cxx.

Referenced by parser().

03122 {
03123   cout << CmtSystem::get_cmt_config () << endl;
03124 }

void Cmt::do_show_tags ( ) [static]
 

Definition at line 3043 of file cmt_parser.cxx.

Referenced by parser().

03044 {
03045   Tag::TagPtrVector tags = Tag::tags ();
03046   int index;
03047 
03048   set_standard_macros ();
03049 
03050   for (index = 0; index < tags.size (); index++)
03051     {
03052       const Tag* tag = tags[index];
03053       if (tag != 0)
03054         {
03055           tag->show (m_quiet);
03056         }
03057     }
03058 }

void Cmt::do_show_uses ( ) [static]
 

Definition at line 3061 of file cmt_parser.cxx.

Referenced by parser().

03062 {
03063   Use::show_all ();
03064 
03065 /*
03066   {
03067     Use::UsePtrVector& Uses = Use::uses ();
03068 
03069     Use& cu = Use::current ();
03070 
03071     for (int i = 0; i < Uses.size (); i++)
03072       {
03073         Use* use = Uses[i];
03074         
03075         if (use == 0) continue;
03076         if (use->discarded) continue;
03077         
03078         Use::UsePtrVector list;
03079         
03080         cu.get_paths (use, list);
03081 
03082         cout << " to " << use->package << endl;
03083 
03084         for (int j = list.size (); j >= 0; j--)
03085           {
03086             Use* u = list[j];
03087             if (u == 0) continue;
03088             cout << "  " << u->package << endl;
03089           }
03090       }
03091   }
03092 */
03093 }

void Cmt::do_show_version ( ) [static]
 

Definition at line 3096 of file cmt_parser.cxx.

Referenced by parser().

03097 {
03098   cout << m_current_version << endl;
03099 }

void Cmt::do_show_versions ( const CmtSystem::cmt_string_vector & arguments ) [static]
 

Definition at line 3102 of file cmt_parser.cxx.

Referenced by parser().

03103 {
03104   cmt_string package_name;
03105 
03106   if (arguments.size () > 0) package_name = arguments[0];
03107 
03108   FileScanner scanner;
03109 
03110   int path_index;
03111 
03112   for (path_index = 0; path_index < m_cmt_path.size (); path_index++)
03113     {
03114       const cmt_string& path   = m_cmt_path[path_index];
03115 
03116       scanner.scan_package (path, package_name);
03117     }
03118 }

void Cmt::do_unlock ( const cmt_string & package,
const cmt_string & version,
const cmt_string & path ) [static]
 

Definition at line 3127 of file cmt_parser.cxx.

Referenced by parser().

03130 {
03131   Use& use = Use::current();
03132 
03133   cout << "try to unlock package " << package << " in " << CmtSystem::pwd () << endl;
03134 
03135   set_standard_macros ();
03136 
03137   CmtLock::status status = CmtLock::unlock ();
03138 }

void Cmt::do_version ( ) [static]
 

Definition at line 3141 of file cmt_parser.cxx.

Referenced by parser().

03142 {
03143   cout << CMTVERSION << endl;
03144 }

const cmt_string & Cmt::filter_dir ( const cmt_string & dir ) [static]
 

Definition at line 3220 of file cmt_parser.cxx.

Referenced by Include::print_filters().

03221 {
03222   static cmt_string newdir;
03223 
03224   CmtSystem::compress_path (dir, newdir);
03225 
03226   return (newdir);
03227 }

ActionType Cmt::get_action ( ) [static]
 

Definition at line 3149 of file cmt_parser.cxx.

Referenced by MacroBuilder::build(), PathBuilder::build(), SetBuilder::build(), use_action_iterator::get_use(), and Symbol::show_macro().

03150 {
03151   return (m_action);
03152 }

const cmt_string & Cmt::get_cmt_home ( ) [static]
 

Definition at line 3159 of file cmt_parser.cxx.

Referenced by Use::show_all().

03160 {
03161   return (m_cmt_home);
03162 }

const CmtSystem::cmt_string_vector & Cmt::get_cmt_path ( ) [static]
 

Definition at line 3154 of file cmt_parser.cxx.

Referenced by Use::move_to().

03155 {
03156   return (m_cmt_path);
03157 }

const cmt_string & Cmt::get_cmt_user_context ( ) [static]
 

Definition at line 3164 of file cmt_parser.cxx.

Referenced by Use::show_all().

03165 {
03166   return (m_cmt_user_context);
03167 }

AccessMode Cmt::get_current_access ( ) [static]
 

Definition at line 3179 of file cmt_parser.cxx.

Referenced by Symbol::action().

03180 {
03181   return (m_current_access);
03182 }

const cmt_string & Cmt::get_current_dir ( ) [static]
 

Definition at line 3169 of file cmt_parser.cxx.

03170 {
03171   return (m_current_dir);
03172 }

const cmt_string & Cmt::get_current_package ( ) [static]
 

Definition at line 3174 of file cmt_parser.cxx.

Referenced by Generator::build_constituent_makefile(), Generator::build_msdev(), Generator::build_msdev_workspace(), and Generator::build_readme().

03175 {
03176   return (m_current_package);
03177 }

VersionStrategy Cmt::get_current_strategy ( ) [static]
 

Definition at line 3184 of file cmt_parser.cxx.

Referenced by VersionSelector::instance().

03185 {
03186   return (m_current_strategy);
03187 }

const cmt_string & Cmt::get_current_target ( ) [static]
 

Definition at line 3194 of file cmt_parser.cxx.

Referenced by MacroBuilder::build(), PathBuilder::build(), and SetBuilder::build().

03195 {
03196   return (m_current_target);
03197 }

const cmt_string & Cmt::get_current_version ( ) [static]
 

Definition at line 3189 of file cmt_parser.cxx.

Referenced by Generator::build_readme().

03190 {
03191   return (m_current_version);
03192 }

bool Cmt::get_debug ( ) [static]
 

Definition at line 3199 of file cmt_parser.cxx.

Referenced by Use::add(), MakefileGenerator::analyze_file(), build_deps(), build_deps_stream(), MakefileGenerator::fill_outputs(), get_all_files(), Use::get_paths(), use_action_iterator::get_use(), Use::move_to(), Use::reach_package(), Use::reorder(), Use::select_alternate(), and Use::set_auto_imports().

03200 {
03201   return (m_debug);
03202 }

bool Cmt::get_quiet ( ) [static]
 

Definition at line 3204 of file cmt_parser.cxx.

Referenced by Use::add(), DependencyAnalyzer::filter(), TriggerAnalyzer::filter(), BestFitNoCheckSelector::operate(), BestFitSelector::operate(), Use::show_all(), and Symbol::show_macro().

03205 {
03206   return (m_quiet);
03207 }

bool Cmt::get_recursive ( ) [static]
 

Definition at line 3209 of file cmt_parser.cxx.

Referenced by Use::add().

03210 {
03211   return (m_recursive);
03212 }

ScopeType Cmt::get_scope ( ) [static]
 

Definition at line 3214 of file cmt_parser.cxx.

Referenced by Symbol::action(), Use::add(), Use::clear(), use_action_iterator::get_use(), Use::set(), and Symbol::valid().

03215 {
03216   return (m_scope);
03217 }

void Cmt::install_cleanup_scripts ( ) [static]
 

Definition at line 3230 of file cmt_parser.cxx.

Referenced by do_config().

03231 {
03232 #ifdef WIN32
03233   static const int modes = 1;
03234   static const cmt_string suffix[1]   = {"bat"};
03235   static const PrintMode  mode[1]     = {Bat};
03236 #else
03237   static const int modes = 2;
03238   static const cmt_string suffix[2]   = {"csh", "sh"};
03239   static const PrintMode  mode[2]     = {Csh, Sh};
03240 #endif
03241 
03242   cout << "Creating cleanup scripts." << endl;
03243 
03244   cmt_string temp;
03245   int i;
03246 
03247   for (i = 0; i < modes; i++)
03248     {
03249       cmt_string file_name = "cleanup";
03250       file_name += ".";
03251       file_name += suffix[i];
03252       file_name += ".";
03253       file_name += "new";
03254 
03255       FILE* f = fopen (file_name.c_str (), "wb");
03256       if (f != NULL)
03257         {
03258           if (mode[i] == Csh)
03259             {
03260               fprintf (f, "set tempfile=`${CMTROOT}/mgr/cmt build temporary_name -quiet`\n");
03261               fprintf (f, "if $status != 0 then\n  set tempfile=/tmp/cmt.$$\nendif\n");
03262               fprintf (f, "${CMTROOT}/mgr/cmt -quiet cleanup -%s "
03263                        "-pack=%s -version=%s -path=%s $* >${tempfile}; "
03264                        "source ${tempfile}\n",
03265                        suffix[i].c_str (),
03266                        m_current_package.c_str (),
03267                        m_current_version.c_str (),
03268                        m_current_path.c_str ());
03269               fprintf (f, "/bin/rm -f ${tempfile}\n");
03270             }
03271           else if (mode[i] == Sh)
03272             {
03273               fprintf (f, "tempfile=`${CMTROOT}/mgr/cmt build temporary_name -quiet`\n");
03274               fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n");
03275               fprintf (f, "${CMTROOT}/mgr/cmt -quiet cleanup -%s "
03276                        "-pack=%s -version=%s -path=%s $* >${tempfile}; "
03277                        ". ${tempfile}\n",
03278                        suffix[i].c_str (),
03279                        m_current_package.c_str (),
03280                        m_current_version.c_str (),
03281                        m_current_path.c_str ());
03282               fprintf (f, "/bin/rm -f ${tempfile}\n");
03283             }
03284           else
03285             {
03286             }
03287 
03288           fprintf (f, "\n");
03289 
03290           fclose (f);
03291 
03292           cmt_string old_file_name = "cleanup";
03293           old_file_name += ".";
03294           old_file_name += suffix[i];
03295 
03296           CmtSystem::compare_and_update_files (file_name, old_file_name);
03297         }
03298     }
03299 }

void Cmt::install_setup_scripts ( ) [static]
 

Definition at line 3302 of file cmt_parser.cxx.

Referenced by do_config().

03303 {
03304 #ifdef WIN32
03305   static const int modes = 1;
03306   static const cmt_string suffix[1]   = {"bat"};
03307   static const PrintMode  mode[1]     = {Bat};
03308 #else
03309   static const int modes = 2;
03310   static const cmt_string suffix[2]   = {"csh", "sh"};
03311   static const PrintMode  mode[2]     = {Csh, Sh};
03312 #endif
03313 
03314   cout << "Creating setup scripts." << endl;
03315 
03316   cmt_string temp;
03317   int i;
03318 
03319   for (i = 0; i < modes; i++)
03320     {
03321       cmt_string file_name = "setup";
03322       file_name += ".";
03323       file_name += suffix[i];
03324       file_name += ".";
03325       file_name += "new";
03326 
03327       FILE* f = fopen (file_name.c_str (), "wb");
03328       if (f != NULL)
03329         {
03330           if (mode[i] == Csh)
03331             {
03332               fprintf (f, "# echo \"Setting %s %s in %s\"\n",
03333                        m_current_package.c_str (),
03334                        m_current_version.c_str (),
03335                        m_current_path.c_str ());
03336               fprintf (f, "\n");
03337 
03338               fprintf (f, "setenv CMTROOT %s\n", m_cmt_root.c_str ());
03339               fprintf (f, "source ${CMTROOT}/mgr/setup.csh\n");
03340               fprintf (f, "\n");
03341               fprintf (f, "set tempfile=`${CMTROOT}/mgr/cmt build temporary_name -quiet`\n");
03342               fprintf (f, "if $status != 0 then\n  set tempfile=/tmp/cmt.$$\nendif\n");
03343               fprintf (f, "${CMTROOT}/mgr/cmt -quiet setup -%s "
03344                        "-pack=%s -version=%s -path=%s $* >${tempfile}; "
03345                        "source ${tempfile}\n",
03346                        suffix[i].c_str (),
03347                        m_current_package.c_str (),
03348                        m_current_version.c_str (),
03349                        m_current_path.c_str ());
03350               fprintf (f, "/bin/rm -f ${tempfile}\n");
03351             }
03352           else if (mode[i] == Sh)
03353             {
03354               fprintf (f, "# echo \"Setting %s %s in %s\"\n",
03355                        m_current_package.c_str (),
03356                        m_current_version.c_str (),
03357                        m_current_path.c_str ());
03358               fprintf (f, "\n");
03359 
03360               fprintf (f, "CMTROOT=%s; export CMTROOT\n", m_cmt_root.c_str ());
03361               fprintf (f, ". ${CMTROOT}/mgr/setup.sh\n");
03362               fprintf (f, "\n");
03363               fprintf (f, "tempfile=`${CMTROOT}/mgr/cmt build temporary_name -quiet`\n");
03364               fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n");
03365               fprintf (f, "${CMTROOT}/mgr/cmt -quiet setup -%s "
03366                        "-pack=%s -version=%s -path=%s $* >${tempfile}; "
03367                        ". ${tempfile}\n",
03368                        suffix[i].c_str (),
03369                        m_current_package.c_str (),
03370                        m_current_version.c_str (),
03371                        m_current_path.c_str ());
03372               fprintf (f, "/bin/rm -f ${tempfile}\n");
03373             }
03374           else if (mode[i] == Bat)
03375             {
03376               fprintf (f, "rem Setting %s %s in %s\n",
03377                        m_current_package.c_str (),
03378                        m_current_version.c_str (),
03379                        m_current_path.c_str ());
03380               fprintf (f, "@echo off\n");
03381 
03382               fprintf (f, "set CMTROOT=%s\n", m_cmt_root.c_str ());
03383               fprintf (f, "call %%CMTROOT%%\\mgr\\setup.bat\n");
03384               fprintf (f, "\n");
03385               fprintf (f, "set tempfile=%%HOMEDRIVE%%%%HOMEPATH%%tmpsetup.bat\n");
03386               fprintf (f, "%%CMTROOT%%\\%%CMTBIN%%\\cmt.exe -quiet setup -%s "
03387                        "-pack=%s -version=%s -path=%s "
03388                        "%%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 >%%tempfile%%\n",
03389                        suffix[i].c_str (),
03390                        m_current_package.c_str (),
03391                        m_current_version.c_str (),
03392                        m_current_path.c_str ());
03393               fprintf (f, "if exist %%tempfile%% call %%tempfile%%\n");
03394               fprintf (f, "if exist %%tempfile%% del %%tempfile%%\n");
03395             }
03396 
03397           fprintf (f, "\n");
03398 
03399           fclose (f);
03400 
03401           cmt_string old_file_name = "setup";
03402           old_file_name += ".";
03403           old_file_name += suffix[i];
03404 
03405           CmtSystem::compare_and_update_files (file_name, old_file_name);
03406         }
03407     }
03408 }

void Cmt::install_test_cleanup_scripts ( ) [static]
 

Definition at line 3411 of file cmt_parser.cxx.

Referenced by do_config().

03412 {
03413 #ifdef WIN32
03414   static const int modes = 1;
03415   static const cmt_string suffix[1]   = {"bat"};
03416   static const PrintMode  mode[1]     = {Bat};
03417 #else
03418   static const int modes = 2;
03419   static const cmt_string suffix[2]   = {"csh", "sh"};
03420   static const PrintMode  mode[2]     = {Csh, Sh};
03421 #endif
03422 
03423   cout << "Creating cleanup scripts." << endl;
03424 
03425   cmt_string temp;
03426   int i;
03427 
03428   for (i = 0; i < modes; i++)
03429     {
03430       cmt_string file_name = "cleanup";
03431       file_name += ".";
03432       file_name += suffix[i];
03433       file_name += ".";
03434       file_name += "new";
03435 
03436       FILE* f = fopen (file_name.c_str (), "wb");
03437       if (f != NULL)
03438         {
03439           if (mode[i] == Csh)
03440             {
03441               fprintf (f, "setenv CMTROOT %s\n", m_cmt_root.c_str ());
03442               fprintf (f, "source ${CMTROOT}/mgr/setup.csh\n");
03443               fprintf (f, "set tempfile=`${CMTROOT}/mgr/cmt build temporary_name -quiet`\n");
03444               fprintf (f, "if $status != 0 then\n  set tempfile=/tmp/cmt.$$\nendif\n");
03445               fprintf (f, "${CMTROOT}/mgr/cmt -quiet cleanup -%s -path=%s $* >${tempfile}; "
03446                        "source ${tempfile}\n",
03447                        suffix[i].c_str (),
03448                        m_current_path.c_str ());
03449               fprintf (f, "/bin/rm -f ${tempfile}\n");
03450             }
03451           else if (mode[i] == Sh)
03452             {
03453               fprintf (f, "CMTROOT=%s; export CMTROOT\n", m_cmt_root.c_str ());
03454               fprintf (f, ". ${CMTROOT}/mgr/setup.sh\n");
03455               fprintf (f, "tempfile=`${CMTROOT}/mgr/cmt build temporary_name -quiet`\n");
03456               fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n");
03457               fprintf (f, "${CMTROOT}/mgr/cmt -quiet cleanup -%s -path=%s $* >${tempfile}; "
03458                        ". ${tempfile}\n",
03459                        suffix[i].c_str (),
03460                        m_current_path.c_str ());
03461               fprintf (f, "/bin/rm -f ${tempfile}\n");
03462             }
03463           else
03464             {
03465               fprintf (f, "set CMTROOT=%s\n", m_cmt_root.c_str ());
03466               fprintf (f, "call %%CMTROOT%%\\mgr\\setup.bat\n");
03467               fprintf (f, "set tempfile=%%HOMEDRIVE%%%%HOMEPATH%%tmpsetup.bat\n");
03468               fprintf (f, "%%CMTROOT%%\\%%CMTBIN%%\\cmt.exe -quiet cleanup -%s "
03469                        "-path=%s "
03470                        "%%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 >%%tempfile%%\n",
03471                        suffix[i].c_str (),
03472                        m_current_path.c_str ());
03473               fprintf (f, "if exist %%tempfile%% call %%tempfile%%\n");
03474               fprintf (f, "if exist %%tempfile%% del %%tempfile%%\n");
03475             }
03476 
03477           fprintf (f, "\n");
03478 
03479           fclose (f);
03480 
03481           cmt_string old_file_name = "cleanup";
03482           old_file_name += ".";
03483           old_file_name += suffix[i];
03484 
03485           CmtSystem::compare_and_update_files (file_name, old_file_name);
03486         }
03487     }
03488 }

void Cmt::install_test_setup_scripts ( ) [static]
 

Definition at line 3491 of file cmt_parser.cxx.

Referenced by do_config().

03492 {
03493 #ifdef WIN32
03494   static const int modes = 1;
03495   static const cmt_string suffix[1]   = {"bat"};
03496   static const PrintMode  mode[1]     = {Bat};
03497 #else
03498   static const int modes = 2;
03499   static const cmt_string suffix[2]   = {"csh", "sh"};
03500   static const PrintMode  mode[2]     = {Csh, Sh};
03501 #endif
03502 
03503   cout << "Creating setup scripts." << endl;
03504 
03505   cmt_string temp;
03506   int i;
03507 
03508   for (i = 0; i < modes; i++)
03509     {
03510       cmt_string file_name = "setup";
03511       file_name += ".";
03512       file_name += suffix[i];
03513       file_name += ".";
03514       file_name += "new";
03515 
03516       FILE* f = fopen (file_name.c_str (), "wb");
03517       if (f != NULL)
03518         {
03519           if (mode[i] == Csh)
03520             {
03521               fprintf (f, "# echo \"Setting standalone package\"\n");
03522               fprintf (f, "\n");
03523 
03524               fprintf (f, "setenv CMTROOT %s\n", m_cmt_root.c_str ());
03525               fprintf (f, "source ${CMTROOT}/mgr/setup.csh\n");
03526               fprintf (f, "set tempfile=`${CMTROOT}/mgr/cmt build temporary_name -quiet`\n");
03527               fprintf (f, "if $status != 0 then\n  set tempfile=/tmp/cmt.$$\nendif\n");
03528               fprintf (f, "${CMTROOT}/mgr/cmt -quiet setup -%s -path=%s $* >${tempfile}; "
03529                        "source ${tempfile}\n",
03530                        suffix[i].c_str (),
03531                        m_current_path.c_str ());
03532               fprintf (f, "/bin/rm -f ${tempfile}\n");
03533             }
03534           else if (mode[i] == Sh)
03535             {
03536               fprintf (f, "# echo \"Setting standalone package\"\n");
03537               fprintf (f, "\n");
03538 
03539               fprintf (f, "CMTROOT=%s; export CMTROOT\n", m_cmt_root.c_str ());
03540               fprintf (f, ". ${CMTROOT}/mgr/setup.sh\n");
03541               fprintf (f, "\n");
03542               fprintf (f, "tempfile=`${CMTROOT}/mgr/cmt build temporary_name -quiet`\n");
03543               fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n");
03544               fprintf (f, "${CMTROOT}/mgr/cmt -quiet setup -%s -path=%s $* >${tempfile}; "
03545                        ". ${tempfile}\n",
03546                        suffix[i].c_str (),
03547                        m_current_path.c_str ());
03548               fprintf (f, "/bin/rm -f ${tempfile}\n");
03549             }
03550           else
03551             {
03552               fprintf (f, "rem Setting standalone package\n");
03553               fprintf (f, "@echo off\n");
03554 
03555               fprintf (f, "set CMTROOT=%s\n", m_cmt_root.c_str ());
03556               fprintf (f, "call %%CMTROOT%%\\mgr\\setup.bat\n");
03557               fprintf (f, "\n");
03558               fprintf (f, "set tempfile=%%HOMEDRIVE%%%%HOMEPATH%%tmpsetup.bat\n");
03559               fprintf (f, "%%CMTROOT%%\\%%CMTBIN%%\\cmt.exe -quiet setup -%s "
03560                        "-path=%s "
03561                        "%%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 >%%tempfile%%\n",
03562                        suffix[i].c_str (),
03563                        m_current_path.c_str ());
03564               fprintf (f, "if exist %%tempfile%% call %%tempfile%%\n");
03565               fprintf (f, "if exist %%tempfile%% del %%tempfile%%\n");
03566             }
03567 
03568           fprintf (f, "\n");
03569 
03570           fclose (f);
03571 
03572           cmt_string old_file_name = "setup";
03573           old_file_name += ".";
03574           old_file_name += suffix[i];
03575 
03576           CmtSystem::compare_and_update_files (file_name, old_file_name);
03577         }
03578     }
03579 }

bool Cmt::load ( const cmt_string & path,
const cmt_string & package,
const cmt_string & version,
const cmt_string & tag_name = "" ) [static]
 

Definition at line 3582 of file cmt_parser.cxx.

03586 {
03587   clear ();
03588   configure ();
03589 
03590   m_action  = action_load;
03591   m_recursive = true;
03592 
03593   if (((package != "") && (version != "")) || (m_current_package == ""))
03594     {
03595       //
03596       //  package may be specified with a prefix.
03597       //
03598       cmt_string dir;
03599       cmt_string base;
03600       
03601       CmtSystem::dirname (package, dir);
03602       CmtSystem::basename (package, base);
03603       
03604       if (dir != "")
03605         {
03606           m_current_path = path;
03607           m_current_path += CmtSystem::file_separator ();
03608           m_current_path += dir;
03609         }
03610       else
03611         {
03612           m_current_path = path;
03613         }
03614       
03615       m_current_package = base;
03616       m_current_version = version;
03617     }
03618 
03619   if (tag_name != "")
03620     {
03621       Tag* tag;
03622 
03623       Tag::unmark_all ();
03624       configure_site_tag (0);
03625       configure_uname_tag ();
03626       configure_hosttype_tag ();
03627 
03628       m_current_tag = tag_name;
03629 
03630       //if (!m_quiet) cerr << "load1> current_tag=" << m_current_tag << endl;
03631 
03632       tag = Tag::add (tag_name, PriorityTag, "load", 0);
03633       tag->mark ();
03634     }
03635 
03636   /*
03637     Set to developer mode if positioned into the package
03638     (which is detected since we were able to retreive the
03639     Version, Package and Path)
03640   */
03641 
03642   if ((m_current_path.size () == 0) ||
03643       (m_current_package.size () == 0) ||
03644       (m_current_version.size () == 0))
03645     {
03646       m_current_access = UserMode;
03647     }
03648   else
03649     {
03650       m_current_access = DeveloperMode;
03651     }
03652 
03653   use_cmt ();
03654 
03655   cmt_string dir;
03656 
03657   /*
03658     Try to access the package.
03659   */
03660 
03661   if (m_current_path != "")
03662     {
03663       dir = m_current_path;
03664     }
03665   else
03666     {
03667       dir = m_default_path;
03668     }
03669 
03670   if (!CmtSystem::cd (m_current_path))
03671     {
03672       if (!m_quiet)
03673         {
03674           cout << "#CMT> Cannot reach the directory " <<
03675             m_current_path << endl;
03676         }
03677       CmtError::set (CmtError::package_not_found, "Load> Cannot reach the path directory");
03678       CmtSystem::cd (m_current_dir);
03679 
03680       return (false);
03681     }
03682 
03683   dir += CmtSystem::file_separator ();
03684   dir += m_current_package;
03685 
03686   if (!CmtSystem::cd (m_current_package))
03687     {
03688       if (!m_quiet)
03689         {
03690           cout << "#CMT::load> Cannot reach the package " <<
03691             m_current_package << endl;
03692         }
03693       CmtError::set (CmtError::package_not_found, "Load> Cannot reach the package directory");
03694       CmtSystem::cd (m_current_dir);
03695 
03696       return (false);
03697     }
03698 
03699   dir += CmtSystem::file_separator ();
03700   dir += m_current_version;
03701 
03702   if (!CmtSystem::cd (m_current_version))
03703     {
03704       if (!m_quiet)
03705         {
03706           cout << "#CMT> Cannot reach the version " <<
03707             m_current_version << endl;
03708         }
03709       CmtError::set (CmtError::package_not_found, "Load> Cannot reach the version directory");
03710       CmtSystem::cd (m_current_dir);
03711 
03712       return (false);
03713     }
03714 
03715   if (CmtSystem::cd ("cmt"))
03716     {
03717       dir += CmtSystem::file_separator ();
03718       dir += "cmt";
03719       m_current_style = cmt_style;
03720     }
03721   else
03722     {
03723       /*
03724         if (!m_quiet)
03725         {
03726         cout << "Cannot reach the cmt branch" << endl;
03727         }
03728       */
03729 
03730       if (CmtSystem::cd ("mgr"))
03731         {
03732           dir += CmtSystem::file_separator ();
03733           dir += "mgr";
03734           m_current_style = mgr_style;
03735         }
03736       else
03737         {
03738           if (!m_quiet)
03739             {
03740               cout << "#CMT> Cannot reach the mgr branch" << endl;
03741             }
03742 
03743           CmtError::set (CmtError::package_not_found,
03744                          "Load> Cannot reach the mgr/cmt directory");
03745           CmtSystem::cd (m_current_dir);
03746 
03747           return (false);
03748         }
03749     }
03750 
03751   /*
03752     Check Tag is always set up
03753   */
03754 
03755   if (m_current_tag == "")
03756     {
03757       char* env;
03758 
03759       env = getenv (m_current_config.c_str ());
03760       if (env != 0)
03761         {
03762           Tag* tag;
03763 
03764           tag = Tag::add (env, PriorityConfig, "load", 0);
03765           tag->mark ();
03766           m_current_tag = env;
03767 
03768           //if (!m_quiet) cerr << "load2> current_tag=" << m_current_tag << endl;
03769 
03770         }
03771       else
03772         {
03773           m_current_tag = m_cmt_config;
03774 
03775           //if (!m_quiet) cerr << "load3> current_tag=" << m_current_tag << endl;
03776 
03777         }
03778     }
03779 
03780   if (m_debug)
03781     {
03782       cout << "pwd = " << CmtSystem::pwd () << endl;
03783     }
03784 
03785   configure_current_dir ();
03786   build_prefix (m_current_package, m_current_prefix);
03787   build_config (m_current_prefix, m_current_config);
03788 
03789   Use* use = &(Use::current());
03790   use->path    = m_current_path;
03791   use->package = m_current_package;
03792   use->version = m_current_version;
03793   use->prefix  = m_current_prefix;
03794   use->done    = false;
03795 
03796   /*
03797     Work on the requirements file.
03798   */
03799 
03800   dir += CmtSystem::file_separator ();
03801   dir += "requirements";
03802   parse_requirements (dir, use);
03803 
03804   if (CmtError::has_pending_error ()) return (false);
03805 
03809   Pattern::apply_all_globals ();
03810 
03811   /*
03812     Select all possible tags
03813   */
03814 
03815   Tag::restore_tree ();
03816 
03817   return (true);
03818 }

bool Cmt::need_prototypes ( ) [static]
 

See reach_current_package for an explanation of this call.

Definition at line 3821 of file cmt_parser.cxx.

Referenced by Constituent::add().

03822 {
03823   if ((m_current_build_strategy & PrototypesMask) == Prototypes) return (true);
03824   else return (false);
03825 }

void Cmt::parse_arguments ( int argc,
char * argv[],
CmtSystem::cmt_string_vector & arguments,
cmt_string & extra_line,
cmt_string & extra_file,
PrintMode & mode ) [static]
 

Definition at line 3828 of file cmt_parser.cxx.

Referenced by parser().

03833 {
03834   /*
03835     Decoding arguments.
03836 
03837     While decoding all arguments, no requirements analysis should
03838     occur. Every new option, or parameter should be saved and
03839     used later at actual analysis time.
03840   */
03841 
03842   cmt_string arg;
03843 
03844   m_action = action_none;
03845 
03846   arguments.clear ();
03847   extra_line.erase (0);
03848   extra_file.erase (0);
03849   mode = Csh;
03850 
03851     /*
03852       Tag management.
03853       ---------------
03854 
03855       Tag settings may come from :
03856 
03857       - existing environment variables:
03858 
03859           1) CMTCONFIG
03860 
03861           2) CMTEXTRATAGS for addons
03862 
03863       - arguments:
03864 
03865           -tag=<tag-list>
03866           -tag_add=<tag-list>
03867           -tag_remove=<tag-list>
03868 
03869        o Arguments should take precedence over environment variables.
03870        o when nothing is specified:
03871 
03872           - primary tag = CMTCONFIG
03873           - tag set is empty
03874 
03875 
03876      */
03877 
03878 
03879   restore_all_tags (0);
03880 
03881 #ifdef WIN32
03882   m_build_nmake = true;
03883 #endif
03884 
03885   while (argc > 1)
03886     {
03887       int lf;
03888 
03889       arg = argv[1];
03890       lf = arg.find ('\r');
03891       if (lf != cmt_string::npos) arg.erase (lf);
03892 
03893       if (arg[0] == '\"') arg.erase (0, 1);
03894       if (arg[arg.size () - 1] == '\"') arg.erase (arg.size () - 1, 1);
03895 
03896       //fprintf (stderr, "arg=[%s]\n", arg.c_str ());
03897 
03898       switch (arg[0])
03899         {
03900         case 'b' :
03901           if ((arg == "b") ||
03902               (arg == "br") ||
03903               (arg == "bro") ||
03904               (arg == "broa") ||
03905               (arg == "broad") ||
03906               (arg == "broadc") ||
03907               (arg == "broadca") ||
03908               (arg == "broadcas") ||
03909               (arg == "broadcast"))
03910             {
03911               argc--;
03912               argv++;
03913               while (argc > 1)
03914                 {
03915                   cmt_string& s = arguments.add ();
03916                   s = argv[1];
03917                   argc--;
03918                   argv++;
03919                 }
03920 
03921               m_action = action_broadcast;
03922             }
03923           else if (arg == "build")
03924             {
03925               argc--;
03926               argv++;
03927 
03928               if (argc > 1)
03929                 {
03930                   arg = argv[1];
03931 
03932                   if (arg == "-nmake")
03933                     {
03934                       m_build_nmake = true;
03935                       argc--;
03936                       argv++;
03937                     }
03938                 }
03939 
03940               if (argc > 1)
03941                 {
03942                   arg = argv[1];
03943 
03944                   if (arg == "-nmake")
03945                     {
03946                       argc--;
03947                       argv++;
03948                     }
03949 
03950                   if (arg == "constituent_makefile")
03951                     {
03952                       argc--;
03953                       argv++;
03954                       if (argc > 1)
03955                         {
03956                           cmt_string& s = arguments.add ();
03957                           s = argv[1];
03958 
03959                           m_action = action_build_constituent_makefile;
03960                         }
03961                       else
03962                         {
03963                           if (!m_quiet) cout << "#CMT> syntax error : constituent name missing" << endl;
03964                         }
03965                     }
03966                   else if (arg == "constituents_makefile")
03967                     {
03968                       m_action = action_build_constituents_makefile;
03969                     }
03970                   else if (arg == "dependencies")
03971                     {
03972                       argc--;
03973                       argv++;
03974                       if (argc > 1)
03975                         {
03976                           cmt_string& s = arguments.add ();
03977                           s = argv[1];
03978 
03979                           m_action = action_build_dependencies;
03980                         }
03981                       else
03982                         {
03983                           if (!m_quiet) cout << "#CMT> syntax error : arguments missing " << endl;
03984                         }
03985 
03986                       argc = 0;
03987                     }
03988                   else if (arg == "library_links")
03989                     {
03990                       m_action = action_build_library_links;
03991                     }
03992                   else if (arg == "make_setup")
03993                     {
03994                       m_action = action_build_make_setup;
03995                     }
03996                   else if (arg == "msdev")
03997                     {
03998                       argc--;
03999                       argv++;
04000 
04001                       if (argc > 1)
04002                         {
04003                           cmt_string& s = arguments.add ();
04004                           s = argv[1];
04005                           if (s[0] == '-')
04006                             {
04007                               s = "";
04008                               argc++;
04009                               argv--;
04010                             }
04011                         }
04012 
04013                       m_action = action_build_msdev;
04014                     }
04015                   else if (arg == "os9_makefile")
04016                     {
04017                       argc--;
04018                       argv++;
04019                       if (argc > 1)
04020                         {
04021                           cmt_string& s = arguments.add ();
04022                           s = argv[1];
04023 
04024                           m_action = action_build_os9_makefile;
04025                         }
04026                       else
04027                         {
04028                           if (!m_quiet) cout << "#CMT> syntax error : arguments missing " << endl;
04029                         }
04030                     }
04031                   else if (arg == "prototype")
04032                     {
04033                       argc--;
04034                       argv++;
04035                       if (argc > 1)
04036                         {
04037                           cmt_string& s = arguments.add ();
04038                           s = argv[1];
04039 
04040                           m_action = action_build_prototype;
04041                         }
04042                       else
04043                         {
04044                           if (!m_quiet) cout << "#CMT> syntax error : arguments missing" << endl;
04045                         }
04046                     }
04047                   else if (arg == "readme")
04048                     {
04049                       m_action = action_build_readme;
04050 
04051                       argc--;
04052                       argv++;
04053                       while (argc > 1)
04054                         {
04055                           cmt_string& s = arguments.add ();
04056                           s = argv[1];
04057                           argc--;
04058                           argv++;
04059                         }
04060                     }
04061                   else if (arg == "tag_makefile")
04062                     {
04063                       m_action = action_build_tag_makefile;
04064                     }
04065                   else if (arg == "temporary_name")
04066                     {
04067                       m_action = action_build_temporary_name;
04068                     }
04069                   else if (arg == "triggers")
04070                     {
04071                       argc--;
04072                       argv++;
04073                       if (argc > 1)
04074                         {
04075                           cmt_string& s = arguments.add ();
04076                           s = argv[1];
04077 
04078                           m_action = action_build_triggers;
04079                         }
04080                       else
04081                         {
04082                           if (!m_quiet) cout << "#CMT> syntax error : arguments missing" << endl;
04083                         }
04084                     }
04085                   else if (arg == "windefs")
04086                     {
04087                       argc--;
04088                       argv++;
04089                       if (argc > 1)
04090                         {
04091                           cmt_string& s = arguments.add ();
04092                           s = argv[1];
04093 
04094                           m_action = action_build_windefs;
04095                         }
04096                       else
04097                         {
04098                           if (!m_quiet) cout << "#CMT> syntax error : arguments missing" << endl;
04099                         }
04100                     }
04101                 }
04102               else
04103                 {
04104                   if (!m_quiet) cout << "#CMT> syntax error : don't know what to build" << endl;
04105                 }
04106             }
04107           else
04108             {
04109               if (!m_quiet) cout << "#CMT> syntax error : bad verb " << arg << endl;
04110             }
04111           break;
04112         case 'c' :
04113           if (arg == "check")
04114             {
04115               argc--;
04116               argv++;
04117 
04118               if (argc > 1)
04119                 {
04120                   arg = argv[1];
04121 
04122                   if (arg == "configuration")
04123                     {
04124                       m_action = action_check_configuration;
04125                     }
04126                   else if (arg == "files")
04127                     {
04128                       argc--;
04129                       argv++;
04130                       if (argc > 1)
04131                         {
04132                           cmt_string& s = arguments.add ();
04133                           s = argv[1];
04134                           argc--;
04135                           argv++;
04136                           if (argc > 1)
04137                             {
04138                               cmt_string& s = arguments.add ();
04139                               s = argv[1];
04140 
04141                               m_action = action_check_files;
04142                             }
04143                           else
04144                             {
04145                               if (!m_quiet) cout << "#CMT> syntax error : reference file name missing" 
04146                                                  << endl;
04147                             }
04148                         }
04149                       else
04150                         {
04151                           if (!m_quiet) cout << "#CMT> syntax error : file name missing" << endl;
04152                         }
04153                     }
04154                   else if (arg == "version")
04155                     {
04156                       argc--;
04157                       argv++;
04158                       if (argc > 1)
04159                         {
04160                           cmt_string& s = arguments.add ();
04161                           s = argv[1];
04162 
04163                           m_action = action_check_version;
04164                         }
04165                       else
04166                         {
04167                           if (!m_quiet) cout << "#CMT> syntax error : package name missing" << endl;
04168                         }
04169                     }
04170                   else
04171                     {
04172                       if (!m_quiet) cout << "#CMT> syntax error : bad check option" << endl;
04173                     }
04174                 }
04175               else
04176                 {
04177                   if (!m_quiet) cout << "#CMT> syntax error : don't know what to check" << endl;
04178                 }
04179             }
04180           else if (arg == "check_files")
04181             {
04182               argc--;
04183               argv++;
04184               if (argc > 1)
04185                 {
04186                   cmt_string& s = arguments.add ();
04187                   s = argv[1];
04188                   argc--;
04189                   argv++;
04190                   if (argc > 1)
04191                     {
04192                       cmt_string& s = arguments.add ();
04193                       s = argv[1];
04194 
04195                       m_action = action_check_files;
04196                     }
04197                   else
04198                     {
04199                       if (!m_quiet) cout << "#CMT> syntax error : reference file missing" << endl;
04200                     }
04201                 }
04202               else
04203                 {
04204                   if (!m_quiet) cout << "#CMT> syntax error : file name missing" << endl;
04205                 }
04206             }
04207           else if ((arg == "co") ||
04208                    (arg == "checkout"))
04209             {
04210               // handle all of the command line arguments in a vector
04211               argc--;
04212               argv++;
04213               if (argc > 1)
04214                 {
04215                   m_action = action_checkout;
04216 
04217                   while (argc > 1)
04218                     {
04219                       cmt_string& s = arguments.add ();
04220                       s = argv[1];
04221                       argc--;
04222                       argv++;
04223                     }
04224                 }
04225               else
04226                 {
04227                   if (!m_quiet) cout << "#CMT> syntax error : checkout arguments missing" << endl;
04228                 }
04229             }
04230           else if (arg == "cleanup")
04231             {
04232               m_action = action_cleanup;
04233             }
04234           else if (arg == "config")
04235             {
04236               argc--;
04237               argv++;
04238               if (argc > 1)
04239                 {
04240                   cout << "#---------------------------------------------------------" << endl;
04241                   cout << "# Warning : using 'cmt config ...' to create a package is "
04242                       "becoming obsolete" << endl;
04243                   cout << "# Please use 'cmt create ...' instead" << endl;
04244                   cout << "#---------------------------------------------------------" << endl;
04245 
04246                   m_current_package = argv[1];
04247                   m_current_version.erase (0);
04248                   m_current_path.erase (0);
04249 
04250                   argc--;
04251                   argv++;
04252                   if (argc > 1)
04253                     {
04254                       m_current_version = argv[1];
04255 
04256                       {
04257                         cmt_string& s = arguments.add ();
04258                         s = m_current_package;
04259                       }
04260                       {
04261                         cmt_string& s = arguments.add ();
04262                         s = m_current_version;
04263                       }
04264 
04265                       argc--;
04266                       argv++;
04267                       if (argc > 1)
04268                         {
04269                           m_current_path = argv[1];
04270                           if (m_current_path[0] == '-')
04271                             {
04272                               m_current_path.erase (0);
04273                             }
04274                         }
04275 
04276                       m_action = action_create;
04277                     }
04278                   else
04279                     {
04280                       if (!m_quiet) cout << "#CMT> syntax error : create arguments missing" << endl;
04281                     }
04282                 }
04283               else
04284                 {
04285                   m_action = action_config;
04286                 }
04287             }
04288           else if (arg == "create")
04289             {
04290               argc--;
04291               argv++;
04292 
04293               if (argc > 1)
04294                 {
04295                   while (argc > 1)
04296                     {
04297                       cmt_string& s = arguments.add ();
04298                       s = argv[1];
04299                       argc--;
04300                       argv++;
04301                     }
04302 
04303                   m_action = action_create;
04304                 }
04305               else
04306                 {
04307                   if (!m_quiet) cout << "#CMT> syntax error : create arguments missing" << endl;
04308                 }
04309             }
04310           else if (arg == "cvsbranches")
04311             {
04312               argc--;
04313               argv++;
04314               if (argc > 1)
04315                 {
04316                   cmt_string& s = arguments.add ();
04317                   s = argv[1];
04318                   argc--;
04319                   argv++;
04320 
04321                   m_action = action_cvsbranches;
04322                 }
04323               else
04324                 {
04325                   if (!m_quiet) cout << "#CMT> syntax error : cvsbranches arguments missing" << endl;
04326                 }
04327             }
04328           else if (arg == "cvssubpackages")
04329             {
04330               argc--;
04331               argv++;
04332               if (argc > 1)
04333                 {
04334                   cmt_string& s = arguments.add ();
04335                   s = argv[1];
04336                   argc--;
04337                   argv++;
04338 
04339                   m_action = action_cvssubpackages;
04340                 }
04341               else
04342                 {
04343                   if (!m_quiet) cout << "#CMT> syntax error : cvssubpackages arguments missing" << endl;
04344                 }
04345             }
04346           else if (arg == "cvstags")
04347             {
04348               argc--;
04349               argv++;
04350               if (argc > 1)
04351                 {
04352                   while (argc > 1)
04353                     {
04354                       cmt_string& s = arguments.add ();
04355                       s = argv[1];
04356                       argc--;
04357                       argv++;
04358                     }
04359 
04360                   m_action = action_cvstags;
04361                 }
04362               else
04363                 {
04364                   if (!m_quiet) cout << "#CMT> syntax error : package name missing" << endl;
04365                 }
04366             }
04367           else
04368             {
04369               if (!m_quiet) cout << "#CMT> syntax error : bad verb " << arg << endl;
04370             }
04371           break;
04372         case 'e' :
04373           if (arg == "expand")
04374             {
04375               argc--;
04376               argv++;
04377 
04378               if (argc > 1)
04379                 {
04380                   arg = argv[1];
04381 
04382                   if (arg == "model")
04383                     {
04384                       argc--;
04385                       argv++;
04386 
04387                       if (argc > 1)
04388                         {
04389                           while (argc > 1)
04390                             {
04391                               cmt_string& s = arguments.add ();
04392                               s = argv[1];
04393                               argc--;
04394                               argv++;
04395                             }
04396 
04397                           m_action = action_expand_model;
04398                         }
04399                       else
04400                         {
04401                           if (!m_quiet) cout << "#CMT> syntax error : model not specified" << endl;
04402                         }
04403                     }
04404                   else
04405                     {
04406                       if (!m_quiet) cout << "#CMT> syntax error : bad expand option" << endl;
04407                     }
04408                 }
04409               else
04410                 {
04411                   if (!m_quiet) cout << "#CMT> syntax error : don't know what to expand" << endl;
04412                 }
04413             }
04414           else
04415             {
04416               if (!m_quiet) cout << "#CMT> syntax error : bad verb " << arg << endl;
04417             }
04418           break;
04419         case 'f' :
04420           if ((arg == "f") ||
04421               (arg == "fi") ||
04422               (arg == "fil") ||
04423               (arg == "filt") ||
04424               (arg == "filte") ||
04425               (arg == "filter"))
04426             {
04427               // handle all of the command line arguments in a vector
04428               argc--;
04429               argv++;
04430               while (argc > 1)
04431                 {
04432                   cmt_string& s = arguments.add ();
04433                   s = argv[1];
04434                   argc--;
04435                   argv++;
04436                 }
04437 
04438               m_action = action_filter;
04439             }
04440           else
04441             {
04442               if (!m_quiet) cout << "#CMT> syntax error : bad verb " << arg << endl;
04443             }
04444           break;
04445         case 'h' :
04446           if ((arg == "h") ||
04447               (arg == "he") ||
04448               (arg == "hel") ||
04449               (arg == "help"))
04450             {
04451               m_action = action_help;
04452             }
04453           else
04454             {
04455               if (!m_quiet) cout << "#CMT> syntax error : bad verb " << arg << endl;
04456             }
04457           break;
04458         case 'l' :
04459           if (arg == "lock")
04460             {
04461               argc--;
04462               argv++;
04463               if (argc > 1)
04464                 {
04465                   m_current_package = argv[1];
04466                   {
04467                     cmt_string& s = arguments.add ();
04468                     s = m_current_package;
04469                   }
04470 
04471                   m_current_version.erase (0);
04472                   m_current_path.erase (0);
04473 
04474                   argc--;
04475                   argv++;
04476                   if (argc > 1)
04477                     {
04478                       m_current_version = argv[1];
04479 
04480                       {
04481                         cmt_string& s = arguments.add ();
04482                         s = m_current_version;
04483                       }
04484                     
04485                       m_action = action_lock;
04486 
04487                       argc--;
04488                       argv++;
04489                       if (argc > 1)
04490                         {
04491                           m_current_path = argv[1];
04492                           if (m_current_path[0] == '-')
04493                             {
04494                               m_current_path.erase (0);
04495                             }
04496                         }
04497 
04498                       m_current_access = UserMode;
04499                       (Use::current()).set (m_current_package, 
04500                                             m_current_version, 
04501                                             m_current_path);
04502 
04503                     }
04504                   else
04505                     {
04506                       if (!m_quiet) cout << "#CMT> syntax error : version missing" << endl;
04507                     }
04508                 }
04509               else
04510                 {
04511                   m_action = action_lock;
04512                 }
04513             }
04514           else
04515             {
04516               if (!m_quiet) cout << "#CMT> syntax error : bad verb " << arg << endl;
04517             }
04518           break;
04519         case 'r' :
04520           if (arg == "remove")
04521             {
04522               argc--;
04523               argv++;
04524 
04525               if (argc > 1)
04526                 {
04527                   arg = argv[1];
04528 
04529                   if (arg == "library_links")
04530                     {
04531                       m_action = action_remove_library_links;
04532                     }
04533                   else
04534                     {
04535                       m_current_package = argv[1];
04536                       {
04537                         cmt_string& s = arguments.add ();
04538                         s = m_current_package;
04539                       }
04540                       
04541                       m_current_version.erase (0);
04542                       m_current_path.erase (0);
04543                       
04544                       argc--;
04545                       argv++;
04546                       if (argc > 1)
04547                         {
04548                           m_current_version = argv[1];
04549                           
04550                           {
04551                             cmt_string& s = arguments.add ();
04552                             s = m_current_version;
04553                           }
04554                           
04555                           argc--;
04556                           argv++;
04557                           if (argc > 1)
04558                             {
04559                               m_current_path = argv[1];
04560                               if (m_current_path[0] == '-')
04561                                 {
04562                                   m_current_path.erase (0);
04563                                 }
04564                             }
04565                             
04566                           m_action = action_remove;
04567                         }
04568                       else
04569                         {
04570                           if (!m_quiet) cout << "#CMT> syntax error : version missing" << endl;
04571                         }
04572                     }
04573                 }
04574               else
04575                 {
04576                   if (!m_quiet) cout << "#CMT> syntax error : don't know what to remove" << endl;
04577                 }
04578             }
04579           else if (arg == "run")
04580             {
04581               argc--;
04582               argv++;
04583               if (argc > 1)
04584                 {
04585                   cmt_string& s = arguments.add ();
04586                   s = argv[1];
04587 
04588                   m_action = action_run;
04589                 }
04590               else
04591                 {
04592                   if (!m_quiet) cout << "#CMT> syntax error : run arguments missing" << endl;
04593                 }
04594             }
04595           else
04596             {
04597               if (!m_quiet) cout << "#CMT> syntax error : bad verb " << arg << endl;
04598             }
04599           break;
04600         case 's' :
04601           if (arg == "setup")
04602             {
04603               m_action = action_setup;
04604             }
04605           else if ((arg == "s") ||
04606                    (arg == "sh") ||
04607                    (arg == "sho") ||
04608                    (arg == "show"))
04609             {
04610               argc--;
04611               argv++;
04612               if (argc > 1)
04613                 {
04614                   arg = argv[1];
04615 
04616                   if (arg == "applied_patterns")
04617                     {
04618                       m_action = action_show_applied_patterns;
04619                     }
04620                   else if (arg == "author")
04621                     {
04622                       m_action = action_show_author;
04623                     }
04624                   else if (arg == "branches")
04625                     {
04626                       m_action = action_show_branches;
04627                     }
04628                   else if (arg == "clients")
04629                     {
04630                       argc--;
04631                       argv++;
04632                       if (argc > 1)
04633                         {
04634                           cmt_string& s = arguments.add ();
04635                           s = argv[1];
04636                           m_current_target = argv[1];
04637 
04638                           m_action = action_show_clients;
04639 
04640                           argc--;
04641                           argv++;
04642                           if (argc > 1)
04643                             {
04644                               cmt_string& s = arguments.add ();
04645                               s = argv[1];
04646 
04647                               argc--;
04648                               argv++;
04649                               if (argc > 1)
04650                                 {
04651                                   cmt_string& s = arguments.add ();
04652                                   s = argv[1];
04653                                 }
04654                             }
04655                         }
04656                       else
04657                         {
04658                           if (!m_quiet) cout << "#CMT> syntax error : package name missing" << endl;
04659                         }
04660                     }
04661                   else if (arg == "constituent")
04662                     {
04663                       argc--;
04664                       argv++;
04665                       if (argc > 1)
04666                         {
04667                           cmt_string& s = arguments.add ();
04668                           s = argv[1];
04669                           m_current_target = argv[1];
04670 
04671                           m_action = action_show_constituent;
04672                         }
04673                       else
04674                         {
04675                           if (!m_quiet) cout << "#CMT> syntax error : constituent name missing" << endl;
04676                         }
04677                     }
04678                   else if (arg == "constituent_names")
04679                     {
04680                       m_action = action_show_constituent_names;
04681                     }
04682                   else if (arg == "constituents")
04683                     {
04684                       m_action = action_show_constituents;
04685                     }
04686                   else if (arg == "fragment")
04687                     {
04688                       argc--;
04689                       argv++;
04690                       if (argc > 1)
04691                         {
04692                           cmt_string& s = arguments.add ();
04693                           s = argv[1];
04694                           m_current_target = argv[1];
04695 
04696                           m_action = action_show_fragment;
04697                         }
04698                       else
04699                         {
04700                           if (!m_quiet) cout << "#CMT> syntax error : fragment name missing" << endl;
04701                         }
04702                     }
04703                   else if (arg == "fragments")
04704                     {
04705                       m_action = action_show_fragments;
04706                     }
04707                   else if (arg == "groups")
04708                     {
04709                       m_action = action_show_groups;
04710                     }
04711                   else if (arg == "include_dirs")
04712                     {
04713                       m_action = action_show_include_dirs;
04714                     }
04715                   else if (arg == "language")
04716                     {
04717                       argc--;
04718                       argv++;
04719                       if (argc > 1)
04720                         {
04721                           cmt_string& s = arguments.add ();
04722                           s = argv[1];
04723                           m_current_target = argv[1];
04724 
04725                           m_action = action_show_language;
04726                         }
04727                       else
04728                         {
04729                           if (!m_quiet) cout << "#CMT> syntax error : language name missing" << endl;
04730                         }
04731                     }
04732                   else if (arg == "languages")
04733                     {
04734                       m_action = action_show_languages;
04735                     }
04736                   else if (arg == "macro")
04737                     {
04738                       argc--;
04739                       argv++;
04740                       if (argc > 1)
04741                         {
04742                           cmt_string& s = arguments.add ();
04743                           s = argv[1];
04744                           m_current_target = argv[1];
04745 
04746                           m_action = action_show_macro;
04747                         }
04748                       else
04749                         {
04750                           if (!m_quiet) cout << "#CMT> syntax error : macro name missing" << endl;
04751                         }
04752                     }
04753                   else if (arg == "macro_value")
04754                     {
04755                       m_quiet = true;
04756                       argc--;
04757                       argv++;
04758                       if (argc > 1)
04759                         {
04760                           cmt_string& s = arguments.add ();
04761                           s = argv[1];
04762                           m_current_target = argv[1];
04763 
04764                           m_action = action_show_macro_value;
04765                         }
04766                       else
04767                         {
04768                           if (!m_quiet) cout << "#CMT> syntax error : macro name missing" << endl;
04769                         }
04770                     }
04771                   else if (arg == "macros")
04772                     {
04773                       m_action = action_show_macros;
04774                     }
04775                   else if (arg == "manager")
04776                     {
04777                       m_action = action_show_manager;
04778                     }
04779                   else if (arg == "packages")
04780                     {
04781                       argc--;
04782                       argv++;
04783                       if (argc > 1)
04784                         {
04785                           cmt_string& s = arguments.add ();
04786                           s = argv[1];
04787                           m_current_target = argv[1];
04788                         }
04789 
04790                       m_action = action_show_packages;
04791                     }
04792                   else if (arg == "path")
04793                     {
04794                       m_action = action_show_path;
04795                     }
04796                   else if (arg == "pattern")
04797                     {
04798                       argc--;
04799                       argv++;
04800                       if (argc > 1)
04801                         {
04802                           cmt_string& s = arguments.add ();
04803                           s = argv[1];
04804                           m_current_target = argv[1];
04805 
04806                           m_action = action_show_pattern;
04807                         }
04808                       else
04809                         {
04810                           if (!m_quiet) cout << "#CMT> syntax error : pattern name missing" << endl;
04811                         }
04812                     }
04813                   else if (arg == "pattern_names")
04814                     {
04815                       m_action = action_show_pattern_names;
04816                     }
04817                   else if (arg == "patterns")
04818                     {
04819                       m_action = action_show_patterns;
04820                     }
04821                   else if (arg == "pwd")
04822                     {
04823                       m_action = action_show_pwd;
04824                     }
04825                   else if (arg == "set_value")
04826                     {
04827                       m_quiet = true;
04828                       argc--;
04829                       argv++;
04830                       if (argc > 1)
04831                         {
04832                           cmt_string& s = arguments.add ();
04833                           s = argv[1];
04834                           m_current_target = argv[1];
04835 
04836                           m_action = action_show_set_value;
04837                         }
04838                       else
04839                         {
04840                           if (!m_quiet) cout << "#CMT> syntax error : set name missing" << endl;
04841                         }
04842                     }
04843                   else if (arg == "set")
04844                     {
04845                       argc--;
04846                       argv++;
04847                       if (argc > 1)
04848                         {
04849                           cmt_string& s = arguments.add ();
04850                           s = argv[1];
04851                           m_current_target = argv[1];
04852 
04853                           m_action = action_show_set;
04854                         }
04855                       else
04856                         {
04857                           if (!m_quiet) cout << "#CMT> syntax error : set name missing" << endl;
04858                         }
04859                     }
04860                   else if (arg == "sets")
04861                     {
04862                       m_action = action_show_sets;
04863                     }
04864                   else if (arg == "strategies")
04865                     {
04866                       m_action = action_show_strategies;
04867                     }
04868                   else if (arg == "tags")
04869                     {
04870                       m_action = action_show_tags;
04871                     }
04872                   else if ((arg == "u") ||
04873                            (arg == "us") ||
04874                            (arg == "use") ||
04875                            (arg == "uses"))
04876                     {
04877                       m_action = action_show_uses;
04878                     }
04879                   else if (arg == "version")
04880                     {
04881                       m_action = action_show_version;
04882                     }
04883                   else if (arg == "versions")
04884                     {
04885                       argc--;
04886                       argv++;
04887                       if (argc > 1)
04888                         {
04889                           cmt_string& s = arguments.add ();
04890                           s = argv[1];
04891                           m_current_target = argv[1];
04892 
04893                           m_action = action_show_versions;
04894                         }
04895                       else
04896                         {
04897                           if (!m_quiet) cout << "#CMT> syntax error : package name missing" << endl;
04898                         }
04899                     }
04900                   else
04901                     {
04902                       if (!m_quiet) cout << "#CMT> syntax error : bad show argument" << endl;
04903                     }
04904                 }
04905               else
04906                 {
04907                   if (!m_quiet) cout << "#CMT> syntax error : don't know what to show" << endl;
04908                 }
04909             }
04910           else if (arg == "system")
04911             {
04912               m_action = action_system;
04913             }
04914           else
04915             {
04916               if (!m_quiet) cout << "#CMT> syntax error : bad verb " << arg << endl;
04917             }
04918 
04919           break;
04920         case 'u' :
04921           if (arg == "unlock")
04922             {
04923               argc--;
04924               argv++;
04925               if (argc > 1)
04926                 {
04927                   m_current_package = argv[1];
04928                   {
04929                     cmt_string& s = arguments.add ();
04930                     s = m_current_package;
04931                   }
04932 
04933                   m_current_version.erase (0);
04934                   m_current_path.erase (0);
04935                                         
04936                   argc--;
04937                   argv++;
04938                   if (argc > 1)
04939                     {
04940                       m_current_version = argv[1];
04941 
04942                       {
04943                         cmt_string& s = arguments.add ();
04944                         s = m_current_version;
04945                       }
04946                                                 
04947                       m_action = action_unlock;
04948 
04949                       argc--;
04950                       argv++;
04951                       if (argc > 1)
04952                         {
04953                           m_current_path = argv[1];
04954                           if (m_current_path[0] == '-')
04955                             {
04956                               m_current_path.erase (0);
04957                             }
04958                         }
04959                                                 
04960                       m_current_access = UserMode;
04961                       (Use::current()).set (m_current_package, 
04962                                             m_current_version, 
04963                                             m_current_path);
04964 
04965                     }
04966                   else
04967                     {
04968                       if (!m_quiet) cout << "#CMT> syntax error : version missing" << endl;
04969                     }
04970                 }
04971               else
04972                 {
04973                   m_action = action_unlock;
04974                 }
04975             }
04976           else
04977             {
04978               if (!m_quiet) cout << "#CMT> syntax error : bad verb " << arg << endl;
04979             }
04980 
04981           break;
04982         case 'v' :
04983           if ((arg == "v") ||
04984               (arg == "ve") ||
04985               (arg == "ver") ||
04986               (arg == "vers") ||
04987               (arg == "versi") ||
04988               (arg == "versio") ||
04989               (arg == "version"))
04990             {
04991               m_action = action_version;
04992             }
04993           else
04994             {
04995               if (!m_quiet) cout << "#CMT> syntax error : bad verb " << arg << endl;
04996             }
04997           break;
04998         case '+' :
04999           if (arg.substr (0, 6) == "+path=")
05000             {
05001               arg.erase (0, 6);
05002               CmtSystem::add_cmt_path (arg, "argument",
05003                                        m_cmt_path, 
05004                                        m_cmt_path_pwds, 
05005                                        m_cmt_path_sources);
05006             }
05007           else
05008             {
05009               if (!m_quiet) cout << "#CMT> syntax error : bad verb " 
05010                                << arg << endl;
05011             }
05012 
05013           break;
05014         case '-' :
05015           if (arg == "-n")
05016             {
05017               m_simulation = true;
05018             }
05019           else if ((arg == "-q") ||
05020                    (arg == "-qu") ||
05021                    (arg == "-qui") ||
05022                    (arg == "-quie") ||
05023                    (arg == "-quiet"))
05024             {
05025               m_quiet = true;
05026             }
05027           else if (arg == "-csh")
05028             {
05029               mode = Csh;
05030             }
05031           else if (arg == "-sh")
05032             {
05033               mode = Sh;
05034             }
05035           else if (arg == "-bat")
05036             {
05037               mode = Bat;
05038             }
05039           else if (arg.substr (0, 5) == "-use=")
05040             {
05041               arg.erase (0, 5);
05042 
05043               if (m_action != action_create)
05044                 {
05045                   CmtSystem::cmt_string_vector words;
05046 
05047                   CmtSystem::split (arg, ":", words);
05048 
05049                   m_current_access = UserMode;
05050 
05051                   if (words.size () > 0) m_current_package = words[0];
05052                   if (words.size () > 1) m_current_version = words[1];
05053                   if (words.size () > 2) m_current_path    = words[2];
05054                   (Use::current()).set (m_current_package, 
05055                                         m_current_version, 
05056                                         m_current_path);
05057                 }
05058             }
05059           else if (arg.substr (0, 6) == "-pack=")
05060             {
05061               arg.erase (0, 6);
05062               if ((m_action != action_create) && (m_current_package != arg))
05063                 {
05064                   //CmtSystem::cd (m_default_path);
05065 
05066                   m_current_access = UserMode;
05067 
05068                   m_current_package = arg;
05069                   m_current_version = "";
05070                   m_current_path    = m_default_path;
05071 
05072                   (Use::current()).set (m_current_package, 
05073                                         m_current_version, 
05074                                         m_current_path);
05075                 }
05076             }
05077           else if (arg.substr (0, 9) == "-version=")
05078             {
05079               arg.erase (0, 9);
05080               if ((m_action != action_create) && (m_current_version != arg))
05081                 {
05082                   m_current_access = UserMode;
05083                   m_current_version = arg;
05084                   (Use::current()).set (m_current_package, 
05085                                         m_current_version, 
05086                                         m_current_path);
05087                 }
05088             }
05089           else if (arg.substr (0, 6) == "-path=")
05090             {
05091               arg.erase (0, 6);
05092               /*
05093               cerr << "-path=" << arg << 
05094                 " cp=" << m_current_package <<
05095                 " cv=" << m_current_version <<
05096                 " cp=" << m_current_path << endl;
05097               */
05098 
05099               if ((m_action != action_create) && (m_current_path != arg))
05100                 {
05101                   m_current_access = UserMode;
05102                   m_current_path = arg;
05103                   (Use::current()).set (m_current_package, 
05104                                         m_current_version, 
05105                                         m_current_path);
05106 
05107                   CmtSystem::add_cmt_path (m_current_path, "argument",
05108                                            m_cmt_path, 
05109                                            m_cmt_path_pwds, 
05110                                            m_cmt_path_sources);
05111                 }
05112             }
05113           else if (arg.substr (0, 3) == "-f=")
05114             {
05115               arg.substr (3, extra_file);
05116             }
05117           else if (arg.substr (0, 3) == "-e=")
05118             {
05119               cout << "extra statement = " << arg << endl;
05120               arg.substr (3, extra_line);
05121             }
05122           else if (arg.substr (0, 6) == "-home=")
05123             {
05124               arg.erase (0, 6);
05125               if (CmtSystem::test_directory (arg))
05126                 {
05127                   m_cmt_home = arg;
05128                 }
05129             }
05130           else if (arg.substr (0, 5) == "-tag=")
05131             {
05132                 /*
05133                   Here we are going to change the complete tag set
05134                 */
05135 
05136               Tag* tag;
05137               CmtSystem::cmt_string_vector words;
05138               
05140               Tag::clear_all ();
05141               Cmt::m_extra_tags = "";
05142 
05144               configure_site_tag (0);
05145               configure_uname_tag ();
05146               configure_hosttype_tag ();
05147               configure_config_tag ();
05148 
05149               arg.erase (0, 5);
05150 
05151               CmtSystem::split (arg, " \t,", words);
05152 
05153               for (int i = 0; i < words.size (); i++)
05154                 {
05155                   const cmt_string& a = words[i];
05156 
05157                   cmt_string s = a;
05158                   s += ",";
05159 
05160                   if (i == 0)
05161                     {
05162                       m_current_tag = a;
05163 
05164                       if (CmtSystem::testenv ("TAGDEBUG")) cerr 
05165                           << "parse_argument(tag_add)> current_tag=" << m_current_tag << endl;
05166                     }
05167 
05168                   if (Cmt::m_extra_tags.find (s) == cmt_string::npos)
05169                     {
05170                       //if (!m_quiet) cerr << "  a=[" << a << "]" << endl;
05171                       
05173                       if (a == CmtSystem::get_cmt_config ())
05174                         {
05175                           configure_uname_tag ();
05176                         }
05177                       
05178                       tag = Tag::add (a, PriorityArgument, "arguments", 0);
05179                       
05180                       tag->mark ();
05181 
05182                       Cmt::m_extra_tags += a;
05183                       Cmt::m_extra_tags += ",";
05184                     }
05185                 }
05186             }
05187           else if (arg.substr (0, 9) == "-tag_add=")
05188             {
05189               Tag* tag;
05190               CmtSystem::cmt_string_vector words;
05191               
05192               arg.erase (0, 9);
05193 
05194               //if (!m_quiet) cerr << "-tag_add=" << arg << endl;
05195 
05196               CmtSystem::split (arg, " \t,", words);
05197 
05198               for (int i = 0; i < words.size (); i++)
05199                 {
05200                   const cmt_string& a = words[i];
05201 
05202                   cmt_string s = a;
05203                   s += ",";
05204 
05205                   if (Cmt::m_extra_tags.find (s) == cmt_string::npos)
05206                     {
05207                         //if (!m_quiet) cerr << "  a=[" << a << "]" << endl;
05208 
05210                       if (a == CmtSystem::get_cmt_config ())
05211                         {
05212                           configure_uname_tag ();
05213                         }
05214                       
05215                       tag = Tag::add (a, PriorityUserTag, "arguments", 0);
05216                       
05217                       tag->mark ();
05218 
05219                       Cmt::m_extra_tags += a;
05220                       Cmt::m_extra_tags += ",";
05221                     }
05222                 }
05223             }
05224           else if (arg.substr (0, 12) == "-tag_remove=")
05225             {
05226               Tag::TagPtrVector tags = Tag::tags ();
05227               int i;
05228               Tag* tag;
05229 
05230               /*
05231               for (i = 0; i < tags.size (); i++)
05232                 {
05233                   tag = tags[i];
05234                   if ((tag != 0) &&
05235                       (tag->selected))
05236                     {
05237                         if (!m_quiet) cerr << "  original tag_list=" << tag->name << tag->priority << endl;
05238                     }
05239                 }
05240               */
05241 
05242               CmtSystem::cmt_string_vector words;
05243 
05244               arg.erase (0, 12);
05245 
05246               //if (!m_quiet) cerr << "-arg_remove=" << arg << endl;
05247 
05248               CmtSystem::split (arg, " \t,", words);
05249 
05250                 //
05251                 // Now erase all entries in the old list that match
05252                 // the specified tags 
05253                 //
05254 
05255               for (i = 0; i < words.size (); i++)
05256                 {
05257                   const cmt_string& a = words[i];
05258 
05259                   cmt_string s = a;
05260                   s += ",";
05261 
05262                   int pos;
05263 
05264                   pos = Cmt::m_extra_tags.find (s);
05265 
05266                   if (pos != cmt_string::npos)
05267                     {
05268                       Cmt::m_extra_tags.erase (pos, s.size ());
05269                     }
05270 
05271                   //if (!m_quiet) cerr << "  tag_list=[" << tag_list << "]" << endl;
05272                 }
05273 
05274                 //
05275                 // Now reinject the purged list of tags into the database
05276                 // exactly as when using -tag=<tag-list>
05277                 //
05278 
05280               Tag::unmark_all ();
05281 
05283               configure_site_tag (0);
05284               configure_uname_tag ();
05285               configure_hosttype_tag ();
05286               
05287               CmtSystem::split (Cmt::m_extra_tags, " \t,", words);
05288 
05289               for (i = 0; i < words.size (); i++)
05290                 {
05291                   const cmt_string& a = words[i];
05292 
05293                   //fprintf (stderr, "  a=[%s]\n", a.c_str ());
05294 
05296                   if (a == CmtSystem::get_cmt_config ())
05297                     {
05298                       configure_uname_tag ();
05299                     }
05300 
05301                   if (i == 0)
05302                     {
05303                       m_current_tag = a;
05304 
05305                       //if (!m_quiet) cerr << "parse_argument(tag_remove)> current_tag=" 
05306                         //<< m_current_tag << endl;
05307 
05308                       tag = Tag::add (a, PriorityTag, "restore configuration", 0);
05309                     }
05310                   else
05311                     {
05312                       tag = Tag::add (a, PriorityUserTag, "restore configuration", 0);
05313                     }
05314 
05315                   tag->mark ();
05316                 }
05317             }
05318           else if (arg.substr (0, 14) == "-user_context=")
05319             {
05320               arg.erase (0, 14);
05321               if (CmtSystem::test_directory (arg))
05322                 {
05323                   m_cmt_user_context = arg;
05324                 }
05325             }
05326           else
05327             {
05328               if (!m_quiet) cout << "#CMT> syntax error : bad verb " << arg << endl;
05329             }
05330 
05331           break;
05332         default:
05333           if (!m_quiet) cout << "#CMT> syntax error : bad command parameter " << arg << endl;
05334           break;
05335         }
05336 
05337       argc--;
05338       argv++;
05339     }
05340 }

void Cmt::parse_requirements ( const cmt_string & file_name,
Use * use ) [static]
 

Parse the input file, rejecting comments and rebuilding complete lines (from sections separated by \ characters.

Each reformatted line is parsed by filter_line

Definition at line 5349 of file cmt_parser.cxx.

Referenced by Use::add(), load(), parser(), reach_current_package(), use_home_requirements(), and use_user_context_requirements().

05350 {
05351   cmt_string actual_file_name = file_name;
05352   cmt_string text;
05353 
05354   CmtError::clear ();
05355 
05356   if (use == 0) use = &(Use::current ());
05357 
05358   if (!CmtSystem::test_file (actual_file_name))
05359     {
05360       actual_file_name = "../cmt/";
05361       actual_file_name += file_name;
05362 
05363       if (!CmtSystem::test_file (actual_file_name))
05364         {
05365           actual_file_name = "../mgr/";
05366           actual_file_name += file_name;
05367 
05368           if (!CmtSystem::test_file (actual_file_name))
05369             {
05370                 /*
05371               cmt_string text;
05372 
05373               text = "Package ";
05374               text += use->package;
05375               text += " version ";
05376               text += use->specified_version;
05377               text += " path ";
05378               text += use->specified_path;
05379               text += " file ";
05380               text += actual_file_name;
05381 
05382               CmtError::set (CmtError::file_access_error, text);
05383                 */
05384 
05385               return;
05386             }
05387         }
05388     }
05389 
05390   text.read (actual_file_name);
05391 
05411   AccessMode saved_current_access;
05412   ScopeType saved_scope;
05413 
05414   saved_current_access = Cmt::m_current_access;
05415   saved_scope          = Cmt::m_scope;
05416 
05417   if (use != &(Use::current ()))
05418     {
05419       Cmt::m_current_access = UserMode;
05420     }
05421 
05422   Cmt::m_scope = ScopePublic;
05423 
05424   parse_requirements_text (text, actual_file_name, use);
05425 
05426     //Pattern::apply_all_globals (use);
05427 
05428   Cmt::m_current_access = saved_current_access;
05429   Cmt::m_scope          = saved_scope;
05430 }

void Cmt::parse_requirements_line ( const cmt_string & line,
Use * use,
const cmt_string & file_name = "",
int line_number = 0 ) [static]
 

Apply the basic parser to one single line :.

o Append to global text if previous back_slash o Split into words o Apply the generic Select operator

Definition at line 5439 of file cmt_parser.cxx.

Referenced by parse_requirements_text(), parser(), and set_standard_macros().

05443 {
05444   int length;
05445   int nl;
05446   int back_slash;
05447   cmt_string temp_line = line;
05448 
05449   if (temp_line.size () == 0) return;
05450   if (temp_line[0] == '#') return;
05451 
05452   nl = temp_line.find_last_of ('\n');
05453   if (nl != cmt_string::npos) temp_line.erase (nl);
05454 
05455   length = temp_line.size ();
05456   if (length == 0) return;
05457 
05458   //
05459   // We scan the line for handling backslashes.
05460   //
05461   // o Really terminating backslashes (ie those only followed by spaces/tabs
05462   // mean continued line
05463   //
05464   //
05465 
05466   bool finished = true;
05467 
05468   length = temp_line.size ();
05469 
05470   back_slash = temp_line.find_last_of ('\\');
05471 
05472   if (back_slash != cmt_string::npos)
05473     {
05474       //
05475       // This is the last backslash
05476       // check if there are only space chars after it
05477       //
05478       
05479       bool at_end = true;
05480 
05481       for (int i = (back_slash + 1); i < length; i++)
05482         {
05483           char c = temp_line[i];
05484           if ((c != ' ') && (c != '\t'))
05485             {
05486               at_end = false;
05487               break;
05488             }
05489         }
05490 
05491       if (at_end)
05492         {
05493           temp_line.erase (back_slash);
05494           finished = false;
05495         }
05496       else
05497         {
05498           // This was not a trailing backslash.
05499           finished = true;
05500         }
05501     }
05502 
05503   m_filtered_text += temp_line;
05504 
05505   if (!finished)
05506     {
05507       // We still need to accumulate forthcoming lines
05508       // before parsing the resulting text.
05509       return;
05510     }
05511 
05512   /*
05513     Here a full line (possibly accumulating several lines
05514     ended by backslashes) is parsed :
05515     
05516     o Special characters are filtered now :
05517     
05518     <cmt:tab/>  \t
05519     <cmt:cr/>   \r
05520     <cmt:lf/>   \n
05521     
05522     o Split into words (a word is a string not containing
05523     spaces or enclosed in quotes)
05524 
05525     o Parse the word array (function Select)
05526 
05527   */
05528 
05529   m_filtered_text.replace_all ("<cmt:tab/>", "\t");
05530   m_filtered_text.replace_all ("<cmt:cr/>",  "\r");
05531   m_filtered_text.replace_all ("<cmt:lf/>",  "\n");
05532 
05533   if (m_debug)
05534     {
05535       cout << "parse_requirements_line [" << m_filtered_text << "]" << endl;
05536     }
05537   
05538   static CmtSystem::cmt_string_vector words;
05539   
05540   CmtSystem::split (m_filtered_text, " \t", words);
05541   
05542   if (words.size () != 0)
05543     {
05544       select (words, use, file_name, line_number);
05545     }
05546   
05547   m_filtered_text.erase (0);
05548 }

void Cmt::parse_requirements_text ( const cmt_string & text,
const cmt_string & file_name,
Use * use ) [static]
 

Parse a text, rejecting comments and rebuilding complete lines (from sections separated by \ characters.

Each reformatted line is parsed by filter_line

Definition at line 5557 of file cmt_parser.cxx.

Referenced by Pattern::apply(), ApplicationAnalyzer::end(), LibraryAnalyzer::end(), and parse_requirements().

05560 {
05561   cmt_string line;
05562   int pos;
05563   int max_pos;
05564   int line_number = 1;
05565 
05566   if (use == 0) use = &(Use::current ());
05567 
05568   m_filtered_text.erase (0);
05569 
05570   pos = 0;
05571   max_pos = text.size ();
05572 
05573   for (pos = 0; pos < max_pos;)
05574     {
05575       int cr = text.find (pos, "\r\n");
05576       int nl = text.find (pos, '\n');
05577       int first = nl;
05578       int length = 1;
05579 
05580       if (cr != cmt_string::npos)
05581         {
05582           if (nl == cmt_string::npos)
05583             {
05584               first = cr;
05585               length = 2;
05586             }
05587           else
05588             {
05589               first = (nl < cr) ? nl : cr;
05590               length = (nl < cr) ? 1 : 2;
05591             }
05592         }
05593 
05594       if (first == cmt_string::npos)
05595         {
05596           text.substr (pos, line);
05597           pos = max_pos;
05598         }
05599       else if (first > pos)
05600         {
05601           text.substr (pos, first - pos, line);
05602           pos = first + length;
05603         }
05604       else
05605         {
05606           line.erase (0);
05607           pos += length;
05608         }
05609 
05610       parse_requirements_line (line, use, file_name, line_number);
05611 
05612       if ((m_action == action_check_configuration) && CmtError::has_pending_error ())
05613         {
05614           break;
05615         }
05616 
05617       line_number++;
05618     }
05619 }

int Cmt::parser ( int argc,
char * argv[] ) [static]
 

Definition at line 5647 of file cmt_parser.cxx.

05648 {
05649   PrintMode mode = Csh;
05650   CmtSystem::cmt_string_vector arguments;
05651   cmt_string extra_line;
05652   cmt_string extra_file;
05653 
05654   if (argc <= 1)
05655     {
05656       do_help ();
05657       exit (0);
05658     }
05659 
05660   clear ();
05661   configure ();
05662 
05663   CmtError::clear ();
05664 
05665   /*
05666     Set private if positioned inside the package
05667     (which is detected since we were able to retreive the
05668     Version, Package and Path)
05669   */
05670 
05671   if ((m_current_path.size () == 0) ||
05672       (m_current_package.size () == 0) ||
05673       (m_current_version.size () == 0))
05674     {
05675       m_current_access = UserMode;
05676     }
05677   else
05678     {
05679       m_current_access = DeveloperMode;
05680     }
05681 
05682   parse_arguments (argc, argv, arguments,
05683                    extra_line, extra_file, mode);
05684 
05685   if (m_configure_error != "")
05686     {
05687       if (!m_quiet) cout << "# CMT>" << m_configure_error << endl;
05688     }
05689 
05690   if (CmtError::has_pending_error ())
05691     {
05692       int code = CmtError::get_last_error_code ();
05693       if (!m_quiet) CmtError::print ();
05694       clear ();
05695 
05696       return (code);
05697     }
05698 
05699   if (m_debug)
05700     {
05701       cout << "After parse_argument> pack=" << m_current_package
05702            << " m_current_tag=" << m_current_tag
05703            << endl;
05704     }
05705 
05706   /*
05707     Now actual requirements analysis can take place.
05708 
05709     Extra lines or files are analysed first.
05710   */
05711 
05712   if (strlen (extra_file.c_str ()) > 0) parse_requirements (extra_file, 0);
05713   if (strlen (extra_line.c_str ()) > 0) parse_requirements_line (extra_line, 0);
05714 
05715   //
05716   //  For some of the actions, the CMT package must be automatically
05717   //  included
05718   //
05719 
05720   if (m_debug) cerr << "parser1> current_tag=" << m_current_tag << endl;
05721 
05722   switch (m_action)
05723     {
05724       // case action_none :
05725     case action_broadcast :
05726     case action_build_constituent_makefile :
05727     case action_build_constituents_makefile :
05728     case action_build_dependencies :
05729     case action_build_library_links :
05730     case action_build_make_setup :
05731     case action_build_msdev :
05732     case action_build_os9_makefile :
05733       // case action_build_prototype :
05734     case action_build_readme :
05735     case action_build_tag_makefile :
05736       // case action_build_temporary_name :
05737     case action_build_triggers :
05738     case action_build_windefs :
05739     case action_check_configuration :
05740       // case action_check_files :
05741       // case action_check_version :
05742     case action_checkout :
05743     case action_cleanup :
05744     case action_config :
05745     case action_create :
05746       // case action_cvsbranches :
05747       // case action_cvssubpackages :
05748       // case action_cvstags :
05749     case action_expand_model :
05750     case action_filter :
05751       // case action_help :
05752     case action_load :
05753     case action_lock :
05754     case action_remove :
05755     case action_remove_library_links :
05756     case action_run :
05757     case action_setup :
05758     case action_show_applied_patterns :
05759       // case action_show_author :
05760       // case action_show_branches :
05761       // case action_show_clients :
05762       // case action_show_constituent :
05763       // case action_show_constituent_names :
05764       // case action_show_constituents :
05765     case action_show_fragment :
05766     case action_show_fragments :
05767     case action_show_groups :
05768     case action_show_include_dirs :
05769     case action_show_language :
05770     case action_show_languages :
05771     case action_show_macro :
05772     case action_show_macro_value :
05773     case action_show_macros :
05774       // case action_show_manager :
05775       // case action_show_packages :
05776     case action_show_path :
05777     case action_show_pattern :
05778     case action_show_pattern_names :
05779     case action_show_patterns :
05780       // case action_show_pwd :
05781     case action_show_set :
05782     case action_show_set_value :
05783     case action_show_sets :
05784     case action_show_strategies :
05785     case action_show_tags :
05786     case action_show_uses :
05787     case action_show_version :
05788       // case action_show_versions :
05789       // case action_system :
05790     case action_unlock :
05791     case action_version :
05792       use_cmt ();
05793         //
05794         // Now parse the requirements file stored in ${CMTHOME}
05795         //
05796       
05797       use_home_requirements ();
05798 
05799       break;
05800     default:
05801       break;
05802     }
05803 
05804   if (m_debug) cerr << "parser2> current_tag=" << m_current_tag << endl;
05805 
05806   //
05807   // Setting up recursive actions
05808   //
05809 
05810   switch (m_action)
05811     {
05812       // case action_none :
05813     case action_broadcast :
05814     case action_build_constituent_makefile :
05815     case action_build_constituents_makefile :
05816     case action_build_dependencies :
05817     case action_build_library_links :
05818     case action_build_make_setup :
05819     case action_build_msdev :
05820     case action_build_os9_makefile :
05821       // case action_build_prototype :
05822     case action_build_readme :
05823     case action_build_tag_makefile :
05824       // case action_build_temporary_name :
05825     case action_build_triggers :
05826     case action_build_windefs :
05827     case action_check_configuration :
05828       // case action_check_files :
05829       // case action_check_version :
05830       // case action_checkout :
05831     case action_cleanup :
05832     case action_config :
05833       // case action_create :
05834       // case action_cvsbranches :
05835       // case action_cvssubpackages :
05836       // case action_cvstags :
05837     case action_expand_model :
05838     case action_filter :
05839       // case action_help :
05840     case action_load :
05841       // case action_lock :
05842       // case action_remove :
05843     case action_remove_library_links :
05844       // case action_run :
05845     case action_setup :
05846     case action_show_applied_patterns :
05847       // case action_show_author :
05848       // case action_show_branches :
05849       // case action_show_clients :
05850     case action_show_constituent :
05851     case action_show_constituent_names :
05852     case action_show_constituents :
05853     case action_show_fragment :
05854     case action_show_fragments :
05855     case action_show_groups :
05856     case action_show_include_dirs :
05857     case action_show_language :
05858     case action_show_languages :
05859     case action_show_macro :
05860     case action_show_macro_value :
05861     case action_show_macros :
05862       // case action_show_manager :
05863       // case action_show_packages :
05864     case action_show_path :
05865     case action_show_pattern :
05866     case action_show_pattern_names :
05867     case action_show_patterns :
05868       // case action_show_pwd :
05869     case action_show_set :
05870     case action_show_set_value :
05871     case action_show_sets :
05872     case action_show_strategies :
05873     case action_show_tags :
05874     case action_show_uses :
05875       // case action_show_version :
05876       // case action_show_versions :
05877       // case action_system :
05878       // case action_unlock :
05879       // case action_version :
05880       m_recursive = true;
05881       break;
05882     default:
05883       m_recursive = false;
05884       break;
05885     }
05886 
05887   //
05888   //  Actions for which the context of the package is checked,
05889   //  and the requirements file is analysed.
05890   //
05891 
05892   switch (m_action)
05893     {
05894     case action_none :
05895     case action_broadcast :
05896     case action_build_constituent_makefile :
05897     case action_build_constituents_makefile :
05898     case action_build_dependencies :
05899     case action_build_library_links :
05900     case action_build_make_setup :
05901     case action_build_msdev :
05902     case action_build_os9_makefile :
05903       // case action_build_prototype :
05904     case action_build_readme :
05905     case action_build_tag_makefile :
05906       // case action_build_temporary_name :
05907     case action_build_triggers :
05908     case action_build_windefs :
05909     case action_check_configuration :
05910       // case action_check_files :
05911       // case action_check_version :
05912       // case action_checkout :
05913     case action_cleanup :
05914     case action_config :
05915       // case action_create :
05916       // case action_cvsbranches :
05917       // case action_cvssubpackages :
05918       // case action_cvstags :
05919     case action_expand_model :
05920     case action_filter :
05921     case action_help :
05922     case action_load :
05923     case action_lock :
05924       // case action_remove :
05925     case action_remove_library_links :
05926     case action_run :
05927     case action_setup :
05928     case action_show_applied_patterns :
05929     case action_show_author :
05930     case action_show_branches :
05931       // case action_show_clients :
05932     case action_show_constituent :
05933     case action_show_constituent_names :
05934     case action_show_constituents :
05935     case action_show_fragment :
05936     case action_show_fragments :
05937     case action_show_groups :
05938     case action_show_include_dirs :
05939     case action_show_language :
05940     case action_show_languages :
05941     case action_show_macro :
05942     case action_show_macro_value :
05943     case action_show_macros :
05944     case action_show_manager :
05945       // case action_show_packages :
05946     case action_show_path :
05947     case action_show_pattern :
05948     case action_show_pattern_names :
05949     case action_show_patterns :
05950     case action_show_pwd :
05951     case action_show_set :
05952     case action_show_set_value :
05953     case action_show_sets :
05954     case action_show_strategies :
05955     case action_show_tags :
05956     case action_show_uses :
05957     case action_show_version :
05958       // case action_show_versions :
05959       // case action_system :
05960     case action_unlock :
05961       // case action_version :
05962       reach_current_package ();
05963       use_user_context_requirements ();
05964       break;
05965     default:
05966       break;
05967     }
05968 
05969   if (m_debug) cerr << "parser3> current_tag=" << m_current_tag << endl;
05970 
05971   //
05972   // Perform some actions even if there is an error
05973   //
05974 
05975   if (CmtError::has_pending_error ())
05976     {
05977       int code = CmtError::get_last_error_code ();
05978       if (!m_quiet) CmtError::print ();
05979 
05980       switch (m_action)
05981         {
05982           // case action_none :
05983           // case action_broadcast :
05984         case action_build_constituent_makefile :
05985         case action_build_constituents_makefile :
05986         case action_build_dependencies :
05987         case action_build_library_links :
05988         case action_build_make_setup :
05989         case action_build_msdev :
05990         case action_build_os9_makefile :
05991         case action_build_prototype :
05992         case action_build_readme :
05993         case action_build_tag_makefile :
05994           // case action_build_temporary_name :
05995         case action_build_triggers :
05996         case action_build_windefs :
05997         case action_check_configuration :
05998           // case action_check_files :
05999           // case action_check_version :
06000           // case action_checkout :
06001         case action_cleanup :
06002           // case action_config :
06003           // case action_create :
06004           // case action_cvsbranches :
06005           // case action_cvssubpackages :
06006           // case action_cvstags :
06007           // case action_expand_model :
06008           // case action_filter :
06009           // case action_help :
06010         case action_load :
06011         case action_lock :
06012         case action_remove :
06013         case action_remove_library_links :
06014           // case action_run :
06015         case action_setup :
06016           // case action_show_applied_patterns :
06017           // case action_show_author :
06018           // case action_show_branches :
06019           // case action_show_clients :
06020           // case action_show_constituent :
06021           // case action_show_constituent_names :
06022           // case action_show_constituents :
06023           // case action_show_fragment :
06024           // case action_show_fragments :
06025           // case action_show_groups :
06026           // case action_show_include_dirs :
06027           // case action_show_language :
06028           // case action_show_languages :
06029           // case action_show_macro :
06030           // case action_show_macro_value :
06031           // case action_show_macros :
06032           // case action_show_manager :
06033           // case action_show_packages :
06034           // case action_show_path :
06035           // case action_show_pattern :
06036           // case action_show_pattern_names :
06037           // case action_show_patterns :
06038           // case action_show_pwd :
06039           // case action_show_set :
06040           // case action_show_set_value :
06041           // case action_show_sets :
06042           // case action_show_strategies :
06043           // case action_show_tags :
06044           // case action_show_uses :
06045           // case action_show_version :
06046           // case action_show_versions :
06047           // case action_system :
06048         case action_unlock :
06049           // case action_version :
06050           clear ();
06051           return (code);
06052         default:
06053           CmtError::clear ();
06054           break;
06055         }
06056     }
06057 
06058   //
06059   // Perform actions
06060   //
06061 
06062   switch (m_action)
06063     {
06064     case action_none :
06065       CmtError::set (CmtError::syntax_error, "ParseArguments> ");
06066       break;
06067     case action_broadcast :
06068       do_broadcast (arguments, argc, argv);
06069       break;
06070     case action_build_constituent_makefile :
06071       do_build_constituent_makefile (arguments, argc, argv);
06072       break;
06073     case action_build_constituents_makefile :
06074       do_build_constituents_makefile (arguments, argc, argv);
06075       break;
06076     case action_build_dependencies :
06077       do_build_dependencies (arguments, argc, argv);
06078       break;
06079     case action_build_library_links :
06080       do_build_library_links ();
06081       break;
06082     case action_build_make_setup :
06083       do_build_make_setup ();
06084       break;
06085     case action_build_msdev :
06086       do_build_msdev (arguments);
06087       break;
06088     case action_build_os9_makefile :
06089       do_build_os9_makefile (arguments);
06090       break;
06091     case action_build_prototype :
06092       do_build_prototype (arguments);
06093       break;
06094     case action_build_readme :
06095       do_build_readme (arguments);
06096       break;
06097     case action_build_tag_makefile :
06098       do_build_tag_makefile ();
06099       break;
06100     case action_build_temporary_name :
06101       do_build_temporary_name ();
06102       break;
06103     case action_build_triggers :
06104       do_build_triggers (arguments);
06105       break;
06106     case action_build_windefs :
06107       do_build_windefs (arguments);
06108       break;
06109     case action_check_configuration :
06110       do_check_configuration ();
06111       break;
06112     case action_check_files :
06113       do_check_files (arguments);
06114       break;
06115     case action_check_version :
06116       do_check_version (arguments);
06117       break;
06118     case action_checkout :
06119       do_checkout (arguments);
06120       break;
06121     case action_cleanup :
06122       do_cleanup (mode);
06123       break;
06124     case action_config :
06125       do_config ();
06126       break;
06127     case action_create :
06128       do_create (arguments);
06129       break;
06130     case action_cvsbranches :
06131       do_cvsbranches (arguments);
06132       break;
06133     case action_cvssubpackages :
06134       do_cvssubpackages (arguments);
06135       break;
06136     case action_cvstags :
06137       do_cvstags (arguments);
06138       break;
06139     case action_expand_model :
06140       do_expand_model (arguments);
06141       break;
06142     case action_filter :
06143       do_filter (arguments);
06144       break;
06145     case action_help :
06146       do_help ();
06147       break;
06148     case action_load :
06149       cout << "#CMT> action not implemented" << endl;
06150       break;
06151     case action_lock :
06152       do_lock (m_current_package, m_current_version, m_current_path);
06153       break;
06154     case action_remove :
06155       do_remove (m_current_package, m_current_version, m_current_path);
06156       break;
06157     case action_remove_library_links :
06158       do_remove_library_links ();
06159       break;
06160     case action_run :
06161       do_run (arguments);
06162       break;
06163     case action_setup :
06164       do_setup (mode);
06165       break;
06166     case action_show_applied_patterns :
06167       do_show_applied_patterns ();
06168       break;
06169     case action_show_author :
06170       do_show_author ();
06171       break;
06172     case action_show_branches :
06173       do_show_branches (mode);
06174       break;
06175     case action_show_clients :
06176       do_show_clients (arguments);
06177       break;
06178     case action_show_constituent :
06179       do_show_constituent (arguments);
06180       break;
06181     case action_show_constituent_names :
06182       do_show_constituent_names ();
06183       break;
06184     case action_show_constituents :
06185       do_show_constituents ();
06186       break;
06187     case action_show_fragment :
06188       do_show_fragment (arguments);
06189       break;
06190     case action_show_fragments :
06191       do_show_fragments ();
06192       break;
06193     case action_show_groups :
06194       do_show_groups ();
06195       break;
06196     case action_show_include_dirs :
06197       do_show_include_dirs ();
06198       break;
06199     case action_show_language :
06200       do_show_language (arguments);
06201       break;
06202     case action_show_languages :
06203       do_show_languages ();
06204       break;
06205     case action_show_macro :
06206       do_show_macro (arguments, mode);
06207       break;
06208     case action_show_macro_value :
06209       do_show_macro_value (arguments, mode);
06210       break;
06211     case action_show_macros :
06212       do_show_macros (mode);
06213       break;
06214     case action_show_manager :
06215       do_show_manager ();
06216       break;
06217     case action_show_packages :
06218       do_show_packages (arguments);
06219       break;
06220     case action_show_path :
06221       do_show_path ();
06222       break;
06223     case action_show_pattern :
06224       do_show_pattern (arguments);
06225       break;
06226     case action_show_pattern_names :
06227       do_show_pattern_names ();
06228       break;
06229     case action_show_patterns :
06230       do_show_patterns ();
06231       break;
06232     case action_show_pwd :
06233       do_show_pwd ();
06234       break;
06235     case action_show_set :
06236       do_show_set (arguments, mode);
06237       break;
06238     case action_show_set_value :
06239       do_show_set_value (arguments, mode);
06240       break;
06241     case action_show_sets :
06242       do_show_sets (mode);
06243       break;
06244     case action_show_strategies :
06245       do_show_strategies ();
06246       break;
06247     case action_show_tags :
06248       do_show_tags ();
06249       break;
06250     case action_show_uses :
06251       do_show_uses ();
06252       break;
06253     case action_show_version :
06254       do_show_version ();
06255       break;
06256     case action_show_versions :
06257       do_show_versions (arguments);
06258       break;
06259     case action_system :
06260       do_show_system ();
06261       break;
06262     case action_unlock :
06263       do_unlock (m_current_package, m_current_version, m_current_path);
06264       break;
06265     case action_version :
06266       do_version ();
06267       break;
06268     default:
06269       CmtError::set (CmtError::syntax_error, "ParseArguments>");
06270       break;
06271     }
06272 
06273   if (CmtError::has_pending_error ())
06274     {
06275       int code = CmtError::get_last_error_code ();
06276       if (!m_quiet) CmtError::print ();
06277       clear ();
06278       return (code);
06279     }
06280   else
06281     {
06282       clear ();
06283       return (0);
06284     }
06285 }

int Cmt::parser ( const cmt_string & command_line ) [static]
 

Definition at line 5622 of file cmt_parser.cxx.

Referenced by do_broadcast(), and main().

05623 {
05624   CmtSystem::cmt_string_vector v;
05625 
05626   CmtSystem::split (command_line, " \t", v);
05627 
05628   int argc = v.size ();
05629 
05630   char** argv = (char**) malloc ((argc + 1) * sizeof (char*));
05631 
05632   int i;
05633   for (i = 0; i < argc; i++)
05634     {
05635       argv[i] = (char*) v[i].c_str ();
05636     }
05637   argv[argc] = 0;
05638 
05639   int status = parser (argc, argv);
05640 
05641   free (argv);
05642 
05643   return (status);
05644 }

void Cmt::print ( PrintMode mode ) [static]
 

Format as one single line a set of 'setenv' statements joined with semi-colons to form one shell command.

Definition at line 6292 of file cmt_parser.cxx.

Referenced by do_setup().

06293 {
06294   Use::UsePtrVector& Uses = Use::uses ();
06295 
06296   cmt_string tag;
06297 
06298   set_standard_macros ();
06299 
06300     //cerr << "# current_tag=" << m_current_tag << endl;
06301     //cerr << "# current_config=" << m_current_config << endl;
06302 
06303   if (m_current_tag == "")
06304     {
06305       if (mode == Bat) tag = "%CMTCONFIG%";
06306       else tag = "${CMTCONFIG}";
06307     }
06308   else
06309     {
06310       tag = m_current_tag;
06311     }
06312 
06313   if (m_current_access == DeveloperMode)
06314     {
06315       m_scope = ScopePrivate;
06316     }
06317   else
06318     {
06319       m_scope = ScopePublic;
06320     }
06321 
06322     //
06323     //  Now check if all extra tags are still valid. Some of them
06324     //  may be discarded du to some conflict with highest priority
06325     //  tags, or with exclude statements
06326     //
06327 
06328   {
06329     CmtSystem::cmt_string_vector words;
06330       
06331     cmt_string tags;
06332 
06333     tags = Cmt::m_extra_tags;
06334       
06335     CmtSystem::split (tags, " \t,", words);
06336 
06337     Cmt::m_extra_tags = "";
06338       
06339     for (int i = 0; i < words.size (); i++)
06340       {
06341         Tag* tag;
06342         const cmt_string& a = words[i];
06343 
06344         tag = Tag::find (a);
06345 
06346         if ((tag != 0) && (tag->is_selected ()))
06347           {
06348             Cmt::m_extra_tags += a;
06349             Cmt::m_extra_tags += ",";
06350           }
06351       }
06352   }
06353 
06354   if (Uses.size () > 0)
06355     {
06356       int number;
06357 
06358       for (number = 0; number < Uses.size (); number++)
06359         {
06360           Use& use = *(Uses[number]);
06361 
06362           if (use.discarded) continue;
06363 
06364           print_context (use, mode, tag);
06365         }
06366     }
06367 
06368   print_context (Use::current (), mode, tag);
06369 
06370   Symbol::all_print (mode);
06371   // Script::all_print (mode);
06372 
06373   cout << endl;
06374 }

void Cmt::print_clean ( PrintMode mode ) [static]
 

Definition at line 6377 of file cmt_parser.cxx.

Referenced by do_cleanup().

06378 {
06379   Use::UsePtrVector& Uses = Use::uses ();
06380 
06381   set_standard_macros ();
06382 
06383   Script::all_print_clean (mode);
06384   Symbol::all_print_clean (mode);
06385 
06386   switch (mode)
06387     {
06388     case Csh :
06389       if (m_current_package != "CMT")
06390         {
06391           cout << "unsetenv " << m_current_prefix << "ROOT" << endl;
06392           cout << "unsetenv " << m_current_prefix << "CONFIG" << endl;
06393         }
06394       break;
06395     case Sh :
06396       if (m_current_package != "CMT")
06397         {
06398           cout << "unset " << m_current_prefix << "ROOT" << endl;
06399           cout << "unset " << m_current_prefix << "CONFIG" << endl;
06400         }
06401       break;
06402     case Bat :
06403       if (m_current_package != "CMT")
06404         {
06405           cout << "set " << m_current_prefix << "ROOT=" << endl;
06406           cout << "set " << m_current_prefix << "CONFIG=" << endl;
06407         }
06408       break;
06409     }
06410 
06411   if (Uses.size () > 0)
06412     {
06413       int number;
06414 
06415       for (number = 0; number < Uses.size (); number++)
06416         {
06417           Use* use = Uses[number];
06418 
06419           if (use->package == "CMT") continue;
06420           if (use->package == "methods") continue;
06421           if (use->discarded) continue;
06422 
06423           switch (mode)
06424             {
06425             case Csh :
06426               cout << "unsetenv " << use->prefix << "ROOT" << endl;
06427               cout << "unsetenv " << use->prefix << "CONFIG" << endl;
06428               break;
06429             case Sh :
06430               cout << "unset " << use->prefix << "ROOT" << endl;
06431               cout << "unset " << use->prefix << "CONFIG" << endl;
06432               break;
06433             case Bat :
06434               cout << "set " << use->prefix << "ROOT=" << endl;
06435               cout << "set " << use->prefix << "CONFIG" << endl;
06436               break;
06437             }
06438         }
06439     }
06440 
06441   switch (mode)
06442     {
06443     case Csh :
06444       cout << "unsetenv CMTEXTRATAGS" << endl;
06445       break;
06446     case Sh :
06447       cout << "unset CMTEXTRATAGS" << endl;
06448       break;
06449     case Bat :
06450       cout << "set CMTEXTRATAGS=" << endl;
06451       break;
06452     }
06453 
06454   cout << endl;
06455 }

void Cmt::print_context ( Use & use,
PrintMode mode,
const cmt_string & tag ) [static]
 

Definition at line 6458 of file cmt_parser.cxx.

Referenced by print().

06459 {
06460   if (use.package == "cmt_standalone") return;
06461 
06462   cmt_string fs = CmtSystem::file_separator ();
06463 
06464   use.real_path.replace_all (CmtSystem::file_separator (), fs);
06465 
06466   cmt_string system = CmtSystem::get_cmt_config ();
06467 
06468   switch (mode)
06469     {
06470     case Csh :
06471       cout << "setenv " << use.prefix << "ROOT \"" <<
06472         use.real_path << fs <<
06473         use.package << fs <<
06474         use.version << "\"" << endl;
06475         
06476       if (use.package == "CMT")
06477         {
06478             //cout << "setenv CMTCONFIG `${CMTROOT}/mgr/cmt system`; " << endl;
06479           cout << "setenv CMTCONFIG " << system << endl;
06480           //cout << "setenv CMTEXTRATAGS " << Cmt::m_extra_tags << endl;
06481         }
06482       else
06483         {
06484           cout << "setenv " << use.prefix << "CONFIG \"" << tag << "\"" << endl;
06485         }
06486         
06487       break;
06488     case Sh :
06489       cout << use.prefix << "ROOT=\"" <<
06490         use.real_path << fs <<
06491         use.package << fs <<
06492         use.version << "\"; export " <<
06493         use.prefix << "ROOT" << endl;
06494         
06495       if (use.package == "CMT")
06496         {
06497           //cout << "CMTCONFIG=`${CMTROOT}/mgr/cmt system`; export CMTCONFIG; ";
06498           cout << "CMTCONFIG=" << system << "; export CMTCONFIG" << endl;
06499           //cout << "CMTEXTRATAGS=" << Cmt::m_extra_tags << "; export CMTEXTRATAGS" << endl;
06500         }
06501       else
06502         {
06503           cout << use.prefix << "CONFIG=\"" <<
06504             tag << "\"; export " <<
06505             use.prefix << "CONFIG" << endl;
06506         }
06507         
06508       break;
06509     case Bat :
06510       cout << "set " << use.prefix << "ROOT=" <<
06511         use.real_path << fs <<
06512         use.package << fs <<
06513         use.version << endl;
06514         
06515       if (use.package == "CMT")
06516         {
06517           //cout << "set CMTCONFIG=VisualC" << endl;
06518           cout << "set CMTCONFIG=" << system << endl;
06519           //cout << "set CMTEXTRATAGS=" << Cmt::m_extra_tags << endl;
06520         }
06521       else
06522         {
06523           cout << "set " << use.prefix << "CONFIG=" << tag << endl;
06524         }
06525         
06526       break;
06527     }
06528 }

void Cmt::print_macros ( PrintMode mode ) [static]
 

Format a set of make macro definitions (one per line) Each macro value is provided enclosed in single quotes.

Take the macro values from the macro statements found in recursively read requirements files.

Definition at line 6537 of file cmt_parser.cxx.

Referenced by do_build_tag_makefile(), do_show_macros(), and do_show_sets().

06538 {
06539   int number;
06540 
06541   set_standard_macros ();
06542 
06543   for (number = 0; number < Symbol::symbol_number (); number++)
06544     {
06545       Symbol& symbol = Symbol::symbol (number);
06546 
06547       if (m_action == action_show_macros)
06548         {
06549           // Only keep macros.
06550           if ((symbol.command == CommandSet) ||
06551               (symbol.command == CommandSetAppend) ||
06552               (symbol.command == CommandSetPrepend) ||
06553               (symbol.command == CommandSetRemove) ||
06554               (symbol.command == CommandAlias) ||
06555               (symbol.command == CommandPath) ||
06556               (symbol.command == CommandPathAppend) ||
06557               (symbol.command == CommandPathPrepend) ||
06558               (symbol.command == CommandPathRemove)) continue;
06559         }
06560       else if (m_action == action_show_sets)
06561         {
06562           // Exclude macros.
06563           if ((symbol.command == CommandMacro) ||
06564               (symbol.command == CommandMacroAppend) ||
06565               (symbol.command == CommandMacroPrepend) ||
06566               (symbol.command == CommandMacroRemove) ||
06567               (symbol.command == CommandMacroRemoveAll)) continue;
06568         }
06569       else if (m_action == action_build_tag_makefile)
06570         {
06571           // Exclude scripts.
06572           if ((symbol.command == CommandSetupScript) ||
06573               (symbol.command == CommandCleanupScript)) continue;
06574         }
06575 
06576       if (symbol.value_lists.size () < 1) continue;
06577 
06578       symbol.show_macro (mode);
06579     }
06580 }

void Cmt::print_tabs ( int tabs ) [static]
 

Definition at line 6583 of file cmt_parser.cxx.

06584 {
06585   while (tabs > 0)
06586     {
06587       cout << "  ";
06588       tabs--;
06589     }
06590 }

int Cmt::reach_current_package ( ) [static]
 

Definition at line 6593 of file cmt_parser.cxx.

Referenced by do_config(), and parser().

06594 {
06595   Use& use = Use::current ();
06596   cmt_string dir;
06597 
06598   if (m_debug)
06599     {
06600       cout << "Cmt::reach_current_package> pwd = " <<
06601         CmtSystem::pwd () <<
06602         " path=" << m_current_path <<
06603         endl;
06604     }
06605 
06606   /*
06607     Try to access the package.
06608   */
06609 
06610   if (m_current_package == "cmt_standalone")
06611     {
06612       if ((m_current_path != "") && (m_current_path != CmtSystem::pwd ()))
06613         {
06614           if (!CmtSystem::cd (m_current_path))
06615             {
06616               CmtError::set (CmtError::package_not_found,
06617                              "ReachCurrentPackage> Cannot reach the path directory");
06618               return (0);
06619             }
06620         }
06621 
06622       if (!CmtSystem::test_file ("requirements"))
06623         {
06624           if (!m_quiet)
06625             {
06626               cout << "#CMT> Cannot reach the requirements file" << endl;
06627             }
06628               
06629           CmtError::set (CmtError::package_not_found,
06630                          "ReachCurrentPackage> Cannot reach the requirements file");
06631           return (0);
06632         }
06633     }
06634   else if (m_current_package != "")
06635     {
06636       if (!use.move_to ())
06637         {
06638           CmtError::set (CmtError::package_not_found,
06639                          "ReachCurrentPackage> Cannot reach the path directory");
06640           return (0);
06641         }
06642 
06643       m_current_path = use.real_path;
06644 
06645       cmt_string parent = m_current_path;
06646       cmt_string d = m_current_path;
06647 
06648       for (;;)
06649         {
06650           d += "/../";
06651           if (!CmtSystem::is_package_directory (d))
06652             {
06653               CmtSystem::add_cmt_path (parent, "current package",
06654                                        m_cmt_path, 
06655                                        m_cmt_path_pwds, 
06656                                        m_cmt_path_sources);
06657               break;
06658             }
06659           parent = d;
06660         }
06661     }
06662   else
06663     {
06664       //
06665       // The cmt command has been given without explicit search for 
06666       // a package. Thus it is expected that we are in the context of a
06667       // true package.
06668       //
06669       //  This means that there should be a requirements file visible.
06670       //
06671       //  If this is not true, we'll make a try into ../cmt and then
06672       // a last try into ../mgr
06673       //
06674 
06675       if (!CmtSystem::test_file ("requirements"))
06676         {
06677           if (CmtSystem::cd ("../cmt") && 
06678               CmtSystem::test_file ("requirements"))
06679             {
06680               m_current_style = cmt_style;
06681             }
06682           else if (CmtSystem::cd ("../mgr") && 
06683                    CmtSystem::test_file ("requirements"))
06684             {
06685               m_current_style = mgr_style;
06686             }
06687           else
06688             {
06689               if (!m_quiet)
06690                 {
06691                   cout << "#CMT> Cannot reach the mgr branch" << endl;
06692                 }
06693               
06694               CmtError::set (CmtError::package_not_found,
06695                              "ReachCurrentPackage> Cannot reach the mgr/cmt directory");
06696               return (0);
06697             }
06698         }
06699 
06700       dir = CmtSystem::pwd ();
06701 
06702       CmtSystem::dirname (dir, m_current_path);
06703       CmtSystem::basename (m_current_path, m_current_version);
06704       CmtSystem::dirname (m_current_path, m_current_path);
06705       CmtSystem::basename (m_current_path, m_current_package);
06706       CmtSystem::dirname (m_current_path, m_current_path);
06707       
06708       Use& use = Use::current ();
06709       
06710       use.package = m_current_package;
06711       use.version = m_current_version;
06712       use.path    = m_current_path;
06713       use.style   = m_current_style;
06714     }
06715 
06716   configure_current_dir ();
06717 
06718   /*
06719     Check Tag is always set up
06720   */
06721 
06722   if (m_debug) cerr << "reach_current_package0> current_tag=" << m_current_tag << endl;
06723 
06724   if (m_current_tag == "")
06725     {
06726       cmt_string env;
06727 
06728       env = CmtSystem::getenv (m_current_config);
06729       if (env != "")
06730         {
06731           Tag* tag;
06732 
06733           tag = Tag::add (env, PriorityConfig, "reach current package", 0);
06734           tag->mark ();
06735             //m_current_tag = env;
06736 
06737           //if (!m_quiet) cerr << "reach_current_package1> current_tag=" << m_current_tag << endl;
06738 
06739         }
06740     }
06741 
06742   if (m_debug)
06743     {
06744       cout << "pwd = " << CmtSystem::pwd () << endl;
06745     }
06746 
06747   /*
06748     Work on the requirements file.
06749   */
06750 
06751   if (dir != "") dir += CmtSystem::file_separator ();
06752   dir += "requirements";
06753   parse_requirements (dir, 0);
06754 
06755   if (m_debug) cerr << "reach_current_package2> current_tag=" << m_current_tag << endl;
06756 
06778   Pattern::apply_all_globals ();
06779 
06780   /*
06781     Select all possible tags
06782   */
06783 
06784   Tag::restore_tree ();
06785 
06786   return (1);
06787 }

void Cmt::restore_all_tags ( Use * use ) [static]
 

Definition at line 1005 of file cmt_parser.cxx.

Referenced by parse_arguments().

01006 {
01007     //cerr << "restore_all_tags" << endl;
01008 
01009   Cmt::configure_tags (use);
01010 
01011     /*
01012       Then get existing extra tags
01013      */
01014 
01015   if (CmtSystem::testenv ("CMTEXTRATAGS"))
01016     {
01017       cmt_string s = "CMTEXTRATAGS";
01018 
01019       if (use != 0)
01020         {
01021           s += " in ";
01022         }
01023 
01024       Tag* tag;
01025       CmtSystem::cmt_string_vector words;
01026       
01027       cmt_string tags = CmtSystem::getenv ("CMTEXTRATAGS");
01028       
01029       CmtSystem::split (tags, " \t,", words);
01030 
01031       Cmt::m_extra_tags = "";
01032       
01033       for (int i = 0; i < words.size (); i++)
01034         {
01035           const cmt_string& a = words[i];
01036 
01037           Cmt::m_extra_tags += a;
01038           Cmt::m_extra_tags += ",";
01039           
01040           tag = Tag::add (a, PriorityUserTag, s, use);
01041           
01042           tag->mark ();
01043         }
01044     }
01045 }

void Cmt::select ( const CmtSystem::cmt_string_vector & words,
Use * use,
const cmt_string & file_name,
int line_number ) [static]
 

Parse a line reformatted into a set of words.

Specific action are taken according to the keyword

Definition at line 6794 of file cmt_parser.cxx.

Referenced by parse_requirements_line().

06798 {
06799   cmt_string command;
06800   CommandType command_type = CommandNone;
06801   int i;
06802 
06803   CmtError::clear ();
06804 
06805   if (words.size () == 0) return;
06806 
06807   command = words[0];
06808 
06809   if (command.size () == 0) return;
06810 
06811   //
06812   // First analyze the syntax
06813   //
06814 
06815   switch (command[0])
06816     {
06817     case 'a':
06818       if (command == "alias")
06819         {
06820           command_type = CommandAlias;
06821         }
06822       else if (command == "application")
06823         {
06824           command_type = CommandApplication;
06825         }
06826       else if (command == "apply_pattern")
06827         {
06828           command_type = CommandApplyPattern;
06829         }
06830       else if (command == "author")
06831         {
06832           command_type = CommandAuthor;
06833         }
06834       else
06835         {
06836           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
06837         }
06838       break;
06839     case 'b':
06840       if (command == "branches")
06841         {
06842           command_type = CommandBranches;
06843         }
06844       else if (command == "build_strategy")
06845         {
06846           command_type = CommandBuildStrategy;
06847         }
06848       else
06849         {
06850           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
06851         }
06852       break;
06853     case 'c':
06854       if (command == "cleanup_script")
06855         {
06856           command_type = CommandCleanupScript;
06857         }
06858       else
06859         {
06860           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
06861         }
06862       break;
06863     case 'd':
06864       if (command == "document")
06865         {
06866           command_type = CommandDocument;
06867         }
06868       else
06869         {
06870           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
06871         }
06872       break;
06873     case 'i':
06874       if (command == "ignore_pattern")
06875         {
06876           command_type = CommandIgnorePattern;
06877         }
06878       else if (command == "include_dirs")
06879         {
06880           command_type = CommandIncludeDirs;
06881         }
06882       else if (command == "include_path")
06883         {
06884           command_type = CommandIncludePath;
06885         }
06886       else
06887         {
06888           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
06889         }
06890       break;
06891     case 'l':
06892       if (command == "language")
06893         {
06894           command_type = CommandLanguage;
06895         }
06896       else if (command == "library")
06897         {
06898           command_type = CommandLibrary;
06899         }
06900       else
06901         {
06902           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
06903         }
06904       break;
06905     case 'm':
06906       if (command == "macro")
06907         {
06908           command_type = CommandMacro;
06909         }
06910       else if (command == "macro+")
06911         {
06912           command_type = CommandMacroAppend;
06913         }
06914       else if (command == "macro_prepend")
06915         {
06916           command_type = CommandMacroPrepend;
06917         }
06918       else if ((command == "macro_append") ||
06919                (command == "macro+"))
06920         {
06921           command_type = CommandMacroAppend;
06922         }
06923       else if (command == "macro_remove")
06924         {
06925           command_type = CommandMacroRemove;
06926         }
06927       else if (command == "macro_remove_all")
06928         {
06929           command_type = CommandMacroRemoveAll;
06930         }
06931       else if (command == "make_fragment")
06932         {
06933           command_type = CommandMakeFragment;
06934         }
06935       else if (command == "manager")
06936         {
06937           command_type = CommandManager;
06938         }
06939       else
06940         {
06941           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
06942         }
06943       break;
06944     case 'p':
06945       if (command == "package")
06946         {
06947           command_type = CommandPackage;
06948         }
06949       else if (command == "path")
06950         {
06951           command_type = CommandPath;
06952         }
06953       else if (command == "path_append")
06954         {
06955           command_type = CommandPathAppend;
06956         }
06957       else if (command == "path_prepend")
06958         {
06959           command_type = CommandPathPrepend;
06960         }
06961       else if (command == "path_remove")
06962         {
06963           command_type = CommandPathRemove;
06964         }
06965       else if (command == "pattern")
06966         {
06967           command_type = CommandPattern;
06968         }
06969       else if (command == "public")
06970         {
06971           command_type = CommandPublic;
06972         }
06973       else if (command == "private")
06974         {
06975           command_type = CommandPrivate;
06976         }
06977       else
06978         {
06979           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
06980         }
06981       break;
06982     case 's':
06983       if (command == "set")
06984         {
06985           command_type = CommandSet;
06986         }
06987       else if (command == "set_append")
06988         {
06989           command_type = CommandSetAppend;
06990         }
06991       else if (command == "set_prepend")
06992         {
06993           command_type = CommandSetPrepend;
06994         }
06995       else if (command == "set_remove")
06996         {
06997           command_type = CommandSetRemove;
06998         }
06999       else if (command == "setup_script")
07000         {
07001           command_type = CommandSetupScript;
07002         }
07003       else
07004         {
07005           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
07006         }
07007       break;
07008     case 't':
07009       if (command == "tag")
07010         {
07011           command_type = CommandTag;
07012         }
07013       else if (command == "tag_exclude")
07014         {
07015           command_type = CommandTagExclude;
07016         }
07017       else
07018         {
07019           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
07020         }
07021       break;
07022     case 'u':
07023       if (command == "use")
07024         {
07025           command_type = CommandUse;
07026         }
07027       else
07028         {
07029           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
07030         }
07031       break;
07032     case 'v':
07033       if (command == "version_strategy")
07034         {
07035           command_type = CommandVersionStrategy;
07036         }
07037       else if (command == "version")
07038         {
07039           command_type = CommandVersion;
07040         }
07041       else
07042         {
07043           CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
07044         }
07045       break;
07046     default:
07047       CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
07048       break;
07049     }
07050 
07051   if (CmtError::has_pending_error ())
07052     {
07053       if (!m_quiet)
07054         {
07055           cout << "#CMT> bad syntax in requirements of " << use->package
07056                << " " << use->version 
07057                << " " << use->specified_path 
07058                << " line #" << line_number;
07059           cout << " [" << command << " ...]" << endl;
07060         }
07061 
07062       return;
07063     }
07064 
07065 
07066   //
07067   // Then interpret the action
07068   //
07069 
07070   switch (command_type)
07071     {
07072     case CommandAlias :
07073       Symbol::action (words, command_type, use);
07074       break;
07075     case CommandApplication :
07076       if (use == &(Use::current ()))
07077         {
07078           Constituent::action (Application, words);
07079         }
07080       break;
07081     case CommandApplyPattern :
07082       ApplyPattern::action (words, use);
07083       break;
07084     case CommandAuthor :
07085       use->author_action (words);
07086       break;
07087     case CommandBranches :
07088       if (use == &(Use::current ())) Branch::action (words);
07089       break;
07090     case CommandBuildStrategy :
07091       m_current_build_strategy = DefaultBuildStrategy;
07092 
07093       for (i = 1; i < words.size (); i++)
07094         {
07095           const cmt_string& w = words[i];
07096 
07097           if (w == "prototypes")
07098             {
07099               m_current_build_strategy |= Prototypes;
07100             }
07101           else if (w == "no_prototypes")
07102             {
07103               m_current_build_strategy |= NoPrototypes;
07104             }
07105           else if (w == "keep_makefiles")
07106             {
07107               m_current_build_strategy |= KeepMakefiles;
07108             }
07109           else if (w == "rebuild_makefiles")
07110             {
07111               m_current_build_strategy |= RebuildMakefiles;
07112             }
07113 
07114           if ((m_action == action_show_strategies) && !m_quiet)
07115             {
07116               cout << "# Package " << use->package <<
07117                 " adds " << w << " to build strategy" << endl;
07118             }
07119         }
07120       break;
07121     case CommandCleanupScript :
07122       Script::action (words, CleanupScript, use);
07123       Symbol::action (words, command_type, use);
07124       break;
07125     case CommandDocument :
07126       if (use == &(Use::current ()))
07127         Constituent::action (Document, words);
07128       break;
07129     case CommandIgnorePattern :
07130       IgnorePattern::action (words, use);
07131       break;
07132     case CommandIncludeDirs :
07133       Include::action (words, use);
07134       break;
07135     case CommandIncludePath :
07136       if (words.size () > 1)
07137         {
07138           use->set_include_path (words[1]);
07139         }
07140       break;
07141     case CommandLanguage :
07142       Language::action (words);
07143       break;
07144     case CommandLibrary :
07145       if (use == &(Use::current ()))
07146         Constituent::action (Library, words);
07147       break;
07148     case CommandMacro :
07149     case CommandMacroPrepend :
07150     case CommandMacroAppend :
07151     case CommandMacroRemove :
07152     case CommandMacroRemoveAll :
07153       Symbol::action (words, command_type, use);
07154       break;
07155     case CommandMakeFragment :
07156       Fragment::action (words, use);
07157       break;
07158     case CommandManager :
07159       use->manager_action (words);
07160       break;
07161     case CommandPackage :
07162       if (words.size () > 1)
07163         {
07164           if (use == &(Use::current()))
07165             {
07166               m_current_package = words[1];
07167               build_prefix (m_current_package, m_current_prefix);
07168 
07169               if ((use->package != "") &&
07170                   (use->package != m_current_package))
07171                 {
07172                   /*
07173                     Unknown keyword : just ignore the line
07174                   */
07175                   if (!m_quiet)
07176                     {
07177                       cout << "#CMT> package name mismatch in requirements of " <<
07178                         use->package << " " <<
07179                         use->version << " line #" << line_number;
07180                       cout << " : " << m_current_package << " versus " <<
07181                         use->package << endl;
07182                     }
07183                 }
07184 
07185               use->set (m_current_package,
07186                         m_current_version,
07187                         m_current_path,
07188                         "",
07189                         "");
07190 
07191               use->change_path (m_current_path);
07192               use->style = m_current_style;
07193             }
07194         }
07195       break;
07196     case CommandPath :
07197     case CommandPathAppend :
07198     case CommandPathPrepend :
07199     case CommandPathRemove :
07200       Symbol::action (words, command_type, use);
07201       break;
07202     case CommandPattern :
07203       Pattern::action (words, use);
07204       break;
07205     case CommandPrivate :
07206       m_scope = ScopePrivate;
07207       break;
07208     case CommandPublic :
07209       m_scope = ScopePublic;
07210       break;
07211     case CommandSet :
07212     case CommandSetAppend :
07213     case CommandSetPrepend :
07214     case CommandSetRemove :
07215       Symbol::action (words, command_type, use);
07216       break;
07217     case CommandSetupScript :
07218       Script::action (words, SetupScript, use);
07219       Symbol::action (words, command_type, use);
07220       break;
07221     case CommandTag :
07222       Tag::action (words, use);
07223       break;
07224     case CommandTagExclude :
07225       Tag::action_exclude (words, use);
07226       break;
07227     case CommandUse :
07228       Use::action (words, use);
07229       break;
07230     case CommandVersionStrategy :
07231       if (words.size () > 1)
07232         {
07233           const cmt_string& w = words[1];
07234 
07235           if (w == "best_fit")
07236             {
07237               m_current_strategy = BestFit;
07238             }
07239           else if (w == "best_fit_no_check")
07240             {
07241               m_current_strategy = BestFitNoCheck;
07242             }
07243           else if (w == "first_choice")
07244             {
07245               m_current_strategy = FirstChoice;
07246             }
07247           else if (w == "last_choice")
07248             {
07249               m_current_strategy = LastChoice;
07250             }
07251           else if (w == "keep_all")
07252             {
07253               m_current_strategy = KeepAll;
07254             }
07255 
07256           if ((m_action == action_show_strategies) && !m_quiet)
07257             {
07258               cout << "# Package " << use->package <<
07259                 " sets version strategy to " << w << endl;
07260             }
07261         }
07262       break;
07263     case CommandVersion :
07264       /*
07265         m_current_version = words[1];
07266       */
07267       break;
07268     default:
07269       /*
07270         Unknown keyword : just ignore the line
07271       */
07272       if (!m_quiet)
07273         {
07274           cout << "#CMT> bad syntax in requirements of " << use->package
07275                << " " << use->version << " line #" << line_number;
07276           cout << " [" << command << "...]" << endl;
07277         }
07278 
07279       CmtError::set (CmtError::syntax_error, "ParseRequirements> ");
07280 
07281       return;
07282     }
07283 }

void Cmt::set_standard_macros ( ) [static]
 

Definition at line 7380 of file cmt_parser.cxx.

Referenced by build_msdev_file(), do_build_constituent_makefile(), do_build_constituents_makefile(), do_build_dependencies(), do_build_library_links(), do_build_make_setup(), do_build_msdev(), do_build_os9_makefile(), do_build_prototype(), do_build_readme(), do_build_triggers(), do_build_windefs(), do_expand_model(), do_filter(), do_lock(), do_remove_library_links(), do_show_constituent(), do_show_constituent_names(), do_show_constituents(), do_show_include_dirs(), do_show_language(), do_show_languages(), do_show_macro(), do_show_tags(), do_unlock(), print(), print_clean(), and print_macros().

07381 {
07382   if (m_standard_macros_done) return;
07383 
07384   m_standard_macros_done = true;
07385 
07386   int number;
07387   int include_number;
07388   cmt_string temp;
07389   Use::UsePtrVector& Uses = Use::uses ();
07390   Use& current_use = Use::current ();
07391 
07392   cmt_string fs = CmtSystem::file_separator ();
07393 
07394   if (CmtSystem::test_file ("../cmt/requirements")) m_current_style = cmt_style;
07395   else if (CmtSystem::test_file ("../mgr/requirements")) m_current_style = mgr_style;
07396   else m_current_style = none_style;
07397 
07398   cmt_string pwd = CmtSystem::pwd ();
07399   CmtSystem::cmt_string_vector vb;
07400   CmtSystem::split (pwd, fs, vb);
07401 
07402 
07407   bool tag_debug = CmtSystem::testenv ("TAGDEBUG");
07408 
07409   if (tag_debug) cerr << "set_standard_macro0> current_tag=" << m_current_tag << endl;
07410 
07411   if (m_current_tag != "")
07412     {
07413         // this is when some -tag= argument was used.
07414       if (tag_debug) cerr << "set_standard_macro0.1> current_tag=" << m_current_tag << endl;
07415     }
07416   else if (Symbol::is_selected ("CMTCONFIG"))
07417     {
07418         // This is when CMTCONFIG has been set from some requirements file
07419       Symbol* macro = Symbol::find ("CMTCONFIG");
07420       if (macro != 0)
07421         {
07422           m_current_tag = macro->build_macro_value ();
07423           if (tag_debug) cerr << "set_standard_macro1> current_tag=" << m_current_tag << endl;
07424         }
07425     }
07426   else
07427     {
07428         // this is when no -tag= argument was used.
07429       if (tag_debug) cerr << "set_standard_macro(before2)> current_tag=" << m_current_tag << endl;
07430       if (current_use.package == "CMT")
07431         {
07432           m_current_tag = CmtSystem::getenv ("CMTBIN");
07433         }
07434       else
07435         {
07436           m_current_tag = CmtSystem::getenv ("CMTCONFIG");
07437         }
07438 
07439       if (tag_debug) cerr << "set_standard_macro2> current_tag=" << m_current_tag << endl;
07440     }
07441 
07442   if (!Symbol::is_selected ("tag"))
07443     {
07444       if (tag_debug) cerr << "set_standard_macro2.1> current_tag=" << m_current_tag << endl;
07445 
07446       temp.erase (0);
07447 
07448       if (m_current_tag == "")
07449         {
07450           temp += "macro tag \"$(CMTCONFIG)\"";
07451         }
07452       else
07453         {
07454           temp += "macro tag \"";
07455           temp += m_current_tag;
07456           temp += "\"";
07457         }
07458 
07459       if (tag_debug) cerr << " define tag: " << temp << endl;
07460       
07461       parse_requirements_line (temp, &current_use);
07462     }
07463 
07464   if (tag_debug) cerr << "set_standard_macro3> current_tag=" << m_current_tag << endl;
07465 
07466 
07467   cmt_string package_tag = m_current_package;
07468   package_tag += "_tag";
07469 
07470   if (!Symbol::is_selected (package_tag))
07471     {
07472       temp  = "macro ";
07473       temp += package_tag;
07474       temp += " \"$(tag)\"";
07475       parse_requirements_line (temp, &current_use);
07476     }
07477 
07482   cmt_string PACKAGE_ROOT = m_current_prefix;
07483   PACKAGE_ROOT += "ROOT";
07484 
07485   if (!Symbol::is_selected (PACKAGE_ROOT))
07486     {
07487       if (current_use.path == "")
07488         {
07489           temp  = "macro ";
07490           temp += PACKAGE_ROOT;
07491           temp += " \"";
07492           temp += m_current_dir;
07493           temp += "\"";
07494         }
07495       else
07496         {
07497           current_use.path.replace_all (CmtSystem::file_separator (), fs);
07498 
07499           temp  = "macro ";
07500           temp += PACKAGE_ROOT;
07501           temp += " \"";
07502           temp += current_use.path;
07503           temp += fs;
07504           temp += current_use.package;
07505           temp += fs;
07506           temp += current_use.version;
07507           temp += "\"";
07508         }
07509 
07510       parse_requirements_line (temp, &current_use);
07511     }
07512 
07513   cmt_string package_root = current_use.package;
07514   package_root += "_root";
07515 
07516   if (!Symbol::is_selected (package_root))
07517     {
07518       if (current_use.path == "")
07519         {
07520           temp  = "macro ";
07521           temp += package_root;
07522           temp += " \"";
07523           temp += m_current_dir;
07524           temp += "\"";
07525         }
07526       else
07527         {
07528           current_use.path.replace_all (CmtSystem::file_separator (), fs);
07529 
07530           temp  = "macro ";
07531           temp += package_root;
07532           temp += " \"";
07533           temp += get_best_form (vb, current_use.path);
07534           temp += fs;
07535           temp += current_use.package;
07536           temp += fs;
07537           temp += current_use.version;
07538           temp += "\"";
07539         }
07540 
07541       parse_requirements_line (temp, &current_use);
07542     }
07543 
07544   cmt_string package_version = m_current_prefix;
07545   package_version += "VERSION";
07546 
07547   if (!Symbol::is_selected (package_version))
07548     {
07549       temp  = "macro ";
07550       temp += package_version;
07551       temp += " \"";
07552       temp += current_use.version;
07553       temp += "\"";
07554 
07555       parse_requirements_line (temp, &current_use);
07556     }
07557 
07558   if (!Symbol::is_selected ("PACKAGE_ROOT"))
07559     {
07560       temp  = "macro PACKAGE_ROOT \"$(";
07561       temp += PACKAGE_ROOT;
07562       temp += ")\"";
07563 
07564       parse_requirements_line (temp, &current_use);
07565     }
07566 
07571   if (m_current_style == none_style)
07572     {
07573       temp = "macro srcdir \".";
07574       temp += "\"";
07575       parse_requirements_line (temp, &current_use);
07576       temp = "macro src \".";
07577       temp += fs;
07578       temp += "\"";
07579       parse_requirements_line (temp, &current_use);
07580       temp = "macro inc \".";
07581       temp += fs;
07582       temp += "\"";
07583       parse_requirements_line (temp, &current_use);
07584       temp = "macro mgr \".";
07585       temp += fs;
07586       temp += "\"";
07587       parse_requirements_line (temp, &current_use);
07588       temp = "macro bin \".";
07589       temp += fs;
07590       temp += "\"";
07591       parse_requirements_line (temp, &current_use);
07592       temp = "macro javabin \".";
07593       temp += fs;
07594       temp += "\"";
07595       parse_requirements_line (temp, &current_use);
07596       temp = "macro doc \".";
07597       temp += fs;
07598       temp += "\"";
07599       parse_requirements_line (temp, &current_use);
07600       temp = "macro version \"\"";
07601       parse_requirements_line (temp, &current_use);
07602 
07603       temp  = "macro package \"";
07604       temp += m_current_package;
07605       temp += "\"";
07606       parse_requirements_line (temp, &current_use);
07607     }
07608   else
07609     {
07610       temp = "macro srcdir \"..";
07611       temp += fs;
07612       temp += "src";
07613       temp += "\"";
07614       parse_requirements_line (temp, &current_use);
07615       temp = "macro src \"..";
07616       temp += fs;
07617       temp += "src";
07618       temp += fs;
07619       temp += "\"";
07620       parse_requirements_line (temp, &current_use);
07621       temp = "macro inc \"..";
07622       temp += fs;
07623       temp += "src";
07624       temp += fs;
07625       temp += "\"";
07626       parse_requirements_line (temp, &current_use);
07627       temp = "macro doc \"..";
07628       temp += fs;
07629       temp += "doc";
07630       temp += fs;
07631       temp += "\"";
07632       parse_requirements_line (temp, &current_use);
07633 
07634       if (!Symbol::is_selected ("bin"))
07635         {
07636           temp  = "macro bin \"..";
07637           temp += fs;
07638           temp += "$(";
07639           temp += package_tag;
07640           temp += ")";
07641           temp += fs;
07642           temp += "\"";
07643           parse_requirements_line (temp, &current_use);
07644         }
07645 
07646       if (!Symbol::is_selected ("javabin"))
07647         {
07648           temp  = "macro javabin \"..";
07649           temp += fs;
07650           temp += "classes";
07651           temp += fs;
07652           temp += "\"";
07653           parse_requirements_line (temp, &current_use);
07654         }
07655 
07656       if (m_current_style == cmt_style)
07657         {
07658           temp  = "macro mgrdir \"cmt\"";
07659           parse_requirements_line (temp, &current_use);
07660         }
07661       else
07662         {
07663           temp  = "macro mgrdir \"mgr\"";
07664           parse_requirements_line (temp, &current_use);
07665         }
07666 
07667       if (m_current_style == cmt_style)
07668         {
07669           parse_requirements_line (temp, &current_use);
07670           temp  = "macro mgr \"..";
07671           temp += fs;
07672           temp += "cmt";
07673           temp += fs;
07674           temp += "\"";
07675           parse_requirements_line (temp, &current_use);
07676         }
07677 
07678       temp  = "macro version \"";
07679       temp += m_current_version;
07680       temp += "\"";
07681       parse_requirements_line (temp, &current_use);
07682 
07683       temp  = "macro package \"";
07684       temp += m_current_package;
07685       temp += "\"";
07686       parse_requirements_line (temp, &current_use);
07687     }
07688 
07693   if (Uses.size () > 0)
07694     {
07695       for (number = 0; number < Uses.size (); number++)
07696         {
07697           Use* use = Uses[number];
07698 
07699           if (use->package == "CMT") continue;
07700           if (use->package == "methods") continue;
07701           if (use->discarded) continue;
07702 
07703           package_tag = use->package + "_tag";
07704 
07705           if (!Symbol::is_selected (package_tag))
07706             {
07707               temp  = "macro ";
07708               temp += package_tag;
07709               temp += " \"$(tag)\"";
07710               parse_requirements_line (temp, &current_use);
07711             }
07712 
07713           PACKAGE_ROOT = use->prefix;
07714           PACKAGE_ROOT += "ROOT";
07715 
07716           if (!Symbol::is_selected (PACKAGE_ROOT))
07717             {
07718               if (use->located ())
07719                 {
07720                   temp  = "macro ";
07721                   temp += PACKAGE_ROOT;
07722                   temp += " \"";
07723                   temp += use->real_path;
07724                   temp += fs;
07725                   temp += use->package;
07726                   temp += fs;
07727                   temp += use->version;
07728                   temp += "\"";
07729                   parse_requirements_line (temp, &current_use);
07730                 }
07731             }
07732 
07733           package_root = use->package;
07734           package_root += "_root";
07735 
07736           if (!Symbol::is_selected (package_root))
07737             {
07738               if (use->located ())
07739                 {
07740                   temp  = "macro ";
07741                   temp += package_root;
07742                   temp += " \"";
07743                   temp += get_best_form (vb, use->real_path);
07744                   temp += fs;
07745                   temp += use->package;
07746                   temp += fs;
07747                   temp += use->version;
07748                   temp += "\"";
07749                   parse_requirements_line (temp, &current_use);
07750                 }
07751             }
07752 
07753           package_version = use->prefix;
07754           package_version += "VERSION";
07755 
07756           if (!Symbol::is_selected (package_version))
07757             {
07758               temp  = "macro ";
07759               temp += package_version;
07760               temp += " \"";
07761               temp += use->version;
07762               temp += "\"";
07763               parse_requirements_line (temp, &current_use);
07764             }
07765         }
07766 
07767       if (!Symbol::is_selected ("use_requirements"))
07768         {
07769           temp  = "macro use_requirements \"";
07770           temp += "requirements ";
07771 
07772           for (number = 0; number < Uses.size (); number++)
07773             {
07774               Use* use = Uses[number];
07775 
07776               if (use->discarded) continue;
07777 
07778               if (use->located ())
07779                 {
07780                   temp += "$(";
07781                   temp += use->prefix;
07782                   switch (use->style)
07783                     {
07784                     case cmt_style:
07785                       temp += "ROOT)";
07786                       temp += fs;
07787                       temp += "cmt";
07788                       temp += fs;
07789                       temp += "requirements ";
07790                       break;
07791                     case mgr_style:
07792                       temp += "ROOT)";
07793                       temp += fs;
07794                       temp += "mgr";
07795                       temp += fs;
07796                       temp += "requirements ";
07797                       break;
07798                     }
07799                 }
07800             }
07801 
07802           temp += "\"";
07803 
07804           parse_requirements_line (temp, &current_use);
07805         }
07806 
07807       //
07808       // Filtered through auto_imports :
07809       //
07810       //    use_includes    -> <constituent>_use_includes
07811       //    use_fincludes   -> <constituent>_use_fincludes
07812       //    use_cflags      -> <constituent>_use_cflags
07813       //    use_pp_cflags   -> <constituent>_use_pp_cflags
07814       //    use_cppflags    -> <constituent>_use_cpp_flags
07815       //    use_pp_cppflags -> <constituent>_use_pp_cflags
07816       //    use_fflags      -> <constituent>_use_fflags
07817       //    use_pp_fflags   -> <constituent>_use_pp_fflags
07818       //    use_linkopts    -> <constituent>_use_linkopts
07819       //
07820 
07821       if (!Symbol::is_selected ("use_includes"))
07822         {
07823           temp  = "macro_append use_includes \' ";
07824 
07825           for (number = 0; number < Uses.size (); number++)
07826             {
07827               Use* use = Uses[number];
07828 
07829               if (use->package == "CMT") continue;
07830               if (use->package == "methods") continue;
07831 
07832               if (m_debug)
07833                 {
07834                   cout << "fill use_includes for " << use->package 
07835                        << " discarded=" << use->discarded
07836                        << " auto_imports=" << use->auto_imports << endl;
07837                 }
07838 
07839               if (use->discarded) continue;
07840               if (use->auto_imports == Off) continue;
07841 
07842               use->fill_includes_macro (temp);
07843             }
07844 
07845           temp += "\'";
07846 
07847           parse_requirements_line (temp, &current_use);
07848         }
07849 
07850       if (!Symbol::is_selected ("use_fincludes"))
07851         {
07852           temp = "macro_append use_fincludes \" $(use_includes)\"";
07853           parse_requirements_line (temp, &current_use);
07854         }
07855 
07856       if (!Symbol::is_selected ("use_stamps"))
07857         {
07858           temp  = "macro use_stamps \"";
07859           (Use::current()).fill_macro (temp, "stamps");
07860 
07861           for (number = 0; number < Uses.size (); number++)
07862             {
07863               Use* use = Uses[number];
07864 
07865               if (use->package == "CMT") continue;
07866               if (use->package == "methods") continue;
07867               if (use->discarded) continue;
07868 
07869               use->fill_macro (temp, "stamps");
07870             }
07871 
07872           temp += "\"";
07873 
07874           parse_requirements_line (temp, &current_use);
07875         }
07876 
07877       if (!Symbol::is_selected ("use_cflags"))
07878         {
07879           Use::fill_macro_all (temp, "cflags");
07880           parse_requirements_line (temp, &current_use);
07881         }
07882 
07883       if (!Symbol::is_selected ("use_pp_cflags"))
07884         {
07885           Use::fill_macro_all (temp, "pp_cflags");
07886           parse_requirements_line (temp, &current_use);
07887         }
07888 
07889       if (!Symbol::is_selected ("use_cppflags"))
07890         {
07891           Use::fill_macro_all (temp, "cppflags");
07892           parse_requirements_line (temp, &current_use);
07893         }
07894 
07895       if (!Symbol::is_selected ("use_pp_cppflags"))
07896         {
07897           Use::fill_macro_all (temp, "pp_cppflags");
07898           parse_requirements_line (temp, &current_use);
07899         }
07900 
07901       if (!Symbol::is_selected ("use_fflags"))
07902         {
07903           Use::fill_macro_all (temp, "fflags");
07904           parse_requirements_line (temp, &current_use);
07905         }
07906 
07907       if (!Symbol::is_selected ("use_pp_fflags"))
07908         {
07909           Use::fill_macro_all (temp, "pp_fflags");
07910           parse_requirements_line (temp, &current_use);
07911         }
07912 
07913       if (!Symbol::is_selected ("use_linkopts"))
07914         {
07915           Use::fill_macro_all (temp, "linkopts");
07916           parse_requirements_line (temp, &current_use);
07917         }
07918 
07919       if (!Symbol::is_selected ("use_libraries"))
07920         {
07921           temp  = "macro use_libraries \"";
07922 
07923           for (number = 0; number < Uses.size (); number++)
07924             {
07925               Use* use = Uses[number];
07926 
07927               if (use->package == "CMT") continue;
07928               if (use->package == "methods") continue;
07929               if (use->discarded) continue;
07930 
07931               use->fill_macro (temp, "libraries");
07932             }
07933 
07934           temp += "\"";
07935 
07936           parse_requirements_line (temp, &current_use);
07937         }
07938 
07939       if (!Symbol::is_selected ("includes"))
07940         {
07941           temp = "macro_append includes \' ";
07942 
07943           Use& use = Use::current();
07944 
07945           if (use.include_path == "")
07946             {
07947               temp += "$(ppcmd)\"$(srcdir)\" ";
07948             }
07949           else if (use.include_path != "none")
07950             {
07951               temp += "$(ppcmd)\"";
07952               temp += use.include_path;
07953               temp += "\" ";
07954             }
07955 
07956           for (include_number = 0;
07957                include_number < use.includes.size ();
07958                include_number++)
07959             {
07960               Include& incl = use.includes[include_number];
07961 
07962               temp += "$(ppcmd)\"";
07963               temp += incl.name;
07964               temp += "\" ";
07965             }
07966 
07967           temp += "$(use_includes)\'";
07968 
07969           parse_requirements_line (temp, &current_use);
07970         }
07971 
07972       if (!Symbol::is_selected ("fincludes"))
07973         {
07974           temp = "macro_append fincludes \" $(includes)\"";
07975           parse_requirements_line (temp, &current_use);
07976         }
07977 
07978     }
07979 
07985 
07986   Constituent::parse_all ();
07987 
07988   const Constituent::ConstituentVector& constituents =
07989     Constituent::constituents ();
07990   
07991   for (number = 0; number < constituents.size (); number++)
07992     {
07993       const Constituent& constituent = constituents[number];
07994 
07995       Use::UsePtrVector imports;
07996       int i;
07997 
07998       for (i = 0; i < constituent.imports.size (); i++)
07999         {
08000           const cmt_string& import = constituent.imports[i];
08001 
08002           if (constituent.type == Document) continue;
08003 
08004           //
08005           // Resolve the imported uses
08006           //
08007 
08008           Use* u = Use::find (import, "", "");
08009 
08010           if (u != 0)
08011             {
08012               if (u->package == "CMT") continue;
08013               if (u->package == "methods") continue;
08014               if (u->discarded) continue;
08015               if (u->auto_imports != Off) continue;
08016 
08017               imports.push_back (u);
08018             }
08019         }
08020 
08021       if (imports.size () > 0)
08022         {
08023           cmt_string prefix;
08024 
08025           //
08026           // Documents are not considered 
08027           //
08028           switch (constituent.type)
08029             {
08030             case Application:
08031               prefix = "app_";
08032               break;
08033             case Library:
08034               prefix = "lib_";
08035               break;
08036             }
08037 
08038           temp = "macro_append ";
08039           temp += prefix;
08040           temp += constituent.name;
08041           temp += "_cflags ";
08042           temp += " \' ";
08043           for (i = 0; i < imports.size (); i++)
08044             {
08045               Use* u = imports[i];
08046 
08047               u->fill_includes_macro (temp);
08048               u->fill_macro (temp, "cflags");
08049             }
08050           temp += "\'";
08051           parse_requirements_line (temp, &current_use);
08052 
08053           temp = "macro_append ";
08054           temp += prefix;
08055           temp += constituent.name;
08056           temp += "_pp_cflags ";
08057           temp += " \" ";
08058           for (i = 0; i < imports.size (); i++)
08059             {
08060               Use* u = imports[i];
08061 
08062               u->fill_macro (temp, "pp_cflags");
08063             }
08064           temp += "\"";
08065           parse_requirements_line (temp, &current_use);
08066 
08067           temp = "macro_append ";
08068           temp += prefix;
08069           temp += constituent.name;
08070           temp += "_cppflags ";
08071           temp += " \' ";
08072           for (i = 0; i < imports.size (); i++)
08073             {
08074               Use* u = imports[i];
08075 
08076               u->fill_includes_macro (temp);
08077               u->fill_macro (temp, "cppflags");
08078             }
08079           temp += "\'";
08080           parse_requirements_line (temp, &current_use);
08081 
08082           temp = "macro_append ";
08083           temp += prefix;
08084           temp += constituent.name;
08085           temp += "_pp_cppflags ";
08086           temp += " \" ";
08087           for (i = 0; i < imports.size (); i++)
08088             {
08089               Use* u = imports[i];
08090 
08091               u->fill_macro (temp, "pp_cppflags");
08092             }
08093           temp += "\"";
08094           parse_requirements_line (temp, &current_use);
08095 
08096           temp = "macro_append ";
08097           temp += prefix;
08098           temp += constituent.name;
08099           temp += "_fflags ";
08100           temp += " \' ";
08101           for (i = 0; i < imports.size (); i++)
08102             {
08103               Use* u = imports[i];
08104 
08105               u->fill_includes_macro (temp);
08106               u->fill_macro (temp, "fflags");
08107             }
08108           temp += "\'";
08109           parse_requirements_line (temp, &current_use);
08110 
08111           temp = "macro_append ";
08112           temp += prefix;
08113           temp += constituent.name;
08114           temp += "_pp_fflags ";
08115           temp += " \" ";
08116           for (i = 0; i < imports.size (); i++)
08117             {
08118               Use* u = imports[i];
08119 
08120               u->fill_macro (temp, "pp_fflags");
08121             }
08122           temp += "\"";
08123           parse_requirements_line (temp, &current_use);
08124 
08125           temp = "macro_append ";
08126           temp += constituent.name;
08127           temp += "linkopts ";
08128           temp += " \" ";
08129           for (i = 0; i < imports.size (); i++)
08130             {
08131               Use* u = imports[i];
08132 
08133               u->fill_macro (temp, "linkopts");
08134             }
08135           temp += "\"";
08136           parse_requirements_line (temp, &current_use);
08137 
08138         }
08139     }
08140       
08141   if (!Symbol::is_selected ("constituents"))
08142     {
08143       temp = "macro_append constituents \" ";
08144       
08145       for (number = 0; number < constituents.size (); number++)
08146         {
08147           const Constituent& constituent = constituents[number];
08148 
08149           if (constituent.group == 0)
08150             {
08151               temp += constituent.name;
08152               temp += " ";
08153             }
08154         }
08155       
08156       temp += "\"";
08157       
08158       parse_requirements_line (temp, &current_use);
08159     }
08160 
08161   parse_requirements_line ("macro_append all_constituents \" $(constituents)\"", 
08162                            &current_use);
08163 
08164   if (!Symbol::is_selected ("constituentsclean"))
08165     {
08166       temp = "macro_append constituentsclean \" ";
08167       
08168       for (number = constituents.size () - 1; number >= 0 ; number--)
08169         {
08170           const Constituent& constituent = constituents[number];
08171 
08172           if (constituent.group == 0)
08173             {
08174               temp += constituent.name;
08175               temp += "clean ";
08176             }
08177         }
08178       
08179       temp += "\"";
08180       
08181       parse_requirements_line (temp, &current_use);
08182     }
08183 
08184   parse_requirements_line ("macro_append all_constituentsclean \" $(constituentsclean)\"", 
08185                            &current_use);
08186 
08187   const Group::GroupVector& groups = Group::groups ();
08188   
08189   for (number = 0; number < groups.size (); number++)
08190     {
08191       const Group& group = groups[number];
08192 
08193       temp = "macro_append ";
08194       temp += group.name ();
08195       temp += "_constituents \" ";
08196 
08197       int i;
08198 
08199       for (i = 0; i < constituents.size (); i++)
08200         {
08201           const Constituent& constituent = constituents[i];
08202 
08203           if ((constituent.group != 0) && 
08204               (group.name () == constituent.group->name ()))
08205             {
08206               temp += constituent.name;
08207               temp += " ";
08208             }
08209         }
08210       
08211       temp += "\"";
08212       
08213       parse_requirements_line (temp, &current_use);
08214 
08215       temp = "macro_append ";
08216       temp += group.name ();
08217       temp += "_constituentsclean \" ";
08218       
08219       for (i = constituents.size () - 1; i >= 0 ; i--)
08220         {
08221           const Constituent& constituent = constituents[i];
08222 
08223           if ((constituent.group != 0) && 
08224               (group.name () == constituent.group->name ()))
08225             {
08226               temp += constituent.name;
08227               temp += "clean ";
08228             }
08229         }
08230       
08231       temp += "\"";
08232       
08233       parse_requirements_line (temp, &current_use);
08234     }
08235 }

void Cmt::use_cmt ( ) [static]
 

Macros implied or required to manage constituents.

Definition at line 8238 of file cmt_parser.cxx.

Referenced by load(), and parser().

08239 {
08240   UseRef use;
08241   bool recursive_copy = m_recursive;
08242   bool debug_copy = m_debug;
08243 
08244   if (m_default_path.size () <= 0) return;
08245   if (m_current_package == "CMT") return;
08246 
08247   m_recursive = true;
08248   m_debug = false;
08249   use = Use::add (m_default_path, "CMT", m_cmt_version, "", "", 0);
08250   m_recursive = recursive_copy;
08251   m_debug = debug_copy;
08252 }

void Cmt::use_home_requirements ( ) [static]
 

Definition at line 8255 of file cmt_parser.cxx.

Referenced by parser().

08256 {
08257   cmt_string f = m_cmt_home;
08258 
08259   if (f == "") 
08260     {
08261         //if (!m_quiet) cerr << "No CMTHOME" << endl;
08262       return;
08263     }
08264 
08265     //if (!m_quiet) cerr << "Using CMTHOME in " << f << endl;
08266 
08267   UseRef use;
08268   bool recursive_copy = m_recursive;
08269 
08270   if (m_default_path.size () <= 0) return;
08271   if (m_current_package == "CMT") return;
08272 
08273   m_recursive = true;
08274 
08275   cmt_string name = CmtSystem::get_home_package ();
08276 
08277   use = Use::add (f, name, "", "", "", 0);
08278 
08279   f += CmtSystem::file_separator ();
08280   f += "requirements";
08281   parse_requirements (f, use);
08282 
08283   m_recursive = recursive_copy;
08284 }

void Cmt::use_user_context_requirements ( ) [static]
 

Definition at line 8287 of file cmt_parser.cxx.

Referenced by parser().

08288 {
08289   cmt_string f = m_cmt_user_context;
08290 
08291   if (f == "") 
08292     {
08293         //if (!m_quiet) cerr << "No CMTUSERCONTEXT" << endl;
08294       return;
08295     }
08296 
08297     //if (!m_quiet) cerr << "Using CMTUSERCONTEXT in " << f << endl;
08298 
08299   UseRef use;
08300   bool recursive_copy = m_recursive;
08301 
08302   if (m_default_path.size () <= 0) return;
08303   if (m_current_package == "CMT") return;
08304 
08305   m_recursive = true;
08306 
08307   cmt_string name = CmtSystem::get_user_context_package ();
08308 
08309   use = Use::add (f, name, "", "", "", 0);
08310 
08311   f += CmtSystem::file_separator ();
08312   f += "requirements";
08313   parse_requirements (f, use);
08314 
08315   m_recursive = recursive_copy;
08316 }

void Cmt::vector_to_string ( const CmtSystem::cmt_string_vector & v,
const cmt_string & separator,
cmt_string & result ) [static]
 

Definition at line 8319 of file cmt_parser.cxx.

08322 {
08323   result.erase (0);
08324 
08325   for (int i = 0; i < v.size (); i++)
08326     {
08327       if (i > 0) result += separator;
08328       result += v[i];
08329     }
08330 }

cmt_string Cmt::vector_to_string ( const CmtSystem::cmt_string_vector & v ) [static]
 

Definition at line 8333 of file cmt_parser.cxx.

Referenced by PathBuilder::build(), and PathBuilder::clean().

08334 {
08335   cmt_string result;
08336 
08337   vector_to_string (v, " ", result);
08338 
08339   return (result);
08340 }


Member Data Documentation

ActionType Cmt::m_action [static, private]
 

All Attributes are private.

Definition at line 29 of file cmt_parser.cxx.

bool Cmt::m_build_nmake [static, private]
 

Definition at line 30 of file cmt_parser.cxx.

cmt_string Cmt::m_cmt_config [static, private]
 

Definition at line 31 of file cmt_parser.cxx.

cmt_string Cmt::m_cmt_home [static, private]
 

Definition at line 36 of file cmt_parser.cxx.

CmtSystem::cmt_string_vector Cmt::m_cmt_path [static, private]
 

Definition at line 32 of file cmt_parser.cxx.

CmtSystem::cmt_string_vector Cmt::m_cmt_path_pwds [static, private]
 

Definition at line 33 of file cmt_parser.cxx.

CmtSystem::cmt_string_vector Cmt::m_cmt_path_sources [static, private]
 

Definition at line 34 of file cmt_parser.cxx.

cmt_string Cmt::m_cmt_root [static, private]
 

Definition at line 35 of file cmt_parser.cxx.

cmt_string Cmt::m_cmt_site [static, private]
 

Definition at line 38 of file cmt_parser.cxx.

cmt_string Cmt::m_cmt_user_context [static, private]
 

Definition at line 37 of file cmt_parser.cxx.

cmt_string Cmt::m_cmt_version [static, private]
 

Definition at line 39 of file cmt_parser.cxx.

cmt_string Cmt::m_configure_error [static, private]
 

Definition at line 58 of file cmt_parser.cxx.

AccessMode Cmt::m_current_access = UserMode [static, private]
 

Definition at line 48 of file cmt_parser.cxx.

int Cmt::m_current_build_strategy = DefaultBuildStrategy [static, private]
 

Definition at line 40 of file cmt_parser.cxx.

cmt_string Cmt::m_current_config [static, private]
 

Definition at line 44 of file cmt_parser.cxx.

cmt_string Cmt::m_current_dir [static, private]
 

Definition at line 42 of file cmt_parser.cxx.

cmt_string Cmt::m_current_package [static, private]
 

Definition at line 43 of file cmt_parser.cxx.

cmt_string Cmt::m_current_path [static, private]
 

Definition at line 45 of file cmt_parser.cxx.

cmt_string Cmt::m_current_prefix [static, private]
 

Definition at line 46 of file cmt_parser.cxx.

VersionStrategy Cmt::m_current_strategy = BestFit [static, private]
 

Definition at line 49 of file cmt_parser.cxx.

CmtDirStyle Cmt::m_current_style = cmt_style [static, private]
 

Definition at line 50 of file cmt_parser.cxx.

cmt_string Cmt::m_current_tag [static, private]
 

Definition at line 52 of file cmt_parser.cxx.

cmt_string Cmt::m_current_target [static, private]
 

Definition at line 53 of file cmt_parser.cxx.

cmt_string Cmt::m_current_version [static, private]
 

Definition at line 54 of file cmt_parser.cxx.

bool Cmt::m_debug [static, private]
 

Definition at line 60 of file cmt_parser.cxx.

cmt_string Cmt::m_default_path [static, private]
 

Definition at line 62 of file cmt_parser.cxx.

cmt_string Cmt::m_extra_tags [static, private]
 

Definition at line 56 of file cmt_parser.cxx.

cmt_string Cmt::m_filtered_text [static, private]
 

Definition at line 63 of file cmt_parser.cxx.

bool Cmt::m_quiet [static, private]
 

Definition at line 64 of file cmt_parser.cxx.

bool Cmt::m_recursive [static, private]
 

Definition at line 65 of file cmt_parser.cxx.

ScopeType Cmt::m_scope [static, private]
 

Definition at line 66 of file cmt_parser.cxx.

bool Cmt::m_simulation [static, private]
 

Definition at line 67 of file cmt_parser.cxx.

bool Cmt::m_standard_macros_done [static, private]
 

Definition at line 68 of file cmt_parser.cxx.


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