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_all_tags ()
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 << "         all_tags          :  all defined tags" << endl;
02359   cout << "         applied_patterns  :  all patterns actually applied" << endl;
02360   cout << "         author            :  package author" << endl;
02361   cout << "         branches          :  added branches" << endl;
02362   cout << "         clients           :  package clients" << endl;
02363   cout << "         constituent_names :  constituent names" << endl;
02364   cout << "         constituents      :  constituent definitions" << endl;
02365   cout << "         uses              :  the use tree" << endl;
02366   cout << "         fragment <name>   :  one fragment definition" << endl;
02367   cout << "         fragments         :  fragment definitions" << endl;
02368   cout << "         groups            :  group definitions" << endl;
02369   cout << "         languages         :  language definitions" << endl;
02370   cout << "         macro <name>      :  a formatted macro definition" << endl;
02371   cout << "         macro_value <name>  :  a raw macro definition" << endl;
02372   cout << "         macros            :  all macro definitions" << endl;
02373   cout << "         manager           :  package manager" << endl;
02374   cout << "         packages          :  packages reachable from the current context" << endl;
02375   cout << "         path              :  the package search list" << endl;
02376   cout << "         pattern <name>    :  the pattern definition and usages" << endl;
02377   cout << "         pattern_names     :  pattern names" << endl;
02378   cout << "         patterns          :  the pattern definitions" << endl;
02379   cout << "         pwd               :  filtered current directory" << endl;
02380   cout << "         set_value <name>  :  a raw set definition" << endl;
02381   cout << "         set <name>        :  a formatted set definition" << endl;
02382   cout << "         sets              :  set definitions" << endl;
02383   cout << "         strategies        :  all strategies (build & version)" << endl;
02384   cout << "         tags              :  all currently active tags" << endl;
02385   cout << "         uses              :  used packages" << endl;
02386   cout << "         version           :  version of the current package" << endl;
02387   cout << "         versions <name>   :  visible versions of the selected package" << endl;
02388   cout << "" << endl;
02389   cout << "   system                  : display the system tag" << endl;
02390   cout << "   unlock [<p> <v> [<path>]] : unlock a package" << endl;
02391   cout << "   version                 : version of CMT" << endl;
02392   cout << "" << endl;
02393   cout << "   cvstags <module>         : display the CVS tags for a module" << endl;
02394   cout << "   cvsbranches <module>     : display the subdirectories for a module" << endl;
02395   cout << "   cvssubpackagess <module> : display the subpackages for a module" << endl;
02396 
02397   cout << " global options :" << endl;
02398 
02399   cout << "   -quiet                  : don't print errors" << endl;
02400   cout << "   -use=<p>:<v>:<path>     : set package version path" << endl;
02401   cout << "   -pack=<package>         : set package" << endl;
02402   cout << "   -version=<version>      : set version" << endl;
02403   cout << "   -path=<path>            : set root path" << endl;
02404   cout << "   -f=<requirement-file>   : set input file" << endl;
02405   cout << "   -e=<statement>          : add a one line statement" << endl;
02406   cout << "   -tag=<tag-list>         : select a new tag-set" << endl;
02407   cout << "   -tag_add=<tag-list>     : add specific comma-separated tag(s)" << endl;
02408   cout << "   -tag_remove=<tag-list>  : remove specific comma-separated tag(s)" << endl;
02409 }

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

Definition at line 2412 of file cmt_parser.cxx.

Referenced by parser().

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

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

Definition at line 2426 of file cmt_parser.cxx.

Referenced by parser().

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

void Cmt::do_remove_library_links ( ) [static]
 

Definition at line 2496 of file cmt_parser.cxx.

Referenced by parser().

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

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 2621 of file cmt_parser.cxx.

Referenced by parser().

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

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

Definition at line 2627 of file cmt_parser.cxx.

Referenced by parser().

02628 {
02629   print (mode);
02630 }

void Cmt::do_show_all_tags ( ) [static]
 

Definition at line 2633 of file cmt_parser.cxx.

Referenced by parser().

02634 {
02635   Tag::TagPtrVector tags = Tag::tags ();
02636   int index;
02637 
02638   set_standard_macros ();
02639 
02640   for (index = 0; index < tags.size (); index++)
02641     {
02642       const Tag* tag = tags[index];
02643       if (tag != 0)
02644         {
02645           tag->show_definition (true);
02646         }
02647     }
02648 }

void Cmt::do_show_applied_patterns ( ) [static]
 

Definition at line 2651 of file cmt_parser.cxx.

Referenced by parser().

02652 {
02653   Pattern::show_all_applied_patterns ();
02654 }

void Cmt::do_show_author ( ) [static]
 

Definition at line 2657 of file cmt_parser.cxx.

Referenced by parser().

02658 {
02659   Use& use = Use::current();
02660 
02661   cout << use.author << endl;
02662 }

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

Definition at line 2665 of file cmt_parser.cxx.

Referenced by parser().

02666 {
02667   Branch::print_all (mode);
02668 }

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

Definition at line 2671 of file cmt_parser.cxx.

Referenced by parser().

02672 {
02673   cmt_string package;
02674   cmt_string version;
02675   cmt_string path_name;
02676 
02677   if (arguments.size () >= 1) package = arguments[0];
02678   if (arguments.size () >= 2) version = arguments[1];
02679   if (arguments.size () >= 3) path_name = arguments[2];
02680 
02681   FileScanner scanner;
02682   PackageCollector collector (package, version);
02683 
02684   clear ();
02685   configure ();
02686 
02687   cout << "# ----------- Clients of " << package <<
02688     " " << version <<
02689     " " << path_name <<
02690     endl;
02691 
02692   if (path_name == "")
02693     {
02694       int path_index;
02695 
02696       for (path_index = 0; path_index < m_cmt_path.size (); path_index++)
02697         {
02698           const cmt_string& path = m_cmt_path[path_index];
02699 
02700           scanner.scan_path (path, collector);
02701         }
02702     }
02703   else
02704     {
02705       scanner.scan_path (path_name, collector);
02706     }
02707   cout << "# ----------- " << collector.count () << " clients found." << endl;
02708 }

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

Definition at line 2711 of file cmt_parser.cxx.

Referenced by parser().

02712 {
02713   if (arguments.size () > 0) 
02714     {
02715       set_standard_macros ();
02716       Constituent::show (arguments[0]);
02717     }
02718 }

void Cmt::do_show_constituent_names ( ) [static]
 

Definition at line 2721 of file cmt_parser.cxx.

Referenced by parser().

02722 {
02723   set_standard_macros ();
02724   Constituent::show_names ();
02725 }

void Cmt::do_show_constituents ( ) [static]
 

Definition at line 2728 of file cmt_parser.cxx.

Referenced by parser().

02729 {
02730   set_standard_macros ();
02731   Constituent::show_all ();
02732 }

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

Definition at line 2735 of file cmt_parser.cxx.

Referenced by parser().

02736 {
02737   if (arguments.size () > 0) Fragment::show (arguments[0]);
02738 }

void Cmt::do_show_fragments ( ) [static]
 

Definition at line 2741 of file cmt_parser.cxx.

Referenced by parser().

02742 {
02743   Fragment::show_all ();
02744 }

void Cmt::do_show_groups ( ) [static]
 

Definition at line 2747 of file cmt_parser.cxx.

Referenced by parser().

02748 {
02749   Group::show_all ();
02750 }

void Cmt::do_show_include_dirs ( ) [static]
 

Definition at line 2753 of file cmt_parser.cxx.

Referenced by parser().

02754 {
02755   cmt_string temp;
02756 
02757   Use& use = Use::current();
02758 
02759   set_standard_macros ();
02760 
02761   if (use.include_path == "")
02762     {
02763       temp += "$(src) ";
02764     }
02765   else if (use.include_path != "none")
02766     {
02767       temp += use.include_path;
02768       temp += " ";
02769     }
02770 
02771   for (int include_number = 0;
02772        include_number < use.includes.size ();
02773        include_number++)
02774     {
02775       Include& incl = use.includes[include_number];
02776       
02777       temp += incl.name;
02778       temp += " ";
02779     }
02780 
02781   cout << temp << endl;
02782 }

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

Definition at line 2785 of file cmt_parser.cxx.

Referenced by parser().

02786 {
02787   if (arguments.size () > 0) 
02788     {
02789       set_standard_macros ();
02790       Language::show (arguments[0]);
02791     }
02792 }

void Cmt::do_show_languages ( ) [static]
 

Definition at line 2795 of file cmt_parser.cxx.

Referenced by parser().

02796 {
02797   set_standard_macros ();
02798   Language::show_all ();
02799 }

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

Definition at line 2802 of file cmt_parser.cxx.

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

02804 {
02805   cmt_string target;
02806 
02807   if (arguments.size () > 0) target = arguments[0];
02808 
02809   Symbol* symbol;
02810 
02811   set_standard_macros ();
02812 
02813   symbol = Symbol::find (target);
02814 
02815   if (symbol == 0) 
02816     {
02817       cmt_string t = " ";
02818       t += target;
02819       t += " is not a ";
02820 
02821       if ((m_action == action_show_macro) ||
02822           (m_action == action_show_macro_value))
02823         {
02824           t += "macro";
02825         }
02826       else if ((m_action == action_show_set) ||
02827                (m_action == action_show_set_value))
02828         {
02829           t += "set";
02830         }
02831 
02832       CmtError::set (CmtError::symbol_not_found, t);
02833 
02834       return;
02835     }
02836   else
02837     {
02838       cmt_string t = " ";
02839       t += target;
02840       t += " is not a ";
02841 
02842       if ((m_action == action_show_macro) ||
02843           (m_action == action_show_macro_value))
02844         {
02845           if ((symbol->command != CommandMacro) &&
02846               (symbol->command != CommandMacroAppend) &&
02847               (symbol->command != CommandMacroPrepend) &&
02848               (symbol->command != CommandMacroRemove) &&
02849               (symbol->command != CommandMacroRemoveAll))
02850             {
02851               t += "macro";
02852 
02853               CmtError::set (CmtError::symbol_not_found, t);
02854 
02855               return;
02856             }
02857         }
02858       else if ((m_action == action_show_set) ||
02859                (m_action == action_show_set_value))
02860         {
02861           if ((symbol->command != CommandSet) &&
02862               (symbol->command != CommandSetAppend) &&
02863               (symbol->command != CommandSetPrepend) &&
02864               (symbol->command != CommandSetRemove) &&
02865               (symbol->command != CommandPath) &&
02866               (symbol->command != CommandPathAppend) &&
02867               (symbol->command != CommandPathPrepend) &&
02868               (symbol->command != CommandPathRemove))
02869             {
02870               t += "set";
02871 
02872               CmtError::set (CmtError::symbol_not_found, t);
02873 
02874               return;
02875             }
02876         }
02877     }
02878 
02879   if (symbol->value_lists.size () < 1) return;
02880 
02881   symbol->show_macro (mode);
02882 }

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

Definition at line 2885 of file cmt_parser.cxx.

Referenced by parser().

02887 {
02888   do_show_macro (arguments, mode);
02889 }

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

Definition at line 2892 of file cmt_parser.cxx.

Referenced by parser().

02893 {
02894   print_macros (mode);
02895 }

void Cmt::do_show_manager ( ) [static]
 

Definition at line 2898 of file cmt_parser.cxx.

Referenced by parser().

02899 {
02900   Use& use = Use::current();
02901 
02902   cout << use.manager << endl;
02903 }

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

Definition at line 2906 of file cmt_parser.cxx.

Referenced by parser().

02907 {
02908   cmt_string path_name;
02909 
02910   if (arguments.size () > 0) path_name = arguments[0];
02911 
02912   FileScanner scanner;
02913   PackageViewer viewer;
02914 
02915   if (path_name == "")
02916     {
02917       int path_index;
02918 
02919       for (path_index = 0; path_index < m_cmt_path.size (); path_index++)
02920         {
02921           const cmt_string& path = m_cmt_path[path_index];
02922 
02923           scanner.scan_path (path, viewer);
02924         }
02925     }
02926   else
02927     {
02928       scanner.scan_path (path_name, viewer);
02929     }
02930 }

void Cmt::do_show_path ( ) [static]
 

Definition at line 2933 of file cmt_parser.cxx.

Referenced by parser().

02934 {
02935   int path_index;
02936 
02937   if (!m_quiet)
02938     {
02939       for (path_index = 0; path_index < m_cmt_path.size (); path_index++)
02940         {
02941           const cmt_string& path   = m_cmt_path[path_index];
02942           const cmt_string& source = m_cmt_path_sources[path_index];
02943 
02944           cout << "# Add path " << path << " from " << source << endl;
02945         }
02946 
02947       cout << "#" << endl;
02948     }
02949 
02950   for (path_index = 0; path_index < m_cmt_path.size (); path_index++)
02951     {
02952       const cmt_string& path   = m_cmt_path[path_index];
02953       const cmt_string& source = m_cmt_path_sources[path_index];
02954 
02955       if (path_index > 0) cout << CmtSystem::path_separator ();
02956 
02957       cout << path;
02958     }
02959 
02960   cout << endl;
02961 }

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

Definition at line 2964 of file cmt_parser.cxx.

Referenced by parser().

02965 {
02966   cmt_string name;
02967   if (arguments.size () > 0) name = arguments[0];
02968   Pattern::show (name);
02969 }

void Cmt::do_show_pattern_names ( ) [static]
 

Definition at line 2972 of file cmt_parser.cxx.

Referenced by parser().

02973 {
02974   Pattern::show_all_names ();
02975 }

void Cmt::do_show_patterns ( ) [static]
 

Definition at line 2978 of file cmt_parser.cxx.

Referenced by parser().

02979 {
02980   Pattern::show_all ();
02981 }

void Cmt::do_show_pwd ( ) [static]
 

Definition at line 2984 of file cmt_parser.cxx.

Referenced by parser().

02985 {
02986   cout << m_current_dir << endl;
02987 }

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

Definition at line 2990 of file cmt_parser.cxx.

Referenced by parser().

02992 {
02993   do_show_macro (arguments, mode);
02994 }

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

Definition at line 2997 of file cmt_parser.cxx.

Referenced by parser().

02999 {
03000   do_show_macro (arguments, mode);
03001 }

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

Definition at line 3004 of file cmt_parser.cxx.

Referenced by parser().

03005 {
03006   print_macros (mode);
03007 }

void Cmt::do_show_strategies ( ) [static]
 

Definition at line 3010 of file cmt_parser.cxx.

Referenced by parser().

03011 {
03012   cout << "Version strategy : ";
03013 
03014   switch (m_current_strategy)
03015     {
03016     case BestFit :
03017       cout << "BestFit";
03018       break;
03019     case BestFitNoCheck :
03020       cout << "BestFitNoCheck";
03021       break;
03022     case FirstChoice :
03023       cout << "FirstChoice";
03024       break;
03025     case LastChoice :
03026       cout << "LastChoice";
03027       break;
03028     case KeepAll :
03029       cout << "KeepAll";
03030       break;
03031     default :
03032       cout << "BestFit";
03033       break;
03034     }
03035   
03036   cout << endl;
03037   
03038   cout << "Build strategy   : ";
03039   
03040   if ((m_current_build_strategy & PrototypesMask) == Prototypes)
03041     {
03042       cout << "prototypes";
03043     }
03044   else
03045     {
03046       cout << "no_prototypes";
03047     }
03048   
03049   if ((m_current_build_strategy & KeepMakefilesMask) == KeepMakefiles)
03050     {
03051       cout << " keep_makefiles";
03052     }
03053   else
03054     {
03055       cout << " rebuild_makefiles";
03056     }
03057   
03058   cout << endl;
03059 }

void Cmt::do_show_system ( ) [static]
 

Definition at line 3140 of file cmt_parser.cxx.

Referenced by parser().

03141 {
03142   cout << CmtSystem::get_cmt_config () << endl;
03143 }

void Cmt::do_show_tags ( ) [static]
 

Definition at line 3062 of file cmt_parser.cxx.

Referenced by parser().

03063 {
03064   Tag::TagPtrVector tags = Tag::tags ();
03065   int index;
03066 
03067   set_standard_macros ();
03068 
03069   for (index = 0; index < tags.size (); index++)
03070     {
03071       const Tag* tag = tags[index];
03072       if (tag != 0)
03073         {
03074           tag->show (m_quiet);
03075         }
03076     }
03077 }

void Cmt::do_show_uses ( ) [static]
 

Definition at line 3080 of file cmt_parser.cxx.

Referenced by parser().

03081 {
03082   Use::show_all ();
03083 
03084 /*
03085   {
03086     Use::UsePtrVector& Uses = Use::uses ();
03087 
03088     Use& cu = Use::current ();
03089 
03090     for (int i = 0; i < Uses.size (); i++)
03091       {
03092         Use* use = Uses[i];
03093         
03094         if (use == 0) continue;
03095         if (use->discarded) continue;
03096         
03097         Use::UsePtrVector list;
03098         
03099         cu.get_paths (use, list);
03100 
03101         cout << " to " << use->package << endl;
03102 
03103         for (int j = list.size (); j >= 0; j--)
03104           {
03105             Use* u = list[j];
03106             if (u == 0) continue;
03107             cout << "  " << u->package << endl;
03108           }
03109       }
03110   }
03111 */
03112 }

void Cmt::do_show_version ( ) [static]
 

Definition at line 3115 of file cmt_parser.cxx.

Referenced by parser().

03116 {
03117   cout << m_current_version << endl;
03118 }

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

Definition at line 3121 of file cmt_parser.cxx.

Referenced by parser().

03122 {
03123   cmt_string package_name;
03124 
03125   if (arguments.size () > 0) package_name = arguments[0];
03126 
03127   FileScanner scanner;
03128 
03129   int path_index;
03130 
03131   for (path_index = 0; path_index < m_cmt_path.size (); path_index++)
03132     {
03133       const cmt_string& path   = m_cmt_path[path_index];
03134 
03135       scanner.scan_package (path, package_name);
03136     }
03137 }

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

Definition at line 3146 of file cmt_parser.cxx.

Referenced by parser().

03149 {
03150   Use& use = Use::current();
03151 
03152   cout << "try to unlock package " << package << " in " << CmtSystem::pwd () << endl;
03153 
03154   set_standard_macros ();
03155 
03156   CmtLock::status status = CmtLock::unlock ();
03157 }

void Cmt::do_version ( ) [static]
 

Definition at line 3160 of file cmt_parser.cxx.

Referenced by parser().

03161 {
03162   cout << CMTVERSION << endl;
03163 }

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

Definition at line 3239 of file cmt_parser.cxx.

Referenced by Include::print_filters().

03240 {
03241   static cmt_string newdir;
03242 
03243   CmtSystem::compress_path (dir, newdir);
03244 
03245   return (newdir);
03246 }

ActionType Cmt::get_action ( ) [static]
 

Definition at line 3168 of file cmt_parser.cxx.

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

03169 {
03170   return (m_action);
03171 }

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

Definition at line 3178 of file cmt_parser.cxx.

Referenced by Use::show_all().

03179 {
03180   return (m_cmt_home);
03181 }

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

Definition at line 3173 of file cmt_parser.cxx.

Referenced by Use::move_to().

03174 {
03175   return (m_cmt_path);
03176 }

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

Definition at line 3183 of file cmt_parser.cxx.

Referenced by Use::show_all().

03184 {
03185   return (m_cmt_user_context);
03186 }

AccessMode Cmt::get_current_access ( ) [static]
 

Definition at line 3198 of file cmt_parser.cxx.

Referenced by Symbol::action().

03199 {
03200   return (m_current_access);
03201 }

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

Definition at line 3188 of file cmt_parser.cxx.

03189 {
03190   return (m_current_dir);
03191 }

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

Definition at line 3193 of file cmt_parser.cxx.

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

03194 {
03195   return (m_current_package);
03196 }

VersionStrategy Cmt::get_current_strategy ( ) [static]
 

Definition at line 3203 of file cmt_parser.cxx.

Referenced by VersionSelector::instance().

03204 {
03205   return (m_current_strategy);
03206 }

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

Definition at line 3213 of file cmt_parser.cxx.

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

03214 {
03215   return (m_current_target);
03216 }

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

Definition at line 3208 of file cmt_parser.cxx.

Referenced by Generator::build_readme().

03209 {
03210   return (m_current_version);
03211 }

bool Cmt::get_debug ( ) [static]
 

Definition at line 3218 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().

03219 {
03220   return (m_debug);
03221 }

bool Cmt::get_quiet ( ) [static]
 

Definition at line 3223 of file cmt_parser.cxx.

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

03224 {
03225   return (m_quiet);
03226 }

bool Cmt::get_recursive ( ) [static]
 

Definition at line 3228 of file cmt_parser.cxx.

Referenced by Use::add().

03229 {
03230   return (m_recursive);
03231 }

ScopeType Cmt::get_scope ( ) [static]
 

Definition at line 3233 of file cmt_parser.cxx.

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

03234 {
03235   return (m_scope);
03236 }

void Cmt::install_cleanup_scripts ( ) [static]
 

Definition at line 3249 of file cmt_parser.cxx.

Referenced by do_config().

03250 {
03251 #ifdef WIN32
03252   static const int modes = 1;
03253   static const cmt_string suffix[1]   = {"bat"};
03254   static const PrintMode  mode[1]     = {Bat};
03255 #else
03256   static const int modes = 2;
03257   static const cmt_string suffix[2]   = {"csh", "sh"};
03258   static const PrintMode  mode[2]     = {Csh, Sh};
03259 #endif
03260 
03261   cout << "Creating cleanup scripts." << endl;
03262 
03263   cmt_string temp;
03264   int i;
03265 
03266   for (i = 0; i < modes; i++)
03267     {
03268       cmt_string file_name = "cleanup";
03269       file_name += ".";
03270       file_name += suffix[i];
03271       file_name += ".";
03272       file_name += "new";
03273 
03274       FILE* f = fopen (file_name.c_str (), "wb");
03275       if (f != NULL)
03276         {
03277           if (mode[i] == Csh)
03278             {
03279               fprintf (f, "set tempfile=`${CMTROOT}/mgr/cmt build temporary_name -quiet`\n");
03280               fprintf (f, "if $status != 0 then\n  set tempfile=/tmp/cmt.$$\nendif\n");
03281               fprintf (f, "${CMTROOT}/mgr/cmt -quiet cleanup -%s "
03282                        "-pack=%s -version=%s -path=%s $* >${tempfile}; "
03283                        "source ${tempfile}\n",
03284                        suffix[i].c_str (),
03285                        m_current_package.c_str (),
03286                        m_current_version.c_str (),
03287                        m_current_path.c_str ());
03288               fprintf (f, "/bin/rm -f ${tempfile}\n");
03289             }
03290           else if (mode[i] == Sh)
03291             {
03292               fprintf (f, "tempfile=`${CMTROOT}/mgr/cmt build temporary_name -quiet`\n");
03293               fprintf (f, "if test ! $? = 0 ; then tempfile=/tmp/cmt.$$; fi\n");
03294               fprintf (f, "${CMTROOT}/mgr/cmt -quiet cleanup -%s "
03295                        "-pack=%s -version=%s -path=%s $* >${tempfile}; "
03296                        ". ${tempfile}\n",
03297                        suffix[i].c_str (),
03298                        m_current_package.c_str (),
03299                        m_current_version.c_str (),
03300                        m_current_path.c_str ());
03301               fprintf (f, "/bin/rm -f ${tempfile}\n");
03302             }
03303           else
03304             {
03305             }
03306 
03307           fprintf (f, "\n");
03308 
03309           fclose (f);
03310 
03311           cmt_string old_file_name = "cleanup";
03312           old_file_name += ".";
03313           old_file_name += suffix[i];
03314 
03315           CmtSystem::compare_and_update_files (file_name, old_file_name);
03316         }
03317     }
03318 }

void Cmt::install_setup_scripts ( ) [static]
 

Definition at line 3321 of file cmt_parser.cxx.

Referenced by do_config().

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

void Cmt::install_test_cleanup_scripts ( ) [static]
 

Definition at line 3430 of file cmt_parser.cxx.

Referenced by do_config().

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

void Cmt::install_test_setup_scripts ( ) [static]
 

Definition at line 3510 of file cmt_parser.cxx.

Referenced by do_config().

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

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

Definition at line 3601 of file cmt_parser.cxx.

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

bool Cmt::need_prototypes ( ) [static]
 

See reach_current_package for an explanation of this call.

Definition at line 3840 of file cmt_parser.cxx.

Referenced by Constituent::add().

03841 {
03842   if ((m_current_build_strategy & PrototypesMask) == Prototypes) return (true);
03843   else return (false);
03844 }

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 3847 of file cmt_parser.cxx.

Referenced by parser().

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

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 5372 of file cmt_parser.cxx.

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

05373 {
05374   cmt_string actual_file_name = file_name;
05375   cmt_string text;
05376 
05377   CmtError::clear ();
05378 
05379   if (use == 0) use = &(Use::current ());
05380 
05381   if (!CmtSystem::test_file (actual_file_name))
05382     {
05383       actual_file_name = "../cmt/";
05384       actual_file_name += file_name;
05385 
05386       if (!CmtSystem::test_file (actual_file_name))
05387         {
05388           actual_file_name = "../mgr/";
05389           actual_file_name += file_name;
05390 
05391           if (!CmtSystem::test_file (actual_file_name))
05392             {
05393                 /*
05394               cmt_string text;
05395 
05396               text = "Package ";
05397               text += use->package;
05398               text += " version ";
05399               text += use->specified_version;
05400               text += " path ";
05401               text += use->specified_path;
05402               text += " file ";
05403               text += actual_file_name;
05404 
05405               CmtError::set (CmtError::file_access_error, text);
05406                 */
05407 
05408               return;
05409             }
05410         }
05411     }
05412 
05413   text.read (actual_file_name);
05414 
05434   AccessMode saved_current_access;
05435   ScopeType saved_scope;
05436 
05437   saved_current_access = Cmt::m_current_access;
05438   saved_scope          = Cmt::m_scope;
05439 
05440   if (use != &(Use::current ()))
05441     {
05442       Cmt::m_current_access = UserMode;
05443     }
05444 
05445   Cmt::m_scope = ScopePublic;
05446 
05447   parse_requirements_text (text, actual_file_name, use);
05448 
05449     //Pattern::apply_all_globals (use);
05450 
05451   Cmt::m_current_access = saved_current_access;
05452   Cmt::m_scope          = saved_scope;
05453 }

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 5462 of file cmt_parser.cxx.

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

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

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 5580 of file cmt_parser.cxx.

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

05583 {
05584   cmt_string line;
05585   int pos;
05586   int max_pos;
05587   int line_number = 1;
05588 
05589   if (use == 0) use = &(Use::current ());
05590 
05591   m_filtered_text.erase (0);
05592 
05593   pos = 0;
05594   max_pos = text.size ();
05595 
05596   for (pos = 0; pos < max_pos;)
05597     {
05598       int cr = text.find (pos, "\r\n");
05599       int nl = text.find (pos, '\n');
05600       int first = nl;
05601       int length = 1;
05602 
05603       if (cr != cmt_string::npos)
05604         {
05605           if (nl == cmt_string::npos)
05606             {
05607               first = cr;
05608               length = 2;
05609             }
05610           else
05611             {
05612               first = (nl < cr) ? nl : cr;
05613               length = (nl < cr) ? 1 : 2;
05614             }
05615         }
05616 
05617       if (first == cmt_string::npos)
05618         {
05619           text.substr (pos, line);
05620           pos = max_pos;
05621         }
05622       else if (first > pos)
05623         {
05624           text.substr (pos, first - pos, line);
05625           pos = first + length;
05626         }
05627       else
05628         {
05629           line.erase (0);
05630           pos += length;
05631         }
05632 
05633       parse_requirements_line (line, use, file_name, line_number);
05634 
05635       if ((m_action == action_check_configuration) && CmtError::has_pending_error ())
05636         {
05637           break;
05638         }
05639 
05640       line_number++;
05641     }
05642 }

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

Definition at line 5670 of file cmt_parser.cxx.

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

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

Definition at line 5645 of file cmt_parser.cxx.

Referenced by do_broadcast(), and main().

05646 {
05647   CmtSystem::cmt_string_vector v;
05648 
05649   CmtSystem::split (command_line, " \t", v);
05650 
05651   int argc = v.size ();
05652 
05653   char** argv = (char**) malloc ((argc + 1) * sizeof (char*));
05654 
05655   int i;
05656   for (i = 0; i < argc; i++)
05657     {
05658       argv[i] = (char*) v[i].c_str ();
05659     }
05660   argv[argc] = 0;
05661 
05662   int status = parser (argc, argv);
05663 
05664   free (argv);
05665 
05666   return (status);
05667 }

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 6322 of file cmt_parser.cxx.

Referenced by do_setup().

06323 {
06324   Use::UsePtrVector& Uses = Use::uses ();
06325 
06326   cmt_string tag;
06327 
06328   set_standard_macros ();
06329 
06330     //cerr << "# current_tag=" << m_current_tag << endl;
06331     //cerr << "# current_config=" << m_current_config << endl;
06332 
06333   if (m_current_tag == "")
06334     {
06335       if (mode == Bat) tag = "%CMTCONFIG%";
06336       else tag = "${CMTCONFIG}";
06337     }
06338   else
06339     {
06340       tag = m_current_tag;
06341     }
06342 
06343   if (m_current_access == DeveloperMode)
06344     {
06345       m_scope = ScopePrivate;
06346     }
06347   else
06348     {
06349       m_scope = ScopePublic;
06350     }
06351 
06352     //
06353     //  Now check if all extra tags are still valid. Some of them
06354     //  may be discarded du to some conflict with highest priority
06355     //  tags, or with exclude statements
06356     //
06357 
06358   {
06359     CmtSystem::cmt_string_vector words;
06360       
06361     cmt_string tags;
06362 
06363     tags = Cmt::m_extra_tags;
06364       
06365     CmtSystem::split (tags, " \t,", words);
06366 
06367     Cmt::m_extra_tags = "";
06368       
06369     for (int i = 0; i < words.size (); i++)
06370       {
06371         Tag* tag;
06372         const cmt_string& a = words[i];
06373 
06374         tag = Tag::find (a);
06375 
06376         if ((tag != 0) && (tag->is_selected ()))
06377           {
06378             Cmt::m_extra_tags += a;
06379             Cmt::m_extra_tags += ",";
06380           }
06381       }
06382   }
06383 
06384   if (Uses.size () > 0)
06385     {
06386       int number;
06387 
06388       for (number = 0; number < Uses.size (); number++)
06389         {
06390           Use& use = *(Uses[number]);
06391 
06392           if (use.discarded) continue;
06393 
06394           print_context (use, mode, tag);
06395         }
06396     }
06397 
06398   print_context (Use::current (), mode, tag);
06399 
06400   Symbol::all_print (mode);
06401   // Script::all_print (mode);
06402 
06403   cout << endl;
06404 }

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

Definition at line 6407 of file cmt_parser.cxx.

Referenced by do_cleanup().

06408 {
06409   Use::UsePtrVector& Uses = Use::uses ();
06410 
06411   set_standard_macros ();
06412 
06413   Script::all_print_clean (mode);
06414   Symbol::all_print_clean (mode);
06415 
06416   switch (mode)
06417     {
06418     case Csh :
06419       if (m_current_package != "CMT")
06420         {
06421           cout << "unsetenv " << m_current_prefix << "ROOT" << endl;
06422           cout << "unsetenv " << m_current_prefix << "CONFIG" << endl;
06423         }
06424       break;
06425     case Sh :
06426       if (m_current_package != "CMT")
06427         {
06428           cout << "unset " << m_current_prefix << "ROOT" << endl;
06429           cout << "unset " << m_current_prefix << "CONFIG" << endl;
06430         }
06431       break;
06432     case Bat :
06433       if (m_current_package != "CMT")
06434         {
06435           cout << "set " << m_current_prefix << "ROOT=" << endl;
06436           cout << "set " << m_current_prefix << "CONFIG=" << endl;
06437         }
06438       break;
06439     }
06440 
06441   if (Uses.size () > 0)
06442     {
06443       int number;
06444 
06445       for (number = 0; number < Uses.size (); number++)
06446         {
06447           Use* use = Uses[number];
06448 
06449           if (use->package == "CMT") continue;
06450           if (use->package == "methods") continue;
06451           if (use->discarded) continue;
06452 
06453           switch (mode)
06454             {
06455             case Csh :
06456               cout << "unsetenv " << use->prefix << "ROOT" << endl;
06457               cout << "unsetenv " << use->prefix << "CONFIG" << endl;
06458               break;
06459             case Sh :
06460               cout << "unset " << use->prefix << "ROOT" << endl;
06461               cout << "unset " << use->prefix << "CONFIG" << endl;
06462               break;
06463             case Bat :
06464               cout << "set " << use->prefix << "ROOT=" << endl;
06465               cout << "set " << use->prefix << "CONFIG" << endl;
06466               break;
06467             }
06468         }
06469     }
06470 
06471   switch (mode)
06472     {
06473     case Csh :
06474       cout << "unsetenv CMTEXTRATAGS" << endl;
06475       break;
06476     case Sh :
06477       cout << "unset CMTEXTRATAGS" << endl;
06478       break;
06479     case Bat :
06480       cout << "set CMTEXTRATAGS=" << endl;
06481       break;
06482     }
06483 
06484   cout << endl;
06485 }

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

Definition at line 6488 of file cmt_parser.cxx.

Referenced by print().

06489 {
06490   if (use.package == "cmt_standalone") return;
06491 
06492   cmt_string fs = CmtSystem::file_separator ();
06493 
06494   use.real_path.replace_all (CmtSystem::file_separator (), fs);
06495 
06496   cmt_string system = CmtSystem::get_cmt_config ();
06497 
06498   switch (mode)
06499     {
06500     case Csh :
06501       cout << "setenv " << use.prefix << "ROOT \"" <<
06502         use.real_path << fs <<
06503         use.package << fs <<
06504         use.version << "\"" << endl;
06505         
06506       if (use.package == "CMT")
06507         {
06508             //cout << "setenv CMTCONFIG `${CMTROOT}/mgr/cmt system`; " << endl;
06509           cout << "setenv CMTCONFIG " << system << endl;
06510           //cout << "setenv CMTEXTRATAGS " << Cmt::m_extra_tags << endl;
06511         }
06512       else
06513         {
06514           cout << "setenv " << use.prefix << "CONFIG \"" << tag << "\"" << endl;
06515         }
06516         
06517       break;
06518     case Sh :
06519       cout << use.prefix << "ROOT=\"" <<
06520         use.real_path << fs <<
06521         use.package << fs <<
06522         use.version << "\"; export " <<
06523         use.prefix << "ROOT" << endl;
06524         
06525       if (use.package == "CMT")
06526         {
06527           //cout << "CMTCONFIG=`${CMTROOT}/mgr/cmt system`; export CMTCONFIG; ";
06528           cout << "CMTCONFIG=" << system << "; export CMTCONFIG" << endl;
06529           //cout << "CMTEXTRATAGS=" << Cmt::m_extra_tags << "; export CMTEXTRATAGS" << endl;
06530         }
06531       else
06532         {
06533           cout << use.prefix << "CONFIG=\"" <<
06534             tag << "\"; export " <<
06535             use.prefix << "CONFIG" << endl;
06536         }
06537         
06538       break;
06539     case Bat :
06540       cout << "set " << use.prefix << "ROOT=" <<
06541         use.real_path << fs <<
06542         use.package << fs <<
06543         use.version << endl;
06544         
06545       if (use.package == "CMT")
06546         {
06547           //cout << "set CMTCONFIG=VisualC" << endl;
06548           cout << "set CMTCONFIG=" << system << endl;
06549           //cout << "set CMTEXTRATAGS=" << Cmt::m_extra_tags << endl;
06550         }
06551       else
06552         {
06553           cout << "set " << use.prefix << "CONFIG=" << tag << endl;
06554         }
06555         
06556       break;
06557     }
06558 }

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 6567 of file cmt_parser.cxx.

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

06568 {
06569   int number;
06570 
06571   set_standard_macros ();
06572 
06573   for (number = 0; number < Symbol::symbol_number (); number++)
06574     {
06575       Symbol& symbol = Symbol::symbol (number);
06576 
06577       if (m_action == action_show_macros)
06578         {
06579           // Only keep macros.
06580           if ((symbol.command == CommandSet) ||
06581               (symbol.command == CommandSetAppend) ||
06582               (symbol.command == CommandSetPrepend) ||
06583               (symbol.command == CommandSetRemove) ||
06584               (symbol.command == CommandAlias) ||
06585               (symbol.command == CommandPath) ||
06586               (symbol.command == CommandPathAppend) ||
06587               (symbol.command == CommandPathPrepend) ||
06588               (symbol.command == CommandPathRemove)) continue;
06589         }
06590       else if (m_action == action_show_sets)
06591         {
06592           // Exclude macros.
06593           if ((symbol.command == CommandMacro) ||
06594               (symbol.command == CommandMacroAppend) ||
06595               (symbol.command == CommandMacroPrepend) ||
06596               (symbol.command == CommandMacroRemove) ||
06597               (symbol.command == CommandMacroRemoveAll)) continue;
06598         }
06599       else if (m_action == action_build_tag_makefile)
06600         {
06601           // Exclude scripts.
06602           if ((symbol.command == CommandSetupScript) ||
06603               (symbol.command == CommandCleanupScript)) continue;
06604         }
06605 
06606       if (symbol.value_lists.size () < 1) continue;
06607 
06608       symbol.show_macro (mode);
06609     }
06610 }

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

Definition at line 6613 of file cmt_parser.cxx.

06614 {
06615   while (tabs > 0)
06616     {
06617       cout << "  ";
06618       tabs--;
06619     }
06620 }

int Cmt::reach_current_package ( ) [static]
 

Definition at line 6623 of file cmt_parser.cxx.

Referenced by do_config(), and parser().

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

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 6824 of file cmt_parser.cxx.

Referenced by parse_requirements_line().

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

void Cmt::set_standard_macros ( ) [static]
 

Definition at line 7410 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_all_tags(), 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().

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

void Cmt::use_cmt ( ) [static]
 

Macros implied or required to manage constituents.

Definition at line 8283 of file cmt_parser.cxx.

Referenced by load(), and parser().

08284 {
08285   UseRef use;
08286   bool recursive_copy = m_recursive;
08287   bool debug_copy = m_debug;
08288 
08289   if (m_default_path.size () <= 0) return;
08290   if (m_current_package == "CMT") return;
08291 
08292   m_recursive = true;
08293   m_debug = false;
08294   use = Use::add (m_default_path, "CMT", m_cmt_version, "", "", 0);
08295   m_recursive = recursive_copy;
08296   m_debug = debug_copy;
08297 }

void Cmt::use_home_requirements ( ) [static]
 

Definition at line 8300 of file cmt_parser.cxx.

Referenced by parser().

08301 {
08302   cmt_string f = m_cmt_home;
08303 
08304   if (f == "") 
08305     {
08306         //if (!m_quiet) cerr << "No CMTHOME" << endl;
08307       return;
08308     }
08309 
08310     //if (!m_quiet) cerr << "Using CMTHOME in " << f << endl;
08311 
08312   UseRef use;
08313   bool recursive_copy = m_recursive;
08314 
08315   if (m_default_path.size () <= 0) return;
08316   if (m_current_package == "CMT") return;
08317 
08318   m_recursive = true;
08319 
08320   cmt_string name = CmtSystem::get_home_package ();
08321 
08322   use = Use::add (f, name, "", "", "", 0);
08323 
08324   f += CmtSystem::file_separator ();
08325   f += "requirements";
08326   parse_requirements (f, use);
08327 
08328   m_recursive = recursive_copy;
08329 }

void Cmt::use_user_context_requirements ( ) [static]
 

Definition at line 8332 of file cmt_parser.cxx.

Referenced by parser().

08333 {
08334   cmt_string f = m_cmt_user_context;
08335 
08336   if (f == "") 
08337     {
08338         //if (!m_quiet) cerr << "No CMTUSERCONTEXT" << endl;
08339       return;
08340     }
08341 
08342     //if (!m_quiet) cerr << "Using CMTUSERCONTEXT in " << f << endl;
08343 
08344   UseRef use;
08345   bool recursive_copy = m_recursive;
08346 
08347   if (m_default_path.size () <= 0) return;
08348   if (m_current_package == "CMT") return;
08349 
08350   m_recursive = true;
08351 
08352   cmt_string name = CmtSystem::get_user_context_package ();
08353 
08354   use = Use::add (f, name, "", "", "", 0);
08355 
08356   f += CmtSystem::file_separator ();
08357   f += "requirements";
08358   parse_requirements (f, use);
08359 
08360   m_recursive = recursive_copy;
08361 }

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

Definition at line 8364 of file cmt_parser.cxx.

08367 {
08368   result.erase (0);
08369 
08370   for (int i = 0; i < v.size (); i++)
08371     {
08372       if (i > 0) result += separator;
08373       result += v[i];
08374     }
08375 }

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

Definition at line 8378 of file cmt_parser.cxx.

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

08379 {
08380   cmt_string result;
08381 
08382   vector_to_string (v, " ", result);
08383 
08384   return (result);
08385 }


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 May 16 16:27:39 2002 for CMT by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000