Changeset 561 for CMT/HEAD


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

See C.L. 444

Location:
CMT/HEAD
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r560 r561  
     12011-03-07    <rybkin@lal.in2p3.fr> 444
     2
     3        * source/cmt_system.cxx: In class CmtSystem, introduce function quote
     4        * source/cmt_system.h: idem
     5        * source/cmt_fragment.cxx: In class fragment_action_iterator, function
     6        add_word, ensure that header, trailer fragments are overridden, if declared
     7        again, introduce, parse and set for current use fragment m_path. In class
     8        Fragment, in function add, introduce argument path, in function print
     9        introduce PrintMode, ostream arguments and add implementation for
     10        Requirements mode, in function locate, optimise fragment search, add
     11        warning, if not found. In class FragmentHandle, in functions copy do not
     12        print info message about not found fragment, in function setup make such
     13        message warning
     14        * source/cmt_fragment.h: idem
     15        * source/cmt_constituent.cxx: In class Constituent, in function show
     16        introduce argument ostream, make use of class CmtSystem function quote
     17        * source/cmt_constituent.h: idem
     18        * source/cmt_language.cxx: In class Language, introduce members m_use,
     19        m_dependencies_options_expanded, function dependencies_options_expanded, in
     20        function show, introduce PrintMode, ostream arguments and add
     21        implementation for Requirements mode, in function action, introduce
     22        argument Use*
     23        * source/cmt_language.h: idem
     24        * source/cmt_syntax.cxx: Make use of modified class Language function action
     25        * source/cmt_symbol.cxx: Remove helper function quote
     26        * source/cmt.h: In class CmtContext, introduce member m_use_cmt, in class
     27        Cmt, function use_extra_file
     28        * source/cmt_generators.h: In class ConstituentsMakefileGenerator function
     29        build use package, and file arguments only
     30        * source/cmt_generators.cxx: In class LibraryGenerator, in function,
     31        java_file_action do not test for output file existence, in function build,
     32        do not invoke function prepare_use_context. In class DocumentGenerator, in
     33        function build, do not invoke function filter_path, prepare_use_context,
     34        get_all_files for second time, do not check for existence of source file or
     35        issue warning (done in function analyze_file), in function analyze_file, do
     36        not define variable output_dir. In class ConstituentsMakefileGenerator
     37        function build, use file argument rather than parse string vector
     38        * source/cmt_generator.h: Introduce class InGenerator, in class Generator
     39        function build_constituents_makefile, use file argument rather than string
     40        vector, introduce function build_constituent_infile
     41        * source/cmt_generator.cxx: Implement introduced class and function in
     42        order to generate input constituent requirements file
     43        * source/cmt_commands.h: Introduce global options -with_cmt, -without_cmt
     44        * source/cmt_commands.cxx: Implement options -with_cmt, -without_cmt,
     45        global and for commands "build constituent makefile", "build constituents
     46        config", enhance options parsing for commands "build constituent(s)
     47        makefile/config", improve error handling, diagnostic and help messages
     48        * source/cmt_parser.cxx: Enhance options parsing and error handling in Cmt
     49        class functions do_build_constituent(s)_makefile,
     50        do_build_constituent(s)_config, generate input requirements file for
     51        constituent(s) without associated tag in function
     52        do_build_constituents_config. In function parser, handle help requests
     53        immediately after parse_arguments, do not use CMT if requested, use extra
     54        file instead of requirements, if specified, via implemented function
     55        use_extra_file
     56        * mgr/fragments/constituent: Generate constituent Makefile from input
     57        requirements file (with -f, -without_cmt options) for constituent without
     58        associated tag
     59        * mgr/fragments/constituent_lock: idem
     60        * mgr/cmt_make_shlib_common.sh: Improve error handling, unset CMTDEBUG if
     61        set in order to avoid debug output interference with script
     62        * mgr/cmt_install_action.sh: idem
     63        * mgr/requirements: Do not declare readme_doc fragment (not provided)
     64       
    1652010-09-07    <rybkin@lal.in2p3.fr> 443
    266
  • CMT/HEAD/mgr/cmt_install_action.sh

    r446 r561  
    110110   
    111111  if test "${cmtpath}" = ""; then
    112     package=`cmt show macro_value package`
    113     cmtpath=`cmt show macro_value ${package}_cmtpath`
     112    if [ "${CMTDEBUG:-}" ]; then
     113      unset CMTDEBUG
     114      set -x
     115    fi
     116    package=`cmt show macro_value package` || exit
     117    cmtpath=`cmt show macro_value ${package}_cmtpath` || exit
    114118  fi
    115119
  • CMT/HEAD/mgr/cmt_make_shlib_common.sh

    r469 r561  
    2929extra=$*
    3030
    31 ld=`${CMTROOT}/mgr/cmt show macro_value shlibbuilder -tag=${tag}`
    32 ldflags=`${CMTROOT}/mgr/cmt show macro_value shlibflags -tag=${tag}`
    33 suffix=`${CMTROOT}/mgr/cmt show macro_value shlibsuffix -tag=${tag}`
    34 libprefix=`${CMTROOT}/mgr/cmt show macro_value library_prefix -tag=${tag}`
    35 libsuffix=`${CMTROOT}/mgr/cmt show macro_value library_suffix -tag=${tag}`
     31if [ "${CMTDEBUG:-}" ]; then
     32unset CMTDEBUG
     33set -x
     34fi
     35
     36ld=`${CMTROOT}/mgr/cmt show macro_value shlibbuilder -tag=${tag}` || exit
     37ldflags=`${CMTROOT}/mgr/cmt show macro_value shlibflags -tag=${tag}` || exit
     38suffix=`${CMTROOT}/mgr/cmt show macro_value shlibsuffix -tag=${tag}` || exit
     39libprefix=`${CMTROOT}/mgr/cmt show macro_value library_prefix -tag=${tag}` || exit
     40libsuffix=`${CMTROOT}/mgr/cmt show macro_value library_suffix -tag=${tag}` || exit
    3641
    3742libname=${libprefix}${lib}${libsuffix}
     
    4247
    4348if test "${bin}" = "" ; then
    44   bin=`${CMTROOT}/mgr/cmt show macro_value bin -tag=${tag}`
     49  bin=`${CMTROOT}/mgr/cmt show macro_value bin -tag=${tag}` || exit
    4550fi
    4651
    4752here=`/bin/pwd`
    48 cd ${bin}
     53cd ${bin} || exit
    4954
    50 /bin/rm -f ${libname}.${suffix}
     55/bin/rm -f ${libname}.${suffix} || exit
    5156
    5257result=0
     
    6166
    6267  (cd ${temp_shlib}; ar x ../${libname}.a)
     68  result=$?
     69  if [ ${result} -ne 0 ]; then
     70      \rm -rf ${temp_shlib}
     71      cd ${here}
     72      exit ${result}
     73  fi
    6374
    6475  #
  • CMT/HEAD/mgr/fragments/constituent

    r548 r561  
    6666#endif
    6767
    68 makefiles : $(cmt_local_${CONSTITUENT}_makefile)
     68ifdef cmt_${CONSTITUENT}_has_target_tag
    6969
    7070ifndef QUICK
    7171$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) build_library_links
    72 #$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_local_tagfile_${CONSTITUENT}) build_library_links
    7372        $(echo) "(constituents.make) Building ${CONSTITUENT}.make"; \
    7473          $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
    7574else
    7675$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies)
    77 #$(cmt_local_${CONSTITUENT}_makefile) : $(cmt_local_tagfile_${CONSTITUENT})
    7876        if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
    7977          [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \
     
    8280          $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}; \
    8381          fi
     82endif
     83
     84else
     85
     86ifndef QUICK
     87$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) build_library_links
     88        $(echo) "(constituents.make) Building ${CONSTITUENT}.make"; \
     89          $(cmtexe) -f=$(bin)${CONSTITUENT}.in -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_makefile -without_cmt -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
     90else
     91$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies)
     92        if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
     93          [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \
     94          test -z "$(cmtmsg)" || \
     95          echo "$(CMTMSGPREFIX)" "(constituents.make) Building ${CONSTITUENT}.make"; \
     96          $(cmtexe) -f=$(bin)${CONSTITUENT}.in -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_makefile -without_cmt -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}; \
     97          fi
     98endif
     99
    84100endif
    85101
  • CMT/HEAD/mgr/fragments/constituent_lock

    r548 r561  
    6666#endif
    6767
    68 makefiles : $(cmt_local_${CONSTITUENT}_makefile)
     68ifdef cmt_${CONSTITUENT}_has_target_tag
    6969
    7070ifndef QUICK
    7171$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) build_library_links
    72 #$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_local_tagfile_${CONSTITUENT}) build_library_links
    7372        $(echo) "(constituents.make) Building ${CONSTITUENT}.make"; \
    7473          $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
    7574else
    7675$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies)
    77 #$(cmt_local_${CONSTITUENT}_makefile) : $(cmt_local_tagfile_${CONSTITUENT})
    7876        if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
    7977          [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \
     
    8280          $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}; \
    8381          fi
     82endif
     83
     84else
     85
     86ifndef QUICK
     87$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) build_library_links
     88        $(echo) "(constituents.make) Building ${CONSTITUENT}.make"; \
     89          $(cmtexe) -f=$(bin)${CONSTITUENT}.in -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_makefile -without_cmt -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
     90else
     91$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies)
     92        if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
     93          [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \
     94          test -z "$(cmtmsg)" || \
     95          echo "$(CMTMSGPREFIX)" "(constituents.make) Building ${CONSTITUENT}.make"; \
     96          $(cmtexe) -f=$(bin)${CONSTITUENT}.in -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_makefile -without_cmt -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}; \
     97          fi
     98endif
     99
    84100endif
    85101
  • CMT/HEAD/mgr/requirements

    r556 r561  
    593593make_fragment readme_header
    594594make_fragment readme
    595 make_fragment readme_doc
     595#make_fragment readme_doc
    596596make_fragment readme_use
    597597make_fragment readme_trailer
  • CMT/HEAD/source/cmt.h

    r550 r561  
    3333  cmt_string m_cmt_site;
    3434  cmt_string m_cmt_version;
     35  bool m_use_cmt;
    3536 
    3637  cmt_string m_current_dir;
     
    263264  static void print_xml_prolog (const cmt_string& root = "cmt", ostream& out = cout);
    264265  static int reach_current_package ();
     266  static int use_extra_file (const cmt_string& file);
    265267  static void restore_all_tags (Use* use);
    266268  static void set_current_access (AccessMode mode);
  • 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";
  • CMT/HEAD/source/cmt_commands.h

    r550 r561  
    8181  void option_tag_remove ();
    8282  void option_user_context ();
     83  void option_with_cmt ();
     84  void option_without_cmt ();
    8385  void option_with_version_directory ();
    8486  void option_without_version_directory ();
  • CMT/HEAD/source/cmt_constituent.cxx

    r459 r561  
    573573
    574574//----------------------------------------------------------
    575 void Constituent::show () const
     575void Constituent::show (ostream& out) const
     576//void Constituent::show () const
    576577{
    577578  int i;
     
    580581    {
    581582    case Library:
    582       cout << "library";
     583      out << "library";
    583584      break;
    584585    case Application:
    585       cout << "application";
     586      out << "application";
    586587      break;
    587588    case Document:
    588       cout << "document " << generator;
     589      out << "document " << generator;
    589590      break;
    590591    }
    591592 
    592   cout << " " << name;
     593  out << " " << name;
    593594 
    594595  if (group != 0)
    595596    {
    596       cout << " -group=" << group->name ();
     597      out << " -group=" << group->name ();
    597598    }
    598599 
    599600  if (suffix != 0)
    600601    {
    601       cout << " -suffix=" << suffix;
     602      out << " -suffix=" << suffix;
    602603    }
    603604 
    604605  if ((type == Application) && need_check)
    605606    {
    606       cout << " -check";
     607      out << " -check";
    607608    }
    608609 
    609610  if ((type == Library) && no_share)
    610611    {
    611       cout << " -no_share";
     612      out << " -no_share";
    612613    }
    613614 
    614615  if ((type == Library) && no_static)
    615616    {
    616       cout << " -no_static";
     617      out << " -no_static";
    617618    }
    618619 
    619620  if ((type == Library) && build_triggers)
    620621    {
    621       cout << " -triggers";
     622      out << " -triggers";
    622623    }
    623624 
    624625  if (has_target_tag)
    625626    {
    626       cout << " -target_tag";
     627      out << " -target_tag";
    627628    }
    628629 
     
    631632      const cmt_string& import_name = imports[i];
    632633     
    633       cout << " -import=" << import_name;
     634      out << " -import=" << import_name;
    634635    }
    635636 
     
    638639      const cmt_string& exclude = excludes[i];
    639640     
    640       cout << " -x=" << exclude;
     641      out << " -x=" << exclude;
    641642    }
    642643 
     
    645646      const cmt_string& select = selects[i];
    646647     
    647       cout << " -k=" << select;
     648      out << " -k=" << select;
    648649    }
    649650 
     
    652653      const cmt_string& module_name = modules[i];
    653654     
    654       cout << " " << module_name;
     655      out << " " << module_name;
    655656    }
    656657 
     
    659660      const Variable& v = variables[i];
    660661     
    661       cout << " " << v.name << "=" << v.value;
    662     }
    663  
    664   cout << endl;
    665 }
     662      //      out << " " << v.name << "=" << v.value;
     663      // quote (up to) 2 times as split is applied 2 times
     664      // - before action
     665      // - in parse
     666      cmt_string qvalue (CmtSystem::quote (v.value, " \t"));
     667      out << " " << v.name << "="
     668          << (qvalue == v.value ? v.value : CmtSystem::quote (qvalue, " \t"));
     669      //          << CmtSystem::quote (CmtSystem::quote (v.value, " \t"), " \t");
     670    }
     671 
     672  out << endl;
     673}
  • CMT/HEAD/source/cmt_constituent.h

    r11 r561  
    4343  virtual void build_msdev_file (bool simulation) const;
    4444  virtual void build_vsnet_file (bool simulation) const;
    45   virtual void show () const;
     45  virtual void show (ostream& out = cout) const;
     46  //  virtual void show () const;
    4647
    4748  cmt_string name;
  • CMT/HEAD/source/cmt_fragment.cxx

    r528 r561  
    200200            m_header.replace ("-header=", "");
    201201
    202             if (Fragment::find (m_header) == 0)
    203               {
    204                 Fragment::add (m_header, "", "", "", false, m_use);
    205               }
     202//          if (Fragment::find (m_header) == 0)
     203//            {
     204            Fragment::add (m_header, "", "", "", false, m_use, "");
     205//            }
    206206          }
    207207        else if (w.find ("-trailer=") != cmt_string::npos)
     
    210210            m_trailer.replace ("-trailer=", "");
    211211           
    212             if (Fragment::find (m_trailer) == 0)
    213               {
    214                 Fragment::add (m_trailer, "", "", "", false, m_use);
    215               }
     212//          if (Fragment::find (m_trailer) == 0)
     213//            {
     214            Fragment::add (m_trailer, "", "", "", false, m_use, "");
     215//            }
     216          }
     217        else if (0 == m_use || &Use::current () == m_use)
     218          {
     219            m_path = w;
    216220          }
    217221        break;
     
    221225  void commit ()
    222226  {
    223     Fragment::add (m_name, m_suffix, m_header, m_trailer, m_need_dependencies, m_use);
     227    Fragment::add (m_name, m_suffix, m_header, m_trailer, m_need_dependencies, m_use, m_path);
    224228  }
    225229
     
    238242  bool m_need_dependencies;
    239243  Use* m_use;
     244  cmt_string m_path;
    240245};
    241246
     
    309314                    const cmt_string& trailer,
    310315                    bool need_dependencies,
    311                     Use* use)
     316                    Use* use,
     317                    const cmt_string& path)
     318//                    Use* use)
    312319{
    313320  static FragmentVector& Fragments = fragments ();
     
    339346
    340347        fragment->use = use;
     348        if (path != "")
     349          {
     350            fragment->path = path;
     351          }
    341352        return;
    342353      }
     
    351362  fragment.need_dependencies = need_dependencies;
    352363  fragment.use               = use;
     364  fragment.path              = path;
    353365}
    354366
     
    409421
    410422/*----------------------------------------------------------*/
    411 int Fragment::print ()
     423int Fragment::print (PrintMode mode, ostream& out)
     424//int Fragment::print ()
    412425{
    413426  int result = 1;
     
    423436    }
    424437 
     438  switch (mode)
     439    {
     440    case Requirements :
     441      out << "make_fragment " << name
     442          << (suffix != "" ? " -suffix=" + suffix : "")
     443          << (header != "" ? " -header=" + header : "")
     444          << (trailer != "" ? " -trailer=" + trailer : "")
     445          << (need_dependencies ? " -dependencies" : "")
     446        ;
     447      break;
     448    default:
     449      break;
     450    }
     451
    425452  cmt_string the_path = path;
    426453
    427   use->reduce_path (the_path);
    428 
    429   cout << the_path;
    430 
    431   if (suffix != "")
    432     {
    433       cout << "->" << suffix;
    434     }
    435 
    436   cout << endl;
    437 
     454  switch (mode)
     455    {
     456    case Requirements :
     457      the_path = " " + the_path;
     458      break;
     459    default:
     460      use->reduce_path (the_path);
     461      break;
     462    }
     463 
     464  out << the_path;
     465
     466  switch (mode)
     467    {
     468    case Requirements :
     469      break;
     470    default:
     471      if (suffix != "")
     472        {
     473          out << "->" << suffix;
     474        }
     475      break;
     476    }
     477
     478  out << endl;
     479 
    438480  return (result);
    439481}
     
    442484bool Fragment::locate ()
    443485{
    444   cmt_string root_path;
     486  if (path != "") return (true);
    445487
    446488  if (use == 0)
     
    450492    }
    451493
     494  if (Cmt::get_debug ())
     495    {
     496      cout << "Fragment::locate> " << name
     497           << " in " << use->get_package_name () << endl;
     498    }
     499  cmt_string root_path;
     500
     501  // First try <root>/cmt/fragments/<name> for Unix
     502  //       or <root>/cmt/fragments/nmake/<name> for Win
     503
    452504  use->get_full_path (root_path);
    453505
    454   if (path != "") return (true);
    455 
    456   // First try <root>/fragments/<name> or <root>/fragments/nmake/<name>
    457 
    458   path = root_path;
    459   path += CmtSystem::file_separator ();
    460   path += "fragments";
    461   path += CmtSystem::file_separator ();
    462  
    463   if (Cmt::build_nmake ())
    464     {
    465       path += "nmake";
    466       path += CmtSystem::file_separator ();
    467     }
    468  
    469   path += name;
    470 
    471   if (CmtSystem::test_file (path)) return (true);
    472 
    473   // Then try <root>/fragments/<name> for both Win and Unix
    474 
    475   path = root_path;
    476   path += CmtSystem::file_separator ();
    477   path += "fragments";
    478   path += CmtSystem::file_separator ();
    479   path += name;
    480 
    481   if (CmtSystem::test_file (path)) return (true);
    482 
    483   // Then try <root>/cmt/fragments/<name> or <root>/cmt/fragments/nmake/<name>
    484 
    485   root_path += CmtSystem::file_separator ();
    486 
    487   if (use->style == mgr_style) root_path += "mgr";
    488   else root_path += "cmt";
     506  if (use->style == cmt_style)
     507    {
     508      root_path += CmtSystem::file_separator ();
     509      root_path += "cmt";
     510    }
     511  else if (use->style == mgr_style)
     512    {
     513      root_path += CmtSystem::file_separator ();
     514      root_path += "mgr";
     515    }
    489516 
    490517  root_path += CmtSystem::file_separator ();
     
    501528 
    502529  path += name;
    503  
     530  //cerr << "test_file: " << path << endl; 
    504531  if (CmtSystem::test_file (path)) return (true);
    505532
    506   // Then try <root>/cmt/fragments/<name> for both Win and Unix
     533  // Then try <root>/cmt/fragments/<name> for Win
     534
     535  if (Cmt::build_nmake ())
     536    {
     537      path = root_path;
     538      path += name;
     539     
     540      if (CmtSystem::test_file (path)) return (true);
     541    }
     542
     543  // Then try <root>/fragments/<name> for Unix
     544  //      or <root>/fragments/nmake/<name> for Win
     545
     546  use->get_full_path (root_path);
     547
     548  root_path += CmtSystem::file_separator ();
     549  root_path += "fragments";
     550  root_path += CmtSystem::file_separator ();
    507551
    508552  path = root_path;
    509553 
     554  if (Cmt::build_nmake ())
     555    {
     556      path += "nmake";
     557      path += CmtSystem::file_separator ();
     558    }
     559 
    510560  path += name;
    511561
     562  //cerr << "test_file: " << path << endl; 
    512563  if (CmtSystem::test_file (path)) return (true);
    513564
     565  // Then try <root>/fragments/<name> for Win
     566
     567  if (Cmt::build_nmake ())
     568    {
     569      path = root_path;
     570      path += name;
     571
     572      if (CmtSystem::test_file (path)) return (true);
     573    }
     574
     575  CmtMessage::warning
     576    (CmtError::get_error_name (CmtError::fragment_not_found)
     577     + ": " + name);
    514578  return (false);
    515579}
     
    11161180  if (!result)
    11171181    {
     1182      //      CmtMessage::info ("Fragment " + _name + " not found");
     1183      //      cerr << "#CMT> Fragment " << _name << " not found" << endl;
     1184      _fragment = 0;
     1185    }
     1186
     1187  return (result);
     1188}
     1189
     1190//--------------------------------------------------
     1191bool FragmentHandle::copy (cmt_string& out, int variables, ...)
     1192{
     1193  if (!setup ()) return (false);
     1194
     1195  va_list ids;
     1196
     1197  va_start (ids, variables);
     1198  bool result = _fragment->copy (out, variables, ids);
     1199  va_end (ids);
     1200
     1201  if (!result)
     1202    {
     1203      //      CmtMessage::info ("Fragment " + _name + " not found");
     1204      //      cerr << "#CMT> Fragment " << _name << " not found" << endl;
     1205      _fragment = 0;
     1206    }
     1207
     1208  return (result);
     1209}
     1210
     1211//--------------------------------------------------
     1212bool FragmentHandle::wincopy (FILE* out, int variables, ...)
     1213{
     1214  if (!setup ()) return (false);
     1215
     1216  va_list ids;
     1217
     1218  va_start (ids, variables);
     1219  bool result = _fragment->wincopy (out, variables, ids);
     1220  va_end (ids);
     1221
     1222  if (!result)
     1223    {
    11181224      CmtMessage::info ("Fragment " + _name + " not found");
    11191225      //      cerr << "#CMT> Fragment " << _name << " not found" << endl;
     
    11251231
    11261232//--------------------------------------------------
    1127 bool FragmentHandle::copy (cmt_string& out, int variables, ...)
     1233bool FragmentHandle::wincopy (cmt_string& out, int variables, ...)
    11281234{
    11291235  if (!setup ()) return (false);
     
    11321238
    11331239  va_start (ids, variables);
    1134   bool result = _fragment->copy (out, variables, ids);
     1240  bool result = _fragment->wincopy (out, variables, ids);
    11351241  va_end (ids);
    11361242
     
    11451251}
    11461252
    1147 //--------------------------------------------------
    1148 bool FragmentHandle::wincopy (FILE* out, int variables, ...)
     1253
     1254
     1255
     1256//--------------------------------------------------
     1257bool FragmentHandle::copy (FILE* out, const Variable::VariableVector& vector, int variables, ...)
    11491258{
    11501259  if (!setup ()) return (false);
     
    11531262
    11541263  va_start (ids, variables);
    1155   bool result = _fragment->wincopy (out, variables, ids);
     1264  bool result = _fragment->copy (out, vector, variables, ids);
     1265  va_end (ids);
     1266
     1267  if (!result)
     1268    {
     1269      //      CmtMessage::info ("Fragment " + _name + " not found");
     1270      //      cerr << "#CMT> Fragment " << _name << " not found" << endl;
     1271      _fragment = 0;
     1272    }
     1273
     1274  return (result);
     1275}
     1276
     1277//--------------------------------------------------
     1278bool FragmentHandle::copy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...)
     1279{
     1280  if (!setup ()) return (false);
     1281
     1282  va_list ids;
     1283
     1284  va_start (ids, variables);
     1285  bool result = _fragment->copy (out, vector, variables, ids);
     1286  va_end (ids);
     1287
     1288  if (!result)
     1289    {
     1290      //      CmtMessage::info ("Fragment " + _name + " not found");
     1291      //      cerr << "#CMT> Fragment " << _name << " not found" << endl;
     1292      _fragment = 0;
     1293    }
     1294
     1295  return (result);
     1296}
     1297
     1298//--------------------------------------------------
     1299bool FragmentHandle::wincopy (FILE* out, const Variable::VariableVector& vector, int variables, ...)
     1300{
     1301  if (!setup ()) return (false);
     1302
     1303  va_list ids;
     1304
     1305  va_start (ids, variables);
     1306  bool result = _fragment->wincopy (out, vector, variables, ids);
    11561307  va_end (ids);
    11571308
     
    11671318
    11681319//--------------------------------------------------
    1169 bool FragmentHandle::wincopy (cmt_string& out, int variables, ...)
     1320bool FragmentHandle::wincopy (cmt_string& out,
     1321                              const Variable::VariableVector& vector,
     1322                              int variables, ...)
    11701323{
    11711324  if (!setup ()) return (false);
     
    11741327
    11751328  va_start (ids, variables);
    1176   bool result = _fragment->wincopy (out, variables, ids);
     1329  bool result = _fragment->wincopy (out, vector, variables, ids);
    11771330  va_end (ids);
    11781331
     
    11871340}
    11881341
    1189 
    1190 
    1191 
    1192 //--------------------------------------------------
    1193 bool FragmentHandle::copy (FILE* out, const Variable::VariableVector& vector, int variables, ...)
    1194 {
    1195   if (!setup ()) return (false);
    1196 
    1197   va_list ids;
    1198 
    1199   va_start (ids, variables);
    1200   bool result = _fragment->copy (out, vector, variables, ids);
    1201   va_end (ids);
    1202 
    1203   if (!result)
    1204     {
    1205       CmtMessage::info ("Fragment " + _name + " not found");
    1206       //      cerr << "#CMT> Fragment " << _name << " not found" << endl;
    1207       _fragment = 0;
    1208     }
    1209 
    1210   return (result);
    1211 }
    1212 
    1213 //--------------------------------------------------
    1214 bool FragmentHandle::copy (cmt_string& out, const Variable::VariableVector& vector, int variables, ...)
    1215 {
    1216   if (!setup ()) return (false);
    1217 
    1218   va_list ids;
    1219 
    1220   va_start (ids, variables);
    1221   bool result = _fragment->copy (out, vector, variables, ids);
    1222   va_end (ids);
    1223 
    1224   if (!result)
    1225     {
    1226       CmtMessage::info ("Fragment " + _name + " not found");
    1227       //      cerr << "#CMT> Fragment " << _name << " not found" << endl;
    1228       _fragment = 0;
    1229     }
    1230 
    1231   return (result);
    1232 }
    1233 
    1234 //--------------------------------------------------
    1235 bool FragmentHandle::wincopy (FILE* out, const Variable::VariableVector& vector, int variables, ...)
    1236 {
    1237   if (!setup ()) return (false);
    1238 
    1239   va_list ids;
    1240 
    1241   va_start (ids, variables);
    1242   bool result = _fragment->wincopy (out, vector, variables, ids);
    1243   va_end (ids);
    1244 
    1245   if (!result)
    1246     {
    1247       CmtMessage::info ("Fragment " + _name + " not found");
    1248       //      cerr << "#CMT> Fragment " << _name << " not found" << endl;
    1249       _fragment = 0;
    1250     }
    1251 
    1252   return (result);
    1253 }
    1254 
    1255 //--------------------------------------------------
    1256 bool FragmentHandle::wincopy (cmt_string& out,
    1257                               const Variable::VariableVector& vector,
    1258                               int variables, ...)
    1259 {
    1260   if (!setup ()) return (false);
    1261 
    1262   va_list ids;
    1263 
    1264   va_start (ids, variables);
    1265   bool result = _fragment->wincopy (out, vector, variables, ids);
    1266   va_end (ids);
    1267 
    1268   if (!result)
    1269     {
    1270       CmtMessage::info ("Fragment " + _name + " not found");
    1271       //      cerr << "#CMT> Fragment " << _name << " not found" << endl;
    1272       _fragment = 0;
    1273     }
    1274 
    1275   return (result);
    1276 }
    1277 
    12781342//--------------------------------------------------
    12791343bool FragmentHandle::setup ()
     
    12861350      if (_fragment == 0)
    12871351        {
    1288           CmtMessage::info ("Fragment " + _name + " not found");
     1352          CmtMessage::warning
     1353            (CmtError::get_error_name (CmtError::fragment_not_found)
     1354             + ": " + _name);
    12891355          //          cerr << "#CMT> Fragment " << _name << " not found" << endl;
    12901356        }
    12911357    }
    1292 
     1358 
    12931359  if (_fragment == 0)
    12941360    {
  • CMT/HEAD/source/cmt_fragment.h

    r11 r561  
    6161                   const cmt_string& trailer,
    6262                   bool need_dependencies,
    63                    Use* use);
     63                   Use* use,
     64                   const cmt_string& path);
     65  //                   Use* use);
    6466  static void show (const cmt_string& name);
    6567  static void show_all ();
     
    7981  ~Fragment ();
    8082  void clear ();
    81   int print ();
     83  int print (PrintMode mode = Csh, ostream& out = cout); // Csh is default for ArgParser::mode
     84  //  int print ();
    8285  bool locate ();
    8386
  • CMT/HEAD/source/cmt_generator.cxx

    r527 r561  
    1818#include "cmt_generators.h"
    1919#include "cmt_log.h"
     20#include "cmt_error.h"
    2021
    2122//------------------------------------------------------------------------
     
    5960  m_TITLE.set ("TITLE");
    6061  m_GROUP.set ("GROUP");
    61   m_CONSTITUENT.set ("CONSTITUENT");
    6262  m_CONSTITUENTSUFFIX.set ("CONSTITUENTSUFFIX");
    6363  m_LIBRARYSUFFIX.set ("LIBRARYSUFFIX");
     
    7373  m_SUFFIX.set ("SUFFIX");
    7474  m_FILENAME.set ("FILENAME");
    75   //  m_LINKMACRO.set ("LINKMACRO");
    7675  m_LINE.set ("LINE");
    7776  m_ADDINCLUDE.set ("ADDINCLUDE");
     
    691690
    692691//------------------------------------------------------------------------
    693 static ApplicationGenerator ApplicationContext;
     692//static ApplicationGenerator ApplicationContext;
    694693static LibraryGenerator LibraryContext;
    695694static DocumentGenerator DocumentContext;
     
    735734//--------------------------------------------------
    736735void Generator::build_constituents_makefile (const cmt_string& package,
    737                                              const CmtSystem::cmt_string_vector& arguments)
    738 {
    739   ConstituentsMakefileContext.build (package, arguments);
     736                                             const cmt_string& file)
     737//                                           const CmtSystem::cmt_string_vector& arguments)
     738{
     739  ConstituentsMakefileContext.build (package, file);
     740  //  ConstituentsMakefileContext.build (package, arguments);
     741}
     742
     743//--------------------------------------------------
     744int Generator::build_constituent_infile (const Constituent& constituent,
     745                                         const cmt_string& outdir,
     746                                         bool usecmt)
     747{
     748  cmt_string file (constituent.name + ".in");
     749  if (outdir != "")
     750    {
     751      if (outdir [outdir.size () - 1] != CmtSystem::file_separator ())
     752        file = outdir + CmtSystem::file_separator () + file;
     753      else
     754        file = outdir + file;
     755    }
     756
     757  static InGenerator InGen (usecmt);
     758
     759  bool gen (true);
     760  ostringstream os;
     761  ofstream s;
     762  //  s.open (file);
     763  s.open (file, ios::in);
     764  if (s) // file already exists
     765    {
     766      InGen.build (constituent, os);
     767      ostringstream osn;
     768      osn << s.rdbuf ();
     769      if (os.str () == osn.str ())
     770        {
     771          //      cerr << file << " up-to-date" << endl;
     772          gen = false;
     773        }
     774    }
     775  s.clear ();
     776  s.close ();
     777  s.clear ();
     778  if (gen)
     779    {
     780      s.open (file);
     781      if (!s)
     782        {
     783          CmtError::set (CmtError::file_access_error, file);
     784          return -1;
     785        }
     786      s.exceptions (ios::failbit | ios::badbit);
     787      try
     788        {
     789          if (os.str ().size () != 0)
     790            {
     791              //  cerr << file << " contents already generated" << endl;
     792              s << os.str ();
     793            }
     794          else
     795            {
     796              InGen.build (constituent, s);
     797            }
     798          s.close (); // ios_base::failbit
     799        }
     800      catch (const ios::failure& e)
     801        {
     802          CmtSystem::close_ostream (NULL, file + ": " + cmt_string (e.what ()));
     803          return -1;
     804        }
     805    }
     806
     807      //  InGen.build (constituent, s);
     808
     809  //  s.close (); // ios_base::failbit
     810
     811  return 0;
    740812}
    741813
     
    749821    {
    750822    case Application:
    751       ApplicationContext.build (package, constituent, file);
    752       break;
     823      //ApplicationContext.build (package, constituent, file);
     824      //break;
    753825    case Library:
    754826      LibraryContext.build (package, constituent, file);
     
    10091081}
    10101082
     1083//------------------------------------------------------------------------
     1084InGenerator::Buffer::Buffer ()
     1085  : m_initialized (false), m_usecmt (true)
     1086{ }
     1087
     1088//------------------------------------------------------------------------
     1089void InGenerator::Buffer::set_names (const CmtSystem::cmt_string_vector& names)
     1090{
     1091  m_names = names;
     1092}
     1093
     1094//------------------------------------------------------------------------
     1095int InGenerator::Buffer::print (ostream& s)
     1096{
     1097  initialize ();
     1098  s << m_buffer.str ();
     1099  return 0;
     1100}
     1101
     1102//------------------------------------------------------------------------
     1103void InGenerator::Buffer::set_uses (bool usecmt)
     1104{
     1105  m_usecmt = usecmt;
     1106}
     1107
     1108//------------------------------------------------------------------------
     1109int InGenerator::Languages::initialize ()
     1110{
     1111  int errors (0);
     1112  if (m_initialized) return - errors;
     1113  m_initialized = true;
     1114  for (int i = 0; i < m_names.size (); i++)
     1115    {
     1116      const cmt_string& name = m_names[i];
     1117      Language& p (Language::find (name));
     1118      if (Language::null () == p) { errors += 1; continue; }
     1119      p.show (Requirements, m_buffer);
     1120      /*
     1121      if (!p->use->get_package ()->is_cmt ())
     1122        p->print (Requirements, m_buffer);
     1123      */
     1124    }
     1125  //  cerr << "Languages::initialize: " << m_buffer.str ();
     1126  return - errors;
     1127}
     1128
     1129//------------------------------------------------------------------------
     1130int InGenerator::Fragments::initialize ()
     1131{
     1132  int errors (0);
     1133  if (m_initialized) return - errors;
     1134  m_initialized = true;
     1135  for (int i = 0; i < m_names.size (); i++)
     1136    {
     1137      const cmt_string& name = m_names[i];
     1138      Fragment* fragment (Fragment::find (name));
     1139      if (0 == fragment) { errors += 1; continue; }
     1140      if (m_usecmt || !fragment->use->get_package ()->is_cmt ())
     1141        fragment->print (Requirements, m_buffer);
     1142    }
     1143  //  cerr << "initialize: " << m_buffer.str ();
     1144  return - errors;
     1145}
     1146
     1147//------------------------------------------------------------------------
     1148InGenerator::InGenerator (bool usecmt)
     1149  : m_usecmt (usecmt)
     1150{
     1151  CmtSystem::cmt_string_vector common;
     1152  common.push_back ("make_header");
     1153  common.push_back ("dependencies");
     1154  common.push_back ("cleanup_header");
     1155  m_common.set_names (common);
     1156  m_common.set_uses (usecmt);
     1157
     1158  CmtSystem::cmt_string_vector application;
     1159  application.push_back ("java_header");
     1160  application.push_back ("application_header");
     1161  application.push_back ("application");
     1162  application.push_back ("check_java");
     1163  application.push_back ("cleanup_application");
     1164  application.push_back ("cleanup_objects");
     1165  application.push_back ("check_application");
     1166
     1167  CmtSystem::cmt_string_vector application_library;
     1168  application_library.push_back ("protos_header");
     1169  application_library.push_back ("buildproto");
     1170  application_library.push_back ("dependencies_and_triggers");
     1171  application_library.push_back ("java");
     1172  application_library.push_back ("java_copy");
     1173  application_library.push_back ("cleanup");
     1174  application_library.push_back ("cleanup_java");
     1175  m_application_library.set_names (application_library);
     1176  m_application_library.set_uses (usecmt);
     1177
     1178  CmtSystem::cmt_string_vector library;
     1179  library.push_back ("jar_header");
     1180  library.push_back ("library_header");
     1181  library.push_back ("jar");
     1182  library.push_back ("library_no_share");
     1183  library.push_back ("library_no_static");
     1184  library.push_back ("library");
     1185  library.push_back ("cleanup_library");
     1186
     1187  CmtSystem::cmt_string_vector languages;
     1188  Language::LanguageVector& Languages = Language::languages ();
     1189  for (int n = 0; n < Languages.size (); n++)
     1190    {
     1191      Language& language = Languages[n];
     1192      //language.setup_fragments ();
     1193      application.push_back (language.fragment_name); //application.name ();
     1194      library.push_back (language.fragment_name + "_library"); //library.name ();
     1195      if (m_usecmt || !language.m_use->get_package ()->is_cmt ())
     1196//       if (!language.m_use->get_package ()->is_cmt ())
     1197        {
     1198          languages.push_back (language.m_name);
     1199        }
     1200      else if (language.dependencies_options () !=
     1201          language.dependencies_options_expanded ())
     1202        {
     1203          languages.push_back (language.m_name);
     1204        }
     1205    }
     1206  m_languages.set_names (languages);
     1207  m_languages.set_uses (usecmt);
     1208  m_application.set_names (application);
     1209  m_application.set_uses (usecmt);
     1210  m_library.set_names (library);
     1211  m_library.set_uses (usecmt);
     1212 
     1213  CmtSystem::cmt_string_vector document;
     1214  document.push_back ("document_header");
     1215  m_document.set_names (document);
     1216  m_document.set_uses (usecmt);
     1217}
     1218
     1219//------------------------------------------------------------------------
     1220int InGenerator::build (const Constituent& constituent, ostream& s)
     1221{
     1222  constituent.show (s);
     1223  m_common.print (s);
     1224
     1225  switch (constituent.type)
     1226    {
     1227    case Application:
     1228      m_application.print (s);
     1229      m_application_library.print (s);
     1230      m_languages.print (s);
     1231      break;
     1232    case Library:
     1233      m_application_library.print (s);
     1234      m_library.print (s);
     1235      m_languages.print (s);
     1236      break;
     1237    case Document:
     1238      Fragment* fragment (Fragment::find (constituent.generator));
     1239      if (0 == fragment) return -1;
     1240      if (m_usecmt || !fragment->use->get_package ()->is_cmt ())
     1241        fragment->print (Requirements, s);
     1242      if ("" != fragment->header)
     1243        {
     1244          Fragment* header (Fragment::find (fragment->header));
     1245          if (0 == header) return -1;
     1246          //      if (header->use != fragment->use &&
     1247          if (m_usecmt || !header->use->get_package ()->is_cmt ())
     1248            header->print (Requirements, s);
     1249        }
     1250      if ("" != fragment->trailer)
     1251        {
     1252          Fragment* trailer (Fragment::find (fragment->trailer));
     1253          if (0 == trailer) return -1;
     1254          //      if (trailer->use != fragment->use &&
     1255          if (m_usecmt || !trailer->use->get_package ()->is_cmt ())
     1256            trailer->print (Requirements, s);
     1257        }
     1258      m_document.print (s);
     1259      break;
     1260    }
     1261
     1262  return 0;
     1263}
     1264//------------------------------------------------------------------------
  • CMT/HEAD/source/cmt_generator.h

    r488 r561  
    138138};
    139139
     140class InGenerator
     141{
     142 public:
     143  InGenerator (bool usecmt);
     144  int build (const Constituent& constituent, ostream& out = cout);
     145 
     146 private:
     147  InGenerator ();
     148
     149 private:
     150  class Buffer
     151  {
     152  public:
     153    Buffer ();
     154    void set_names (const CmtSystem::cmt_string_vector& names);
     155    int print (ostream& s);
     156    void set_uses (bool usecmt);
     157  private:
     158    virtual int initialize () = 0;
     159
     160  protected:
     161    CmtSystem::cmt_string_vector m_names;
     162    ostringstream m_buffer;
     163    bool m_initialized;
     164    bool m_usecmt;
     165  };
     166 
     167  class Languages : public Buffer
     168  {
     169  private:
     170    int initialize ();
     171  };
     172 
     173  class Fragments : public Buffer
     174  {
     175  private:
     176    int initialize ();
     177  };
     178 
     179 private:
     180  Fragments m_common;
     181  Fragments m_application;
     182  Fragments m_application_library;
     183  Fragments m_library;
     184  Fragments m_document;
     185  Languages m_languages;
     186  bool m_usecmt;
     187};
     188
    140189/**
    141190   Generic command interface to be used by the cmt command driver.
     
    161210    // Build the constituents.make file
    162211  static void build_constituents_makefile (const cmt_string& package,
    163                                            const CmtSystem::cmt_string_vector& arguments);
     212                                           const cmt_string& file = "");
     213                                           //                                      const CmtSystem::cmt_string_vector& arguments);
    164214
    165215    // Build the makefile fragment for one constituent
     
    167217                                         const cmt_string& file = "");
    168218  static void build_constituent_makefile (const CmtSystem::cmt_string_vector& arguments);
     219  static int build_constituent_infile (const Constituent& constituent,
     220                                       const cmt_string& outdir = "",
     221                                       bool usecmt = true);
    169222
    170223  static void build_default_makefile ();
  • CMT/HEAD/source/cmt_generators.cxx

    r547 r561  
    230230  CmtSystem::basename (m_FULLNAME, m_FILENAME.value);
    231231 
    232   if (CmtSystem::test_file (m_FULLNAME))
    233     {
     232  //  if (CmtSystem::test_file (m_FULLNAME))
     233  //    {
    234234      java_fragment.copy (m_output_file, constituent.variables, 5,
    235235                          &m_NAME,
     
    238238                          &m_CONSTITUENT,
    239239                          &m_CONSTITUENTSUFFIX);
     240      /*
    240241    }
    241242  else
     
    244245      //      cerr << "#CMT> Warning: file " << m_FULLNAME << " not found" << endl;
    245246    }
     247      */
    246248}
    247249
     
    514516  //fill_outputs ();
    515517
    516   prepare_use_context ();
     518  //prepare_use_context ();
    517519
    518520  m_DATE = CmtSystem::now ();
     
    986988      int count = get_all_files (full_name, excludes, selects, files);
    987989
    988       filter_path (full_name);
     990      //      filter_path (full_name);
    989991
    990992      /*
     
    10101012  //  fill_outputs ();
    10111013
    1012   prepare_use_context ();
     1014  //  prepare_use_context ();
    10131015
    10141016  m_DATE = CmtSystem::now ();
     
    10691071  else
    10701072    {
     1073      /*
    10711074      for (i = 0; i < sources.size (); i++)
    10721075        {
     
    10861089            {
    10871090              const cmt_string& name = files[j];
    1088              
     1091      */             
     1092      for (i = 0; i < m_source_files.size (); i++)
     1093        {
     1094          SourceFile& file = m_source_files[i];
     1095          const cmt_string& name = file.name ();
    10891096              if (name != "")
    10901097                {
     
    11011108                           name.c_str ());
    11021109                }
    1103             }
     1110              //            }
    11041111        }
    11051112    }
     
    11181125      CmtSystem::basename (file_name, m_FILENAME.value);
    11191126      CmtSystem::get_dot_suffix (m_FILENAME.value, m_FILESUFFIX.value);
    1120 
     1127      /*
    11211128      if (!CmtSystem::test_file (file_name) && !CmtSystem::test_directory (file_name))
    11221129        {
    11231130          CmtMessage::warning ("Source file " + file_name + " not found");
    1124           //          cerr << "#CMT> Warning: Source file " << file_name << " not found" << endl;
    1125         }
    1126 
     1131        }
     1132      */
    11271133      filter_path (m_FULLNAME.value);
    11281134
     
    11641170                                      const cmt_string& output_suffix)
    11651171{
    1166   static cmt_string output_dir;
     1172  //static cmt_string output_dir;
    11671173  static cmt_string suffix;
    11681174  static cmt_string name;
     
    11721178    {
    11731179      CmtMessage::warning ("Source file " + file + " not found");
    1174       //      cerr << "#CMT> Warning: Source file " << file << " not found" << endl;
    1175     }
    1176 
    1177   CmtSystem::dirname (file, output_dir);
    1178   output_dir += CmtSystem::file_separator ();
    1179 
    1180   filter_path (output_dir);
     1180    }
     1181
     1182  //CmtSystem::dirname (file, output_dir);
     1183  //output_dir += CmtSystem::file_separator ();
     1184
     1185  //filter_path (output_dir);
    11811186
    11821187  CmtSystem::get_suffix (file, suffix);
     
    25202525//--------------------------------------------------
    25212526void ConstituentsMakefileGenerator::build (const cmt_string& package,
    2522                                            const CmtSystem::cmt_string_vector& arguments)
     2527                                           const cmt_string& file)
     2528//                                         const CmtSystem::cmt_string_vector& arguments)
    25232529{
    25242530  reset ();
    25252531
    2526   cmt_string file_name, dir_name;
    2527 
    2528   if (arguments.size () > 0)
    2529     {
    2530       cmt_string arg = arguments[0];
    2531       if (arg.substr (0, 5) == "-out=")
    2532         {
    2533           arg.erase (0, 5);
    2534           file_name = arg;
    2535         }
    2536       else if (arg.substr (0, 8) == "-outdir=")
    2537         {
    2538           arg.erase (0, 8);
    2539           dir_name = arg;
    2540         }
    2541     }
     2532  cmt_string file_name (file);
     2533    //, dir_name;
     2534
     2535//   if (arguments.size () > 0)
     2536//     {
     2537//       cmt_string arg = arguments[0];
     2538//       if (arg.substr (0, 5) == "-out=")
     2539//      {
     2540//        arg.erase (0, 5);
     2541//        file_name = arg;
     2542//      }
     2543//       else if (arg.substr (0, 8) == "-outdir=")
     2544//      {
     2545//        arg.erase (0, 8);
     2546//        dir_name = arg;
     2547//      }
     2548//     }
    25422549
    25432550  if (file_name == "")
     
    25572564    }
    25582565
    2559   if (dir_name != "")
    2560     {
    2561       if (dir_name [dir_name.size () - 1] != CmtSystem::file_separator ())
    2562         dir_name += CmtSystem::file_separator ();
    2563       file_name = dir_name + file_name;
    2564     }
     2566//   if (dir_name != "")
     2567//     {
     2568//       if (dir_name [dir_name.size () - 1] != CmtSystem::file_separator ())
     2569//      dir_name += CmtSystem::file_separator ();
     2570//       file_name = dir_name + file_name;
     2571//     }
    25652572
    25662573  cmt_string save_file_name = file_name;
  • CMT/HEAD/source/cmt_generators.h

    r466 r561  
    200200  ConstituentsMakefileGenerator ();
    201201  void build (const cmt_string& package,
    202               const CmtSystem::cmt_string_vector& arguments);
     202              const cmt_string& file);
     203  //          const CmtSystem::cmt_string_vector& arguments);
    203204
    204205private:
  • CMT/HEAD/source/cmt_language.cxx

    r528 r561  
    145145
    146146/*----------------------------------------------------------*/
    147 void Language::action (const CmtSystem::cmt_string_vector& words)
     147void Language::action (const CmtSystem::cmt_string_vector& words,
     148                       Use* use)
     149//void Language::action (const CmtSystem::cmt_string_vector& words)
    148150  /*----------------------------------------------------------*/
    149151{
     
    202204        }
    203205    }
     206  language.m_use = use;
    204207}
    205208
     
    287290  m_native_dependencies = false;
    288291  m_dependencies_options = "none";
     292  m_dependencies_options_expanded = "";
    289293  m_native_dependencies_set = false;
    290 }
    291 
    292 /*----------------------------------------------------------*/
    293 void Language::show ()
    294   /*----------------------------------------------------------*/
    295 {
    296   cout << "language " << m_name;
     294  m_use  = 0;
     295}
     296
     297/*----------------------------------------------------------*/
     298void Language::show (PrintMode mode, ostream& out)
     299//void Language::show ()
     300  /*----------------------------------------------------------*/
     301{
     302  out << "language " << m_name;
    297303
    298304  int i;
     
    302308      cmt_string& suffix = suffixes[i];
    303309     
    304       cout << " -suffix=" << suffix;
    305     }
    306 
    307   if (linker != "")
    308     {
    309       cout << " -linker=" << linker;
     310      out << " -suffix=" << suffix;
     311    }
     312
     313  if (linker != "none")
     314    //  if (linker != "")
     315    {
     316      switch (mode)
     317        {
     318        case Requirements :
     319          out << " -linker=" << CmtSystem::quote (linker, " \t");
     320          break;
     321        default:
     322          out << " -linker=" << linker;
     323          break;
     324        }
    310325    }
    311326
    312327  if (prototypes)
    313328    {
    314       cout << " -prototypes";
     329      out << " -prototypes";
    315330    }
    316331
    317332  if (preprocessor_command != "-I")
    318333    {
    319       cout << " -preprocessor_command=" << preprocessor_command;
     334      out << " -preprocessor_command=";
     335      switch (mode)
     336        {
     337        case Requirements :
     338          out << CmtSystem::quote (preprocessor_command, " \t");
     339          break;
     340        default:
     341          out << preprocessor_command;
     342          break;
     343        }
    320344    }
    321345
    322346  if (fragment_name != m_name)
    323347    {
    324       cout << " -fragment=" << fragment_name;
     348      out << " -fragment=" << fragment_name;
    325349    }
    326350
    327351  if (output_suffix != "")
    328352    {
    329       cout << " -output_suffix=" << output_suffix;
     353      out << " -output_suffix=" << output_suffix;
    330354    }
    331355
     
    334358      cmt_string& suffix = extra_output_suffixes[i];
    335359     
    336       cout << " -extra_output_suffix=" << suffix;
     360      out << " -extra_output_suffix=" << suffix;
    337361    }
    338362
    339363  if (m_dependencies_options != "none")
    340364    {
    341       cout << " -dependencies_options=" << m_dependencies_options;
    342     }
    343 
    344   cout << endl;
     365      out << " -dependencies_options=";
     366      switch (mode)
     367        {
     368        case Requirements :
     369          out << CmtSystem::quote (dependencies_options_expanded (), " \t");
     370          break;
     371        default:
     372          out << m_dependencies_options;
     373          break;
     374        }
     375    }
     376
     377  out << endl;
    345378}
    346379
     
    418451          m_native_dependencies = false;
    419452        }
     453      m_dependencies_options_expanded = opts;
    420454    }
    421455  else
     
    426460  return;
    427461}
     462
     463/*----------------------------------------------------------*/
     464const cmt_string& Language::dependencies_options_expanded ()
     465  /*----------------------------------------------------------*/
     466{
     467  setup_native_dependencies ();
     468  return m_dependencies_options_expanded;
     469}
  • CMT/HEAD/source/cmt_language.h

    r486 r561  
    1515public:
    1616  typedef cmt_vector<Language> LanguageVector;
    17   static void action (const CmtSystem::cmt_string_vector& words);
     17  static void action (const CmtSystem::cmt_string_vector& words,
     18                      Use* use);
    1819  static Language& find (const cmt_string& name);
    1920  static Language& find_with_suffix (const cmt_string& suffix);
     
    3132  ~Language ();
    3233  void clear ();
    33   void show ();
     34  void show (PrintMode mode = Csh, ostream& out = cout); // Csh is default for ArgParser::mode
     35  //  void show ();
    3436  void setup_fragments ();
    3537  bool operator == (const cmt_string& name) const;
     
    3840  bool native_dependencies ();
    3941  const cmt_string& dependencies_options () const;
     42  const cmt_string& dependencies_options_expanded ();
    4043
    4144  cmt_string m_name;
     
    4750  CmtSystem::cmt_string_vector suffixes;
    4851  CmtSystem::cmt_string_vector extra_output_suffixes;
     52  UseRef m_use;
    4953
    5054  FragmentHandle application;
     
    5660  bool m_native_dependencies;
    5761  cmt_string m_dependencies_options;
     62  cmt_string m_dependencies_options_expanded;
    5863  bool m_native_dependencies_set;
    5964};
  • 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)
  • CMT/HEAD/source/cmt_symbol.cxx

    r550 r561  
    30613061
    30623062//-------------------------------------------------------------
    3063 //  Quote separators (spaces and tabs) with double quotes,
    3064 //  double quotes with single quotes,
    3065 //  single quotes with double quotes in text.
    3066 //  Note: quotes preceded by backslash (i.e., \" or \') are NOT quoted
    3067 //  (considered escaped)
    3068 //-------------------------------------------------------------
    3069 static cmt_string quote (const cmt_string& text,
    3070                          const cmt_string& separators)
    3071 {
    3072   //cerr << "quote: `" << text << "'" << endl;
    3073   cmt_string result;
    3074   if (text.size () == 0) return result;
    3075 
    3076   int allocated = 3 * text.size (); // if EACH character of text quoted with " or '
    3077   char* const buffer = (char*) malloc (allocated + 1);
    3078   char* b (buffer);
    3079 
    3080   //  char* const beg (buffer);
    3081   const char* p = text.c_str ();
    3082   const char* const text_c (p);
    3083   //  const char* const beg_t (p);
    3084   //  cerr << "quote: p = `" << p << "'" << endl;
    3085 
    3086   while (*p)
    3087     //  while (*p != '\0')
    3088     {
    3089       size_t l_nonsep = strcspn (p, separators.c_str ());
    3090       //cerr << "quote: l_nonsep = " << l_nonsep << " *p = '" << *p << "'" << endl;
    3091       while (l_nonsep--)
    3092         {
    3093           if (*p == '\"' &&
    3094               (p > text_c && *(p - 1) != '\\' || p == text_c))
    3095             { // quote " with '
    3096               *b++ = '\'';
    3097               *b++ = *p++;
    3098               *b++ = '\'';
    3099             }
    3100           else if (*p == '\'' &&
    3101                    (p > text_c && *(p - 1) != '\\' || p == text_c))
    3102             { // quote ' with "
    3103               *b++ = '\"';
    3104               *b++ = *p++;
    3105               *b++ = '\"';
    3106             }
    3107           else
    3108             { // simply copy
    3109               *b++ = *p++;
    3110             }
    3111         }
    3112       size_t l_sep = strspn (p, separators.c_str ());
    3113       //cerr << "quote: l_sep = " << l_sep << " *p = '" << *p << "'" << endl;
    3114       if (l_sep)
    3115         { // quote separators with "
    3116           // place quote before all backslashes preceding separators, if any
    3117           char* r = b;
    3118           while (r > buffer && *(r - 1) == '\\')
    3119             r--;
    3120           if (r == b)
    3121             *b++ = '\"';
    3122           else
    3123             *r = '\"', *b++ = '\\';
    3124           while (l_sep--)
    3125             *b++ = *p++;
    3126           *b++ = '\"';
    3127         }
    3128     }
    3129   *b = '\0';
    3130   result = buffer;
    3131   free (buffer);
    3132   return result;
    3133 }
    3134 
    3135 //-------------------------------------------------------------
    31363063int SymbolValueList::print (const Symbol& symbol,
    31373064                            const SymbolValue& value,
     
    33113238    }
    33123239
    3313   cout << " " << quote (value.text, " \t");
     3240  cout << " " << CmtSystem::quote (value.text, " \t");
    33143241  //  cout << "'" << value.text << "'";
    33153242         
  • CMT/HEAD/source/cmt_syntax.cxx

    r535 r561  
    494494               int line_number)
    495495  {
    496     Language::action (words);
     496    Language::action (words, use);
    497497  }
    498498  void action (const CmtSystem::cmt_string_vector& words,
  • CMT/HEAD/source/cmt_system.cxx

    r545 r561  
    21722172      current_word += word_length + 1;
    21732173    }
     2174}
     2175
     2176//-------------------------------------------------------------
     2177//  Quote separators (spaces and tabs) with double quotes,
     2178//  double quotes with single quotes,
     2179//  single quotes with double quotes in text.
     2180//  Note: quotes preceded by backslash (i.e., \" or \') are NOT quoted
     2181//  (considered escaped)
     2182//-------------------------------------------------------------
     2183cmt_string CmtSystem::quote (const cmt_string& text,
     2184                             const cmt_string& separators)
     2185{
     2186  //cerr << "quote: `" << text << "'" << endl;
     2187  cmt_string result;
     2188  if (text.size () == 0) return result;
     2189
     2190  int allocated = 3 * text.size (); // if EACH character of text quoted with " or '
     2191  char* const buffer = (char*) malloc (allocated + 1);
     2192  char* b (buffer);
     2193
     2194  //  char* const beg (buffer);
     2195  const char* p = text.c_str ();
     2196  const char* const text_c (p);
     2197  //  const char* const beg_t (p);
     2198  //  cerr << "quote: p = `" << p << "'" << endl;
     2199
     2200  while (*p)
     2201    //  while (*p != '\0')
     2202    {
     2203      size_t l_nonsep = strcspn (p, separators.c_str ());
     2204      //cerr << "quote: l_nonsep = " << l_nonsep << " *p = '" << *p << "'" << endl;
     2205      while (l_nonsep--)
     2206        {
     2207          if (*p == '\"' &&
     2208              (p > text_c && *(p - 1) != '\\' || p == text_c))
     2209            { // quote " with '
     2210              *b++ = '\'';
     2211              *b++ = *p++;
     2212              *b++ = '\'';
     2213            }
     2214          else if (*p == '\'' &&
     2215                   (p > text_c && *(p - 1) != '\\' || p == text_c))
     2216            { // quote ' with "
     2217              *b++ = '\"';
     2218              *b++ = *p++;
     2219              *b++ = '\"';
     2220            }
     2221          else
     2222            { // simply copy
     2223              *b++ = *p++;
     2224            }
     2225        }
     2226      size_t l_sep = strspn (p, separators.c_str ());
     2227      //cerr << "quote: l_sep = " << l_sep << " *p = '" << *p << "'" << endl;
     2228      if (l_sep)
     2229        { // quote separators with "
     2230          // place quote before all backslashes preceding separators, if any
     2231          char* r = b;
     2232          while (r > buffer && *(r - 1) == '\\')
     2233            r--;
     2234          if (r == b)
     2235            *b++ = '\"';
     2236          else
     2237            *r = '\"', *b++ = '\\';
     2238          while (l_sep--)
     2239            *b++ = *p++;
     2240          *b++ = '\"';
     2241        }
     2242    }
     2243  *b = '\0';
     2244  result = buffer;
     2245  free (buffer);
     2246  return result;
    21742247}
    21752248
  • CMT/HEAD/source/cmt_system.h

    r527 r561  
    132132                     const cmt_string& separators,
    133133                     cmt_string_vector& strings);
     134  static cmt_string quote (const cmt_string& text,
     135                           const cmt_string& separators);
    134136
    135137  static void compress_path (const cmt_string& dir, cmt_string& new_dir);
Note: See TracChangeset for help on using the changeset viewer.