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_commands.cxx

    r550 r561  
    337337  pv.push_back (&ArgParser::option_version); i++;
    338338
     339  parsers.add ("-with_c", i);
     340  parsers.add ("-with_cm", i);
     341  parsers.add ("-with_cmt", i);
     342  pv.push_back (&ArgParser::option_with_cmt); i++;
     343
     344  parsers.add ("-without_c", i);
     345  parsers.add ("-without_cm", i);
     346  parsers.add ("-without_cmt", i);
     347  pv.push_back (&ArgParser::option_without_cmt); i++;
     348
    339349  parsers.add ("-warn", i);
    340350  parsers.add ("-warni", i);
     
    520530          // We have unexpected arguments (not handled by the command handler). This may sign
    521531          // an unprotected handler implementation.
    522           CmtMessage::warning ("unexpected parameter " + reduced_arg);
     532          if (help_action != action_help)
     533            CmtMessage::warning ("unexpected parameter " + reduced_arg);
    523534          //      if (!cmt.m_quiet) cerr << "#CMT> warning : unexpected parameter " << reduced_arg << endl;
    524535        }
     
    577588      if (arg == "constituent_makefile")
    578589        {
    579           //      if (argc > 0)
    580           if (argc == 1 || (argc == 2 && cmt_string (argv[0]).substr (0, 5) == "-out="))
    581             {
    582               //fill_one_argument ();
    583               fill_arguments ();
    584               cmt.m_action = action_build_constituent_makefile;
    585             }
    586           else if (argc > 0)
    587             {
    588               CmtMessage::error ("syntax: wrong arguments");
    589 //            if (!cmt.m_quiet) cerr << "#CMT> syntax error : wrong arguments" << endl;
    590               cmt.m_action = action_build_constituent_makefile;
     590          cmt.m_action = action_build_constituent_makefile;
     591          bool need_name (true);
     592          while (argc > 0)
     593            {
     594              cmt_string arg(argv[0]);
     595              if (arg.substr (0, 5) == "-out=")
     596                {
     597                  fill_one_argument ();
     598                }
     599              else if (arg == "-with_cmt")
     600                {
     601                  shift ();
     602                  cmt.m_use_cmt = true;
     603                }
     604              else if (arg == "-without_cmt")
     605                {
     606                  shift ();
     607                  cmt.m_use_cmt = false;
     608                }
     609              else if (need_name && arg != "")
     610                {
     611                  need_name = false;
     612                  fill_one_argument ();
     613                }
     614              else
     615                {
     616                  help_action = action_help;
     617                  CmtError::set (CmtError::syntax_error, arg + ": wrong argument");
     618                  break;
     619                }
     620            }
     621          if (need_name)
     622            {
    591623              help_action = action_help;
    592             }
    593           else
    594             {
    595               CmtMessage::error ("syntax: constituent name missing");
    596               //              if (!cmt.m_quiet) cerr << "#CMT> syntax error : constituent name missing" << endl;
    597               cmt.m_action = action_build_constituent_makefile;
     624              if (!CmtError::has_pending_error ())
     625                CmtError::set (CmtError::syntax_error, "argument(s) missing");
     626            }
     627        }
     628      else if (arg == "constituent_config")
     629        {
     630          cmt.m_action = action_build_constituent_config;
     631          bool need_name (true);
     632          while (argc > 0)
     633            {
     634              cmt_string arg(argv[0]);
     635              if (arg.substr (0, 5) == "-out=")
     636                {
     637                  fill_one_argument ();
     638                }
     639              else if (need_name && arg != "")
     640                {
     641                  need_name = false;
     642                  fill_one_argument ();
     643                }
     644              else
     645                {
     646                  help_action = action_help;
     647                  CmtError::set (CmtError::syntax_error, arg + ": wrong argument");
     648                  break;
     649                }
     650            }
     651          if (need_name)
     652            {
    598653              help_action = action_help;
    599             }
    600         }
    601       else if (arg == "constituent_config")
    602         {
    603           //      if (argc > 0)
    604           if (argc == 1 ||
    605               argc == 2 &&
    606               (cmt_string (argv[0]).substr (0, 5) == "-out=" ||
    607                cmt_string (argv[1]).substr (0, 5) == "-out=")
    608               )
    609             {
    610               //fill_one_argument ();
    611               fill_arguments ();
    612               cmt.m_action = action_build_constituent_config;
    613             }
    614           else if (argc > 0)
    615             {
    616               CmtMessage::error ("syntax: wrong arguments");
    617 //            if (!cmt.m_quiet) cerr << "#CMT> syntax error : wrong arguments" << endl;
    618               cmt.m_action = action_build_constituent_config;
    619               help_action = action_help;
    620             }
    621           else
    622             {
    623               CmtMessage::error ("syntax: constituent name missing");
    624               //              if (!cmt.m_quiet) cerr << "#CMT> syntax error : constituent name missing" << endl;
    625               cmt.m_action = action_build_constituent_config;
    626               help_action = action_help;
     654              if (!CmtError::has_pending_error ())
     655                CmtError::set (CmtError::syntax_error, "argument(s) missing");
    627656            }
    628657        }
    629658      else if (arg == "constituents_makefile")
    630659        {
    631           fill_arguments ();
    632660          cmt.m_action = action_build_constituents_makefile;
     661          while (argc > 0)
     662            {
     663              cmt_string arg(argv[0]);
     664              if (arg.substr (0, 5) == "-out=")
     665                {
     666                  fill_one_argument ();
     667                }
     668              else
     669                {
     670                  help_action = action_help;
     671                  CmtError::set (CmtError::syntax_error, arg + ": wrong argument");
     672                  break;
     673                }
     674            }
    633675        }
    634676      else if (arg == "constituents_config")
    635677        {
    636           fill_arguments ();
    637678          cmt.m_action = action_build_constituents_config;
     679          while (argc > 0)
     680            {
     681              cmt_string arg(argv[0]);
     682              if (arg.substr (0, 5) == "-out=" ||
     683                  arg == "-with_cmt" ||
     684                  arg == "-without_cmt")
     685                {
     686                  fill_one_argument ();
     687                }
     688              else
     689                {
     690                  help_action = action_help;
     691                  CmtError::set (CmtError::syntax_error, arg + ": wrong argument");
     692                  break;
     693                }
     694            }
    638695        }
    639696      else if (arg == "dependencies")
     
    759816      else
    760817        {
    761           CmtMessage::error ("syntax: wrong build argument");
     818          CmtError::set (CmtError::syntax_error, "wrong argument: " + arg);
     819          //CmtMessage::error ("syntax: wrong build argument: " + arg);
    762820          //      if (!cmt.m_quiet) cerr << "#CMT> syntax error : wrong build argument" << endl;
    763821          help_action = action_help;
     
    767825  else
    768826    {
    769       CmtMessage::error ("syntax: don't know what to build");
     827      cmt.m_action = action_build;
     828      if (help_action != action_help)
     829        {
     830          help_action = action_help;
     831          CmtError::set (CmtError::syntax_error, "argument(s) missing");
     832          //CmtMessage::error ("syntax: don't know what to build");
    770833      //      if (!cmt.m_quiet) cerr << "#CMT> syntax error : don't know what to build" << endl;
    771       help_action = action_help;
    772       cmt.m_action = action_build;
     834        }
    773835    }
    774836}
     
    21292191}
    21302192
     2193void ArgParser::option_with_cmt ()
     2194{
     2195  cmt.m_use_cmt = true;
     2196}
     2197
     2198void ArgParser::option_without_cmt ()
     2199{
     2200  cmt.m_use_cmt = false;
     2201}
     2202
    21312203void ArgParser::option_with_version_directory ()
    21322204{
     
    22192291  cerr << "#   -version=<version>      : set version" << endl;
    22202292  cerr << "#   -path=<path>            : set root path" << endl;
    2221   cerr << "#   -f=<requirement-file>   : set input file" << endl;
     2293  cerr << "#   -f=<requirements-file>  : set input file" << endl;
    22222294  cerr << "#   -e=<statement>          : add a one line statement" << endl;
    22232295  cerr << "#   -tag=<tag-list>         : select a new tag-set" << endl;
     
    22402312  if (action == action_build)
    22412313    {
     2314      const cmt_string& s = get_help_text (action);
     2315      cerr << "# " << s << endl;
    22422316      int i;
    22432317
     
    22482322        }
    22492323    }
    2250   if (action == action_check)
     2324  else if (action == action_check)
    22512325    {
    22522326      int i;
     
    22712345    {
    22722346      const cmt_string& s = get_help_text (action);
    2273       cerr << "#" << s << endl;
     2347      cerr << "# " << s << endl;
    22742348    }
    22752349}
     
    22922366  help_texts.add () =  "awk";
    22932367  help_texts.add () =  "broadcast [-select=list] [-exclude=list] [-local] [-global] [-begin=pattern] [-depth=n] <command> : apply a command to [some of] the used packages";
    2294   help_texts.add () =  "build <option>          : build actions. (Try cmt help build)";
    2295   help_texts.add () =  "build constituent_makefile <constituent>  : generate constituent Makefile fragment";
    2296   help_texts.add () =  "build constituent_config <constituent>  : generate constituent Makefile fragment, also tag specific Makefile, and setup definitions file, if constituent has associated tag (via -target_tag option, or is action)";
    2297   help_texts.add () =  "build constituents_makefile : generate constituents.make";
    2298   help_texts.add () =  "build constituents_config : generate constituents.make, tag specific Makefile, and setup definitions file";
     2368  help_texts.add () =  "build <argument>          : build actions. Try 'cmt help build'";
     2369  //  help_texts.add () =  "build <option>          : build actions. (Try cmt help build)";
     2370  help_texts.add () =  "build constituent_makefile [-out=<path>] [-with_cmt] [-without_cmt] <constituent> : generate constituent Makefile fragment";
     2371  help_texts.add () =  "build constituent_config [-out=<path>] <constituent> : generate constituent Makefile fragment, also tag specific Makefile, and setup definitions file for constituent with associated tag (via -target_tag option, or action)";
     2372  help_texts.add () =  "build constituents_makefile [-out=<path>] : generate constituents Makefile";
     2373  help_texts.add () =  "build constituents_config [-out=<path>] [-with_cmt] [-without_cmt] : generate constituents Makefile, tag specific Makefile, and setup definitions file, also input requirements file for constituent(s) without associated tag";
    22992374  help_texts.add () =  "build dependencies      : generate dependencies";
    23002375  help_texts.add () =  "build library_links     : build symbolic links towards all imported libraries";
Note: See TracChangeset for help on using the changeset viewer.