#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fstream>
#include <ctime>
Go to the source code of this file.
|
int | main (int argc, char *argv[]) |
|
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 8 of file generateVersionAndContext.cc.
12 std::cerr <<
" usage: generateVersionAndContext <cmake source directory> " <<
std::endl;
19 char *g4lbneDirChr =
getenv(
"G4LBNE_DIR");
20 if (g4lbneDirChr == 0) {
21 std::cerr <<
" Environment variable G4LBNE_DIR not set.... " <<
std::endl;
27 if (cMakeDirectoryStr != g4lbneDirStr) {
28 std::cerr <<
" Possible confusion on where the source was installed, CMake src " <<
29 cMakeDirectoryStr <<
" env. var. from setup " << g4lbneDirStr <<
std::endl;
32 fp = popen(
"git describe --all",
"r");
34 std::cerr <<
"Failed to run the git command" <<
std::endl;
37 fgets(gitRes,
sizeof(gitRes)-1, fp);
40 gitResStr = gitResStr.substr(0, gitResStr.length()-1);
41 std::cerr <<
" git version.. " << gitResStr <<
std::endl;
43 std::ofstream fOutCC(
"./VersionAndContext.cc");
44 fOutCC <<
"#include <iostream>" <<
std::endl;
45 fOutCC <<
"#include <stdlib.h>" <<
std::endl;
46 fOutCC <<
"#include <stdio.h>" <<
std::endl;
47 fOutCC <<
"#include <unistd.h>" <<
std::endl;
48 fOutCC <<
"#include <fstream>" << std::endl <<
std::endl;
49 fOutCC <<
"#include \"VersionAndContext.hh\" " << std::endl <<
std::endl;
50 fOutCC <<
"VersionAndContext::VersionAndContext():" <<
std::endl;
51 fOutCC <<
" gitDescription(\""<< gitResStr <<
"\")," <<
std::endl;
52 fOutCC <<
" g4lbnfDir(\""<< g4lbneDirStr <<
"\")," <<
std::endl;
54 struct tm *
now = localtime( & t );
58 strftime(bufTime,
sizeof(bufTime),
"%Y-%m-%d.%X", now);
59 fOutCC <<
" buildTimeStamp(\"" <<
std::string(bufTime)
62 fOutCC <<
" { ; } " << std::endl <<
std::endl;
63 fOutCC <<
"VersionAndContext* VersionAndContext::fInstance = 0; " << std::endl <<
std::endl;
64 fOutCC <<
"VersionAndContext* VersionAndContext::Instance() { " <<
std::endl;
65 fOutCC <<
" if (fInstance == 0) fInstance = new VersionAndContext(); " <<
std::endl;
66 fOutCC <<
" return fInstance; } " <<
std::endl;
std::string getenv(std::string const &name)
QTextStream & endl(QTextStream &s)