Files Classes Functions Hierarchy
#include <makestate.h>
Public Member Functions | |
| void | processqueueadd (compilationfile *cf) |
| Add to both proessqueue's. | |
| void | standardbuild () |
| Populate the standard container. | |
| ~makestate () | |
| Cleanup. | |
| void | print () |
| Print containers. | |
| makestate () | |
| Constructor sets default printing. | |
| void | printdefaults () |
| Set default toggle options on printing. | |
| void | printafterbuild () |
| After the makefile is built print the following as the building of the makefile is not 100%, the programmer should look at the unknown files. | |
| void | eval (compilationfile &cf) |
| Processes the compilation file by parsing it and building the includes, adding it to the process queue, if h cpp pair then adding the cpp to the process queue, if cpp then adding the obj to objs. | |
| void | evaldriver () |
| The driver program's cpp has no header and is treated separately. | |
| void | objseval (compilationfile &cf) |
| First pass build the dependency list in includes. | |
| void | objseval (compilationfile &cf, compilationfile &h) |
| First pass recursive descent into header file. | |
| void | objsdependenciesPass1 () |
| Parse the objs recursively descending to construct dependencies. | |
| void | objsdependenciesPass2 () |
| Remove circular dependencies from Pass1. | |
| compilationfile * | isinprocesschain (stringc &filename) const |
| Looks at the containers for the file. | |
| boolc | valid () |
| Some error checking on processqueue. | |
Public Attributes | |
| CFC | processed |
| Unique list of all past in compilationfile's that have been linked to each other. | |
| CFC | standard |
| Standard C++ header names. | |
| CFC | unknown |
| Unknown files that are not standard and not under proj directory. | |
| CFC | processqueue2 |
| For searching. | |
| deque< compilationfile * > | processqueue |
| For evaluating. | |
| CFC | objs |
| Object files. | |
| bool | printobjs |
| Toggle objs output. | |
| bool | printprocessed |
| Toggle processed output. | |
| bool | printprocessqueue |
| Toggle processqueue output. | |
| bool | printstandard |
| Toggle standard output. | |
| bool | printunknown |
| Toggle unknown output. | |
| bool | printobjsdependencies |
| Toggle objs dependencies output. | |
| projfiles< CFC > | proj |
| Holds a list of all the files. | |
| string | driver |
| Driver cpp file component, by default "main". | |
All includes added through compilationfile::includesadd( ) to guarantee includes[] is unique.
Definition at line 22 of file makestate.h.
Cleanup.
Definition at line 229 of file makestate.h.
References makestate< CFC >::objs.
00230 { 00231 // Cleanup as created separately 00232 for ( objs.reset(); !objs; ++objs) 00233 delete objs(); 00234 }
Constructor sets default printing.
Definition at line 404 of file makestate.h.
References makestate< CFC >::objs, makestate< CFC >::printdefaults(), makestate< CFC >::processed, makestate< CFC >::processqueue2, makestate< CFC >::standard, and makestate< CFC >::unknown.
00405 : driver("main") 00406 { 00407 // I have chosen this on my current project size, for example 00408 // I may have about 50 files being in a container realistically, 00409 // by making the default much larger it should handle more code 00410 // that has many more files. 00411 uintc size=500; 00412 processed.construct(size); 00413 standard.construct(size); 00414 unknown.construct(size); 00415 processqueue2.construct(size); 00416 objs.construct(size); 00417 00418 printdefaults(); 00419 }
| void makestate< CFC >::eval | ( | compilationfile & | cf | ) | [inline] |
Processes the compilation file by parsing it and building the includes, adding it to the process queue, if h cpp pair then adding the cpp to the process queue, if cpp then adding the obj to objs.
Definition at line 293 of file makestate.h.
References compilationfile::component(), compilationfile::filename, compilationfile::ft, compilationfile::header, compilationfile::includes, compilationfile::includesadd(), makestate< CFC >::isinprocesschain(), compilationfile::linkheader, compilationfile::linkobj, compilationfile::linksource, makestate< CFC >::objs, compilationfile::path, makestate< CFC >::processqueueadd(), makestate< CFC >::proj, compilationfile::source, makestate< CFC >::standard, makefilebtglobals::tempheaders, and makestate< CFC >::unknown.
Referenced by makestatetest::test02().
00294 { 00295 //cout << SHOW(cf.filename) << endl; 00296 //cout << SHOW(cf.linkheader) << endl; 00297 //cout << SHOW(cf.linksource) << endl; 00298 //cout << SHOW(cf.linkobj) << endl; 00299 // Has this object been evaluated before? 00300 if (cf.linkheader || cf.linksource || cf.linkobj) 00301 return; 00302 00303 assert(cf.includes.empty()); 00304 00305 assert(!cf.path.empty()); 00306 00307 systemcalls sys01 00308 ( 00309 "perl ../makefilebuildtool/extractheaders.pl " + cf.path + cf.filename, 00310 // "tempheaders.txt" 00311 makefilebtglobals::tempheaders 00312 ); 00313 sys01.eval(); 00314 00315 compilationfile* x; 00316 string filename; 00317 00318 for (uint i=0; i<sys01.lines.size(); ++i) 00319 { 00320 filename=sys01.lines[i]; 00321 if (standard[filename]) 00322 continue; 00323 00324 // Assume the headers have a .h extension. 00325 filename += ".h"; 00326 00327 x = isinprocesschain(filename); 00328 if (x) 00329 { 00330 // cf.includes.push_back(x); 00331 cf.includesadd(x); 00332 continue; 00333 } 00334 00335 assert(!x); //make sure continue works. 00336 //cout << "Not in process chain." << endl; 00337 //cout << SHOW(filename) << endl; 00338 00339 x = proj.files[filename]; 00340 if (!x) 00341 { 00342 unknown.add(new compilationfile("",filename)); 00343 continue; 00344 } 00345 00346 processqueueadd(x); 00347 00348 //cf.includes.push_back(x); 00349 cf.includesadd(x); 00350 00351 //cout << sys01.lines[i] << endl;; 00352 } 00353 00354 00355 if (cf.ft==compilationfile::header) 00356 { 00357 // Headers are included before cpp, 00358 00359 cf.linkheader= &cf; 00360 x = proj.files[cf.component()+".cpp"]; 00361 if (x) 00362 { 00363 cf.linksource = x; 00364 processqueueadd(x); 00365 } 00366 } 00367 00368 if (cf.ft==compilationfile::source) 00369 { 00370 cf.linksource = &cf; 00371 00372 x = proj.files[cf.component()+".h"]; 00373 assert(x); 00374 cf.linkheader = x; 00375 00376 assert(cf.component() == x->linkheader->component()); 00377 00378 x = new compilationfile(cf.path,cf.component()+".o"); 00379 x->linkobj = x; 00380 x->linksource = &cf; 00381 x->linkheader = cf.linkheader; 00382 00383 //cout << "*11*" << cf.filename << endl; 00384 cf.linkheader->linkobj = x; 00385 cf.linkobj = x; 00386 00387 objs.add(x); 00388 } 00389 00390 }
| void makestate< CFC >::evaldriver | ( | ) | [inline] |
The driver program's cpp has no header and is treated separately.
This puts the driver cpp onto the process stack and created a virtual driver header.
Definition at line 280 of file makestate.h.
References makestate< CFC >::processed, makestate< CFC >::processqueueadd(), and makestate< CFC >::proj.
00281 { 00282 assert(!proj.driver.empty()); 00283 00284 compilationfile* x = proj.files[proj.driverh()]; 00285 processed.add(x); 00286 compilationfile* x2 = proj.files[proj.drivercpp()]; 00287 processqueueadd(x2); 00288 x->linkheader = x; 00289 x->linksource = x2; 00290 }
| compilationfile * makestate< CFC >::isinprocesschain | ( | stringc & | filename | ) | const [inline] |
Looks at the containers for the file.
Definition at line 120 of file makestate.h.
References makestate< CFC >::processed, makestate< CFC >::processqueue2, makestate< CFC >::standard, and makestate< CFC >::unknown.
Referenced by makestate< CFC >::eval().
00121 { 00122 compilationfile* x; 00123 00124 x = standard[filename]; 00125 if (x) 00126 return x; 00127 00128 x = processed[filename]; 00129 if (x) 00130 return x; 00131 00132 x = unknown[filename]; 00133 if (x) 00134 return x; 00135 00136 x = processqueue2[filename]; 00137 if (x) 00138 return x; 00139 00140 return 0; 00141 }
| void makestate< CFC >::objsdependenciesPass1 | ( | ) | [inline] |
Parse the objs recursively descending to construct dependencies.
Definition at line 422 of file makestate.h.
References makestate< CFC >::objs, and makestate< CFC >::objseval().
Referenced by makestatetest::test06().
00423 { 00424 // assert(objs.size()!=0); 00425 00426 for (objs.reset(); !objs; ++objs) 00427 objseval(*objs()); 00428 00429 // The driver programs virtual .h file is to be deleted. 00430 objs.reset(); 00431 if (!objs) 00432 objs()->includes.pop_back(); 00433 }
| void makestate< CFC >::objsdependenciesPass2 | ( | ) | [inline] |
Remove circular dependencies from Pass1.
Definition at line 436 of file makestate.h.
References compilationfile::ft, compilationfile::includes, compilationfile::includesadd(), compilationfile::obj, and makestate< CFC >::objs.
Referenced by makestatetest::test06().
00437 { 00438 00439 compilationfile *x; 00440 compilationfile *y; 00441 for (objs.reset(); !objs; ++objs) 00442 { 00443 x=objs(); 00444 uint imax = x->includes.size(); 00445 for (uint i=0; i<imax; ++i) 00446 { 00447 y = x->includes[i]; 00448 if (y->ft!=compilationfile::obj) 00449 continue; 00450 00451 uint kmax = y->includes.size(); 00452 for (uint k=0; k<kmax; ++k) 00453 { 00454 if (x!=y->includes[k]) 00455 continue; 00456 00457 // Searched and found circular dependency 00458 //cout << SHOW(i) << " " << SHOW(k) << endl; 00459 x->includes[i] = x->includes[i]->linkheader; 00460 //x->includes.push_back( x->includes[i]->linksource ); 00461 x->includesadd(x->includes[i]->linksource ); 00462 y->includes[k] = y->includes[k]->linkheader; 00463 //y->includes.push_back( y->includes[k]->linksource ); 00464 y->includesadd( y->includes[k]->linksource ); 00465 } 00466 } 00467 } 00468 }
| void makestate< CFC >::objseval | ( | compilationfile & | cf, | |
| compilationfile & | h | |||
| ) | [inline] |
First pass recursive descent into header file.
Definition at line 472 of file makestate.h.
References compilationfile::filename, compilationfile::ft, compilationfile::header, compilationfile::includes, compilationfile::includesadd(), compilationfile::linkobj, compilationfile::linksource, compilationfile::obj, makestate< CFC >::objseval(), and makestate< CFC >::unknown.
00473 { 00474 assert(cf.ft==compilationfile::obj); 00475 assert(h.ft==compilationfile::header); 00476 assert(h.linksource==0); 00477 assert(h.linkobj==0); 00478 00479 // Unknown files are assumed to work, often part of a library, 00480 // which I assume is constant. e.g. GL/gl.h GL/glut.h 00481 if (unknown[h.filename]) 00482 return; 00483 00484 // Stop infinite recursion, case already handled. 00485 if (cf.includesadd(&h)==false) 00486 return; 00487 00488 uint imax=h.includes.size(); 00489 compilationfile* y; 00490 for (uint i=0; i<imax; ++i) 00491 { 00492 y = h.includes[i]; 00493 if (y->linkobj) 00494 cf.includesadd(y->linkobj); 00495 else 00496 objseval(cf,*y); 00497 } 00498 }
| void makestate< CFC >::objseval | ( | compilationfile & | cf | ) | [inline] |
First pass build the dependency list in includes.
Definition at line 501 of file makestate.h.
References compilationfile::ft, compilationfile::includes, compilationfile::includesadd(), compilationfile::includesvalid(), compilationfile::linkheader, compilationfile::linkobj, compilationfile::linksource, and compilationfile::obj.
Referenced by makestate< CFC >::objsdependenciesPass1(), and makestate< CFC >::objseval().
00502 { 00503 assert(cf.ft==compilationfile::obj); 00504 00505 //cout << SHOW(cf.filename) << endl; 00506 00507 compilationfile* x; 00508 00509 // Descend into the header first. 00510 x = cf.linkheader; 00511 assert(x); 00512 assert(x->includesvalid()); 00513 assert(cf.includes.size()==0); 00514 00515 uint imax; 00516 compilationfile* y; 00517 00518 imax = x->includes.size(); 00519 for (uint i=0; i<imax; ++i) 00520 { 00521 y = x->includes[i]; 00522 assert(y!=0); 00523 if (y->linkobj) 00524 cf.includesadd(y->linkobj); 00525 else 00526 objseval(cf,*y); 00527 } 00528 00529 // Now descend into the cpp 00530 x = cf.linksource; 00531 assert(x); 00532 assert(x->includesvalid()); 00533 imax = x->includes.size(); 00534 for (uint i=0; i<imax; ++i) 00535 { 00536 y = x->includes[i]; 00537 if (y->linkobj) 00538 cf.includesadd(y->linkobj); 00539 else 00540 objseval(cf,*y); 00541 } 00542 00543 // Add the cpp and headers 00544 cf.includesadd(cf.linksource); 00545 cf.includesadd(cf.linkheader); 00546 }
| void makestate< CFC >::print | ( | ) | [inline] |
Print containers.
Definition at line 157 of file makestate.h.
References compilationfile::filename, compilationfile::includes, makestate< CFC >::objs, makestate< CFC >::printobjs, makestate< CFC >::printobjsdependencies, makestate< CFC >::printprocessed, makestate< CFC >::printprocessqueue, makestate< CFC >::printstandard, makestate< CFC >::printunknown, makestate< CFC >::processed, makestate< CFC >::processqueue, makestate< CFC >::standard, makestate< CFC >::unknown, and makestate< CFC >::valid().
Referenced by makestate< CFC >::printafterbuild(), makestatetest::test01(), makestatetest::test02(), makestatetest::test03(), makestatetest::test04(), makestatetest::test05(), and makestatetest::test06().
00158 { 00159 if (printprocessed) 00160 printcontainer(processed,"processed"); 00161 if (printstandard) 00162 printcontainer(standard,"standard"); 00163 if (printunknown) 00164 printcontainer(unknown,"unknown"); 00165 if (printobjs) 00166 printcontainer(objs,"objs"); 00167 //printcontainer(processqueue2,"processqueue2"); 00168 00169 if (printprocessqueue) 00170 { 00171 cout << "processqueue: "; 00172 if (!processqueue.empty()) 00173 { 00174 for (deque<compilationfile*>::const_iterator i=processqueue.begin(); 00175 i != processqueue.end(); i++) 00176 cout << " " << (*i)->filename; 00177 cout << endl; 00178 } 00179 else 00180 cout << endl; 00181 } 00182 00183 if (printobjsdependencies) 00184 { 00185 cout << "objsdependencies:" << endl; 00186 compilationfile* x; 00187 for ( objs.reset(); !objs; ++objs ) 00188 { 00189 x = objs(); 00190 assert(x); 00191 cout << x->filename << ": "; 00192 uint imax=x->includes.size(); 00193 for (uint i=0; i<imax; ++i) 00194 { 00195 assert(x->includes[i]); 00196 cout << " " << x->includes[i]->filename; 00197 } 00198 cout << endl; 00199 } 00200 } 00201 00202 assert(valid()); 00203 cout << endl; 00204 }
| void makestate< CFC >::printafterbuild | ( | ) | [inline] |
After the makefile is built print the following as the building of the makefile is not 100%, the programmer should look at the unknown files.
Definition at line 144 of file makestate.h.
References makestate< CFC >::print(), makestate< CFC >::printobjs, makestate< CFC >::printobjsdependencies, makestate< CFC >::printprocessed, makestate< CFC >::printprocessqueue, makestate< CFC >::printstandard, and makestate< CFC >::printunknown.
00145 { 00146 printprocessed=true; 00147 printstandard=false; 00148 printunknown=true; 00149 printobjs=false; 00150 printprocessqueue=false; 00151 printobjsdependencies=false; 00152 00153 print(); 00154 }
| void makestate< CFC >::printdefaults | ( | ) | [inline] |
Set default toggle options on printing.
Definition at line 393 of file makestate.h.
References makestate< CFC >::printobjs, makestate< CFC >::printobjsdependencies, makestate< CFC >::printprocessed, makestate< CFC >::printprocessqueue, makestate< CFC >::printstandard, and makestate< CFC >::printunknown.
Referenced by makestate< CFC >::makestate().
00394 { 00395 printobjs=true; 00396 printprocessqueue=true; 00397 printprocessed=true; 00398 printstandard=false; 00399 printunknown=true; 00400 printobjsdependencies=false; 00401 }
| void makestate< CFC >::processqueueadd | ( | compilationfile * | cf | ) | [inline] |
Add to both proessqueue's.
Definition at line 273 of file makestate.h.
References makestate< CFC >::processqueue, and makestate< CFC >::processqueue2.
Referenced by makestate< CFC >::eval(), makestate< CFC >::evaldriver(), and makestatetest::test03().
00274 { 00275 processqueue2.add(cf); 00276 processqueue.push_back(cf); 00277 }
| void makestate< CFC >::standardbuild | ( | ) | [inline] |
Populate the standard container.
Definition at line 237 of file makestate.h.
References compilationfile::header, tokenizer::reset(), makestate< CFC >::standard, and tokenizer::subtract().
Referenced by makestatetest::test01(), makestatetest::test02(), and makestatetest::test03().
00238 { 00239 string standardstring="algorithm bitset cassert cctype cfloat climits cmath complex cstddef cstdlib cstring ctime deque exception fstream functional iomanip ios iosfwd iostream istream iterator limits list local map memory new numeric ostream queue set sstream stack stdexcept streambuf string strstream typeinfo utility valarray vector"; 00240 00241 tokenizer ss(standardstring); 00242 ss.subtract(" "); 00243 00244 compilationfile* x; 00245 for (ss.reset(); !ss; ++ss) 00246 { 00247 x = new compilationfile("",ss(),compilationfile::header); 00248 standard.add(x); 00249 //cout << ss() << endl; 00250 } 00251 }
Some error checking on processqueue.
Definition at line 254 of file makestate.h.
References makestate< CFC >::processqueue, and makestate< CFC >::processqueue2.
Referenced by makestate< CFC >::print().
00255 { 00256 // The processqueue is contained in processqueue2 00257 // They should have the same elements exactly, but I am not 00258 // testing in the other direction. 00259 if (!processqueue.empty()) 00260 { 00261 for (deque<compilationfile*>::const_iterator i=processqueue.begin(); 00262 i != processqueue.end(); i++) 00263 { 00264 if ( processqueue2[ (*i)->filename ] == 0 ) 00265 return false; 00266 } 00267 } 00268 00269 return true; 00270 }
Driver cpp file component, by default "main".
Definition at line 105 of file makestate.h.
Referenced by makestatetest::test06().
Object files.
Definition at line 42 of file makestate.h.
Referenced by makestate< CFC >::eval(), makestate< CFC >::makestate(), makestate< CFC >::objsdependenciesPass1(), makestate< CFC >::objsdependenciesPass2(), makestate< CFC >::print(), makestatetest::test05(), and makestate< CFC >::~makestate().
Toggle objs output.
Definition at line 57 of file makestate.h.
Referenced by makestate< CFC >::print(), makestate< CFC >::printafterbuild(), makestate< CFC >::printdefaults(), makestatetest::test04(), and makestatetest::test06().
| bool makestate< CFC >::printobjsdependencies |
Toggle objs dependencies output.
Definition at line 67 of file makestate.h.
Referenced by makestate< CFC >::print(), makestate< CFC >::printafterbuild(), makestate< CFC >::printdefaults(), and makestatetest::test06().
| bool makestate< CFC >::printprocessed |
Toggle processed output.
Definition at line 59 of file makestate.h.
Referenced by makestate< CFC >::print(), makestate< CFC >::printafterbuild(), makestate< CFC >::printdefaults(), makestatetest::test04(), and makestatetest::test06().
| bool makestate< CFC >::printprocessqueue |
Toggle processqueue output.
Definition at line 61 of file makestate.h.
Referenced by makestate< CFC >::print(), makestate< CFC >::printafterbuild(), makestate< CFC >::printdefaults(), makestatetest::test04(), and makestatetest::test06().
| bool makestate< CFC >::printstandard |
Toggle standard output.
Definition at line 63 of file makestate.h.
Referenced by makestate< CFC >::print(), makestate< CFC >::printafterbuild(), makestate< CFC >::printdefaults(), and makestatetest::test01().
| bool makestate< CFC >::printunknown |
Toggle unknown output.
Definition at line 65 of file makestate.h.
Referenced by makestate< CFC >::print(), makestate< CFC >::printafterbuild(), makestate< CFC >::printdefaults(), makestatetest::test04(), and makestatetest::test06().
Unique list of all past in compilationfile's that have been linked to each other.
Definition at line 28 of file makestate.h.
Referenced by makestate< CFC >::evaldriver(), makestate< CFC >::isinprocesschain(), makestate< CFC >::makestate(), and makestate< CFC >::print().
| deque<compilationfile*> makestate< CFC >::processqueue |
For evaluating.
processqueue and processque2 are mirrored data.
Definition at line 37 of file makestate.h.
Referenced by makestate< CFC >::print(), makestate< CFC >::processqueueadd(), and makestate< CFC >::valid().
| CFC makestate< CFC >::processqueue2 |
For searching.
processqueue and processque2 are mirrored data.
Definition at line 35 of file makestate.h.
Referenced by makestate< CFC >::isinprocesschain(), makestate< CFC >::makestate(), makestate< CFC >::processqueueadd(), and makestate< CFC >::valid().
Holds a list of all the files.
Definition at line 102 of file makestate.h.
Referenced by makestate< CFC >::eval(), makestate< CFC >::evaldriver(), makestatetest::test02(), makestatetest::test03(), and makestatetest::test05().
Standard C++ header names.
Definition at line 30 of file makestate.h.
Referenced by makestate< CFC >::eval(), makestate< CFC >::isinprocesschain(), makestate< CFC >::makestate(), makestate< CFC >::print(), makestate< CFC >::standardbuild(), and makestatetest::test01().
Unknown files that are not standard and not under proj directory.
Definition at line 32 of file makestate.h.
Referenced by makestate< CFC >::eval(), makestate< CFC >::isinprocesschain(), makestate< CFC >::makestate(), makestate< CFC >::objseval(), and makestate< CFC >::print().
1.5.8