Files Classes Functions Hierarchy
00001 00002 #include <commandline.h> 00003 #include <mkerrors.h> 00004 #include <mkerrorsconfig.h> 00005 #include <mkerrorsstate.h> 00006 #include <stringconvert.h> 00007 #include <stringserialization.h> 00008 #include <stringspace.h> 00009 #include <systemcalls.h> 00010 00011 string mkerrorscompile::fileout_txt="projcompile.txt"; 00012 00013 int mkerrorscompile::compilecode 00014 ( 00015 mkerrorscompiletag const & ct, 00016 stringc& tempfile 00017 ) 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 } 00045 00046 int mkerrorscompile::eval2(int argc, char** argv) 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 } 00094 00095 00096 int mkerrorscompile::eval(int argc, char** argv) 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 } 00152 00153 stringc mkerrorscompile::xml() const 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 } 00164 00165 mkerrorscompile::mkerrorscompile() 00166 : exitstatus(1) 00167 { 00168 } 00169 00170 mkerrorscompiletag::mkerrorscompiletag() 00171 { 00172 } 00173 00174 mkerrorscompiletag::mkerrorscompiletag 00175 ( 00176 stringc& id_, 00177 stringc& command_, 00178 stringc& libraries_ 00179 ) 00180 : id(id_), command(command_), libraries(libraries_) 00181 { 00182 } 00183 00184 stringc mkerrorscompiletag::xml() const 00185 { 00186 string s1; 00187 s1 += stringtag(id,"id"); 00188 s1 += stringtag(command,"command"); 00189 s1 += stringtag(libraries,"libraries"); 00190 s1 = stringtag(s1,"compiletag"); 00191 00192 return s1; 00193 } 00194
1.5.8