- Timestamp:
- Mar 8, 2011, 1:56:48 PM (13 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r560 r561 1 2011-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 1 65 2010-09-07 <rybkin@lal.in2p3.fr> 443 2 66 -
CMT/HEAD/mgr/cmt_install_action.sh
r446 r561 110 110 111 111 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 114 118 fi 115 119 -
CMT/HEAD/mgr/cmt_make_shlib_common.sh
r469 r561 29 29 extra=$* 30 30 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}` 31 if [ "${CMTDEBUG:-}" ]; then 32 unset CMTDEBUG 33 set -x 34 fi 35 36 ld=`${CMTROOT}/mgr/cmt show macro_value shlibbuilder -tag=${tag}` || exit 37 ldflags=`${CMTROOT}/mgr/cmt show macro_value shlibflags -tag=${tag}` || exit 38 suffix=`${CMTROOT}/mgr/cmt show macro_value shlibsuffix -tag=${tag}` || exit 39 libprefix=`${CMTROOT}/mgr/cmt show macro_value library_prefix -tag=${tag}` || exit 40 libsuffix=`${CMTROOT}/mgr/cmt show macro_value library_suffix -tag=${tag}` || exit 36 41 37 42 libname=${libprefix}${lib}${libsuffix} … … 42 47 43 48 if 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 45 50 fi 46 51 47 52 here=`/bin/pwd` 48 cd ${bin} 53 cd ${bin} || exit 49 54 50 /bin/rm -f ${libname}.${suffix} 55 /bin/rm -f ${libname}.${suffix} || exit 51 56 52 57 result=0 … … 61 66 62 67 (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 63 74 64 75 # -
CMT/HEAD/mgr/fragments/constituent
r548 r561 66 66 #endif 67 67 68 makefiles : $(cmt_local_${CONSTITUENT}_makefile) 68 ifdef cmt_${CONSTITUENT}_has_target_tag 69 69 70 70 ifndef QUICK 71 71 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) build_library_links 72 #$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_local_tagfile_${CONSTITUENT}) build_library_links73 72 $(echo) "(constituents.make) Building ${CONSTITUENT}.make"; \ 74 73 $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT} 75 74 else 76 75 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) 77 #$(cmt_local_${CONSTITUENT}_makefile) : $(cmt_local_tagfile_${CONSTITUENT})78 76 if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \ 79 77 [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \ … … 82 80 $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}; \ 83 81 fi 82 endif 83 84 else 85 86 ifndef 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} 90 else 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 98 endif 99 84 100 endif 85 101 -
CMT/HEAD/mgr/fragments/constituent_lock
r548 r561 66 66 #endif 67 67 68 makefiles : $(cmt_local_${CONSTITUENT}_makefile) 68 ifdef cmt_${CONSTITUENT}_has_target_tag 69 69 70 70 ifndef QUICK 71 71 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) build_library_links 72 #$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_local_tagfile_${CONSTITUENT}) build_library_links73 72 $(echo) "(constituents.make) Building ${CONSTITUENT}.make"; \ 74 73 $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT} 75 74 else 76 75 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) 77 #$(cmt_local_${CONSTITUENT}_makefile) : $(cmt_local_tagfile_${CONSTITUENT})78 76 if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \ 79 77 [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \ … … 82 80 $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}; \ 83 81 fi 82 endif 83 84 else 85 86 ifndef 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} 90 else 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 98 endif 99 84 100 endif 85 101 -
CMT/HEAD/mgr/requirements
r556 r561 593 593 make_fragment readme_header 594 594 make_fragment readme 595 make_fragment readme_doc595 #make_fragment readme_doc 596 596 make_fragment readme_use 597 597 make_fragment readme_trailer -
CMT/HEAD/source/cmt.h
r550 r561 33 33 cmt_string m_cmt_site; 34 34 cmt_string m_cmt_version; 35 bool m_use_cmt; 35 36 36 37 cmt_string m_current_dir; … … 263 264 static void print_xml_prolog (const cmt_string& root = "cmt", ostream& out = cout); 264 265 static int reach_current_package (); 266 static int use_extra_file (const cmt_string& file); 265 267 static void restore_all_tags (Use* use); 266 268 static void set_current_access (AccessMode mode); -
CMT/HEAD/source/cmt_commands.cxx
r550 r561 337 337 pv.push_back (&ArgParser::option_version); i++; 338 338 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 339 349 parsers.add ("-warn", i); 340 350 parsers.add ("-warni", i); … … 520 530 // We have unexpected arguments (not handled by the command handler). This may sign 521 531 // an unprotected handler implementation. 522 CmtMessage::warning ("unexpected parameter " + reduced_arg); 532 if (help_action != action_help) 533 CmtMessage::warning ("unexpected parameter " + reduced_arg); 523 534 // if (!cmt.m_quiet) cerr << "#CMT> warning : unexpected parameter " << reduced_arg << endl; 524 535 } … … 577 588 if (arg == "constituent_makefile") 578 589 { 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 { 591 623 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 { 598 653 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"); 627 656 } 628 657 } 629 658 else if (arg == "constituents_makefile") 630 659 { 631 fill_arguments ();632 660 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 } 633 675 } 634 676 else if (arg == "constituents_config") 635 677 { 636 fill_arguments ();637 678 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 } 638 695 } 639 696 else if (arg == "dependencies") … … 759 816 else 760 817 { 761 CmtMessage::error ("syntax: wrong build argument"); 818 CmtError::set (CmtError::syntax_error, "wrong argument: " + arg); 819 //CmtMessage::error ("syntax: wrong build argument: " + arg); 762 820 // if (!cmt.m_quiet) cerr << "#CMT> syntax error : wrong build argument" << endl; 763 821 help_action = action_help; … … 767 825 else 768 826 { 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"); 770 833 // 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 } 773 835 } 774 836 } … … 2129 2191 } 2130 2192 2193 void ArgParser::option_with_cmt () 2194 { 2195 cmt.m_use_cmt = true; 2196 } 2197 2198 void ArgParser::option_without_cmt () 2199 { 2200 cmt.m_use_cmt = false; 2201 } 2202 2131 2203 void ArgParser::option_with_version_directory () 2132 2204 { … … 2219 2291 cerr << "# -version=<version> : set version" << endl; 2220 2292 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; 2222 2294 cerr << "# -e=<statement> : add a one line statement" << endl; 2223 2295 cerr << "# -tag=<tag-list> : select a new tag-set" << endl; … … 2240 2312 if (action == action_build) 2241 2313 { 2314 const cmt_string& s = get_help_text (action); 2315 cerr << "# " << s << endl; 2242 2316 int i; 2243 2317 … … 2248 2322 } 2249 2323 } 2250 if (action == action_check)2324 else if (action == action_check) 2251 2325 { 2252 2326 int i; … … 2271 2345 { 2272 2346 const cmt_string& s = get_help_text (action); 2273 cerr << "# " << s << endl;2347 cerr << "# " << s << endl; 2274 2348 } 2275 2349 } … … 2292 2366 help_texts.add () = "awk"; 2293 2367 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"; 2299 2374 help_texts.add () = "build dependencies : generate dependencies"; 2300 2375 help_texts.add () = "build library_links : build symbolic links towards all imported libraries"; -
CMT/HEAD/source/cmt_commands.h
r550 r561 81 81 void option_tag_remove (); 82 82 void option_user_context (); 83 void option_with_cmt (); 84 void option_without_cmt (); 83 85 void option_with_version_directory (); 84 86 void option_without_version_directory (); -
CMT/HEAD/source/cmt_constituent.cxx
r459 r561 573 573 574 574 //---------------------------------------------------------- 575 void Constituent::show () const 575 void Constituent::show (ostream& out) const 576 //void Constituent::show () const 576 577 { 577 578 int i; … … 580 581 { 581 582 case Library: 582 cout << "library";583 out << "library"; 583 584 break; 584 585 case Application: 585 cout << "application";586 out << "application"; 586 587 break; 587 588 case Document: 588 cout << "document " << generator;589 out << "document " << generator; 589 590 break; 590 591 } 591 592 592 cout << " " << name;593 out << " " << name; 593 594 594 595 if (group != 0) 595 596 { 596 cout << " -group=" << group->name ();597 out << " -group=" << group->name (); 597 598 } 598 599 599 600 if (suffix != 0) 600 601 { 601 cout << " -suffix=" << suffix;602 out << " -suffix=" << suffix; 602 603 } 603 604 604 605 if ((type == Application) && need_check) 605 606 { 606 cout << " -check";607 out << " -check"; 607 608 } 608 609 609 610 if ((type == Library) && no_share) 610 611 { 611 cout << " -no_share";612 out << " -no_share"; 612 613 } 613 614 614 615 if ((type == Library) && no_static) 615 616 { 616 cout << " -no_static";617 out << " -no_static"; 617 618 } 618 619 619 620 if ((type == Library) && build_triggers) 620 621 { 621 cout << " -triggers";622 out << " -triggers"; 622 623 } 623 624 624 625 if (has_target_tag) 625 626 { 626 cout << " -target_tag";627 out << " -target_tag"; 627 628 } 628 629 … … 631 632 const cmt_string& import_name = imports[i]; 632 633 633 cout << " -import=" << import_name;634 out << " -import=" << import_name; 634 635 } 635 636 … … 638 639 const cmt_string& exclude = excludes[i]; 639 640 640 cout << " -x=" << exclude;641 out << " -x=" << exclude; 641 642 } 642 643 … … 645 646 const cmt_string& select = selects[i]; 646 647 647 cout << " -k=" << select;648 out << " -k=" << select; 648 649 } 649 650 … … 652 653 const cmt_string& module_name = modules[i]; 653 654 654 cout << " " << module_name;655 out << " " << module_name; 655 656 } 656 657 … … 659 660 const Variable& v = variables[i]; 660 661 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 43 43 virtual void build_msdev_file (bool simulation) const; 44 44 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; 46 47 47 48 cmt_string name; -
CMT/HEAD/source/cmt_fragment.cxx
r528 r561 200 200 m_header.replace ("-header=", ""); 201 201 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 // } 206 206 } 207 207 else if (w.find ("-trailer=") != cmt_string::npos) … … 210 210 m_trailer.replace ("-trailer=", ""); 211 211 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; 216 220 } 217 221 break; … … 221 225 void commit () 222 226 { 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); 224 228 } 225 229 … … 238 242 bool m_need_dependencies; 239 243 Use* m_use; 244 cmt_string m_path; 240 245 }; 241 246 … … 309 314 const cmt_string& trailer, 310 315 bool need_dependencies, 311 Use* use) 316 Use* use, 317 const cmt_string& path) 318 // Use* use) 312 319 { 313 320 static FragmentVector& Fragments = fragments (); … … 339 346 340 347 fragment->use = use; 348 if (path != "") 349 { 350 fragment->path = path; 351 } 341 352 return; 342 353 } … … 351 362 fragment.need_dependencies = need_dependencies; 352 363 fragment.use = use; 364 fragment.path = path; 353 365 } 354 366 … … 409 421 410 422 /*----------------------------------------------------------*/ 411 int Fragment::print () 423 int Fragment::print (PrintMode mode, ostream& out) 424 //int Fragment::print () 412 425 { 413 426 int result = 1; … … 423 436 } 424 437 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 425 452 cmt_string the_path = path; 426 453 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 438 480 return (result); 439 481 } … … 442 484 bool Fragment::locate () 443 485 { 444 cmt_string root_path;486 if (path != "") return (true); 445 487 446 488 if (use == 0) … … 450 492 } 451 493 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 452 504 use->get_full_path (root_path); 453 505 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 } 489 516 490 517 root_path += CmtSystem::file_separator (); … … 501 528 502 529 path += name; 503 530 //cerr << "test_file: " << path << endl; 504 531 if (CmtSystem::test_file (path)) return (true); 505 532 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 (); 507 551 508 552 path = root_path; 509 553 554 if (Cmt::build_nmake ()) 555 { 556 path += "nmake"; 557 path += CmtSystem::file_separator (); 558 } 559 510 560 path += name; 511 561 562 //cerr << "test_file: " << path << endl; 512 563 if (CmtSystem::test_file (path)) return (true); 513 564 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); 514 578 return (false); 515 579 } … … 1116 1180 if (!result) 1117 1181 { 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 //-------------------------------------------------- 1191 bool 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 //-------------------------------------------------- 1212 bool 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 { 1118 1224 CmtMessage::info ("Fragment " + _name + " not found"); 1119 1225 // cerr << "#CMT> Fragment " << _name << " not found" << endl; … … 1125 1231 1126 1232 //-------------------------------------------------- 1127 bool FragmentHandle:: copy (cmt_string& out, int variables, ...)1233 bool FragmentHandle::wincopy (cmt_string& out, int variables, ...) 1128 1234 { 1129 1235 if (!setup ()) return (false); … … 1132 1238 1133 1239 va_start (ids, variables); 1134 bool result = _fragment-> copy (out, variables, ids);1240 bool result = _fragment->wincopy (out, variables, ids); 1135 1241 va_end (ids); 1136 1242 … … 1145 1251 } 1146 1252 1147 //-------------------------------------------------- 1148 bool FragmentHandle::wincopy (FILE* out, int variables, ...) 1253 1254 1255 1256 //-------------------------------------------------- 1257 bool FragmentHandle::copy (FILE* out, const Variable::VariableVector& vector, int variables, ...) 1149 1258 { 1150 1259 if (!setup ()) return (false); … … 1153 1262 1154 1263 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 //-------------------------------------------------- 1278 bool 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 //-------------------------------------------------- 1299 bool 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); 1156 1307 va_end (ids); 1157 1308 … … 1167 1318 1168 1319 //-------------------------------------------------- 1169 bool FragmentHandle::wincopy (cmt_string& out, int variables, ...) 1320 bool FragmentHandle::wincopy (cmt_string& out, 1321 const Variable::VariableVector& vector, 1322 int variables, ...) 1170 1323 { 1171 1324 if (!setup ()) return (false); … … 1174 1327 1175 1328 va_start (ids, variables); 1176 bool result = _fragment->wincopy (out, v ariables, ids);1329 bool result = _fragment->wincopy (out, vector, variables, ids); 1177 1330 va_end (ids); 1178 1331 … … 1187 1340 } 1188 1341 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 1278 1342 //-------------------------------------------------- 1279 1343 bool FragmentHandle::setup () … … 1286 1350 if (_fragment == 0) 1287 1351 { 1288 CmtMessage::info ("Fragment " + _name + " not found"); 1352 CmtMessage::warning 1353 (CmtError::get_error_name (CmtError::fragment_not_found) 1354 + ": " + _name); 1289 1355 // cerr << "#CMT> Fragment " << _name << " not found" << endl; 1290 1356 } 1291 1357 } 1292 1358 1293 1359 if (_fragment == 0) 1294 1360 { -
CMT/HEAD/source/cmt_fragment.h
r11 r561 61 61 const cmt_string& trailer, 62 62 bool need_dependencies, 63 Use* use); 63 Use* use, 64 const cmt_string& path); 65 // Use* use); 64 66 static void show (const cmt_string& name); 65 67 static void show_all (); … … 79 81 ~Fragment (); 80 82 void clear (); 81 int print (); 83 int print (PrintMode mode = Csh, ostream& out = cout); // Csh is default for ArgParser::mode 84 // int print (); 82 85 bool locate (); 83 86 -
CMT/HEAD/source/cmt_generator.cxx
r527 r561 18 18 #include "cmt_generators.h" 19 19 #include "cmt_log.h" 20 #include "cmt_error.h" 20 21 21 22 //------------------------------------------------------------------------ … … 59 60 m_TITLE.set ("TITLE"); 60 61 m_GROUP.set ("GROUP"); 61 m_CONSTITUENT.set ("CONSTITUENT");62 62 m_CONSTITUENTSUFFIX.set ("CONSTITUENTSUFFIX"); 63 63 m_LIBRARYSUFFIX.set ("LIBRARYSUFFIX"); … … 73 73 m_SUFFIX.set ("SUFFIX"); 74 74 m_FILENAME.set ("FILENAME"); 75 // m_LINKMACRO.set ("LINKMACRO");76 75 m_LINE.set ("LINE"); 77 76 m_ADDINCLUDE.set ("ADDINCLUDE"); … … 691 690 692 691 //------------------------------------------------------------------------ 693 static ApplicationGenerator ApplicationContext;692 //static ApplicationGenerator ApplicationContext; 694 693 static LibraryGenerator LibraryContext; 695 694 static DocumentGenerator DocumentContext; … … 735 734 //-------------------------------------------------- 736 735 void 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 //-------------------------------------------------- 744 int 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; 740 812 } 741 813 … … 749 821 { 750 822 case Application: 751 ApplicationContext.build (package, constituent, file);752 break;823 //ApplicationContext.build (package, constituent, file); 824 //break; 753 825 case Library: 754 826 LibraryContext.build (package, constituent, file); … … 1009 1081 } 1010 1082 1083 //------------------------------------------------------------------------ 1084 InGenerator::Buffer::Buffer () 1085 : m_initialized (false), m_usecmt (true) 1086 { } 1087 1088 //------------------------------------------------------------------------ 1089 void InGenerator::Buffer::set_names (const CmtSystem::cmt_string_vector& names) 1090 { 1091 m_names = names; 1092 } 1093 1094 //------------------------------------------------------------------------ 1095 int InGenerator::Buffer::print (ostream& s) 1096 { 1097 initialize (); 1098 s << m_buffer.str (); 1099 return 0; 1100 } 1101 1102 //------------------------------------------------------------------------ 1103 void InGenerator::Buffer::set_uses (bool usecmt) 1104 { 1105 m_usecmt = usecmt; 1106 } 1107 1108 //------------------------------------------------------------------------ 1109 int 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 //------------------------------------------------------------------------ 1130 int 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 //------------------------------------------------------------------------ 1148 InGenerator::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 //------------------------------------------------------------------------ 1220 int 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 138 138 }; 139 139 140 class 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 140 189 /** 141 190 Generic command interface to be used by the cmt command driver. … … 161 210 // Build the constituents.make file 162 211 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); 164 214 165 215 // Build the makefile fragment for one constituent … … 167 217 const cmt_string& file = ""); 168 218 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); 169 222 170 223 static void build_default_makefile (); -
CMT/HEAD/source/cmt_generators.cxx
r547 r561 230 230 CmtSystem::basename (m_FULLNAME, m_FILENAME.value); 231 231 232 if (CmtSystem::test_file (m_FULLNAME))233 {232 // if (CmtSystem::test_file (m_FULLNAME)) 233 // { 234 234 java_fragment.copy (m_output_file, constituent.variables, 5, 235 235 &m_NAME, … … 238 238 &m_CONSTITUENT, 239 239 &m_CONSTITUENTSUFFIX); 240 /* 240 241 } 241 242 else … … 244 245 // cerr << "#CMT> Warning: file " << m_FULLNAME << " not found" << endl; 245 246 } 247 */ 246 248 } 247 249 … … 514 516 //fill_outputs (); 515 517 516 prepare_use_context ();518 //prepare_use_context (); 517 519 518 520 m_DATE = CmtSystem::now (); … … 986 988 int count = get_all_files (full_name, excludes, selects, files); 987 989 988 filter_path (full_name);990 // filter_path (full_name); 989 991 990 992 /* … … 1010 1012 // fill_outputs (); 1011 1013 1012 prepare_use_context ();1014 // prepare_use_context (); 1013 1015 1014 1016 m_DATE = CmtSystem::now (); … … 1069 1071 else 1070 1072 { 1073 /* 1071 1074 for (i = 0; i < sources.size (); i++) 1072 1075 { … … 1086 1089 { 1087 1090 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 (); 1089 1096 if (name != "") 1090 1097 { … … 1101 1108 name.c_str ()); 1102 1109 } 1103 }1110 // } 1104 1111 } 1105 1112 } … … 1118 1125 CmtSystem::basename (file_name, m_FILENAME.value); 1119 1126 CmtSystem::get_dot_suffix (m_FILENAME.value, m_FILESUFFIX.value); 1120 1127 /* 1121 1128 if (!CmtSystem::test_file (file_name) && !CmtSystem::test_directory (file_name)) 1122 1129 { 1123 1130 CmtMessage::warning ("Source file " + file_name + " not found"); 1124 // cerr << "#CMT> Warning: Source file " << file_name << " not found" << endl; 1125 } 1126 1131 } 1132 */ 1127 1133 filter_path (m_FULLNAME.value); 1128 1134 … … 1164 1170 const cmt_string& output_suffix) 1165 1171 { 1166 static cmt_string output_dir;1172 //static cmt_string output_dir; 1167 1173 static cmt_string suffix; 1168 1174 static cmt_string name; … … 1172 1178 { 1173 1179 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); 1181 1186 1182 1187 CmtSystem::get_suffix (file, suffix); … … 2520 2525 //-------------------------------------------------- 2521 2526 void 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) 2523 2529 { 2524 2530 reset (); 2525 2531 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 // } 2542 2549 2543 2550 if (file_name == "") … … 2557 2564 } 2558 2565 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 // } 2565 2572 2566 2573 cmt_string save_file_name = file_name; -
CMT/HEAD/source/cmt_generators.h
r466 r561 200 200 ConstituentsMakefileGenerator (); 201 201 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); 203 204 204 205 private: -
CMT/HEAD/source/cmt_language.cxx
r528 r561 145 145 146 146 /*----------------------------------------------------------*/ 147 void Language::action (const CmtSystem::cmt_string_vector& words) 147 void Language::action (const CmtSystem::cmt_string_vector& words, 148 Use* use) 149 //void Language::action (const CmtSystem::cmt_string_vector& words) 148 150 /*----------------------------------------------------------*/ 149 151 { … … 202 204 } 203 205 } 206 language.m_use = use; 204 207 } 205 208 … … 287 290 m_native_dependencies = false; 288 291 m_dependencies_options = "none"; 292 m_dependencies_options_expanded = ""; 289 293 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 /*----------------------------------------------------------*/ 298 void Language::show (PrintMode mode, ostream& out) 299 //void Language::show () 300 /*----------------------------------------------------------*/ 301 { 302 out << "language " << m_name; 297 303 298 304 int i; … … 302 308 cmt_string& suffix = suffixes[i]; 303 309 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 } 310 325 } 311 326 312 327 if (prototypes) 313 328 { 314 cout << " -prototypes";329 out << " -prototypes"; 315 330 } 316 331 317 332 if (preprocessor_command != "-I") 318 333 { 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 } 320 344 } 321 345 322 346 if (fragment_name != m_name) 323 347 { 324 cout << " -fragment=" << fragment_name;348 out << " -fragment=" << fragment_name; 325 349 } 326 350 327 351 if (output_suffix != "") 328 352 { 329 cout << " -output_suffix=" << output_suffix;353 out << " -output_suffix=" << output_suffix; 330 354 } 331 355 … … 334 358 cmt_string& suffix = extra_output_suffixes[i]; 335 359 336 cout << " -extra_output_suffix=" << suffix;360 out << " -extra_output_suffix=" << suffix; 337 361 } 338 362 339 363 if (m_dependencies_options != "none") 340 364 { 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; 345 378 } 346 379 … … 418 451 m_native_dependencies = false; 419 452 } 453 m_dependencies_options_expanded = opts; 420 454 } 421 455 else … … 426 460 return; 427 461 } 462 463 /*----------------------------------------------------------*/ 464 const 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 15 15 public: 16 16 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); 18 19 static Language& find (const cmt_string& name); 19 20 static Language& find_with_suffix (const cmt_string& suffix); … … 31 32 ~Language (); 32 33 void clear (); 33 void show (); 34 void show (PrintMode mode = Csh, ostream& out = cout); // Csh is default for ArgParser::mode 35 // void show (); 34 36 void setup_fragments (); 35 37 bool operator == (const cmt_string& name) const; … … 38 40 bool native_dependencies (); 39 41 const cmt_string& dependencies_options () const; 42 const cmt_string& dependencies_options_expanded (); 40 43 41 44 cmt_string m_name; … … 47 50 CmtSystem::cmt_string_vector suffixes; 48 51 CmtSystem::cmt_string_vector extra_output_suffixes; 52 UseRef m_use; 49 53 50 54 FragmentHandle application; … … 56 60 bool m_native_dependencies; 57 61 cmt_string m_dependencies_options; 62 cmt_string m_dependencies_options_expanded; 58 63 bool m_native_dependencies_set; 59 64 }; -
CMT/HEAD/source/cmt_parser.cxx
r555 r561 64 64 m_cmt_root = ""; 65 65 m_cmt_version = ""; 66 m_use_cmt = true; 66 67 m_current_dir = ""; 67 68 m_current_file_path = ""; … … 2100 2101 return; 2101 2102 } 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 // } 2107 2127 } 2108 2128 … … 2115 2135 return; 2116 2136 } 2117 if (ap.arguments.size () == 0) return;2118 2137 set_standard_macros (); 2119 2138 2120 2139 CmtSystem::cmt_string_vector files (2); 2121 cmt_string out dir, name;2140 cmt_string out, outdir, name; 2122 2141 for (int i = 0; i < ap.arguments.size (); i++) 2123 2142 { 2124 c mt_string arg = ap.arguments[i];2143 const cmt_string arg = ap.arguments[i]; 2125 2144 if (arg.substr (0, 5) == "-out=") 2126 2145 { 2127 arg. erase (0, 5);2128 CmtSystem::dirname ( arg, outdir);2146 arg.substr (5, out); 2147 CmtSystem::dirname (out, outdir); 2129 2148 } 2130 2149 else … … 2134 2153 } 2135 2154 2136 Generator::build_constituent_makefile (ap.arguments);2155 // Generator::build_constituent_makefile (ap.arguments); 2137 2156 2138 2157 const Constituent* constituent = Constituent::find (name); 2139 2158 if (constituent == 0) 2140 2159 { 2141 // generate error2160 CmtError::set (CmtError::constituent_not_found, name); 2142 2161 return; 2143 2162 } 2163 Generator::build_constituent_makefile (*constituent, out); 2144 2164 if (!constituent->has_target_tag) return; 2145 2165 // cerr << "constituent: " << name << endl; … … 2252 2272 set_standard_macros (); 2253 2273 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); 2255 2286 } 2256 2287 … … 2266 2297 2267 2298 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]; 2272 2304 if (arg.substr (0, 5) == "-out=") 2273 2305 { 2274 arg. erase (0, 5);2275 CmtSystem::dirname ( arg, outdir);2306 arg.substr (5, out); 2307 CmtSystem::dirname (out, outdir); 2276 2308 } 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; 2282 2313 } 2283 2314 // cerr << "outdir: " << outdir << endl; … … 2378 2409 } 2379 2410 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 } 2381 2422 } 2382 2423 … … 6270 6311 parse_arguments (ap); 6271 6312 6272 if (Me.m_debug)6273 {6274 cout << "After parse_argument> pack=" << Me.m_current_package6275 << " Me.m_current_tag=" << Me.m_current_tag6276 << " cwd=" << CmtSystem::pwd ()6277 << " mode=" << Me.m_current_access6278 << 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 automatically6309 // included6310 //6311 6312 if (Me.m_debug) cout << "parser1> current_tag=" << Me.m_current_tag << endl;6313 6314 6313 if (ap.help_action == action_help) 6315 6314 { 6316 do_help (ap);6317 6315 int code (0); 6318 6316 if (CmtError::has_pending_error ()) … … 6321 6319 CmtError::print (); 6322 6320 } 6321 do_help (ap); 6323 6322 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 // } 6326 6379 6327 6380 switch (Me.m_action) … … 6420 6473 case action_unlock : 6421 6474 case action_version : 6475 if (Me.m_use_cmt) 6476 { 6422 6477 use_cmt (); 6478 } 6423 6479 // 6424 6480 // Now parse the requirements file stored in ${CMTHOME} … … 6646 6702 bool w = Me.m_warnings; 6647 6703 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); 6649 6708 use_user_context_requirements (); 6650 6709 Me.m_warnings = w; … … 7764 7823 } 7765 7824 7825 //---------------------------------------------------------- 7826 int 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 //---------------------------------------------------------- 7766 7962 static cmt_string get_best_form (const CmtSystem::cmt_string_vector& pwd, 7767 7963 const cmt_string& path) -
CMT/HEAD/source/cmt_symbol.cxx
r550 r561 3061 3061 3062 3062 //------------------------------------------------------------- 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 quoted3067 // (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 else3108 { // simply copy3109 *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 any3117 char* r = b;3118 while (r > buffer && *(r - 1) == '\\')3119 r--;3120 if (r == b)3121 *b++ = '\"';3122 else3123 *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 //-------------------------------------------------------------3136 3063 int SymbolValueList::print (const Symbol& symbol, 3137 3064 const SymbolValue& value, … … 3311 3238 } 3312 3239 3313 cout << " " << quote (value.text, " \t");3240 cout << " " << CmtSystem::quote (value.text, " \t"); 3314 3241 // cout << "'" << value.text << "'"; 3315 3242 -
CMT/HEAD/source/cmt_syntax.cxx
r535 r561 494 494 int line_number) 495 495 { 496 Language::action (words );496 Language::action (words, use); 497 497 } 498 498 void action (const CmtSystem::cmt_string_vector& words, -
CMT/HEAD/source/cmt_system.cxx
r545 r561 2172 2172 current_word += word_length + 1; 2173 2173 } 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 //------------------------------------------------------------- 2183 cmt_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; 2174 2247 } 2175 2248 -
CMT/HEAD/source/cmt_system.h
r527 r561 132 132 const cmt_string& separators, 133 133 cmt_string_vector& strings); 134 static cmt_string quote (const cmt_string& text, 135 const cmt_string& separators); 134 136 135 137 static void compress_path (const cmt_string& dir, cmt_string& new_dir);
Note: See TracChangeset
for help on using the changeset viewer.