Changeset 561 for CMT/HEAD/source/cmt_parser.cxx
- Timestamp:
- Mar 8, 2011, 1:56:48 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note: See TracChangeset
for help on using the changeset viewer.