proj home

Files   Classes   Functions   Hierarchy  

mkerrorscompile Class Reference

Call make at the command line to compile project. More...

#include <mkerrors.h>

Collaboration diagram for mkerrorscompile:

List of all members.

Public Member Functions

 mkerrorscompile ()
 Non valid state.
int eval (int argc, char **argv)
 mkerrors: Call make with options.
int eval2 (int argc, char **argv)
 mkerrors: Implement with global configuration file.
stringc xml () const
 Write out the class as an xlm".
int compilecode (mkerrorscompiletag const &ct, stringc &tempfile)
 eval forwards make call here.

Public Attributes

int exitstatus
mkerrorscompiletag compiletag
string time
 gdb, gprof, debug(default) and release
string head
 First few lines of make call.

Static Public Attributes

static string fileout_txt = "projcompile.txt"
 Compilation results write to file as xml.


Detailed Description

Call make at the command line to compile project.

Associate executable file called "mkerrors" with eval(int argc, char** argv)

Example use 
$ mkerrors
$ mkerrors gdb
$ mkerrors gprof 
$ mkerrors release
$ mkerrors clean

Definition at line 55 of file mkerrors.h.


Constructor & Destructor Documentation

mkerrorscompile::mkerrorscompile (  ) 

Non valid state.

Definition at line 165 of file mkerrors.cpp.

00166   : exitstatus(1)
00167 {
00168 }


Member Function Documentation

int mkerrorscompile::compilecode ( mkerrorscompiletag const &  ct,
stringc tempfile 
)

eval forwards make call here.

Definition at line 14 of file mkerrors.cpp.

References systemcalls::combine, systemcalls::eval(), mkerrorscompiletag::id, systemcalls::output(), filestring::serializeInverse(), SHOW, and stringtrim().

Referenced by eval(), and eval2().

00018 {
00019   compiletag = ct;
00020   cout << "id=" << compiletag.id << endl;
00021   cout << "command=" << compiletag.command << endl;
00022   cout << "libraries=" << compiletag.libraries << endl;
00023 //    systemcalls("echo "+compile).eval();
00024   systemcalls sys(compiletag.command,tempfile);
00025   sys.combine=true;
00026 //cout << "message: compiling gdb" << endl;
00027   exitstatus=sys.eval();
00028   cout << SHOW(exitstatus) << endl;
00029 
00030   // Could have instead grabbed string and printed 
00031   //   it's first n lines.
00032   systemcalls sys2("head -n 15 " + tempfile);
00033   sys2.combine=true;
00034 //cout << "message: compiling gdb head" << endl;
00035   sys2.eval();
00036   head = sys2.output(); 
00037 //cout << "message: date" << endl;
00038   time = stringtrim( systemcallseval("echo `date +%Y`-`date +%m`-`date +%d`\\ `date +%k`:`date +%M`:`date +%S`").output() );
00039   cout << head << endl;
00040 
00041   filestring::serializeInverse(fileout_txt,xml());
00042 
00043   return exitstatus;
00044 }

int mkerrorscompile::eval ( int  argc,
char **  argv 
)

mkerrors: Call make with options.

Definition at line 96 of file mkerrors.cpp.

References compilecode(), systemcalls::eval(), exitstatus, commandline::hastoken(), and mkerrorsstate::libraries.

00097 {
00098   commandline cmd(argc,argv);
00099 
00100 //cout << "message: clearing" << endl; // should not see this
00101   flush(cout);
00102   system("clear");
00103 
00104   // Error is the default exits status.
00105   // Override to change this state.
00106   exitstatus=1; 
00107 
00108   mkerrorsstate mks;
00109   string lib(mks.libraries);
00110 
00111   if (cmd.hastoken("clean"))
00112   {
00113     //compile = "clean";
00114     systemcalls sys("make clean");
00115     sys.eval();
00116 
00117     return exitstatus;
00118   }
00119 
00120   if (cmd.hastoken("gdb"))
00121     return 
00122   compilecode
00123   ( 
00124   mkerrorscompiletag("gdb","make CC=\"g++ -g -Wall\"",lib),
00125   "/tmp/temp9382.txt"
00126   );
00127 
00128   if (cmd.hastoken("gprof"))
00129     return 
00130   compilecode
00131   ( 
00132   mkerrorscompiletag("gprof","make CC=\"g++ -pg -g -Wall\"",lib),
00133   "/tmp/temp9382.txt"
00134   );
00135 
00136   if (cmd.hastoken("release"))
00137     return 
00138   compilecode
00139   ( 
00140   mkerrorscompiletag("release","make CC=\"g++ -DNDEBUG -O3 -Wall\"",lib),
00141   "/tmp/temp9382.txt"
00142   );
00143 
00144   // Default
00145   return 
00146   compilecode
00147   ( 
00148   mkerrorscompiletag("debug","make",lib),
00149   "/tmp/temp9382.txt"
00150   );
00151 }

int mkerrorscompile::eval2 ( int  argc,
char **  argv 
)

mkerrors: Implement with global configuration file.

Definition at line 46 of file mkerrors.cpp.

References compilecode(), exitstatus, mkerrorsconfig::find(), commandline::hastoken(), mkerrorscompiletag::libraries, mkerrorsstate::libraries, mkerrorsconfig::read(), and mkerrorsconfig::vi.

00047 {
00048   commandline cmd(argc,argv);
00049 
00050 //cout << "message: clearing" << endl; // should not see this
00051   flush(cout);
00052   system("clear");
00053   flush(cout);
00054 
00055   // Error is the default exits status.
00056   // Override to change this state.
00057   exitstatus=1; 
00058 
00059   mkerrorsstate mks;
00060   string lib(mks.libraries);
00061 
00062   mkerrorsconfig mkc;
00063   mkc.read();
00064 
00065   mkerrorscompiletag ct;
00066 
00067   uintc imax=mkc.vi.size();
00068   for (uint i=0; i<imax; ++i)
00069   {
00070     if (cmd.hastoken(mkc.vi[i].id))
00071     {
00072       mkerrorscompiletag ct(mkc.vi[i]);
00073       // Has the local directory overridden the library linkage?
00074       if (lib.empty()==false)
00075         ct.libraries=lib;
00076       return compilecode(ct,"/tmp/temp9382.txt");
00077     }
00078   }
00079 
00080   // By default compile in debug mode.
00081   // If you do not want a default
00082   //   <compiletag><id>debug</id><command>false</command></compiletag> 
00083   // in mkerrorsconfig.txt file in proj directory.
00084   if (mkc.find(ct,"debug"))
00085   {
00086     if (lib.empty()==false)
00087       ct.libraries=lib;
00088 
00089     return compilecode(ct,"/tmp/temp9382.txt");
00090   }
00091 
00092   return 1;
00093 }

stringc mkerrorscompile::xml (  )  const

Write out the class as an xlm".

Definition at line 153 of file mkerrors.cpp.

References compiletag, exitstatus, head, stringtag(), time, and mkerrorscompiletag::xml().

00154 {
00155   string s1;
00156   s1 += stringtag(exitstatus,"exitstatus");
00157   s1 += compiletag.xml(); //stringtag(compile,"compile");
00158   s1 += stringtag(time,"time");
00159   s1 += stringtag(head,"head");
00160   s1 = stringtag(s1,"mkerrorscompile");
00161 
00162   return s1;
00163 }


Member Data Documentation

Definition at line 62 of file mkerrors.h.

Referenced by xml().

Definition at line 60 of file mkerrors.h.

Referenced by eval(), eval2(), and xml().

string mkerrorscompile::fileout_txt = "projcompile.txt" [static]

Compilation results write to file as xml.

Definition at line 91 of file mkerrors.h.

Referenced by modulereport::reset().

First few lines of make call.

Definition at line 70 of file mkerrors.h.

Referenced by xml().

gdb, gprof, debug(default) and release

Timestamp when eval called.

Definition at line 68 of file mkerrors.h.

Referenced by xml().


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:07 2011 for Chelton Evans Source by  doxygen 1.5.8