#include "cmt_deps_builder.h"
#include "cmt_system.h"
#include "cmt_use.h"
#include "cmt_include.h"
#include "cmt_symbol.h"
Include dependency graph for cmt_deps_builder.cxx:
Go to the source code of this file.
|
Definition at line 13 of file cmt_deps_builder.cxx. 00014 { 00015 at_start, // beginning of the file 00016 in_line, // along a line 00017 in_string, // inside a quoted string 00018 in_char, // inside a quoted char 00019 in_comment, // inside a multi-line comment 00020 in_string_comment, // inside a quoted string in a comment 00021 in_char_comment, // inside a quoted char in a comment 00022 in_line_comment // inside a single-line comment 00023 } |
|
Definition at line 98 of file cmt_deps_builder.cxx. Referenced by build_deps_stream(). 00107 { 00108 char term = 0; 00109 00110 if (*ptr == '#') 00111 { 00112 ptr++; 00113 while ((*ptr == ' ') || (*ptr == '\t')) ptr++; 00114 if (!strncmp (ptr, "include", 7)) 00115 { 00116 ptr += 7; 00117 00118 while (*ptr == ' ') ptr++; 00119 if (*ptr == '<') 00120 { 00121 term = '>'; 00122 ptr++; 00123 } 00124 else if (*ptr == '"') 00125 { 00126 term = '"'; 00127 ptr++; 00128 } 00129 else 00130 { 00131 state = in_line; 00132 ptr += strlen (ptr); 00133 return (ptr); 00134 } 00135 } 00136 else 00137 { 00138 state = in_line; 00139 ptr += strlen (ptr); 00140 return (ptr); 00141 } 00142 } 00143 else if (!strncmp (ptr, " include", 13)) 00144 { 00145 ptr += 13; 00146 00147 while ((*ptr == ' ') || (*ptr == '\t')) ptr++; 00148 if (*ptr == '\'') 00149 { 00150 term = '\''; 00151 ptr++; 00152 } 00153 else 00154 { 00155 state = in_line; 00156 return (ptr); 00157 } 00158 } 00159 else if (!strncmp (ptr, "\tinclude", 8)) 00160 { 00161 ptr += 8; 00162 00163 while ((*ptr == ' ') || (*ptr == '\t')) ptr++; 00164 if (*ptr == '\'') 00165 { 00166 term = '\''; 00167 ptr++; 00168 } 00169 else 00170 { 00171 state = in_line; 00172 return (ptr); 00173 } 00174 } 00175 else 00176 { 00177 state = in_line; 00178 return (ptr); 00179 } 00180 00181 char* end; 00182 00183 end = strchr (ptr, term); 00184 if (end != 0) 00185 { 00186 *end = 0; 00187 } 00188 00189 const char* header_file = ptr; 00190 00191 header_file_action (header_file, 00192 dir_name, 00193 current_path_index, 00194 include_paths, 00195 substitutions, 00196 all_deps, 00197 deps); 00198 00199 if (end != 0) 00200 { 00201 *end = term; 00202 } 00203 00204 state = in_line; 00205 ptr += strlen (ptr); 00206 00207 return (ptr); 00208 } |
|
Definition at line 508 of file cmt_deps_builder.cxx. Referenced by header_file_action(), and DepsBuilder::run(). 00516 { 00517 int result = -1; 00518 cmt_string new_dir; 00519 00520 if (Cmt::get_debug ()) 00521 { 00522 cout << "CMT> build_deps name=" << name << " dir_name=" << 00523 dir_name << endl; 00524 } 00525 00526 // 00527 // Return 0 when the file is found in the current directory 00528 // 00529 if (CmtSystem::test_file (name)) 00530 { 00531 ifstream input (name.c_str ()); 00532 if (input) 00533 { 00534 CmtSystem::dirname (name, new_dir); 00535 build_deps_stream (input, new_dir, current_path_index, 00536 include_paths, substitutions, 00537 all_deps, deps); 00538 return (0); 00539 } 00540 } 00541 00542 cmt_string full_name; 00543 00544 full_name = dir_name; 00545 full_name += CmtSystem::file_separator (); 00546 full_name += name; 00547 00548 // 00549 // Return 1 when the file is found in the directory of the 00550 // upper level source file 00551 // 00552 if (CmtSystem::test_file (full_name)) 00553 { 00554 ifstream input (full_name.c_str ()); 00555 if (input) 00556 { 00557 CmtSystem::dirname (full_name, new_dir); 00558 build_deps_stream (input, new_dir, current_path_index, 00559 include_paths, substitutions, 00560 all_deps, deps); 00561 return (1); 00562 } 00563 } 00564 00565 int path_index = -1; 00566 00567 // 00568 // Return [path_index + 2] when the include file is found at one of 00569 // the include_paths 00570 // 00571 for (path_index = 0; path_index < include_paths.size (); path_index++) 00572 { 00573 full_name = include_paths[path_index]; 00574 full_name += CmtSystem::file_separator (); 00575 full_name += name; 00576 00577 if (Cmt::get_debug ()) 00578 { 00579 cout << "CMT> build_deps2 full_name=" << full_name << endl; 00580 } 00581 00582 if (CmtSystem::test_file (full_name)) 00583 { 00584 ifstream in (full_name.c_str ()); 00585 if (in) 00586 { 00587 CmtSystem::dirname (full_name, new_dir); 00588 00589 if (Cmt::get_debug ()) 00590 { 00591 cout << "CMT> build_deps3 new_dir=" << new_dir << endl; 00592 } 00593 00594 build_deps_stream (in, 00595 new_dir, 00596 path_index + 2, 00597 include_paths, 00598 substitutions, 00599 all_deps, 00600 deps); 00601 00602 return (path_index + 2); 00603 } 00604 } 00605 } 00606 00607 if (Cmt::get_debug ()) 00608 { 00609 cout << "CMT> build_deps3" << endl; 00610 } 00611 00612 return (-1); 00613 } |
|
Definition at line 435 of file cmt_deps_builder.cxx. Referenced by build_deps(). 00443 { 00444 if (input) 00445 { 00446 if (Cmt::get_debug ()) 00447 { 00448 cout << "CMT> build_deps_stream dir_name=" << 00449 dir_name << endl; 00450 } 00451 00452 while (!input.eof ()) 00453 { 00454 char line[16384]; 00455 00456 input.getline (line, sizeof (line)); 00457 char* ptr = &line[0]; 00458 state_def state = at_start; 00459 00460 if (Cmt::get_debug ()) 00461 { 00462 cout << "CMT> build_deps_stream2 line=[" << 00463 line << "]" << endl; 00464 } 00465 00466 while (strlen (ptr) > 0) 00467 { 00468 switch (state) 00469 { 00470 case at_start: 00471 ptr = at_start_action (ptr, 00472 state, 00473 dir_name, 00474 current_path_index, 00475 include_paths, 00476 substitutions, 00477 all_deps, 00478 deps); 00479 break; 00480 case in_line: 00481 ptr = in_line_action (ptr, state); 00482 break; 00483 case in_string: 00484 ptr = in_string_action (ptr, state); 00485 break; 00486 case in_char: 00487 ptr = in_char_action (ptr, state); 00488 break; 00489 case in_comment: 00490 ptr = in_comment_action (ptr, state); 00491 break; 00492 case in_string_comment: 00493 ptr = in_string_comment_action (ptr, state); 00494 break; 00495 case in_char_comment: 00496 ptr = in_char_comment_action (ptr, state); 00497 break; 00498 case in_line_comment: 00499 ptr = in_line_action (ptr, state); 00500 break; 00501 } 00502 } 00503 } 00504 } 00505 } |
|
Definition at line 37 of file cmt_deps_builder.cxx. Referenced by at_start_action(). 00044 { 00045 bool found = false; 00046 00047 for (int i = 0; i < all_deps.size (); i++) 00048 { 00049 if (all_deps[i] == header_file) 00050 { 00051 found = true; 00052 break; 00053 } 00054 } 00055 00056 if (!found) 00057 { 00058 all_deps.push_back (header_file); 00059 00060 int path_index = build_deps (header_file, 00061 dir_name, 00062 current_path_index, 00063 include_paths, 00064 substitutions, 00065 all_deps, 00066 deps); 00067 00068 if (path_index >= 0) 00069 { 00070 cmt_string full_name; 00071 00072 if (path_index == 1) 00073 { 00074 full_name = dir_name; 00075 full_name += CmtSystem::file_separator (); 00076 00077 if (current_path_index >= 2) 00078 { 00079 full_name.replace (include_paths[current_path_index - 2], 00080 substitutions[current_path_index - 2]); 00081 } 00082 } 00083 else if (path_index > 1) 00084 { 00085 full_name = substitutions[path_index - 2]; 00086 full_name += CmtSystem::file_separator (); 00087 } 00088 00089 full_name += header_file; 00090 00091 deps.push_back (full_name); 00092 } 00093 } 00094 } |
|
Definition at line 297 of file cmt_deps_builder.cxx. Referenced by build_deps_stream(). 00299 { 00300 char* pos = strchr (ptr, '\''); 00301 if (pos == 0) 00302 { 00303 // This string is not finished till the end of the line.. 00304 // we expect it continues to the nex line... 00305 ptr += strlen (ptr); 00306 } 00307 else 00308 { 00309 pos--; 00310 if (*pos == '\\') 00311 { 00312 ptr = pos + 2; 00313 } 00314 else 00315 { 00316 ptr = pos + 2; 00317 state = in_line; 00318 } 00319 } 00320 00321 return (ptr); 00322 } |
|
Definition at line 398 of file cmt_deps_builder.cxx. Referenced by build_deps_stream(). 00400 { 00401 char* pos = strchr (ptr, '\''); 00402 if (pos == 0) 00403 { 00404 // This string is not finished till the end of the line.. 00405 // we expect it continues to the nex line... 00406 ptr += strlen (ptr); 00407 } 00408 else 00409 { 00410 pos--; 00411 if (*pos == '\\') 00412 { 00413 ptr = pos + 2; 00414 } 00415 else 00416 { 00417 ptr = pos + 2; 00418 state = in_comment; 00419 } 00420 } 00421 00422 return (ptr); 00423 } |
|
Definition at line 325 of file cmt_deps_builder.cxx. Referenced by build_deps_stream(). 00327 { 00328 char* pattern = &ptr[strlen (ptr)]; 00329 char* pos = strchr (ptr, '"'); 00330 if (pos != 0) 00331 { 00332 if (pos < pattern) 00333 { 00334 state = in_string_comment; 00335 pattern = pos; 00336 } 00337 } 00338 pos = strchr (ptr, '\''); 00339 if (pos != 0) 00340 { 00341 if (pos < pattern) 00342 { 00343 state = in_char_comment; 00344 pattern = pos; 00345 } 00346 } 00347 pos = strstr (ptr, "*/"); 00348 if (pos != 0) 00349 { 00350 if (pos < pattern) 00351 { 00352 state = in_line; 00353 pattern = pos + 1; 00354 } 00355 } 00356 00357 if (state == in_comment) 00358 { 00359 ptr += strlen (ptr); 00360 } 00361 else 00362 { 00363 ptr = pattern + 1; 00364 } 00365 00366 return (ptr); 00367 } |
|
Definition at line 211 of file cmt_deps_builder.cxx. Referenced by build_deps_stream(). 00213 { 00214 char* pattern = &ptr[strlen (ptr)]; 00215 00216 char* pos = strchr (ptr, '"'); 00217 if (pos != 0) 00218 { 00219 if (pos < pattern) 00220 { 00221 state = in_string; 00222 pattern = pos; 00223 } 00224 } 00225 00226 pos = strchr (ptr, '\''); 00227 if (pos != 0) 00228 { 00229 if (pos < pattern) 00230 { 00231 state = in_char; 00232 pattern = pos; 00233 } 00234 } 00235 00236 pos = strstr (ptr, "/*"); 00237 if (pos != 0) 00238 { 00239 if (pos < pattern) 00240 { 00241 state = in_comment; 00242 pattern = pos + 1; 00243 } 00244 } 00245 00246 pos = strstr (ptr, "//"); 00247 if (pos != 0) 00248 { 00249 if (pos < pattern) 00250 { 00251 state = in_line_comment; 00252 pattern = pos + 1; 00253 } 00254 } 00255 00256 if (state != in_line) 00257 { 00258 ptr = pattern + 1; 00259 } 00260 else 00261 { 00262 ptr += strlen (ptr); 00263 } 00264 00265 return (ptr); 00266 } |
|
Definition at line 426 of file cmt_deps_builder.cxx. 00428 { 00429 ptr += strlen (ptr); 00430 00431 return (ptr); 00432 } |
|
Definition at line 269 of file cmt_deps_builder.cxx. Referenced by build_deps_stream(). 00271 { 00272 char* pos = strchr (ptr, '"'); 00273 if (pos == 0) 00274 { 00275 // This string is not finished till the end of the line.. 00276 // we expect it continues to the nex line... 00277 ptr += strlen (ptr); 00278 } 00279 else 00280 { 00281 pos--; 00282 if (*pos == '\\') 00283 { 00284 ptr = pos + 2; 00285 } 00286 else 00287 { 00288 ptr = pos + 2; 00289 state = in_line; 00290 } 00291 } 00292 00293 return (ptr); 00294 } |
|
Definition at line 370 of file cmt_deps_builder.cxx. Referenced by build_deps_stream(). 00372 { 00373 char* pos = strchr (ptr, '"'); 00374 if (pos == 0) 00375 { 00376 // This string is not finished till the end of the line.. 00377 // we expect it continues to the nex line... 00378 ptr += strlen (ptr); 00379 } 00380 else 00381 { 00382 pos--; 00383 if (*pos == '\\') 00384 { 00385 ptr = pos + 2; 00386 } 00387 else 00388 { 00389 ptr = pos + 2; 00390 state = in_comment; 00391 } 00392 } 00393 00394 return (ptr); 00395 } |