Ignore:
Timestamp:
Mar 8, 2011, 1:56:48 PM (13 years ago)
Author:
rybkin
Message:

See C.L. 444

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/source/cmt_parser.cxx

    r555 r561  
    6464  m_cmt_root       = "";
    6565  m_cmt_version    = "";
     66  m_use_cmt        = true;
    6667  m_current_dir     = "";
    6768  m_current_file_path = "";
     
    21002101      return;
    21012102    }
    2102   if (ap.arguments.size () > 0)
    2103     {
    2104       set_standard_macros ();
    2105       Generator::build_constituent_makefile (ap.arguments);
    2106     }
     2103  set_standard_macros ();
     2104
     2105  cmt_string out, name;
     2106  for (int i = 0; i < ap.arguments.size (); i++)
     2107    {
     2108      const cmt_string& arg = ap.arguments[i];
     2109      if (arg.substr (0, 5) == "-out=")
     2110        arg.substr (5, out);
     2111      else
     2112        name = arg;
     2113    }
     2114
     2115  const Constituent* constituent = Constituent::find (name);
     2116  if (constituent == 0)
     2117    {
     2118      CmtError::set (CmtError::constituent_not_found, name);
     2119      return;
     2120    }
     2121  Generator::build_constituent_makefile (*constituent, out);
     2122//   if (ap.arguments.size () > 0)
     2123//     {
     2124//       set_standard_macros ();
     2125//       Generator::build_constituent_makefile (ap.arguments);
     2126//     }
    21072127}
    21082128
     
    21152135      return;
    21162136    }
    2117   if (ap.arguments.size () == 0) return;
    21182137  set_standard_macros ();
    21192138
    21202139  CmtSystem::cmt_string_vector files (2);
    2121   cmt_string  outdir, name;
     2140  cmt_string  out, outdir, name;
    21222141  for (int i = 0; i < ap.arguments.size (); i++)
    21232142    {
    2124       cmt_string arg = ap.arguments[i];
     2143      const cmt_string arg = ap.arguments[i];
    21252144      if (arg.substr (0, 5) == "-out=")
    21262145        {
    2127           arg.erase (0, 5);
    2128           CmtSystem::dirname (arg, outdir);
     2146          arg.substr (5, out);
     2147          CmtSystem::dirname (out, outdir);
    21292148        }
    21302149      else
     
    21342153    }
    21352154
    2136   Generator::build_constituent_makefile (ap.arguments);
     2155  //  Generator::build_constituent_makefile (ap.arguments);
    21372156
    21382157  const Constituent* constituent = Constituent::find (name);
    21392158  if (constituent == 0)
    21402159    {
    2141       // generate error
     2160      CmtError::set (CmtError::constituent_not_found, name);
    21422161      return;
    21432162    }
     2163  Generator::build_constituent_makefile (*constituent, out);
    21442164  if (!constituent->has_target_tag) return;
    21452165  //  cerr << "constituent: " << name << endl;
     
    22522272  set_standard_macros ();
    22532273
    2254   Generator::build_constituents_makefile (Me.m_current_package, ap.arguments);
     2274  cmt_string out;
     2275  for (int i = 0; i < ap.arguments.size (); i++)
     2276    {
     2277      const cmt_string& arg = ap.arguments[i];
     2278      if (arg.substr (0, 5) == "-out=")
     2279        {
     2280          arg.substr (5, out);
     2281        }
     2282    }
     2283
     2284  Generator::build_constituents_makefile (Me.m_current_package, out);
     2285  //  Generator::build_constituents_makefile (Me.m_current_package, ap.arguments);
    22552286}
    22562287
     
    22662297
    22672298  CmtSystem::cmt_string_vector files (2);
    2268   cmt_string outdir;
    2269   if (ap.arguments.size () > 0)
    2270     {
    2271       cmt_string arg = ap.arguments[0];
     2299  cmt_string out, outdir;
     2300  bool usecmt (true);
     2301  for (int i = 0; i < ap.arguments.size (); i++)
     2302    {
     2303      const cmt_string& arg = ap.arguments[i];
    22722304      if (arg.substr (0, 5) == "-out=")
    22732305        {
    2274           arg.erase (0, 5);
    2275           CmtSystem::dirname (arg, outdir);
     2306          arg.substr (5, out);
     2307          CmtSystem::dirname (out, outdir);
    22762308        }
    2277       else if (arg.substr (0, 8) == "-outdir=")
    2278         {
    2279           arg.erase (0, 8);
    2280           outdir = arg;
    2281         }
     2309      else if (arg == "-with_cmt")
     2310        usecmt = true;
     2311      else if (arg == "-without_cmt")
     2312        usecmt = false;
    22822313    }
    22832314  //  cerr << "outdir: " << outdir << endl;
     
    23782409    }
    23792410
    2380   Generator::build_constituents_makefile (Me.m_current_package, ap.arguments);
     2411  Generator::build_constituents_makefile (Me.m_current_package, out);
     2412  //  Generator::build_constituents_makefile (Me.m_current_package, ap.arguments);
     2413
     2414  const Constituent::ConstituentVector& constituents =
     2415    Constituent::constituents ();
     2416  for (int n = 0; n < constituents.size (); n++)
     2417    {
     2418      const Constituent& constituent = constituents[n];
     2419      if (constituent.has_target_tag) continue;
     2420      Generator::build_constituent_infile (constituent, outdir, usecmt);
     2421    }
    23812422}
    23822423
     
    62706311  parse_arguments (ap);
    62716312 
    6272   if (Me.m_debug)
    6273     {
    6274       cout << "After parse_argument> pack=" << Me.m_current_package
    6275            << " Me.m_current_tag=" << Me.m_current_tag
    6276            << " cwd=" << CmtSystem::pwd ()
    6277            << " mode=" << Me.m_current_access
    6278            << endl;
    6279     }
    6280 
    6281   if (Me.m_configure_error != "")
    6282     {
    6283       CmtMessage::error (Me.m_configure_error);
    6284       //      if (!Me.m_quiet) cerr << "#CMT> Error: " << Me.m_configure_error << endl;
    6285       return (CmtError::execution_error);
    6286     }
    6287 
    6288   if (CmtError::has_pending_error ())
    6289     {
    6290       int code = CmtError::get_last_error_code ();
    6291       CmtError::print ();
    6292       //      if (!Me.m_quiet) CmtError::print ();
    6293       clear ();
    6294 
    6295       return (code);
    6296     }
    6297 
    6298   /*
    6299     Now actual requirements analysis can take place.
    6300 
    6301     Extra lines or files are analysed first.
    6302   */
    6303 
    6304   if (strlen (ap.extra_file.c_str ()) > 0) SyntaxParser::parse_requirements (ap.extra_file, (Use*) 0);
    6305   if (strlen (ap.extra_line.c_str ()) > 0) SyntaxParser::parse_requirements_line (ap.extra_line, (Use*) 0);
    6306 
    6307   //
    6308   //  For some of the actions, the CMT package must be automatically
    6309   //  included
    6310   //
    6311 
    6312   if (Me.m_debug) cout << "parser1> current_tag=" << Me.m_current_tag << endl;
    6313 
    63146313  if (ap.help_action == action_help)
    63156314    {
    6316       do_help (ap);
    63176315      int code (0);
    63186316      if (CmtError::has_pending_error ())
     
    63216319          CmtError::print ();
    63226320        }
     6321      do_help (ap);
    63236322      return code;
    6324       //return (0);
    6325     }
     6323    }
     6324
     6325  if (Me.m_debug)
     6326    {
     6327      cout << "After parse_argument> pack=" << Me.m_current_package
     6328           << " Me.m_current_tag=" << Me.m_current_tag
     6329           << " cwd=" << CmtSystem::pwd ()
     6330           << " mode=" << Me.m_current_access
     6331           << endl;
     6332    }
     6333
     6334  if (Me.m_configure_error != "")
     6335    {
     6336      CmtMessage::error (Me.m_configure_error);
     6337      //      if (!Me.m_quiet) cerr << "#CMT> Error: " << Me.m_configure_error << endl;
     6338      return (CmtError::execution_error);
     6339    }
     6340
     6341  if (CmtError::has_pending_error ())
     6342    {
     6343      int code = CmtError::get_last_error_code ();
     6344      CmtError::print ();
     6345      //      if (!Me.m_quiet) CmtError::print ();
     6346      clear ();
     6347
     6348      return (code);
     6349    }
     6350
     6351  /*
     6352    Now actual requirements analysis can take place.
     6353
     6354    Extra lines or files are analysed first.
     6355  */
     6356
     6357  //  if (strlen (ap.extra_file.c_str ()) > 0) SyntaxParser::parse_requirements (ap.extra_file, (Use*) 0);
     6358  if (strlen (ap.extra_line.c_str ()) > 0) SyntaxParser::parse_requirements_line (ap.extra_line, (Use*) 0);
     6359
     6360  //
     6361  //  For some of the actions, the CMT package must be automatically
     6362  //  included
     6363  //
     6364
     6365  if (Me.m_debug) cout << "parser1> current_tag=" << Me.m_current_tag << endl;
     6366
     6367//   if (ap.help_action == action_help)
     6368//     {
     6369//       do_help (ap);
     6370//       int code (0);
     6371//       if (CmtError::has_pending_error ())
     6372//      {
     6373//        code = CmtError::get_last_error_code ();
     6374//        CmtError::print ();
     6375//      }
     6376//       return code;
     6377//       //return (0);
     6378//     }
    63266379
    63276380  switch (Me.m_action)
     
    64206473    case action_unlock :
    64216474    case action_version :
     6475      if (Me.m_use_cmt)
     6476        {
    64226477      use_cmt ();
     6478        }
    64236479      //
    64246480      // Now parse the requirements file stored in ${CMTHOME}
     
    66466702        bool w = Me.m_warnings;
    66476703        Me.m_warnings = false;
    6648         reach_current_package ();
     6704        if (strlen (ap.extra_file.c_str ()) == 0)
     6705          reach_current_package ();
     6706        else
     6707          use_extra_file (ap.extra_file);
    66496708        use_user_context_requirements ();
    66506709        Me.m_warnings = w;
     
    77647823}
    77657824
     7825//----------------------------------------------------------
     7826int Cmt::use_extra_file (const cmt_string& file)
     7827{
     7828  if (!CmtSystem::test_file (file))
     7829    {
     7830      CmtError::set (CmtError::path_not_found, file);
     7831      return 0;
     7832    }
     7833
     7834  // (almost) Cmt::reach_current_package ()
     7835  Use& use = Use::current ();
     7836  /*
     7837    Try to access the package.
     7838  */
     7839
     7840  if (Me.m_current_package == "cmt_standalone")
     7841    {
     7842      if ((Me.m_current_path != "") && (Me.m_current_path != CmtSystem::pwd ()))
     7843        {
     7844          if (!CmtSystem::cd (Me.m_current_path))
     7845            {
     7846              CmtError::set (CmtError::package_not_found,
     7847                             "ReachCurrentPackage> Cannot reach the path directory");
     7848              return (0);
     7849            }
     7850        }
     7851      /*
     7852      if (!CmtSystem::test_file ("requirements"))
     7853        {
     7854          return (0);
     7855        }
     7856      */
     7857      Me.m_current_structuring_style = without_version_directory;
     7858    }
     7859  else if (Me.m_current_package != "")
     7860    {
     7861      if (!use.move_to () && !use.move_to ("", true))
     7862        //      if (!use.move_to ())
     7863        {
     7864          CmtError::set (CmtError::package_not_found,
     7865                         "ReachCurrentPackage> Cannot reach the path directory");
     7866          //          return -1;
     7867          return (0);
     7868        }
     7869
     7870      Me.m_current_path = use.real_path;
     7871    }
     7872  else
     7873    {
     7874      //
     7875      // The cmt command has been given without explicit search for
     7876      // a package. Thus it is expected that we are in the context of a
     7877      // true package.
     7878      //
     7879      //  This means that there should be a requirements file visible.
     7880      //
     7881      //  If this is not true, we'll make a try into ../cmt and then
     7882      // a last try into ../mgr
     7883      //
     7884
     7885      //...
     7886    }
     7887
     7888  configure_current_dir ();
     7889  build_prefix (Me.m_current_package, Me.m_current_prefix);
     7890  build_config (Me.m_current_prefix, Me.m_current_config);
     7891
     7892  /*
     7893    Check Tag is always set up
     7894  */
     7895
     7896  if (Me.m_debug) cout << "use_extra_file0> current_tag=" << Me.m_current_tag << endl;
     7897
     7898  if (Me.m_current_tag == "")
     7899    {
     7900      cmt_string env;
     7901
     7902      env = CmtSystem::getenv (Me.m_current_config);
     7903      if (env != "")
     7904        {
     7905          Tag* tag;
     7906
     7907          tag = Tag::add (env, PriorityConfig, "reach current package", 0);
     7908          tag->mark ();
     7909          //Me.m_current_tag = env;
     7910
     7911          //if (!Me.m_quiet) cerr << "use_extra_file1> current_tag=" << Me.m_current_tag << endl;
     7912
     7913        }
     7914    }
     7915
     7916  if (Me.m_debug)
     7917    {
     7918      cout << "pwd = " << CmtSystem::pwd () << endl;
     7919    }
     7920
     7921  /*
     7922    Work on the requirements file.
     7923  */
     7924
     7925  SyntaxParser::parse_requirements (file, &use);
     7926
     7927  if (Me.m_debug) cout << "use_extra_file2> current_tag=" << Me.m_current_tag << endl;
     7928
     7929  /**
     7930   *   It would be useful to change this mechanism. Instead of
     7931   *  applying all global patterns at once to all use contexts, it
     7932   *  would be much better to apply it at the end of each
     7933   *  requirements file parsing, and only in the context the
     7934   *  appropriate Use.
     7935   *
     7936   *   This would avoid the current flaw which is that when a global
     7937   *  pattern specifies a "private" definition, it is actually
     7938   *  applied in the scope context of the Current Use and not in
     7939   *  each individual Use. Therefore the private is lost.
     7940   *
     7941   *   However, this induces problems since some pattern definitions
     7942   *  are done AFTER the use statements, which will NOT receive the
     7943   *  pattern aplications.
     7944   *
     7945   *   Therefore it is decided to leave this "bad" mechanism until
     7946   *  everybody is aware of this constraint.
     7947   *
     7948   *
     7949   */
     7950  Pattern::apply_all_globals ();
     7951
     7952  /*
     7953    Select all possible tags
     7954  */
     7955
     7956  Tag::restore_tree ();
     7957
     7958  return (1);
     7959}
     7960
     7961//----------------------------------------------------------
    77667962static cmt_string get_best_form (const CmtSystem::cmt_string_vector& pwd,
    77677963                                 const cmt_string& path)
Note: See TracChangeset for help on using the changeset viewer.