Changeset 652 for CMT


Ignore:
Timestamp:
Nov 5, 2013, 3:40:52 PM (11 years ago)
Author:
rybkin
Message:

See C.L. 511

Location:
CMT/HEAD
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r651 r652  
     12013-11-05    <rybkin@lal.in2p3.fr> 511
     2
     3        * source/cmt_project.h: In class Project, change fill_selection function
     4        signature to return projects (pointers), introduce function fill_exclusion
     5        * source/cmt_project.cxx: In class ProjectFactory create_project function,
     6        use change_path function on project use object, in class Project implement
     7        fill_selection function for enhanced handling of special CMTHOME,
     8        CMTUSERCONTEXT projects (selected if current project only) and special
     9        depth values (0: CMTUSERCONTEXT project only, -1: CMTHOME project only),
     10        implement fill_exclusion function to exclude special CMTHOME,
     11        CMTUSERCONTEXT projects unless current project, in find_in_cmt_paths
     12        function fix search condition and comment out never used code, in
     13        container_action function issue warning or set error if container package
     14        cannot be located
     15        * source/cmt_use.h: In class Use, add member to hold project (pointer)
     16        package found in, add optional argument project (pointer) to change_path,
     17        select_alternate functions, add set_project function, inline located
     18        function, make m_located member private
     19        * source/cmt_use.cxx: In class Use, assign use project in function
     20        change_path, in class UseProjectAction run and class Use select_alternate
     21        functions, in particular, in functions get_cmtpath_and_offset,
     22        fill_standard_macros, get_project make use of added class member (project)
     23        for optimisation
     24        * source/cmt_generators.h: In class PackagesMakefileGenerator, add member
     25        m_ISINCLUDED
     26        * source/cmt_generators.cxx: In class PackagesMakefileGenerator
     27        constructor, reset function handle added member m_ISINCLUDED, in build
     28        function make use of class Project fill_exclusion function and added
     29        member to ensure packages from special CMTHOME, CMTUSERCONTEXT projects
     30        are only visited, if in current project
     31        * source/cmt_syntax.cxx: In class KwdBuildStrategy, KwdSetupStrategy,
     32        KwdStructureStrategy action functions use class Use get_project function
     33        for optimisation
     34        * source/cmt_commands.cxx: In class ArgParser option_disable_warnings,
     35        option_quiet, option_warnings functions, do not set CmtMessage level, add
     36        option value to CMTFLAGS, in option_use, option_pack, option_version,
     37        option_path functions only record option value, in option_tag,
     38        option_tag_add, option_tag_remove functions, only record option values, in
     39        option_with_version_directory, option_without_version_directory functions
     40        do not change strategy, add option value to CMTFLAGS, in class CommandHelp
     41        show_all function, add message for -home, -user_context options
     42        * source/cmt_pattern.cxx: In class Pattern expand function, use class Use
     43        get_project function for optimisation
     44        * source/cmt_parser.cxx: In class CmtContext constructor, process
     45        CMTEXTRATAGS environment variable value, in clear function, reset all
     46        members, in class Cmt configure function, attempt to locate current use
     47        or package if at least name is available from command line options before
     48        configure_current_package for optimisation, in configure_current_cmtpath
     49        function make use of class Use get_cmtpath_and_offset function,
     50        return from configure_current_package if current use is located, in
     51        configure_current_structuring_style function, do not parse command line
     52        arguments, make use of value from command line or parse CMTFLAGS to set
     53        strategy accordingly, in configure_home, configure_user_context functions,
     54        use value from command line if any, in restore_all_tags function, add tags
     55        from CmtContext m_extra_tags, m_tags, m_tags_add vectors, in
     56        configure_cmt_message function do not parse command line arguments, parse
     57        CMTFLAGS, in do_broadcast function, set error if depth option value cannot
     58        be parsed or is out of range (< -1), make use of class Project
     59        fill_selection, fill_exclusion functions to implement enhanced handling of
     60        special CMTHOME, CMTUSERCONTEXT projects packages (visited if in current
     61        project only) and and special depth values (0: CMTUSERCONTEXT project
     62        packages only, -1: CMTHOME project packages only), in
     63        do_check_configuration function, check tags from CmtContext m_extra_tags,
     64        m_tags, m_tags_add vectors, in do_show_clients function do not re-run
     65        configure, in guess_current_project function, do not use CmtSystem cd or
     66        pwd functions for optimisation, in parse_arguments function do not call
     67        restore_all_tags function, in parser function call parse_arguments first
     68        and then configure, restore_all_tags to make configuration process cleaner,
     69        do not call configure for action_build_temporary_name, in print function do
     70        not check tags or change m_extra_tags since that change affects nothing, in
     71        use_current_package, use_extra_file functions do not attempt to locate
     72        current package if current use located already, factor out
     73        Pattern::apply_all_globalsize and Tag::restore_tree calls into separate
     74        apply_globals function called after all requirements are read, in
     75        use_special_requirements function set special use style, structuring_style,
     76        project members if located, otherwise discard, in particular, that means
     77        that requirements file in special CMTHOME, CMTUSERCONTEXT projects is not
     78        mandatory
     79        * source/cmt_symbol.cxx: In class Symbol action function, make
     80        constituentsclean symbol private (like constituents)
     81        * source/cmt.h: In class CmtContext, add string vector members
     82        m_extra_tags, m_tags, m_tags_add, m_tags_remove instead of string
     83        m_extra_tags, in class Cmt, function reach_current_package renamed
     84        use_current_package, introduce apply_globals function
     85        * mgr/fragments/nmake/package: Ensure that not included packages are
     86        not visited
     87        * mgr/fragments/package: idem
     88        * src/Makefile.header: Update help messages for BCAST mode in presence of
     89        special CMTHOME, CMTUSERCONTEXT packages/projects
     90
    1912013-10-04    <rybkin@lal.in2p3.fr> 510
    292
  • CMT/HEAD/mgr/fragments/nmake/package

    r600 r652  
    11
     2cmt_${PACKAGE}_${ISINCLUDED} = 1
    23cmt_${PACKAGE}_${ISLOCAL} = 1
    34
     
    67
    78!if "$(LOG_LOCATION)" != ""
     9!if "$(cmt_${PACKAGE}_is_included)" != ""
    810!if "$(cmt_${PACKAGE}_is_local)" != ""
    911${PACKAGE}OutErr = >>$(LOG_LOCATION)\$(${PACKAGE}FullName)$(LOG_SUFFIX) 2>&1
     
    1113!if "$(BCAST_GLOBAL)" != ""
    1214${PACKAGE}OutErr = >>$(LOG_LOCATION)\$(${PACKAGE}FullName)$(LOG_SUFFIX) 2>&1
     15!endif
    1316!endif
    1417!endif
     
    2023${PACKAGE} : $(${PACKAGE}MgrPath)\NMake
    2124!endif
     25!if "$(cmt_${PACKAGE}_is_included)" != ""
    2226!if "$(cmt_${PACKAGE}_is_local)" != ""
    2327        @echo "#--------------------------------------------------------------" \
     
    7377!endif
    7478!endif
     79!else
     80       
     81!endif
    7582
    7683$(${PACKAGE}MgrPath)\NMake :
     84!if "$(cmt_${PACKAGE}_is_included)" != ""
    7785!if "$(cmt_${PACKAGE}_is_local)" != ""
    7886        $(echo) configuring ${PACKAGE}
     
    8593       
    8694!endif
     95!endif
     96!else
     97       
    8798!endif
    8899
     
    96107
    97108${PACKAGE}clean : $(${PACKAGE}MgrPath)\NMake
     109!if "$(cmt_${PACKAGE}_is_included)" != ""
    98110!if "$(cmt_${PACKAGE}_is_local)" != ""
    99111        @echo "#--------------------------------------------------------------" \
     
    125137!endif
    126138!endif
     139!else
     140       
     141!endif
    127142
    128143${PACKAGE}binclean : $(${PACKAGE}MgrPath)\NMake
     144!if "$(cmt_${PACKAGE}_is_included)" != ""
    129145!if "$(cmt_${PACKAGE}_is_local)" != ""
    130146        @echo "#--------------------------------------------------------------" \
     
    156172!endif
    157173!endif
     174!else
     175       
     176!endif
    158177
    159178${PACKAGE}uninstall : $(${PACKAGE}MgrPath)\NMake
     179!if "$(cmt_${PACKAGE}_is_included)" != ""
    160180!if "$(cmt_${PACKAGE}_is_local)" != ""
    161181        @echo "#--------------------------------------------------------------" \
     
    187207!endif
    188208!endif
     209!else
     210       
     211!endif
    189212
    190213${PACKAGE}check : $(${PACKAGE}MgrPath)\NMake
     214!if "$(cmt_${PACKAGE}_is_included)" != ""
    191215!if "$(cmt_${PACKAGE}_is_local)" != ""
    192216        @echo "#--------------------------------------------------------------" \
     
    218242!endif
    219243!endif
     244!else
     245       
     246!endif
    220247
    221248${PACKAGE} ${PACKAGE}clean ${PACKAGE}binclean ${PACKAGE}uninstall ${PACKAGE}check : FORCE
  • CMT/HEAD/mgr/fragments/package

    r600 r652  
    11
     2cmt_${PACKAGE}_${ISINCLUDED} = 1
    23cmt_${PACKAGE}_${ISLOCAL} = 1
    34
     
    67
    78ifdef LOG_LOCATION
     9ifdef cmt_${PACKAGE}_is_included
    810ifdef cmt_${PACKAGE}_is_local
    911${PACKAGE}OutErr = >>$(LOG_LOCATION)/$(${PACKAGE}FullName)$(LOG_SUFFIX) 2>&1
     
    1113ifdef BCAST_GLOBAL
    1214${PACKAGE}OutErr = >>$(LOG_LOCATION)/$(${PACKAGE}FullName)$(LOG_SUFFIX) 2>&1
     15endif
    1316endif
    1417endif
     
    2023${PACKAGE} : $(${PACKAGE}MgrPath)/Makefile
    2124endif
     25ifdef cmt_${PACKAGE}_is_included
    2226ifdef cmt_${PACKAGE}_is_local
    2327        @echo "#--------------------------------------------------------------" \
     
    6771endif
    6872endif
     73else
     74       
     75endif
    6976
    7077$(${PACKAGE}MgrPath)/Makefile :
     78ifdef cmt_${PACKAGE}_is_included
    7179ifdef cmt_${PACKAGE}_is_local
    7280        $(echo) configuring ${PACKAGE}
     
    8088endif
    8189endif
     90else
     91       
     92endif
    8293
    8394ifndef BCAST_ONLY
     
    90101
    91102${PACKAGE}clean ${PACKAGE}binclean ${PACKAGE}uninstall ${PACKAGE}check : $(${PACKAGE}MgrPath)/Makefile
     103ifdef cmt_${PACKAGE}_is_included
    92104ifdef cmt_${PACKAGE}_is_local
    93105        @echo "#--------------------------------------------------------------" \
     
    119131endif
    120132endif
     133else
     134       
     135endif
    121136
    122137${PACKAGE} ${PACKAGE}clean ${PACKAGE}binclean ${PACKAGE}uninstall ${PACKAGE}check : FORCE
  • CMT/HEAD/source/cmt.h

    r612 r652  
    5252  cmt_string m_current_version;
    5353 
    54   cmt_string m_extra_tags;
     54  //  cmt_string m_extra_tags;
     55  CmtSystem::cmt_string_vector m_extra_tags;
     56  CmtSystem::cmt_string_vector m_tags;
     57  CmtSystem::cmt_string_vector m_tags_add;
     58  CmtSystem::cmt_string_vector m_tags_remove;
     59
    5560  cmt_string m_configure_error;
    5661 
     
    268273  static void print_tabs (int tabs);
    269274  static void print_xml_prolog (const cmt_string& root = "cmt", ostream& out = cout);
    270   static int reach_current_package ();
     275  //  static int reach_current_package ();
     276  static int use_current_package ();
    271277  static int use_extra_file (const cmt_string& file);
     278  static int apply_globals ();
    272279  static void restore_all_tags (Use* use);
    273280  static void set_current_access (AccessMode mode);
  • CMT/HEAD/source/cmt_commands.cxx

    r649 r652  
    19031903{
    19041904  cmt.m_disable_warnings = true;
    1905   if (CmtMessage::level () <= Warning)
    1906     CmtMessage::set_level (Error);
     1905//   if (CmtMessage::level () <= Warning)
     1906//     CmtMessage::set_level (Error);
     1907  if (!Cmt::add_cmt_flag ("-disable_warnings"))
     1908    CmtError::set (CmtError::system_error, "Cannot add flag `-disable_warnings'");
    19071909}
    19081910
     
    19101912{
    19111913  cmt.m_quiet = true;
    1912   if (CmtMessage::level () <= Error)
    1913     CmtMessage::set_level (Fatal);
     1914//   if (CmtMessage::level () <= Error)
     1915//     CmtMessage::set_level (Fatal);
     1916  if (!Cmt::add_cmt_flag ("-quiet"))
     1917    CmtError::set (CmtError::system_error, "Cannot add flag `-quiet'");
    19141918}
    19151919
     
    19181922{
    19191923  cmt.m_warnings = true;
    1920   if (CmtMessage::level () != Warning)
    1921     CmtMessage::set_level (Warning);
     1924//   if (CmtMessage::level () != Warning)
     1925//     CmtMessage::set_level (Warning);
     1926  if (!Cmt::add_cmt_flag ("-warnings"))
     1927    CmtError::set (CmtError::system_error, "Cannot add flag `-warnings'");
    19221928}
    19231929
     
    19631969      if (words.size () > 1) cmt.m_current_version = words[1];
    19641970      if (words.size () > 2) cmt.m_current_path    = words[2];
    1965       (Use::current()).set (cmt.m_current_package,
    1966                             cmt.m_current_version,
    1967                             cmt.m_current_path);
    1968 
    1969       Use& use = Use::current();
    1970       if (use.get_package_name () == "cmt_standalone")
    1971         {
    1972           if (!CmtSystem::cd (use.path) || !CmtSystem::test_file ("requirements"))
    1973             {
    1974               CmtError::set (CmtError::package_not_found, use.get_info ());
    1975               return;
    1976             }
    1977           use.style = none_style;
    1978           use.structuring_style = without_version_directory;
    1979           use.change_path (CmtSystem::pwd ());
    1980         }
    1981       else if (!use.move_to ())
    1982         {
    1983           CmtError::set (CmtError::package_not_found, use.get_info ());
    1984           return;
    1985         }
    1986       Project::order_all ();
    1987       Cmt::guess_current_project ();
    19881971    }
    19891972}
     
    19981981
    19991982      cmt.m_current_package = arg;
    2000       cmt.m_current_version = "";
    2001 
    2002       /*
    2003       cerr << "ArgParser::option_pack> "
    2004            << " cp=" << cmt.m_current_package
    2005            << " cv=" << cmt.m_current_version
    2006            << " cp=" << cmt.m_current_path << endl;
    2007       */
    2008 
    2009       (Use::current()).set (cmt.m_current_package,
    2010                             cmt.m_current_version,
    2011                             cmt.m_current_path);
     1983      //      cmt.m_current_version = "";
     1984
    20121985    }
    20131986}
     
    20191992      cmt.m_current_access = UserMode;
    20201993      cmt.m_current_version = arg;
    2021 
    2022       /*
    2023       cerr << "ArgParser::option_version> "
    2024            << " cp=" << cmt.m_current_package
    2025            << " cv=" << cmt.m_current_version
    2026            << " cp=" << cmt.m_current_path << endl;
    2027       */
    2028 
    2029       (Use::current()).set (cmt.m_current_package,
    2030                             cmt.m_current_version,
    2031                             cmt.m_current_path);
    20321994    }
    20331995}
     
    20392001      cmt.m_current_access = UserMode;
    20402002      cmt.m_current_path = arg;
    2041 
    2042       /*
    2043       cerr << "ArgParser::option_path> "
    2044            << " cp=" << cmt.m_current_package
    2045            << " cv=" << cmt.m_current_version
    2046            << " cp=" << cmt.m_current_path << endl;
    2047       */
    2048 
    2049       (Use::current()).set (cmt.m_current_package,
    2050                             cmt.m_current_version,
    2051                             cmt.m_current_path);
    2052 
    2053       //IProjectFactory& factory = ProjectFactory::instance ();
    2054       //CmtSystem::add_cmt_path (cmt.m_current_path, "argument", factory);
    2055       Use& use = Use::current();
    2056       if (use.get_package_name () == "cmt_standalone")
    2057         {
    2058           if (!CmtSystem::cd (use.path) || !CmtSystem::test_file ("requirements"))
    2059             {
    2060               CmtError::set (CmtError::package_not_found, use.get_info ());
    2061               return;
    2062             }
    2063           use.style = none_style;
    2064           use.structuring_style = without_version_directory;
    2065           use.change_path (CmtSystem::pwd ());
    2066         }
    2067       else if (!use.move_to ())
    2068         {
    2069           CmtError::set (CmtError::package_not_found, use.get_info ());
    2070           return;
    2071         }
    2072       Project::order_all ();
    2073       Cmt::guess_current_project ();
    20742003    }
    20752004}
     
    20822011void ArgParser::option_e ()
    20832012{
    2084   //CmtMessage::warning ("extra statement = " + arg);
    20852013  extra_line = arg;
    20862014}
     
    21012029  if (arg != "")
    21022030    {
     2031      cmt.m_tags.clear ();
     2032      CmtSystem::cmt_string_vector words;
     2033      CmtSystem::split (arg, " \t,", words);
     2034      for (int i = 0; i < words.size (); i++)
     2035        {
     2036          bool has (false);
     2037          for (int j = 0; j < cmt.m_tags.size (); j++)
     2038            {
     2039              if (cmt.m_tags[j] == words[i])
     2040                {
     2041                  has = true;
     2042                  break;
     2043                }
     2044            }
     2045          if (!has)
     2046            cmt.m_tags.push_back (words[i]);
     2047        }
     2048
     2049      if (cmt.m_tags.size () != 0)
     2050        {
     2051          cmt.m_extra_tags.clear ();
     2052          cmt.m_tags_add.clear ();
     2053          cmt.m_tags_remove.clear ();
     2054        }
     2055
     2056      /*
    21032057      Tag* tag;
    21042058      CmtSystem::cmt_string_vector words;
     
    21542108        // To be sure that a tag
    21552109        Cmt::guess_current_project ();
     2110      */
    21562111    }
    21572112}
     
    21592114void ArgParser::option_tag_add ()
    21602115{
     2116  CmtSystem::cmt_string_vector words;
     2117  CmtSystem::split (arg, " \t,", words);
     2118  for (int i = 0; i < words.size (); i++)
     2119    {
     2120      bool has (false);
     2121      for (int j = 0; j < cmt.m_tags_add.size (); j++)
     2122        {
     2123          if (cmt.m_tags_add[j] == words[i])
     2124            {
     2125              has = true;
     2126              break;
     2127            }
     2128        }
     2129      if (!has)
     2130        {
     2131          cmt.m_tags_add.push_back (words[i]);
     2132        }
     2133     
     2134      for (int j = 0; j < cmt.m_tags_remove.size (); j++)
     2135        {
     2136          if (cmt.m_tags_remove[j] == words[i])
     2137            {
     2138              cmt.m_tags_remove.erase(j);
     2139              break;
     2140            }
     2141        }
     2142    }
     2143  /*
    21612144  Tag* tag;
    21622145  CmtSystem::cmt_string_vector words;
     
    21912174        }
    21922175    }
     2176  */
    21932177}
    21942178
    21952179void ArgParser::option_tag_remove ()
    21962180{
     2181  CmtSystem::cmt_string_vector words;
     2182  CmtSystem::split (arg, " \t,", words);
     2183  for (int i = 0; i < words.size (); i++)
     2184    {
     2185      bool has (false);
     2186      for (int j = 0; j < cmt.m_tags_remove.size (); j++)
     2187        {
     2188          if (cmt.m_tags_remove[j] == words[i])
     2189            {
     2190              has = true;
     2191              break;
     2192            }
     2193        }
     2194      if (!has)
     2195        {
     2196          cmt.m_tags_remove.push_back (words[i]);
     2197        }
     2198
     2199      for (int j = 0; j < cmt.m_extra_tags.size (); j++)
     2200        {
     2201          if (cmt.m_extra_tags[j] == words[i])
     2202            {
     2203              cmt.m_extra_tags.erase(j);
     2204              break;
     2205            }
     2206        }
     2207      for (int j = 0; j < cmt.m_tags.size (); j++)
     2208        {
     2209          if (cmt.m_tags[j] == words[i])
     2210            {
     2211              cmt.m_tags.erase(j);
     2212              break;
     2213            }
     2214        }
     2215      for (int j = 0; j < cmt.m_tags_add.size (); j++)
     2216        {
     2217          if (cmt.m_tags_add[j] == words[i])
     2218            {
     2219              cmt.m_tags_add.erase(j);
     2220              break;
     2221            }
     2222        }
     2223    }
     2224  /*
    21972225  Tag::TagPtrVector tags = Tag::tags ();
    21982226  int i;
    21992227  Tag* tag;
    2200 
    2201   /*
    2202     for (i = 0; i < tags.size (); i++)
    2203     {
    2204     tag = tags[i];
    2205     if ((tag != 0) &&
    2206     (tag->selected))
    2207     {
    2208     if (!cmt.m_quiet) cerr << "  original tag_list=" << tag->name << tag->priority << endl;
    2209     }
    2210     }
    2211   */
    22122228
    22132229  CmtSystem::cmt_string_vector words;
     
    22622278            const cmt_string& a = words[i];
    22632279
    2264             //fprintf (stderr, "  a=[%s]\n", a.c_str ());
    2265 
    22662280            /// Then restore uname if the specified tag is CMTCONFIG
    22672281              if (a == CmtSystem::get_cmt_config ())
     
    22862300              tag->mark ("arguments");
    22872301          }
     2302  */
    22882303}
    22892304
     
    23142329  cmt.m_current_structuring_style = with_version_directory;
    23152330
    2316   StrategyDef* def = StrategyMgr::find_strategy ("VersionDirectory");
    2317   if (def != 0)
    2318     {
    2319       def->m_default_value = true;
    2320       def->m_priority_value = false;
    2321     }
     2331  if (!Cmt::add_cmt_flag ("-with_version_directory"))
     2332    CmtError::set (CmtError::system_error, "Cannot add flag `-with_version_directory'");
     2333
    23222334}
    23232335
     
    23262338  cmt.m_current_structuring_style = without_version_directory;
    23272339
    2328   StrategyDef* def = StrategyMgr::find_strategy ("VersionDirectory");
    2329   if (def != 0)
    2330     {
    2331       def->m_default_value = false;
    2332       def->m_priority_value = true;
    2333     }
     2340  if (!Cmt::add_cmt_flag ("-without_version_directory"))
     2341    CmtError::set (CmtError::system_error, "Cannot add flag `-without_version_directory'");
     2342
    23342343}
    23352344
     
    24012410  cout << "#   -path=<path>            : set root path" << endl;
    24022411  cout << "#   -f=<requirements-file>  : set input file" << endl;
    2403   cout << "#   -e=<statement>          : add a one line statement" << endl;
     2412  cout << "#   -e=<statement(s)>       : add (multiple) statement(s)" << endl;
    24042413  cout << "#   -tag=<tag-list>         : select a new tag-set" << endl;
    24052414  cout << "#   -tag_add=<tag-list>     : add specific comma-separated tag(s)" << endl;
     
    24112420  cout << "#   -no_cleanup             : inhibit install area cleanup" << endl;
    24122421  cout << "#   -xml                    : output in XML format (cmt setup, cmt show projects, cmt show uses)" << endl;
     2422  cout << "#   -user_context=<path>    : set user context package/project directory" << endl;
     2423  cout << "#   -home=<path>            : set home package/project directory" << endl;
    24132424}
    24142425
  • CMT/HEAD/source/cmt_generators.cxx

    r628 r652  
    28412841  m_PACKAGEFULLNAME.set ("PACKAGEFULLNAME");
    28422842  m_ISLOCAL.set ("ISLOCAL");
     2843  m_ISINCLUDED.set ("ISINCLUDED");
    28432844
    28442845  packages_header_fragment.set ("packages_header");
     
    28542855  m_PACKAGEFULLNAME = "";
    28552856  m_ISLOCAL = "";
     2857  m_ISINCLUDED = "";
    28562858
    28572859  packages_header_fragment.reset ();
     
    28992901      if (!packages_header_fragment.copy (m_output_file, 1, &m_PACKAGE)) return;
    29002902
    2901       Project* cur = Project::get_current ();
     2903      const Project* p_cur (Project::get_current ());
    29022904      Use::UsePtrVector uses (Use::get_ordered_uses ());
    29032905      uses.push_back (&Use::current ());
     2906
     2907      Project::ConstProjectPtrVector path_exclusions;
     2908      Project::fill_exclusion (path_exclusions);
     2909
    29042910      cmt_string temp;
    29052911      for (int i = uses.size () - 1; i >= 0; i--)
    29062912        {
    29072913          Use* use = uses[i];
     2914
    29082915          if (use->discarded) continue;
    29092916          if (use->m_hidden) continue;
     
    29112918          if (use->get_package ()->is_cmt ()) continue;
    29122919
    2913           if (use->get_project () == cur)
    2914             m_ISLOCAL = "is_local";
    2915           else
    2916             m_ISLOCAL = "is_not_local";
     2920          const Project* up = use->get_project ();
     2921
     2922          m_ISLOCAL = "is_not_local";
     2923          if (p_cur)
     2924            {
     2925              if (up)
     2926                {
     2927                  if (up == p_cur)
     2928                    {
     2929                      m_ISLOCAL = "is_local";
     2930                    }
     2931                }
     2932              else
     2933                {
     2934                  if (use->get_realpath ().find (p_cur->get_cmtpath_real ()) == 0)
     2935                    {
     2936                      m_ISLOCAL = "is_local";
     2937                    }
     2938                }
     2939            }
     2940          else if (use == &Use::current ())
     2941            {
     2942              m_ISLOCAL = "is_local";
     2943            }
     2944
     2945          m_ISINCLUDED = "is_included";
     2946          for (int j = 0; j < path_exclusions.size (); j++)
     2947            {
     2948              const Project* sp = path_exclusions[j];
     2949              if (up)
     2950                {
     2951                  if (up == sp)
     2952                    {
     2953                      m_ISINCLUDED = "is_not_included";
     2954                    }
     2955                }
     2956              else
     2957                {
     2958                  if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0)
     2959                    {
     2960                      m_ISINCLUDED = "is_not_included";
     2961                    }
     2962                }
     2963            }
    29172964
    29182965          temp = use->get_full_path ();
     
    29272974              temp += "mgr";
    29282975              break;
     2976            default:
     2977              break;
    29292978            }
    29302979#ifdef WIN32
     
    29322981#endif
    29332982          m_PACKAGEMGRPATH = temp;
    2934           //      fprintf (m_output_file, "%s\n", temp.c_str());
    29352983
    29362984          temp = "";
     
    29563004#endif
    29573005          m_PACKAGEFULLNAME = temp;
    2958           //      fprintf (m_output_file, "%s\n", temp.c_str());
    29593006
    29603007          m_PACKAGE = use->get_package_name ();
     
    29913038            }
    29923039
    2993           if (!package_fragment.copy (m_output_file, 6,
     3040          if (!package_fragment.copy (m_output_file, 7,
    29943041                                      &m_PACKAGE, &m_PACKAGEPREFIX,
    29953042                                      &m_DEPENDENCIES,
    29963043                                      &m_PACKAGEMGRPATH, &m_PACKAGEFULLNAME,
    2997                                       &m_ISLOCAL)) return;
     3044                                      &m_ISLOCAL, &m_ISINCLUDED)) return;
    29983045        }
    29993046
     
    30163063
    30173064      CmtSystem::close_ostream (m_output_file, new_file_name);
    3018       //  fclose (m_output_file);
    30193065
    30203066      commit (new_file_name);
  • CMT/HEAD/source/cmt_generators.h

    r628 r652  
    239239  Variable m_PACKAGEFULLNAME;
    240240  Variable m_ISLOCAL;
     241  Variable m_ISINCLUDED;
    241242
    242243  FragmentHandle packages_header_fragment;
  • CMT/HEAD/source/cmt_parser.cxx

    r649 r652  
    1010#include <string.h>
    1111#include <ctype.h>
     12#include <errno.h>
    1213
    1314//----------------------------------------------------------
     
    4849{
    4950  clear ();
     51
     52  cmt_string tags = CmtSystem::getenv ("CMTEXTRATAGS");
     53  CmtSystem::cmt_string_vector words;
     54  CmtSystem::split (tags, " \t,", words);
     55  for (int i = 0; i < words.size (); i++)
     56    {
     57      bool has (false);
     58      for (int j = 0; j < m_extra_tags.size (); j++)
     59        {
     60          if (m_extra_tags[j] == words[i])
     61            {
     62              has = true;
     63              break;
     64            }
     65        }
     66      if (!has)
     67        m_extra_tags.push_back (words[i]);
     68    }
    5069}
    5170
     
    5978  m_build_nmake    = false;
    6079  m_cmt_config     = "";
    61   //m_cmt_path.clear ();
    62   //m_cmt_path_pwds.clear ();
    63   //m_cmt_path_sources.clear ();
    6480  m_cmt_root       = "";
     81  m_cmt_home       = "";
     82  m_cmt_user_context = "";
     83  m_cmt_site       = "";
    6584  m_cmt_version    = "";
    6685  m_use_cmt        = true;
     86
    6787  m_current_dir     = "";
    6888  m_current_file_path = "";
     
    7494  m_current_offset  = "";
    7595
    76   m_current_access   = DeveloperMode;
     96  m_current_access  = UserMode;
     97  m_current_style   = cmt_style;
     98  m_current_structuring_style = default_structuring_style;
    7799
    78100  m_current_tag      = "";
    79101  m_current_target   = "";
    80102  m_current_version  = "";
     103
     104  //  m_extra_tags       = "";
     105  m_extra_tags.clear ();
     106  m_tags.clear ();
     107  m_tags_add.clear ();
     108  m_tags_remove.clear ();
     109
     110  m_configure_error  = "";
     111
     112  m_debug = (::getenv ("CMTDEBUG") != 0) ? true : false;
     113
    81114  m_default_path     = "";
    82 
    83   //m_quiet            = false;
    84 
     115  m_quiet            = false;
    85116  m_disable_warnings = false;
    86117  m_warnings         = false;
     
    91122
    92123  m_standard_macros_done = false;
    93   m_current_access = UserMode;
    94   m_current_style = cmt_style;
    95   m_current_structuring_style = default_structuring_style;
    96124  m_all_sets_done = false;
     125
    97126  m_autoconfigure_cmtpath = false;
    98   m_debug = false;
    99   if (getenv ("CMTDEBUG") != 0) m_debug = true;
    100127}
    101128
     
    497524void Cmt::clear ()
    498525{
    499   Me.m_quiet = false;
    500526  Me.clear ();
     527  //Me.m_quiet = false;
    501528
    502529  Database::clear ();
     
    515542  if (configured) return;
    516543
    517   Me.clear ();
     544  //  Me.clear ();
    518545
    519546  log << "configure_cmt_message" << log_endl;
     
    533560  log << "configure_site_tag" << log_endl;
    534561  configure_site_tag (0);
     562
     563  if (Me.m_current_package.size () != 0 &&
     564      Me.m_current_package != "cmt_standalone")
     565    { // we have a package name (not "cmt_standalone")
     566      Use& use = Use::current();
     567      use.set (Me.m_current_package,
     568               Me.m_current_version,
     569               Me.m_current_path);
     570      if (CmtSystem::absolute_path (Me.m_current_path))
     571        {
     572          if (!use.move_to ())
     573            {
     574              CmtError::set (CmtError::package_not_found, use.get_info ());
     575              return;
     576            }
     577        }
     578      else
     579        {
     580          if (!use.move_to ("", true))
     581            {
     582              // will try again later from CMTPATH entries
     583            }
     584        }
     585    }
     586  else
     587    {
     588      if (Me.m_current_path.size () != 0 &&
     589          !CmtSystem::cd (Me.m_current_path))
     590        {
     591          CmtError::set (CmtError::path_not_found, Me.m_current_path);
     592          return;
     593        }
     594    }
     595
    535596  log << "configure_current_dir" << log_endl;
    536597  configure_current_dir ();
     
    540601  //  log << "configure_current_dir" << log_endl;
    541602
    542 
    543603  bool save_quiet = Me.m_quiet;
    544604  Me.m_quiet = true;
     
    554614  guess_current_project ();
    555615
     616  if (Me.m_current_package.size () != 0 &&
     617      Me.m_current_package != "cmt_standalone")
     618    {
     619      Use& use = Use::current();
     620      if (!use.located ())
     621        {
     622          if (!use.move_to ())
     623            {
     624              CmtError::set (CmtError::package_not_found, use.get_info ());
     625              return;
     626            }
     627          else
     628            {
     629              use.get_full_path (Me.m_current_dir);
     630              switch (use.style)
     631                {
     632                case cmt_style:
     633                  Me.m_current_dir += CmtSystem::file_separator ();
     634                  Me.m_current_dir += "cmt";
     635                  break;
     636                case mgr_style:
     637                  Me.m_current_dir += CmtSystem::file_separator ();
     638                  Me.m_current_dir += "mgr";
     639                  break;
     640                default:
     641                  break;
     642                }
     643              Me.m_current_file_path = Me.m_current_dir;
     644
     645              Project::order_all ();
     646              Cmt::guess_current_project ();
     647            }
     648        }
     649    }
     650
    556651  log << "configure_current_structuring_style" << log_endl;
    557652  //  configure_current_structuring_style ();
     
    562657
    563658  Use& use = Use::current();
    564 
    565   use.set (Me.m_current_package,
    566            Me.m_current_version,
    567            Me.m_current_path,
    568            "",
    569            "");
    570 
    571   use.style = Me.m_current_style;
    572   use.structuring_style = Me.m_current_structuring_style;
    573 
    574   use.change_path (Me.m_current_path);
     659  if (!use.located ())
     660    {
     661      use.set (Me.m_current_package,
     662               Me.m_current_version,
     663               Me.m_current_path);
     664      use.style = Me.m_current_style;
     665
     666      if (use.style != none_style)
     667        {
     668          use.structuring_style = Me.m_current_structuring_style;
     669          use.change_path (Me.m_current_path, Project::get_current ());
     670        }
     671      else
     672        {
     673          use.real_path = Me.m_current_path;
     674        }
     675    }
     676  else if (const Project * p = Project::get_current ())
     677    {
     678      use.set_project (p);
     679    }
    575680
    576681  if (CmtError::has_pending_error ())
     
    621726{
    622727  Use& current_use = Use::current ();
    623 
     728  current_use.get_cmtpath_and_offset (Me.m_current_cmtpath, Me.m_current_offset);
     729  /*
    624730  Me.m_current_cmtpath = "";
    625731  Me.m_current_offset = "";
     
    633739
    634740      Me.m_current_offset = current_use.path;
    635 
     741  */
    636742      /**
    637743         try to remove this current CMTPATH entry from path.  This
     
    639745         absolute path.
    640746      */
    641      
     747  /*     
    642748      Me.m_current_offset.replace (Me.m_current_cmtpath, empty_string);
    643749      if (Me.m_current_offset[0] == CmtSystem::file_separator ())
     
    648754        }
    649755    }
     756  */
    650757}
    651758
     
    788895  Me.m_current_file_path = mount_filter.get_current_dir ();
    789896
    790   cmt_string t = Me.m_current_file_path;
     897  //  cmt_string t = Me.m_current_file_path;
    791898}
    792899
     
    800907    standard directory tree (i.e. <package>/<version>/cmt or mgr)
    801908  */
     909  Use& use = Use::current();
     910  if (use.located ())
     911    {
     912      Me.m_current_style = use.style;
     913      build_prefix (Me.m_current_package, Me.m_current_prefix);
     914      build_config (Me.m_current_prefix, Me.m_current_config);
     915      return;
     916    }
    802917
    803918  cmt_string req = "..";
     
    10621177      // Do NOT (re)set m_current_structuring_style yet
    10631178      // (as requirements may NOT exist, so this is not a package)
    1064       // rather do it in reach_current_package (if/when requirements is read)
     1179      // rather do it in use_current_package (if/when requirements is read)
    10651180      //Me.m_current_structuring_style = without_version_directory;
    10661181      build_prefix (Me.m_current_package, Me.m_current_prefix);
     
    10741189{
    10751190  cmt_string s;
    1076   s = CmtSystem::getenv ("CMTSTRUCTURINGSTYLE");
    1077   if (s == "without_version_directory")
    1078     {
    1079       Me.m_current_structuring_style = without_version_directory;
    1080     }
    1081   else if (s == "with_version_directory")
    1082     {
    1083       Me.m_current_structuring_style = with_version_directory;
    1084     }
    1085 
    1086   CmtSystem::cmt_string_vector flags;
    1087   Cmt::get_cmt_flags (flags);
    1088   for (int i = 0; i < flags.size (); i++)
    1089     {
    1090       const cmt_string& flag = flags[i];
    1091       if (flag == "-without_version_directory")
     1191  if (Me.m_current_structuring_style == default_structuring_style)
     1192    {
     1193      s = CmtSystem::getenv ("CMTSTRUCTURINGSTYLE");
     1194      if (s == "without_version_directory")
    10921195        {
    10931196          Me.m_current_structuring_style = without_version_directory;
    10941197        }
    1095       else if (flag == "-with_version_directory")
     1198      else if (s == "with_version_directory")
    10961199        {
    10971200          Me.m_current_structuring_style = with_version_directory;
    1098         }
    1099     }
    1100 
    1101   for (int i = 1; i < ap.argc; i++)
    1102     {
    1103       const cmt_string& arg = ap.argv[i];
    1104       if (arg[0] != '-') break;
    1105       if (arg == "-without_v" ||
    1106           arg == "-without_ve" ||
    1107           arg == "-without_ver" ||
    1108           arg == "-without_vers" ||
    1109           arg == "-without_versi" ||
    1110           arg == "-without_versio" ||
    1111           arg == "-without_version" ||
    1112           arg == "-without_version_" ||
    1113           arg == "-without_version_d" ||
    1114           arg == "-without_version_di" ||
    1115           arg == "-without_version_dir" ||
    1116           arg == "-without_version_dire" ||
    1117           arg == "-without_version_direc" ||
    1118           arg == "-without_version_direct" ||
    1119           arg == "-without_version_directo" ||
    1120           arg == "-without_version_director" ||
    1121           arg == "-without_version_directory")
    1122         {
    1123           Me.m_current_structuring_style = without_version_directory;
    1124           //      if (!CmtSystem::putenv ("CMTSTRUCTURINGSTYLE", "without_version_directory"))
    1125           //        CmtMessage::error ("Cannot set `CMTSTRUCTURINGSTYLE' to"
    1126           //                           " `without_version_directory' in the environment");
    1127           if (!Cmt::add_cmt_flag ("-without_version_directory"))
    1128             CmtMessage::error ("Cannot add flag `-without_version_directory'");
    1129         }
    1130       else if (arg == "-with_v" ||
    1131                arg == "-with_ve" ||
    1132                arg == "-with_ver" ||
    1133                arg == "-with_vers" ||
    1134                arg == "-with_versi" ||
    1135                arg == "-with_versio" ||
    1136                arg == "-with_version" ||
    1137                arg == "-with_version_" ||
    1138                arg == "-with_version_d" ||
    1139                arg == "-with_version_di" ||
    1140                arg == "-with_version_dir" ||
    1141                arg == "-with_version_dire" ||
    1142                arg == "-with_version_direc" ||
    1143                arg == "-with_version_direct" ||
    1144                arg == "-with_version_directo" ||
    1145                arg == "-with_version_director" ||
    1146                arg == "-with_version_directory")
    1147         {
    1148           Me.m_current_structuring_style = with_version_directory;
    1149           //      if (!CmtSystem::putenv ("CMTSTRUCTURINGSTYLE", "with_version_directory"))
    1150           //        CmtMessage::error ("Cannot set `CMTSTRUCTURINGSTYLE' to"
    1151           //                           " `with_version_directory' in the environment");
    1152           if (!Cmt::add_cmt_flag ("-with_version_directory"))
    1153             CmtMessage::error ("Cannot add flag `-with_version_directory'");
     1201        }
     1202     
     1203      CmtSystem::cmt_string_vector flags;
     1204      Cmt::get_cmt_flags (flags);
     1205      for (int i = 0; i < flags.size (); i++)
     1206        {
     1207          const cmt_string& flag = flags[i];
     1208          if (flag == "-without_version_directory")
     1209            {
     1210              Me.m_current_structuring_style = without_version_directory;
     1211            }
     1212          else if (flag == "-with_version_directory")
     1213            {
     1214              Me.m_current_structuring_style = with_version_directory;
     1215            }
     1216        }
     1217    }
     1218 
     1219  if (Me.m_current_structuring_style != default_structuring_style)
     1220    {
     1221      StrategyDef* def = StrategyMgr::find_strategy ("VersionDirectory");
     1222      if (def != 0)
     1223        {
     1224          def->m_default_value =
     1225            Me.m_current_structuring_style == with_version_directory;
     1226          def->m_priority_value =
     1227            Me.m_current_structuring_style == without_version_directory;
    11541228        }
    11551229    }
     
    11711245void Cmt::configure_home (Use* use)
    11721246{
    1173   Me.m_cmt_home = "";
    1174 
    1175   Symbol* symbol = Symbol::find ("CMTHOME");
    1176   if (symbol != 0)
    1177     {
    1178       Me.m_cmt_home = symbol->build_macro_value ();
    1179       Symbol::expand (Me.m_cmt_home);
    1180     }
    1181   else if (CmtSystem::testenv ("CMTHOME"))
    1182     {
    1183       Me.m_cmt_home = CmtSystem::getenv ("CMTHOME");
     1247  if (Me.m_cmt_home.size () == 0)
     1248    {
     1249      // if not passed on the command line
     1250      if (const Symbol* symbol = Symbol::find ("CMTHOME"))
     1251        {
     1252          Me.m_cmt_home = symbol->build_macro_value ();
     1253          Symbol::expand (Me.m_cmt_home);
     1254        }
     1255      else if (CmtSystem::testenv ("CMTHOME"))
     1256        {
     1257          Me.m_cmt_home = CmtSystem::getenv ("CMTHOME");
     1258        }
    11841259    }
    11851260
     
    11951270void Cmt::configure_user_context (Use* use)
    11961271{
    1197   Me.m_cmt_user_context = "";
    1198 
    1199   Symbol* symbol = Symbol::find ("CMTUSERCONTEXT");
    1200   if (symbol != 0)
    1201     {
    1202       Me.m_cmt_user_context = symbol->build_macro_value ();
    1203       Symbol::expand (Me.m_cmt_user_context);
    1204     }
    1205   else if (CmtSystem::testenv ("CMTUSERCONTEXT"))
    1206     {
    1207       Me.m_cmt_user_context = CmtSystem::getenv ("CMTUSERCONTEXT");
     1272  if (Me.m_cmt_user_context.size () == 0)
     1273    {
     1274      // if not passed on the command line
     1275      if (const Symbol* symbol = Symbol::find ("CMTUSERCONTEXT"))
     1276        {
     1277          Me.m_cmt_user_context = symbol->build_macro_value ();
     1278          Symbol::expand (Me.m_cmt_user_context);
     1279        }
     1280      else if (CmtSystem::testenv ("CMTUSERCONTEXT"))
     1281        {
     1282          Me.m_cmt_user_context = CmtSystem::getenv ("CMTUSERCONTEXT");
     1283        }
    12081284    }
    12091285
     
    12721348
    12731349  Cmt::configure_tags (use);
     1350
     1351  cmt_string s, t;
     1352  if (0 < Me.m_extra_tags.size ())
     1353    {
     1354      s = "CMTEXTRATAGS";
     1355      t = use != 0 ? use->get_package_name () : s;
     1356    }
     1357  for (int i = 0; i < Me.m_extra_tags.size (); i++)
     1358    {
     1359      Tag* tag = Tag::add (Me.m_extra_tags[i], PriorityUserTag, s, use);
     1360      tag->mark (t);
     1361    }
     1362
     1363  for (int i = 0; i < Me.m_tags.size (); i++)
     1364    {
     1365      const cmt_string& a = Me.m_tags[i];
     1366      if (i == 0)
     1367        {
     1368          Me.m_current_tag = a;
     1369        }
     1370//       // Then restore uname if the specified tag is CMTCONFIG
     1371//       if (a == CmtSystem::get_cmt_config ())
     1372//      {
     1373//        Cmt::configure_uname_tag ();
     1374//      }
     1375      Tag* tag = Tag::add (a, PriorityArgument, "arguments", 0);
     1376      tag->mark ("arguments");
     1377    }
     1378
     1379  for (int i = 0; i < Me.m_tags_add.size (); i++)
     1380    {
     1381      const cmt_string& a = Me.m_tags_add[i];
     1382//       // Then restore uname if the specified tag is CMTCONFIG
     1383//       if (a == CmtSystem::get_cmt_config ())
     1384//      {
     1385//        Cmt::configure_uname_tag ();
     1386//      }
     1387      Tag* tag = Tag::add (a, PriorityUserTag, "arguments", 0);
     1388      tag->mark ("arguments");
     1389    }
    12741390
    12751391  /*
     
    12771393  */
    12781394
     1395  /*
    12791396  if (CmtSystem::testenv ("CMTEXTRATAGS"))
    12801397    {
     
    13091426        }
    13101427    }
     1428  */
    13111429}
    13121430
     
    13191437
    13201438  log << "current_tag=" << Me.m_current_tag << log_endl;
     1439
     1440  cmt_string s = "CMTCONFIG";
    13211441
    13221442  Symbol* symbol = Symbol::find ("CMTCONFIG");
     
    13471467    {
    13481468      config_tag = CmtSystem::getenv ("CMTBIN");
     1469      s = "CMTBIN";
    13491470    }
    13501471
     
    13521473    {
    13531474      CmtSystem::get_uname (config_tag);
     1475      s = "uname";
    13541476    }
    13551477
    13561478  log << "current_tag=" << Me.m_current_tag << log_endl;
    13571479
    1358   cmt_string s = "CMTCONFIG";
     1480  //  cmt_string s = "CMTCONFIG";
    13591481  cmt_string t = s;
    13601482
     
    15521674          if (CmtMessage::level () != Warning)
    15531675            CmtMessage::set_level (Warning);
    1554           //      if (CmtMessage::level () > Warning)
    1555         }
    1556     }
    1557 
    1558   for (int i = 1; i < ap.argc; i++)
    1559     {
    1560       const cmt_string& arg = ap.argv[i];
    1561       if (arg[0] != '-') break;
    1562       if (arg == "-d" ||
    1563           arg == "-di" ||
    1564           arg == "-dis" ||
    1565           arg == "-disa" ||
    1566           arg == "-disab" ||
    1567           arg == "-disabl" ||
    1568           arg == "-disable" ||
    1569           arg == "-disable_" ||
    1570           arg == "-disable_w" ||
    1571           arg == "-disable_wa" ||
    1572           arg == "-disable_war" ||
    1573           arg == "-disable_warn" ||
    1574           arg == "-disable_warni" ||
    1575           arg == "-disable_warnin" ||
    1576           arg == "-disable_warning" ||
    1577           arg == "-disable_warnings")
    1578         {
    1579           Me.m_disable_warnings = true;
    1580           if (CmtMessage::level () <= Warning)
    1581             {
    1582               CmtMessage::set_level (Error);
    1583               //              if (!CmtSystem::putenv ("CMTERROR", "1"))
    1584               //                CmtMessage::error ("Cannot set `CMTERROR' in the environment");
    1585             }
    1586           if (!Cmt::add_cmt_flag ("-disable_warnings"))
    1587             CmtMessage::error ("Cannot add flag `-disable_warnings'");
    1588         }
    1589       else if (arg == "-q" ||
    1590                arg == "-qu" ||
    1591                arg == "-qui" ||
    1592                arg == "-quie" ||
    1593                arg == "-quiet")
    1594         {
    1595           Me.m_quiet = true;
    1596           if (CmtMessage::level () <= Error)
    1597             {
    1598               CmtMessage::set_level (Fatal);
    1599               //              if (!CmtSystem::putenv ("CMTFATAL", "1"))
    1600               //                CmtMessage::error ("Cannot set `CMTFATAL' in the environment");
    1601             }
    1602           if (!Cmt::add_cmt_flag ("-quiet"))
    1603             CmtMessage::error ("Cannot add flag `-quiet'");
    1604         }
    1605       else if (arg == "-warn" ||
    1606                arg == "-warni" ||
    1607                arg == "-warnin" ||
    1608                arg == "-warning" ||
    1609                arg == "-warnings")
    1610         {
    1611           Me.m_warnings = true;
    1612           //      if (CmtMessage::level () > Warning)
    1613           if (CmtMessage::level () != Warning)
    1614             {
    1615               CmtMessage::set_level (Warning);
    1616               //              if (!CmtSystem::putenv ("CMTWARNING", "1"))
    1617               //                CmtMessage::error ("Cannot set `CMTWARNING' in the environment");
    1618             }
    1619           if (!Cmt::add_cmt_flag ("-warnings"))
    1620             CmtMessage::error ("Cannot add flag `-warnings'");
    16211676        }
    16221677    }
     
    16681723
    16691724  CmtSystem::cmt_string_vector uses;
     1725  cmt_vector<int> use_indexes;
    16701726  CmtSystem::cmt_string_vector packages;
    16711727  CmtSystem::cmt_string_vector versions;
    1672   CmtSystem::cmt_string_vector path_selections;
     1728  Project::ConstProjectPtrVector path_selections;
     1729  //  CmtSystem::cmt_string_vector path_selections;
     1730  Project::ConstProjectPtrVector path_exclusions;
    16731731  CmtSystem::cmt_string_vector selections;
    16741732  CmtSystem::cmt_string_vector exclusions;
     
    16771735  bool is_cmt = false;
    16781736  int first = 0;
    1679   int i;
    16801737  bool ignore_errors = false;
    16811738  bool all_packages = false;
    1682 
     1739  int depth (1);
    16831740  bool local = true;
    1684 
    1685   for (i = 0; i < ap.arguments.size (); i++)
     1741  bool global (false);
     1742
     1743  for (int i = 0; i < ap.arguments.size (); i++)
    16861744    {
    16871745      const cmt_string& w = ap.arguments[i];
     
    16991757            {
    17001758              local = false;
     1759              global = false;
    17011760
    17021761              cmt_string depth_str;
    1703               int depth_value = 0;
     1762              int depth_value;
    17041763                         
    17051764              w.substr (7, depth_str);
    1706               if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) ||
    1707                   (depth_value < 1))
    1708                 {
     1765              int n = sscanf (depth_str.c_str (), "%d", &depth_value);
     1766              cmt_string msg;
     1767              switch (n)
     1768                {
     1769                case EOF:
     1770                  msg = "Cannot read `depth' value `";
     1771                  msg += depth_str;
     1772                  msg += cmt_string ("'");
     1773                  if (errno)
     1774                    msg += cmt_string (strerror (errno));
     1775                  CmtError::set (CmtError::system_error, msg);
     1776                  return;
     1777                  break;
     1778                case 0:
     1779                  msg = "Invalid `depth' value `";
     1780                  msg += depth_str;
     1781                  msg += cmt_string ("'");
     1782                  CmtError::set (CmtError::syntax_error, msg);
     1783                  return;
     1784                  break;
     1785                case 1:
     1786                  if (depth_value < -1)
     1787                    {
     1788                      char num[32]; sprintf (num, "%lu", -depth_value);
     1789                      msg = "Invalid `depth' value `-";
     1790                      msg += num;
     1791                      msg += cmt_string ("'");
     1792                      CmtError::set (CmtError::syntax_error, msg);
     1793                      return;
     1794                    }
     1795                  depth = depth_value;
     1796                  //cerr << "depth: " << depth << endl;
     1797                  break;
     1798                default:
     1799                  break;
     1800                }
     1801//               if ((sscanf (depth_str.c_str (), "%d", &depth_value) < 1) ||
     1802//                   (depth_value < 1))
     1803//                {
    17091804                  // Syntax error
    17101805                  //  We shall restrict to packages found within
     
    17121807                  //  If CMTPATH is empty, nothing is selected.
    17131808                  // depth=1 is equivalent to local
    1714                 }
    1715 
    1716               Project::fill_selection (depth_value, path_selections);
     1809//                }
     1810
     1811//            Project::fill_selection (depth_value, path_selections);
    17171812            }
    17181813          else if (w.substr (0, 9) == "-exclude=")
     
    17381833          else if (w.substr (0, 7) == "-global")
    17391834            {
    1740               path_selections.clear ();
    1741 
     1835              //path_selections.clear ();
     1836              global = true;
    17421837              local = false;
    17431838            }
     
    17451840            {
    17461841              local = true;
     1842              global = false;
    17471843            }
    17481844          else if (w.substr (0, 8) == "-select=")
     
    17871883    }
    17881884
    1789   if (local)
    1790     {
    1791       Project::fill_selection (1, path_selections);
     1885  const Project* p_cur (Project::get_current ());
     1886  if (global)
     1887    {
     1888      Project::fill_exclusion (path_exclusions);
     1889    }
     1890  else if (local)
     1891    {
     1892      if (p_cur)
     1893        Project::fill_selection (1, path_selections);
     1894      else
     1895        path_selections.push_back (0); // means that we want Use::current ()
     1896      //        path_selections.push_back ((Use::current ()).get_realpath ());
     1897    }
     1898  else
     1899    {
     1900      if (!p_cur
     1901          && depth != 0
     1902          && depth != -1)
     1903        path_selections.push_back (0); // means that we want Use::current ()
     1904//      path_selections.push_back ((Use::current ()).get_realpath ());
     1905      Project::fill_selection (depth, path_selections);
     1906      /*
     1907      cerr << "depth: " << depth << endl;
     1908      for (int j = 0; j < path_selections.size (); j++)
     1909        {
     1910          const Project* sp = path_selections[j];
     1911          cerr << "path_selections: " << (sp ? sp->get_cmtpath () : "current use") << endl;
     1912        }
     1913      */
    17921914    }
    17931915
     
    18001922  //if (command.substr (0, 3) == "cmt") is_cmt = true;
    18011923
    1802   cmt_string curuse = CmtSystem::pwd ();
     1924  //cmt_string curuse = CmtSystem::pwd ();
    18031925  if (all_packages)
    18041926    {
     
    18061928      PathScanner scanner;
    18071929      Project::scan_paths (scanner, selector);
     1930      return;
    18081931    }
    18091932  else
    18101933    {
    1811       for (i = Uses.size () - 1; i >= 0; i--)
     1934      for (int i = Uses.size () - 1; i >= 0; i--)
    18121935        {
    18131936          Use* use = Uses[i];
     
    18151938          if (use->discarded) continue;
    18161939          if (use->m_hidden) continue;
    1817 
    18181940          if (!use->located ())
    18191941            {
    1820               CmtMessage::warning ("package " + use->get_package_name ()
    1821                                    + " " + use->version + " " + use->path
    1822                                    + " not found");
    1823               /*
    1824               if (!Me.m_quiet)
    1825                 {
    1826                   cerr << "#CMT> package " << use->get_package_name () <<
    1827                     " " << use->version << " " << use->path <<
    1828                     " not found" <<
    1829                     endl;
    1830                 }
    1831               */
     1942              CmtMessage::warning
     1943                (CmtError::get_error_name (CmtError::package_not_found)
     1944                 + ": " + use->get_info ());
     1945              continue;
    18321946            }
    1833           else
    1834             {
    1835               if (use->get_package_name () != "CMT")
    1836                 {
    1837                   cmt_string& s = uses.add ();
    1838 
    1839                   use->get_full_path (s);
    1840 
    1841                   s += CmtSystem::file_separator ();
    1842                   if (use->style == mgr_style) s += "mgr";
    1843                   else s += "cmt";
    1844 
    1845                   cmt_string& v = versions.add ();
    1846                   v = use->version;
    1847 
    1848                   cmt_string& p = packages.add ();
    1849                   p = use->get_package_name ();
    1850                 }
    1851             }
    1852         }
     1947          if (use->get_package_name () == "CMT") continue;
     1948
     1949          cmt_string& s = uses.add ();
     1950          use->get_full_path (s);
     1951          switch (use->style)
     1952            {
     1953            case cmt_style:
     1954              s += CmtSystem::file_separator ();
     1955              s += "cmt";
     1956              break;
     1957            case mgr_style:
     1958              s += CmtSystem::file_separator ();
     1959              s += "mgr";
     1960              break;
     1961            default:
     1962              break;
     1963            }
     1964//                   if (use->style == mgr_style) s += "mgr";
     1965//                   else s += "cmt";
     1966
     1967          cmt_string& v = versions.add ();
     1968          v = use->version;
     1969         
     1970          cmt_string& p = packages.add ();
     1971          p = use->get_package_name ();
     1972         
     1973          int& use_index = use_indexes.add ();
     1974          use_index = i;
     1975        }
    18531976         
    18541977      {
     1978        Use* use = &(Use::current ());
     1979       
    18551980        cmt_string& s = uses.add ();
     1981        use->get_full_path (s);
     1982        switch (use->style)
     1983          {
     1984          case cmt_style:
     1985            s += CmtSystem::file_separator ();
     1986            s += "cmt";
     1987            break;
     1988          case mgr_style:
     1989            s += CmtSystem::file_separator ();
     1990            s += "mgr";
     1991            break;
     1992          default:
     1993            break;
     1994          }
     1995//         if (use->get_package_name ().find ("cmt_standalone") != cmt_string::npos)
     1996//           {
     1997//             s = CmtSystem::pwd ();
     1998//           }
     1999//         else
     2000//           {
     2001//             use->get_full_path (s);
     2002
     2003//             s += CmtSystem::file_separator ();
    18562004                 
    1857         Use* use = &(Use::current ());
    1858 
    1859         if (use->get_package_name ().find ("cmt_standalone") != cmt_string::npos)
    1860           {
    1861             s = CmtSystem::pwd ();
    1862           }
    1863         else
    1864           {
    1865             use->get_full_path (s);
    1866 
    1867             s += CmtSystem::file_separator ();
    1868                  
    1869             if (use->style == mgr_style) s += "mgr";
    1870             else s += "cmt";
    1871           }
    1872 
    1873         curuse = s;
     2005//             if (use->style == mgr_style) s += "mgr";
     2006//             else s += "cmt";
     2007//           }
     2008        //curuse = s;
    18742009
    18752010        cmt_string& v = versions.add ();
     
    18782013        cmt_string& p = packages.add ();
    18792014        p = use->get_package_name ();
     2015         
     2016        int& use_index = use_indexes.add ();
     2017        use_index = -1;
    18802018      }
    18812019    }
     
    18912029    CmtSystem::putenv ("CMTBCAST", "");
    18922030
    1893   for (i = 0; i < uses.size (); i++)
     2031  for (int i = 0; i < uses.size (); i++)
    18942032    {
    18952033      const cmt_string& s = uses[i];
    18962034      const cmt_string& v = versions[i];
    18972035      const cmt_string& p = packages[i];
     2036      const int use_index = use_indexes[i];
     2037
     2038      const Use* use = use_index >= 0 ? Uses[use_index] : &(Use::current ());
     2039      const Project* up = use->get_project ();
     2040
    18982041      cmt_string cmtpath;
    18992042
    19002043      bool ok = true;
    1901       bool selected = true;
     2044      bool selected = global ? true : false;
    19022045      bool excluded = false;
    19032046
    1904       /**
    1905          Ensure that the current package is not skipped
    1906          due to symlinks in the paths
    1907        */
    1908       //      if (path_selections.size () > 0)
    1909       if (path_selections.size () > 0 && s != curuse)
     2047      ok = selected;
     2048      if (path_selections.size () > 0)
    19102049        {
    19112050          selected = false;
    1912 
    19132051          for (int j = 0; j < path_selections.size (); j++)
    19142052            {
    1915               const cmt_string& sel = path_selections[j];
    1916              
    1917               if (s.find (sel) != cmt_string::npos)
    1918                 {
    1919                   cmtpath = sel;
    1920                   selected = true;
    1921                   break;
    1922                 }
    1923             }
    1924 
     2053              const Project* sp = path_selections[j];
     2054              if (sp)
     2055                {
     2056                  if (up)
     2057                    {
     2058                      if (up == sp)
     2059                        {
     2060                          cmtpath = sp->get_cmtpath ();
     2061                          selected = true;
     2062                          break;
     2063                        }
     2064                    }
     2065                  else
     2066                    {
     2067                      if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0)
     2068                        {
     2069                          cmtpath = sp->get_cmtpath ();
     2070                          selected = true;
     2071                          break;
     2072                        }
     2073                    }
     2074                }
     2075              else if (use == &(Use::current ()))
     2076                {
     2077                  // means that we want Use::current ()
     2078                  // cmtpath = sp->get_cmtpath ();
     2079                  if (up)
     2080                    cmtpath = up->get_cmtpath ();
     2081                  else
     2082                    cmtpath = "";
     2083                  selected = true;
     2084                  break;
     2085                }
     2086              // const cmt_string& sel = path_selections[j];
     2087              // if (s.find (sel) != cmt_string::npos)
     2088//                 {
     2089//                cmtpath = sel;
     2090//                   selected = true;
     2091//                   break;
     2092//                 }
     2093            }
    19252094          ok = selected;
    19262095        }
     
    19602129        }
    19612130
    1962 
    19632131      if (ok)
    19642132        {
     
    19742142                  break;
    19752143                }
     2144            }
     2145
     2146          if (excluded) ok = false;
     2147        }
     2148
     2149      if (ok)
     2150        {
     2151          excluded = false;
     2152          for (int j = 0; j < path_exclusions.size (); j++)
     2153            {
     2154              const Project* sp = path_exclusions[j];
     2155              if (up)
     2156                {
     2157                  if (up == sp)
     2158                    {
     2159                      excluded = true;
     2160                      break;
     2161                    }
     2162                }
     2163              else
     2164                {
     2165                  if (use->get_realpath ().find (sp->get_cmtpath_real ()) == 0)
     2166                    {
     2167                      excluded = true;
     2168                      break;
     2169                    }
     2170                }
    19762171            }
    19772172
     
    20212216        }
    20222217
     2218      /*
    20232219      if (cmtpath == "")
    20242220        {
     
    20262222          cmtpath = Project::find_in_cmt_paths (sel);
    20272223        }
     2224      */
    20282225
    20292226      cmt_string cmd = command;
     
    20412238      static const cmt_string empty_string;
    20422239      static const cmt_string fs = CmtSystem::file_separator ();
    2043       cmt_string offset = s;
    2044       offset.replace (cmtpath, empty_string);
    2045       if (offset[0] == CmtSystem::file_separator ())
    2046         {
    2047           offset.replace (fs, empty_string);
    2048         }
    2049       CmtSystem::dirname (offset, offset);
    2050 
    2051       cmt_string n;
    2052       CmtSystem::basename (offset, n);
    2053       if (n == p)
    2054         {
     2240      cmt_string offset;
     2241      if (cmtpath.size ())
     2242        {
     2243          offset = s;
     2244          offset.replace (cmtpath, empty_string);
     2245          if (offset[0] == CmtSystem::file_separator ())
     2246            {
     2247              offset.replace (fs, empty_string);
     2248            }
    20552249          CmtSystem::dirname (offset, offset);
     2250         
     2251          cmt_string n;
     2252          CmtSystem::basename (offset, n);
     2253          if (n == p)
     2254            {
     2255              CmtSystem::dirname (offset, offset);
     2256            }
     2257          else
     2258            {
     2259              CmtSystem::dirname (offset, offset);
     2260              CmtSystem::dirname (offset, offset);
     2261            }
    20562262        }
    20572263      else
    20582264        {
    2059           CmtSystem::dirname (offset, offset);
    2060           CmtSystem::dirname (offset, offset);
    2061         }
    2062 
     2265          offset = use->real_path;
     2266        }
    20632267      cmd.replace_all (offset_template, offset);
    20642268
     
    29043108    }
    29053109
    2906   static CmtSystem::cmt_string_vector tags;
     3110  //  static CmtSystem::cmt_string_vector tags;
    29073111
    29083112  if (action_build_constituents_config != get_action ())
    2909     CmtSystem::split (Me.m_extra_tags, " \t,", tags);
    2910 
    2911   for (int i = 0; i < tags.size (); i++)
    2912     {
    2913       const cmt_string& t = tags[i];
    2914 
    2915       tag = Tag::find (t);
    2916       if (tag == 0) continue;
    2917 
    2918       if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
    2919         {
    2920           CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
    2921           //      cerr << "#CMT> The tag " << t << " is not used in any tag expression. Please check spelling" << endl;
     3113    {
     3114    //    CmtSystem::split (Me.m_extra_tags, " \t,", tags);
     3115
     3116    //  for (int i = 0; i < tags.size (); i++)
     3117      //    {
     3118      //      const cmt_string& t = tags[i];
     3119      for (int i = 0; i < Me.m_extra_tags.size (); i++)
     3120        {
     3121          const cmt_string& t = Me.m_extra_tags[i];
     3122          tag = Tag::find (t);
     3123          if (tag == 0) continue;
     3124          if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
     3125            {
     3126              CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
     3127            }
     3128        }
     3129      for (int i = 0; i < Me.m_tags.size (); i++)
     3130        {
     3131          const cmt_string& t = Me.m_tags[i];
     3132          tag = Tag::find (t);
     3133          if (tag == 0) continue;
     3134          if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
     3135            {
     3136              CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
     3137            }
     3138        }
     3139      for (int i = 0; i < Me.m_tags_add.size (); i++)
     3140        {
     3141          const cmt_string& t = Me.m_tags_add[i];
     3142          tag = Tag::find (t);
     3143          if (tag == 0) continue;
     3144          if (!Tag::check_tag_used (tag) && !Symbol::check_tag_used (tag))
     3145            {
     3146              CmtMessage::warning ("The tag " + t + " is not used in any tag expression. Please check spelling");
     3147            }
    29223148        }
    29233149    }
     
    29403166    {
    29413167      CmtMessage::warning ("The CMTSITE value " + env + " is not used in any tag expression. Please check spelling");
    2942       //      cerr << "#CMT> The CMTSITE value " << env << " is not used in any tag expression. Please check spelling" << endl;
    29433168    }
    29443169
     
    44764701
    44774702  Use& use = Use::current();   
     4703  /*
    44784704  use.get_cmtpath_and_offset (cmtpath, offset);
    44794705
    44804706  Project* p = Project::find_by_cmtpath (cmtpath);
    4481 
    4482   cout << p->get_author () << endl;
     4707  */
     4708  if (const Project* p = use.get_project ())
     4709    cout << p->get_author () << endl;
    44834710}
    44844711
     
    45034730  ClientCollector collector (package, version);
    45044731
     4732  /*
    45054733  clear     ();
    45064734  //  configure ();
    45074735  configure (ap);
     4736  */
    45084737
    45094738  cout << "# ----------- Clients of " << package
     
    54255654  log << "guess_current_project" << log_endl;
    54265655
    5427   cmt_string here = CmtSystem::pwd ();
     5656  //  cmt_string here = CmtSystem::pwd ();
    54285657
    54295658  Use& use = Use::current();
     
    54385667    //  if (Project::find_in_cmt_paths (Me.m_current_dir) == "")
    54395668    {
     5669      /*
    54405670      if (!CmtSystem::cd (current_path))
    54415671        {
     
    54445674          return;
    54455675        }
     5676      */
    54465677      cmt_string project_file = "cmt";
    54475678      project_file += CmtSystem::file_separator ();
    54485679      project_file += Project::get_project_file_name ();
    54495680
    5450       cmt_string pwd;
     5681      /*
     5682      cmt_string pwd (CmtSystem::pwd ());
     5683      cmt_string pwd_prev;
     5684      */
     5685      cmt_string dir_cur (current_path);
     5686      cmt_string dir_par;
     5687
     5688      cmt_string proj_file_cur;
    54515689
    54525690      for (;;)
    54535691        {
    5454           pwd = CmtSystem::pwd ();
     5692          /*
     5693          //      pwd = CmtSystem::pwd ();
    54555694          if (CmtSystem::test_file (project_file))
    54565695            {
     
    54625701              break;
    54635702            }
    5464 
    5465           log << "pwd=" << CmtSystem::pwd () << log_endl;
     5703          */
     5704          proj_file_cur = dir_cur;
     5705          proj_file_cur += CmtSystem::file_separator ();
     5706          proj_file_cur += project_file;
     5707          if (CmtSystem::test_file (proj_file_cur))
     5708            {
     5709              //this directory should become the first entry of the CMTPATH
     5710
     5711              IProjectFactory& factory = ProjectFactory::instance ();
     5712              factory.create_project ("", dir_cur, "CurrentProject", 0);
     5713
     5714              break;
     5715            }
     5716
     5717          /*
     5718          log << "pwd=" << pwd << log_endl;
    54665719         
    54675720          if (!CmtSystem::cd (".."))
     
    54715724            }
    54725725
    5473           if (CmtSystem::pwd () == pwd)
     5726          pwd_prev = pwd;
     5727          pwd = CmtSystem::pwd ();
     5728          if (pwd == pwd_prev)
     5729            //    if (CmtSystem::pwd () == pwd)
    54745730            {
    54755731              log << "Looks the same pwd..." << log_endl;
    54765732              break;
    54775733            }
    5478         }
    5479 
    5480       CmtSystem::cd (Me.m_current_dir);
    5481     }
     5734          */
     5735          log << "dir_cur=`" << dir_cur << "'" << log_endl;
     5736          CmtSystem::dirname (dir_cur, dir_par);
     5737          if (dir_par == dir_cur)
     5738            {
     5739              log << "Looks the same dir_cur..." << log_endl;
     5740              break;
     5741            }
     5742          dir_cur = dir_par;
     5743        }
     5744
     5745      //      CmtSystem::cd (Me.m_current_dir);
     5746    } // if (Project::find_in_cmt_paths (current_path) == "")
    54825747
    54835748  //cmt_string buffer = "path CMTPATH \n";
     
    54965761  Me.m_autoconfigure_cmtpath = true;
    54975762
    5498   CmtSystem::cd (here);
     5763  //  CmtSystem::cd (Me.m_current_dir);
     5764  //CmtSystem::cd (here);
    54995765}
    55005766
     
    64096675
    64106676  /**
    6411    * See reach_current_package for an explanation of this call
     6677   * See apply_globals for an explanation of this call
    64126678   */
    64136679  Pattern::apply_all_globals ();
     
    64446710  Me.m_action = action_none;
    64456711
    6446   restore_all_tags (0);
     6712  //  restore_all_tags (0);
    64476713
    64486714#ifdef WIN32
     
    64986764  clear ();
    64996765
     6766  //  Me.clear ();
     6767
     6768  parse_arguments (ap);
     6769
    65006770  //  configure ();
    6501   configure (ap);
    6502 
    6503   CmtError::clear ();
     6771  switch (Me.m_action)
     6772    {
     6773    case action_none :
     6774    case action_build_temporary_name :
     6775    case action_help :
     6776      break;
     6777    default:
     6778      configure (ap);
     6779      restore_all_tags (0);
     6780      break;
     6781    }
     6782 
     6783  //  CmtError::clear ();
    65046784
    65056785  /*
    6506     Set private if positioned inside the package
     6786    Set DeveloperMode if positioned inside the package
    65076787    (which is detected since we were able to retreive the
    65086788    Version, Package and Path)
    65096789  */
    65106790
     6791  if (!Use::current().located ())
     6792  /*
    65116793  if ((Me.m_current_path.size () == 0) ||
    65126794      (Me.m_current_package.size () == 0) ||
    65136795      (Me.m_current_version.size () == 0))
     6796  */
    65146797    {
    65156798      Me.m_current_access = UserMode;
     
    65206803    }
    65216804 
    6522   parse_arguments (ap);
     6805  //  parse_arguments (ap);
    65236806 
    65246807  if (ap.help_action == action_help)
     
    69297212        Me.m_warnings = false;
    69307213        if (strlen (ap.extra_file.c_str ()) == 0)
    6931           reach_current_package ();
     7214          use_current_package ();
     7215        //        reach_current_package ();
    69327216        else
    69337217          use_extra_file (ap.extra_file);
     
    69357219        if (strlen (ap.extra_line.c_str ()) > 0)
    69367220          SyntaxParser::parse_requirements_text (ap.extra_line, "extra statement(s)", (Use*) 0);
     7221        apply_globals ();
    69377222        Me.m_warnings = w;
    6938         //if (strlen (ap.extra_line.c_str ()) > 0) SyntaxParser::parse_requirements_line (ap.extra_line, &(Use::current ()));
    69397223      }
    69407224      break;
     
    69527236  if (use != 0 && !use->discarded && !use->m_hidden && use->located ())
    69537237    uses.push_back (use);
    6954   uses.push_back (&(Use::current()));
     7238  use = &(Use::current());
     7239  if (use != 0 && !use->discarded && !use->m_hidden && use->located ())
     7240    uses.push_back (use);
     7241  //  uses.push_back (&(Use::current()));
    69557242  use = Use::find (CmtSystem::get_user_context_package ());
    69567243  if (use != 0 && !use->discarded && !use->m_hidden && use->located ())
     
    74527739  //
    74537740
     7741  /*
    74547742  {
    74557743    CmtSystem::cmt_string_vector words;
     
    74777765      }
    74787766  }
    7479 
     7767  */
    74807768  if (mode == Requirements)
    74817769    {
     
    79398227
    79408228//----------------------------------------------------------
    7941 int Cmt::reach_current_package ()
     8229int Cmt::use_current_package ()
    79428230{
    79438231  Use& use = Use::current ();
     
    79468234  if (Me.m_debug)
    79478235    {
    7948       cout << "Cmt::reach_current_package> pwd = "
     8236      cout << "Cmt::use_current_package> pwd = "
    79498237           << CmtSystem::pwd ()
    79508238           << " path=" << Me.m_current_path
     
    79598247  if (Me.m_current_package == "cmt_standalone")
    79608248    {
    7961       if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
     8249      if ((Me.m_current_path != "") && (Me.m_current_path != Me.m_current_dir))
     8250//      if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
    79628251        {
    79638252          if (!CmtSystem::cd (Me.m_current_path))
    79648253            {
    79658254              CmtError::set (CmtError::package_not_found,
    7966                              "ReachCurrentPackage> Cannot reach the path directory");
     8255                             "Cannot reach the path directory: "
     8256                             + Me.m_current_path);
    79678257              return (0);
    79688258            }
     
    79758265
    79768266      Me.m_current_structuring_style = without_version_directory;
     8267      use.structuring_style = Me.m_current_structuring_style;
     8268      use.change_path (Me.m_current_path, Project::get_current ());
     8269      Me.m_current_access = DeveloperMode;
    79778270    }
    79788271  else if (Me.m_current_package != "")
    79798272    {
    7980       if (!use.move_to () && !use.move_to ("", true))
    7981         //      if (!use.move_to ())
    7982         {
    7983           CmtError::set (CmtError::package_not_found, use.get_info ());
    7984 //           CmtError::set (CmtError::package_not_found,
    7985 //                          "ReachCurrentPackage> Cannot reach the path directory");
    7986           return (0);
    7987         }
    7988 
    7989       Me.m_current_path = use.real_path;
     8273      if (!use.located ())
     8274        {
     8275          //      if (!use.move_to () && !use.move_to ("", true))
     8276            //      if (!use.move_to ())
     8277          if (!use.move_to ())
     8278            {
     8279              if (!CmtSystem::cd (Cmt::get_current_dir ()))
     8280                {
     8281                  CmtError::set (CmtError::file_access_error,
     8282                                 Cmt::get_current_dir ()
     8283                                 + " (use_current_package)");
     8284                  return 0;
     8285                }
     8286              if (!use.move_to ("", true))
     8287                {
     8288                  CmtError::set (CmtError::package_not_found, use.get_info ());
     8289                  return 0;
     8290                }
     8291            }
     8292         
     8293          Me.m_current_path = use.real_path;
     8294          Me.m_current_access = DeveloperMode;
     8295        }
    79908296    }
    79918297  else
     
    80258331             
    80268332              CmtError::set (CmtError::package_not_found,
    8027                              "ReachCurrentPackage> Cannot reach the mgr/cmt directory");
     8333                             "Cannot reach the mgr/cmt directory: "
     8334                             + use.get_info ());
    80288335              return (0);
    80298336            }
     
    80318338      else
    80328339        Me.m_current_style = none_style;
     8340
     8341      Me.m_current_access = DeveloperMode;
    80338342
    80348343      dir = CmtSystem::pwd ();
     
    80588367      use.style   = Me.m_current_style;
    80598368      use.structuring_style = Me.m_current_structuring_style;
    8060     }
    8061 
     8369
     8370      configure_current_dir ();
     8371      build_prefix (Me.m_current_package, Me.m_current_prefix);
     8372      build_config (Me.m_current_prefix, Me.m_current_config);
     8373    }
     8374
     8375  /*
    80628376  configure_current_dir ();
    80638377  build_prefix (Me.m_current_package, Me.m_current_prefix);
    80648378  build_config (Me.m_current_prefix, Me.m_current_config);
     8379  */
    80658380
    80668381  /*
     
    80688383  */
    80698384
    8070   if (Me.m_debug) cout << "reach_current_package0> current_tag=" << Me.m_current_tag << endl;
     8385  if (Me.m_debug) cout << "use_current_package0> current_tag=" << Me.m_current_tag << endl;
    80718386
    80728387  if (Me.m_current_tag == "")
     
    80798394          Tag* tag;
    80808395
    8081           tag = Tag::add (env, PriorityConfig, "reach current package", 0);
     8396          tag = Tag::add (env, PriorityConfig, "current package", 0);
    80828397          tag->mark (use.get_package_name ());
    80838398          //Me.m_current_tag = env;
    80848399
    8085           //if (!Me.m_quiet) cerr << "reach_current_package1> current_tag=" << Me.m_current_tag << endl;
     8400          //if (!Me.m_quiet) cerr << "use_current_package1> current_tag=" << Me.m_current_tag << endl;
    80868401
    80878402        }
     
    81018416  SyntaxParser::parse_requirements (dir, &use);
    81028417
    8103   if (Me.m_debug) cout << "reach_current_package2> current_tag=" << Me.m_current_tag << endl;
     8418  if (CmtError::has_pending_error ()) return 0;
     8419
     8420  if (Me.m_debug) cout << "use_current_package2> current_tag=" << Me.m_current_tag << endl;
     8421
     8422  return 1;
     8423}
     8424
     8425//----------------------------------------------------------
     8426int Cmt::use_extra_file (const cmt_string& file)
     8427{
     8428  if (!CmtSystem::test_file (file))
     8429    {
     8430      CmtError::set (CmtError::path_not_found, file);
     8431      return 0;
     8432    }
     8433
     8434  // (almost) Cmt::use_current_package ()
     8435  Use& use = Use::current ();
     8436  /*
     8437    Try to access the package.
     8438  */
     8439
     8440  if (Me.m_current_package == "cmt_standalone")
     8441    {
     8442      if ((Me.m_current_path != "") && (Me.m_current_path != Me.m_current_dir))
     8443//      if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
     8444        {
     8445          if (!CmtSystem::cd (Me.m_current_path))
     8446            {
     8447              CmtError::set (CmtError::package_not_found,
     8448                             "Cannot reach the path directory: "
     8449                             + Me.m_current_path);
     8450              return (0);
     8451            }
     8452        }
     8453      /*
     8454      if (!CmtSystem::test_file ("requirements"))
     8455        {
     8456          return (0);
     8457        }
     8458      */
     8459      Me.m_current_structuring_style = without_version_directory;
     8460      use.structuring_style = Me.m_current_structuring_style;
     8461      use.change_path (Me.m_current_path, Project::get_current ());
     8462      Me.m_current_access = DeveloperMode;
     8463    }
     8464  else if (Me.m_current_package != "")
     8465    {
     8466      if (!use.located ())
     8467        {
     8468          //      if (!use.move_to () && !use.move_to ("", true))
     8469            //      if (!use.move_to ())
     8470          if (!use.move_to ())
     8471            {
     8472              if (!CmtSystem::cd (Cmt::get_current_dir ()))
     8473                {
     8474                  CmtError::set (CmtError::file_access_error,
     8475                                 Cmt::get_current_dir ()
     8476                                 + " (use_extra_file)");
     8477                  return 0;
     8478                }
     8479              if (!use.move_to ("", true))
     8480                {
     8481                  CmtError::set (CmtError::package_not_found, use.get_info ());
     8482                  return 0;
     8483                }
     8484            }
     8485         
     8486          Me.m_current_path = use.real_path;
     8487          Me.m_current_access = DeveloperMode;
     8488        }
     8489    }
     8490  else
     8491    {
     8492      //
     8493      // The cmt command has been given without explicit search for
     8494      // a package. Thus it is expected that we are in the context of a
     8495      // true package.
     8496      //
     8497      //  This means that there should be a requirements file visible.
     8498      //
     8499      //  If this is not true, we'll make a try into ../cmt and then
     8500      // a last try into ../mgr
     8501      //
     8502
     8503      Me.m_current_access = DeveloperMode;
     8504      //...
     8505      configure_current_dir ();
     8506      build_prefix (Me.m_current_package, Me.m_current_prefix);
     8507      build_config (Me.m_current_prefix, Me.m_current_config);
     8508    }
     8509
     8510  /*
     8511  configure_current_dir ();
     8512  build_prefix (Me.m_current_package, Me.m_current_prefix);
     8513  build_config (Me.m_current_prefix, Me.m_current_config);
     8514  */
     8515
     8516  /*
     8517    Check Tag is always set up
     8518  */
     8519
     8520  if (Me.m_debug) cout << "use_extra_file0> current_tag=" << Me.m_current_tag << endl;
     8521
     8522  if (Me.m_current_tag == "")
     8523    {
     8524      cmt_string env;
     8525
     8526      env = CmtSystem::getenv (Me.m_current_config);
     8527      if (env != "")
     8528        {
     8529          Tag* tag;
     8530
     8531          tag = Tag::add (env, PriorityConfig, "current package", 0);
     8532          tag->mark (use.get_package_name ());
     8533          //Me.m_current_tag = env;
     8534
     8535          //if (!Me.m_quiet) cerr << "use_extra_file1> current_tag=" << Me.m_current_tag << endl;
     8536
     8537        }
     8538    }
     8539
     8540  if (Me.m_debug)
     8541    {
     8542      cout << "pwd = " << CmtSystem::pwd () << endl;
     8543    }
     8544
     8545  /*
     8546    Work on the requirements file.
     8547  */
     8548
     8549  SyntaxParser::parse_requirements (file, &use);
     8550
     8551  if (CmtError::has_pending_error ()) return 0;
     8552
     8553  if (Me.m_debug) cout << "use_extra_file2> current_tag=" << Me.m_current_tag << endl;
     8554  return 1;
     8555}
     8556
     8557//----------------------------------------------------------
     8558int Cmt::apply_globals ()
     8559{
    81048560
    81058561  /**
     
    81328588  Tag::restore_tree ();
    81338589
    8134   return (1);
    8135 }
    8136 
    8137 //----------------------------------------------------------
    8138 int Cmt::use_extra_file (const cmt_string& file)
    8139 {
    8140   if (!CmtSystem::test_file (file))
    8141     {
    8142       CmtError::set (CmtError::path_not_found, file);
    8143       return 0;
    8144     }
    8145 
    8146   // (almost) Cmt::reach_current_package ()
    8147   Use& use = Use::current ();
    8148   /*
    8149     Try to access the package.
    8150   */
    8151 
    8152   if (Me.m_current_package == "cmt_standalone")
    8153     {
    8154       if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
    8155         {
    8156           if (!CmtSystem::cd (Me.m_current_path))
    8157             {
    8158               CmtError::set (CmtError::package_not_found,
    8159                              "ReachCurrentPackage> Cannot reach the path directory");
    8160               return (0);
    8161             }
    8162         }
    8163       /*
    8164       if (!CmtSystem::test_file ("requirements"))
    8165         {
    8166           return (0);
    8167         }
    8168       */
    8169       Me.m_current_structuring_style = without_version_directory;
    8170     }
    8171   else if (Me.m_current_package != "")
    8172     {
    8173       if (!use.move_to () && !use.move_to ("", true))
    8174         //      if (!use.move_to ())
    8175         {
    8176           CmtError::set (CmtError::package_not_found, use.get_info ());
    8177 //           CmtError::set (CmtError::package_not_found,
    8178 //                          "ReachCurrentPackage> Cannot reach the path directory");
    8179           //          return -1;
    8180           return (0);
    8181         }
    8182 
    8183       Me.m_current_path = use.real_path;
    8184     }
    8185   else
    8186     {
    8187       //
    8188       // The cmt command has been given without explicit search for
    8189       // a package. Thus it is expected that we are in the context of a
    8190       // true package.
    8191       //
    8192       //  This means that there should be a requirements file visible.
    8193       //
    8194       //  If this is not true, we'll make a try into ../cmt and then
    8195       // a last try into ../mgr
    8196       //
    8197 
    8198       //...
    8199     }
    8200 
    8201   configure_current_dir ();
    8202   build_prefix (Me.m_current_package, Me.m_current_prefix);
    8203   build_config (Me.m_current_prefix, Me.m_current_config);
    8204 
    8205   /*
    8206     Check Tag is always set up
    8207   */
    8208 
    8209   if (Me.m_debug) cout << "use_extra_file0> current_tag=" << Me.m_current_tag << endl;
    8210 
    8211   if (Me.m_current_tag == "")
    8212     {
    8213       cmt_string env;
    8214 
    8215       env = CmtSystem::getenv (Me.m_current_config);
    8216       if (env != "")
    8217         {
    8218           Tag* tag;
    8219 
    8220           tag = Tag::add (env, PriorityConfig, "reach current package", 0);
    8221           tag->mark (use.get_package_name ());
    8222           //Me.m_current_tag = env;
    8223 
    8224           //if (!Me.m_quiet) cerr << "use_extra_file1> current_tag=" << Me.m_current_tag << endl;
    8225 
    8226         }
    8227     }
    8228 
    8229   if (Me.m_debug)
    8230     {
    8231       cout << "pwd = " << CmtSystem::pwd () << endl;
    8232     }
    8233 
    8234   /*
    8235     Work on the requirements file.
    8236   */
    8237 
    8238   SyntaxParser::parse_requirements (file, &use);
    8239 
    8240   if (Me.m_debug) cout << "use_extra_file2> current_tag=" << Me.m_current_tag << endl;
    8241 
    8242   /**
    8243    *   It would be useful to change this mechanism. Instead of
    8244    *  applying all global patterns at once to all use contexts, it
    8245    *  would be much better to apply it at the end of each
    8246    *  requirements file parsing, and only in the context the
    8247    *  appropriate Use.
    8248    *
    8249    *   This would avoid the current flaw which is that when a global
    8250    *  pattern specifies a "private" definition, it is actually
    8251    *  applied in the scope context of the Current Use and not in
    8252    *  each individual Use. Therefore the private is lost.
    8253    *
    8254    *   However, this induces problems since some pattern definitions
    8255    *  are done AFTER the use statements, which will NOT receive the
    8256    *  pattern aplications.
    8257    *
    8258    *   Therefore it is decided to leave this "bad" mechanism until
    8259    *  everybody is aware of this constraint.
    8260    *
    8261    *
    8262    */
    8263   Pattern::apply_all_globals ();
    8264 
    8265   /*
    8266     Select all possible tags
    8267   */
    8268 
    8269   Tag::restore_tree ();
    8270 
    8271   return (1);
     8590  if (CmtError::has_pending_error ()) return 0;
     8591
     8592  return 1;
    82728593}
    82738594
     
    997210293  if (CmtSystem::test_file (f))
    997310294    {
    9974       use->m_located = true;
    9975     }
    9976   SyntaxParser::parse_requirements (f, use);
     10295      use->style = none_style;
     10296      use->structuring_style = without_version_directory;
     10297
     10298      if (name == CmtSystem::get_home_package () ||
     10299          name == CmtSystem::get_user_context_package ())
     10300        {
     10301          const Project::ProjectPtrVector& Ordered = Project::ordered_projects ();
     10302          if (0 == Ordered.size ())
     10303            {
     10304              CmtError::set(CmtError::configuration_error,
     10305                            "No ordered project: " + use->get_info ());
     10306              return;
     10307            }
     10308          if (name == CmtSystem::get_home_package ())
     10309            use->change_path (path, Ordered[Ordered.size () - 1]);
     10310          else if (name == CmtSystem::get_user_context_package ())
     10311            use->change_path (path, Ordered[0]);
     10312        }
     10313      else
     10314        {
     10315          CmtMessage::verbose
     10316            (CmtError::get_error_name (CmtError::configuration_error)
     10317             + ": Unknown special use: " + use->get_info ());
     10318          use->change_path (path);
     10319        }
     10320      //      use->m_located = true;
     10321      SyntaxParser::parse_requirements (f, use);
     10322    }
     10323  else
     10324    {
     10325      use->discard ();
     10326    }
    997710327
    997810328  Me.m_recursive = recursive_copy;
  • CMT/HEAD/source/cmt_pattern.cxx

    r607 r652  
    771771      replacement.replace_all ("<version>", context_use->version.c_str ());
    772772      replacement.replace_all ("<path>",    context_use->real_path.c_str ());
    773 
     773      /*
    774774      cmt_string cmtpath = "";
    775775      cmt_string offset = "";
     
    779779      Project* p = Project::find_by_cmtpath (cmtpath);
    780780      if (p != 0)
     781      */
     782      if (const Project* p = context_use->get_project ())
    781783        {
    782           const cmt_string& n = p->get_name ();
    783           replacement.replace_all ("<project>", n.c_str ());
     784          //          const cmt_string& n = p->get_name ();
     785          replacement.replace_all ("<project>", p->get_name ().c_str ());
    784786        }
    785787
  • CMT/HEAD/source/cmt_project.cxx

    r629 r652  
    646646      project_use->m_hidden  = true;
    647647      project_use->selected  = true;
    648       project_use->m_located = true;
     648      project_use->change_path (project->get_cmtpath(), project);
     649      //      project_use->m_located = true;
    649650      cmt_map <Use*, bool> visited;
    650651      project_use->set_auto_imports(Unspecified, Off, visited);
     
    864865  static ProjectVector& Projects = projects ();
    865866
    866   Project* result = 0;
    867 
    868867  for (int i = (Projects.size () - 1); i >= 0; i--)
    869868    {
     
    879878        //      if (here_real.find (p.m_cmtpath_real) == 0)
    880879        {
    881           result = &p;
    882         }
    883     }
    884 
    885   return (result);
     880          return &p;
     881        }
     882    }
     883
     884  return 0;
    886885}
    887886
     
    15231522
    15241523//----------------------------------------------------------
    1525 void Project::fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections)
     1524/**
     1525 *  Fill with projects (pointers) for CMTPATH entries >=1 and <= depth
     1526 *  except for CMTUSERCONTEXT project or CMTHOME project
     1527 *  unless either is current project.
     1528 *  Special values of depth:
     1529 *   0: CMTUSERCONTEXT project only
     1530 *  -1: CMTHOME project only
     1531 *
     1532 *  @param depth in CMTPATH up to which fill
     1533 *  @param path_selections vector to fill
     1534 */
     1535void Project::fill_selection (int depth, ConstProjectPtrVector& path_selections)
     1536{
     1537  static ProjectPtrVector& Ordered = Project::ordered_projects ();
     1538  int curdepth = depth;
     1539  for (int i = 0; i < Ordered.size (); i++)
     1540    {
     1541      const Project* project = Ordered[i];
     1542      const cmt_string& src = project->get_cmtpath_source ();
     1543
     1544      if (src == "default path") continue;
     1545
     1546      if (depth > 0)
     1547        {
     1548          // project for CMTPATH entries >=1 and <= depth
     1549          // except for CMTUSERCONTEXT path or CMTHOME path
     1550          // OR
     1551          // CMTUSERCONTEXT path if it's current project
     1552          // CMTHOME        path if it's current project
     1553          if (i == 0
     1554              && !project->is_current ()
     1555              && src == "CMTUSERCONTEXT") continue;
     1556          // this is CMTUSERCONTEXT
     1557          if (i == Ordered.size () - 1
     1558              && !project->is_current ()
     1559              && src == "CMTHOME") continue;
     1560          // this is CMTHOME
     1561          path_selections.push_back (project);
     1562          //cerr << "fill: " << i << ": " << project->get_cmtpath () << ": " << curdepth << endl;
     1563          if (--curdepth == 0) break;
     1564        }
     1565      else if (depth == 0)
     1566        {
     1567          // CMTUSERCONTEXT path only
     1568          if (i == 0
     1569              && src == "CMTUSERCONTEXT")
     1570            {
     1571              path_selections.push_back (project);
     1572              break;
     1573            }
     1574        }
     1575      else if (depth == -1)
     1576        {
     1577          // CMTHOME path only
     1578          if (i == Ordered.size () - 1
     1579              && src == "CMTHOME")
     1580            {
     1581              path_selections.push_back (project);
     1582              break;
     1583            }
     1584        }
     1585    }
     1586}
     1587
     1588//----------------------------------------------------------
     1589// void Project::fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections)
     1590// {
     1591//   static ProjectPtrVector& Ordered = Project::ordered_projects ();
     1592//   int curdepth = depth;
     1593//   for (int i = 0; i < Ordered.size (); i++)
     1594//     {
     1595//       const Project* project = Ordered[i];
     1596
     1597//       const cmt_string& p = project->get_cmtpath ();
     1598//       const cmt_string& pwd = project->get_cmtpath_pwd ();
     1599//       const cmt_string& p_real = project->get_cmtpath_real ();
     1600//       const cmt_string& src = project->get_cmtpath_source ();
     1601
     1602//       if (src == "default path") continue;
     1603
     1604//       if (depth > 0)
     1605//      {
     1606//        // packages from CMTPATH entries >=1 and <= depth
     1607//        // except for CMTUSERCONTEXT path or CMTHOME path
     1608//        // OR
     1609//        // CMTUSERCONTEXT path if it's current project
     1610//        // CMTHOME        path if it's current project
     1611//        if (i == 0
     1612//            && !project->is_current ()
     1613//            && src == "CMTUSERCONTEXT") continue;
     1614//        // this is CMTUSERCONTEXT
     1615//        if (i = Ordered.size () - 1
     1616//            && !project->is_current ()
     1617//            && src == "CMTHOME") continue;
     1618//        // this is CMTHOME
     1619//        cmt_string& s1 = path_selections.add ();
     1620//        s1 = p;
     1621//        if (pwd != p)
     1622//          {
     1623//            cmt_string& s2 = path_selections.add ();
     1624//            s2 = pwd;
     1625//          }
     1626//        if (p_real != p && p_real != pwd)
     1627//          {
     1628//            cmt_string& s3 = path_selections.add ();
     1629//            s3 = p_real;
     1630//          }
     1631//        if (--curdepth == 0) break;
     1632//      }
     1633//       else if (depth == 0)
     1634//      {
     1635//        // CMTUSERCONTEXT path only
     1636//        if (i == 0
     1637//            && src == "CMTUSERCONTEXT")
     1638//          {
     1639//            cmt_string& s1 = path_selections.add ();
     1640//            s1 = p;
     1641//            if (pwd != p)
     1642//              {
     1643//                cmt_string& s2 = path_selections.add ();
     1644//                s2 = pwd;
     1645//              }
     1646//            if (p_real != p && p_real != pwd)
     1647//              {
     1648//                cmt_string& s3 = path_selections.add ();
     1649//                s3 = p_real;
     1650//              }
     1651//            break;
     1652//          }
     1653//      }
     1654//       else if (depth == -1)
     1655//      {
     1656//        // CMTHOME path only
     1657//        if (i = Ordered.size () - 1
     1658//            && src == "CMTHOME")
     1659//          {
     1660//            cmt_string& s1 = path_selections.add ();
     1661//            s1 = p;
     1662//            if (pwd != p)
     1663//              {
     1664//                cmt_string& s2 = path_selections.add ();
     1665//                s2 = pwd;
     1666//              }
     1667//            if (p_real != p && p_real != pwd)
     1668//              {
     1669//                cmt_string& s3 = path_selections.add ();
     1670//                s3 = p_real;
     1671//              }
     1672//            break;
     1673//          }
     1674//      }
     1675// //     if (depth > 0)
     1676// //       {
     1677// //         cmt_string& s1 = path_selections.add ();
     1678// //         s1 = p;
     1679// //         if (pwd != p)
     1680// //           {
     1681// //             cmt_string& s2 = path_selections.add ();
     1682// //             s2 = pwd;
     1683// //           }
     1684// //         if (p_real != p && p_real != pwd)
     1685// //           {
     1686// //             cmt_string& s3 = path_selections.add ();
     1687// //             s3 = p_real;
     1688// //           }
     1689// //         if (src != "CMTHOME" && src != "CMTUSERCONTEXT")
     1690// //           depth--;
     1691
     1692// //         if (depth == 0) break;
     1693// //       }
     1694
     1695//     }
     1696// }
     1697
     1698//----------------------------------------------------------
     1699/**
     1700 *  Fill with projects (pointers) for CMTUSERCONTEXT and CMTHOME projects
     1701 *  (if any exists)
     1702 *  unless either is current project.
     1703 * 
     1704 *  @param path_exclusions vector to fill
     1705 */
     1706void Project::fill_exclusion (ConstProjectPtrVector& path_exclusions)
    15261707{
    15271708  static ProjectPtrVector& Ordered = Project::ordered_projects ();
     
    15291710    {
    15301711      const Project* project = Ordered[i];
    1531 
    1532       const cmt_string& p = project->get_cmtpath ();
    1533       const cmt_string& pwd = project->get_cmtpath_pwd ();
    1534       const cmt_string& p_real = project->get_cmtpath_real ();
    15351712      const cmt_string& src = project->get_cmtpath_source ();
    1536       /*
    1537   static ProjectVector& Projects = projects ();
    1538 
    1539   for (int i = 0; i < Projects.size (); i++)
    1540     {
    1541       Project& project = Projects[i];
    1542 
    1543       const cmt_string& p = project.get_cmtpath ();
    1544       const cmt_string& pwd = project.get_cmtpath_pwd ();
    1545       const cmt_string& p_real = project.get_cmtpath_real ();
    1546       const cmt_string& src = project.get_cmtpath_source ();
    1547       */
    1548       if (src != "default path")
    1549         {
    1550           if (depth > 0)
    1551             {
    1552               cmt_string& s1 = path_selections.add ();
    1553               s1 = p;
    1554               if (pwd != p)
    1555                 {
    1556                   cmt_string& s2 = path_selections.add ();
    1557                   s2 = pwd;
    1558                 }
    1559               if (p_real != p && p_real != pwd)
    1560                 {
    1561                   cmt_string& s3 = path_selections.add ();
    1562                   s3 = p_real;
    1563                 }
    1564               if (src != "CMTHOME" && src != "CMTUSERCONTEXT")
    1565                 depth--;
    1566 
    1567               if (depth == 0) break;
    1568             }
    1569         }
     1713
     1714      if (!project->is_current ()
     1715          && (src == "CMTUSERCONTEXT" || src == "CMTHOME"))
     1716        path_exclusions.push_back (project);
    15701717    }
    15711718}
     
    16941841//          }
    16951842
    1696           if (path_real.find (p_real) != cmt_string::npos)
     1843          if (path_real.find (p_real) == 0) //!= cmt_string::npos)
    16971844            {
    16981845              return (p);
     
    17001847
    17011848          // To become the current area, a path must correspond to the current package
    1702           if (path.find (w) != cmt_string::npos)
     1849          if (path.find (w) == 0)// != cmt_string::npos)
    17031850            {
    17041851              return (p);
     
    17061853        }
    17071854
     1855        /* This code is never used since p is returned above
    17081856      if (p == w) continue;
    17091857
     
    17111859      //      if (CmtSystem::test_directory (w))
    17121860        {
    1713           if (path.find (w) != cmt_string::npos)
     1861          if (path.find (w) == 0)// != cmt_string::npos)
    17141862            {
    17151863              return (w);
    17161864            }
    17171865        }
     1866        */
    17181867    }
    17191868
     
    23622511  use->get_package ()->remove_use (use);
    23632512  CmtSystem::cd (m_cmtpath_pwd);
    2364   if (use->move_to ("", true) &&
    2365       !CmtSystem::absolute_path (use->real_path))
    2366     {
    2367       use->change_path (m_cmtpath_pwd);
    2368     }
     2513  if (use->move_to ("", true))
     2514    {
     2515      if (use->get_realpath ().find (this->get_cmtpath_real ()) == 0)
     2516        use->set_project (this);
     2517    }
     2518  else
     2519    if (0 == CmtSystem::getenv ("CMTPEDANTIC").size () &&
     2520        0 == CmtSystem::getenv ("PEDANTIC").size ())
     2521      CmtMessage::warning
     2522        (CmtError::get_error_name (CmtError::configuration_error)
     2523         + ": Cannot locate container: " + use->get_info ());
     2524    else
     2525      CmtError::set(CmtError::configuration_error,
     2526                    "Cannot locate container: " + use->get_info ());
     2527 
    23692528  CmtSystem::cd (m_cmtpath_pwd + CmtSystem::file_separator () + "cmt");
     2529
     2530  if (CmtError::get_last_error_code () == CmtError::configuration_error)
     2531    return;
    23702532
    23712533  set_container_name (name);
  • CMT/HEAD/source/cmt_project.h

    r608 r652  
    9797  typedef cmt_vector<Project> ProjectVector;
    9898  typedef cmt_vector<Project*> ProjectPtrVector;
     99  typedef cmt_vector<const Project*> ConstProjectPtrVector;
    99100
    100101  static bool create (const cmt_string& name,
     
    120121  static const cmt_string& get_project_file_name ();
    121122
    122   static void fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections);
     123  static void fill_selection (int depth, ConstProjectPtrVector& path_selections);
     124  //  static void fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections);
     125  static void fill_exclusion (ConstProjectPtrVector& path_exclusions);
    123126
    124127  static void broadcast (IProjectAction& action);
  • CMT/HEAD/source/cmt_symbol.cxx

    r625 r652  
    10841084           */
    10851085          if (name == "constituents") return;
    1086           if (name == "constituentscclean") return;
     1086          if (name == "constituentsclean") return;
    10871087
    10881088          if (use->get_current_scope () == ScopePrivate) return;
  • CMT/HEAD/source/cmt_syntax.cxx

    r607 r652  
    212212               int line_number)
    213213  {
    214        
     214    /*       
    215215    cmt_string cmtpath;
    216216    cmt_string offset;
     
    219219
    220220    Project* p = Project::find_by_cmtpath (cmtpath);
     221    */
     222    Project* p = const_cast<Project*>(use->get_project ());
     223    //    const Project* p = use->get_project ();
    221224
    222225    for (int i = 1; i < words.size (); i++)
     
    10601063               int line_number)
    10611064  {
     1065    /*
    10621066    cmt_string cmtpath;
    10631067    cmt_string offset;
     
    10661070
    10671071    Project* p = Project::find_by_cmtpath (cmtpath);
     1072    */
     1073    Project* p = const_cast<Project*>(use->get_project ());
     1074    //    const Project* p = use->get_project ();
    10681075
    10691076    for (int i = 1; i < words.size (); i++)
     
    11641171               int line_number)
    11651172  {
     1173    /*
    11661174    cmt_string cmtpath;
    11671175    cmt_string offset;
     
    11701178
    11711179    Project* p = Project::find_by_cmtpath (cmtpath);
     1180    */
     1181    Project* p = const_cast<Project*>(use->get_project ());
     1182    //    const Project* p = use->get_project ();
    11721183
    11731184    for (int i = 1; i < words.size (); i++)
     
    14031414      //
    14041415     
    1405       Project* p = use->get_project ();
     1416      const Project* p = use->get_project ();
    14061417      if (p != 0)
    14071418        {     
  • CMT/HEAD/source/cmt_use.cxx

    r610 r652  
    18261826  m_located = false;
    18271827  m_package = 0;
     1828  m_project = 0;
    18281829  m_index = -1;
    18291830
     
    18481849      m_package = 0;
    18491850    }
     1851  m_project = 0;
    18501852
    18511853  version   = "";
     
    19231925
    19241926//----------------------------------------------------------
    1925 void Use::change_path (const cmt_string& new_path)
     1927void Use::change_path (const cmt_string& new_path, const Project* project)
    19261928{
    19271929  //
     
    19291931  // where this package/version has been found.
    19301932  //
     1933  if (Cmt::get_debug ())
     1934    {
     1935      cout << "|Use::change_path> path: " << new_path
     1936           << ": project: " << (project ? project->get_cmtpath () : "0")
     1937           << ": " << get_info () << endl;
     1938    }
    19311939
    19321940  real_path = "";
    19331941  m_realpath = "";
    19341942
    1935   if (new_path != "")
     1943  m_project = 0;
     1944
     1945  if (new_path.size () != 0)
     1946    //  if (new_path != "")
    19361947    {
    19371948      if ((path.size () > 0) &&
     
    19511962      if (!CmtSystem::realpath_ (real_path, m_realpath))
    19521963        {
    1953           CmtError::set (CmtError::file_access_error, "Cannot compute real path `" +
    1954                          real_path + "'");
     1964          CmtError::set (CmtError::file_access_error,
     1965                         "Cannot compute real path `" + real_path + "': " +
     1966                         get_info ());
    19551967          CmtError::print ();
    19561968          return;
     
    19581970    }
    19591971 
     1972  if (project)
     1973    m_project = project;
     1974
    19601975  m_located = true;
     1976
     1977  if (Cmt::get_debug ())
     1978    {
     1979      cout << "<Use::change_path| real_path: " << real_path
     1980           << ": m_project: " << (m_project ? m_project->get_cmtpath () : "0")
     1981           << ": " << get_info () << endl;
     1982    }
    19611983}
    19621984
     
    23472369          }
    23482370       
    2349         m_use->change_path (path);
     2371        m_use->change_path (path, &project);
    23502372
    23512373        m_found = true;
     
    23552377    else if (m_use->alternate_versions.size () > 0)
    23562378      {
    2357         if (m_use->select_alternate ())
     2379        if (m_use->select_alternate (&project))
    23582380          {
    23592381            if (Cmt::get_debug ())
     
    24482470              cout << "move_to2> " << expanded_path << endl;
    24492471            }
    2450 
    24512472          change_path (here);
    2452 
    24532473          return (true);
    24542474        }
     
    24612481                  cout << "move_to5> " << real_path << endl;
    24622482                }
    2463              
    24642483              return (true);
    24652484            }
    24662485        }
     2486
     2487      if (!CmtSystem::cd (here))
     2488        {
     2489          CmtError::set (CmtError::file_access_error, here);
     2490        }
    24672491      return (false);
    24682492//     }
     
    24822506
    24832507//----------------------------------------------------------
    2484 bool Use::select_alternate ()
     2508bool Use::select_alternate (const Project* project)
    24852509{
    24862510  int i;
     
    25672591                }
    25682592
    2569               change_path (alternate_paths[selected_index]);
     2593              change_path (alternate_paths[selected_index], project);
    25702594              return (true);
    25712595            }
     
    35683592  offset = "";
    35693593
    3570   cmtpath = m_realpath.size ()
    3571     ? Project::find_in_cmt_paths (m_realpath, true)
    3572     : Project::find_in_cmt_paths (real_path)
    3573     ;
    3574   const Project* p = Project::find_by_cmtpath (cmtpath);
    3575 
     3594  const Project* p (0);
     3595  if (m_project)
     3596    {
     3597      p = m_project;
     3598      cmtpath = p->get_cmtpath ();
     3599    }
     3600  else
     3601    {
     3602      cmtpath = m_realpath.size ()
     3603        ? Project::find_in_cmt_paths (m_realpath, true)
     3604        : Project::find_in_cmt_paths (real_path)
     3605        ;
     3606      p = Project::find_by_cmtpath (cmtpath);
     3607  //  const Project* p = Project::find_by_cmtpath (cmtpath);
     3608    }
    35763609  //  if (cmtpath != "")
    35773610  if (p != 0)
     
    35903623      else if (!CmtSystem::realpath_ (real_path, offset))
    35913624        {
    3592           CmtError::set (CmtError::file_access_error, "Cannot compute real path `" +
    3593                          real_path + "'");
     3625          CmtError::set (CmtError::file_access_error,
     3626                         "Cannot compute real path `" + real_path + "': " +
     3627                         get_info ());
    35943628          CmtError::print ();
    35953629          return;
     
    37053739  buffer += "\n";
    37063740
    3707   if (located ())
     3741  if (m_located)
     3742    //  if (located ())
    37083743    {
    37093744      buffer += "macro ";
     
    37253760          buffer += package_name;
    37263761        }
    3727       //      if (style != no_version_style)
    37283762      if (structuring_style == with_version_directory)
    37293763        {
     
    37643798  buffer += "\n";
    37653799 
    3766   Project* p = Project::find_by_cmtpath (cmtpath);
     3800  const Project* p (m_project);
     3801  if (!p)
     3802    p = Project::find_by_cmtpath (cmtpath);
    37673803
    37683804  buffer += "macro ";
     
    48294865
    48304866  return (is_in_path);
    4831 }
    4832 
    4833 //----------------------------------------------------------
    4834 bool Use::located () const
    4835 {
    4836   return (m_located);
    48374867}
    48384868
     
    57365766
    57375767//----------------------------------------------------------
    5738 Project* Use::get_project ()
     5768const Project* Use::get_project () const
    57395769{   
     5770  if (m_project)
     5771    return m_project;
     5772
     5773  cmt_string cmtpath = m_realpath.size ()
     5774    ? Project::find_in_cmt_paths (m_realpath, true)
     5775    : Project::find_in_cmt_paths (real_path)
     5776    ;
     5777  return Project::find_by_cmtpath (cmtpath);
     5778  /*
    57405779  Project* p;
    57415780  cmt_string cmtpath = "";
     
    57445783  p = Project::find_by_cmtpath (cmtpath);
    57455784  return p;   
     5785  */
    57465786}
    57475787
  • CMT/HEAD/source/cmt_use.h

    r608 r652  
    128128  bool get_paths (Use* to, UsePtrVector& list);
    129129
    130   bool located () const;
    131 
    132   void change_path (const cmt_string& path);
     130  inline bool located () const { return m_located; }
     131
     132  void change_path (const cmt_string& path, const Project* project = 0);
    133133  void set_auto_imports (State context_state, State specified_state,
    134134                         cmt_map <Use*, bool>& visited);
     
    153153  ScopeType get_current_scope () const;
    154154
    155   Project* get_project ();
     155  const Project* get_project () const;
     156  inline void set_project (const Project* project) { m_project = project; }
    156157  cmt_string get_info () const;
    157158  bool is_head_version (const cmt_string& version);
     
    182183  bool discarded;                /* discarded by version strategy   */
    183184  bool selected;                 /* used for recursive access       */
    184   bool m_located;
     185  //  bool m_located;
    185186  bool m_hidden;
    186187  ScopeType initial_scope;
     
    213214                      bool skip_discarded = false, ostream& out = cout);
    214215  //  void show_sub_uses (const cmt_string& request, bool skip_discarded = false);
    215   bool select_alternate ();
     216  bool select_alternate (const Project* project = 0);
    216217  Use* get_selected_version ();
    217218  Use* set_selected_version (Use* selected_use);
     
    235236  //cmt_string m_package_name; /* directly read from requirements */
    236237
     238  //  Project* m_project;  /* the project the use is found in */
     239  const Project* m_project;  /* the project the use is found in */
     240
     241  bool m_located;
     242
    237243  bool m_has_native_version;
    238244
  • CMT/HEAD/src/Makefile.header

    r616 r652  
    198198        @echo
    199199ifndef BCAST_GLOBAL
    200         @uses=`$(cmtexe) -private show macros '_project$$|package$$' -tag=$(tags)| \
    201           awk -F = '{if ($$1 ~ /_project$$/) {uses[substr($$1,1,length($$1)-8)]=$$2}else if ($$1 == "package") {cur = $$2;gsub("'\''","",cur)}}END{for (u in uses){if (uses[u]==uses[cur]) print u}}'`; \
     200        @uses=`$(cmtexe) -private show macros '_project$$|package$$|_offset$$' -tag=$(tags)| \
     201          awk -F = '{if ($$1 ~ /_project$$/) {p = $$2;gsub("'\''","",p);uses[substr($$1,1,length($$1)-8)]=p} else if ($$1 == "package") {cur = $$2;gsub("'\''","",cur)}else if ($$1 ~ /_offset$$/) {u = substr($$1,1,length($$1)-7);if (!(u in uses))uses[u]=""}}END{for (u in uses){if ((uses[cur] != "" && uses[u] == uses[cur] || u == cur) && u != "CMT" && u != "CMTHOME" && u != "CMTUSERCONTEXT") print u}}'`; \
    202202          for u in $${uses}; do \
    203203            echo "$${u} : (re)build package $${u} ($(_groups))"; \
     
    208208          done
    209209else
    210         @uses=`$(cmtexe) -private show macros '_root$$' -tag=$(tags)| \
    211           awk -F = '{u=substr($$1,1,length($$1)-5);if (u != "CMT" && u != "CMTHOME" && u != "CMTUSERCONTEXT") print u}'`; \
     210        @uses=`$(cmtexe) -private show macros '_project$$|package$$|_offset$$' -tag=$(tags)| \
     211          awk -F = '{if ($$1 ~ /_project$$/) {p = $$2;gsub("'\''","",p);uses[substr($$1,1,length($$1)-8)]=p} else if ($$1 == "package") {cur = $$2;gsub("'\''","",cur)}else if ($$1 ~ /_offset$$/) {u = substr($$1,1,length($$1)-7);if (!(u in uses))uses[u]=""}}END{for (u in uses){if (uses[u] != uses[cur] && (uses[u] == "CMTHOME" || uses[u] == "CMTUSERCONTEXT")) {continue} else if (u != "CMT" && u != "CMTHOME" && u != "CMTUSERCONTEXT") print u}}'`; \
    212212          for u in $${uses}; do \
    213213            echo "$${u} : (re)build package $${u} ($(_groups))"; \
Note: See TracChangeset for help on using the changeset viewer.