possible to use binary --version or -v to get the branch and versionid

This commit is contained in:
Dhanya Maliakal 2017-12-06 19:05:35 +01:00
parent c4a242e10a
commit bf9905ad2a
10 changed files with 130 additions and 105 deletions

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorGui Path: slsDetectorsPackage/slsDetectorGui
URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
Repsitory UUID: b498043ea612fa3148bf1d7ea2a39c46092addf8 Repsitory UUID: c4a242e10a4aafd102cc9a2a7ddae4ac92b8ba99
Revision: 437 Revision: 439
Branch: 3.0.1 Branch: 3.0.1
Last Changed Author: Dhanya_Maliakal Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 3185 Last Changed Rev: 3187
Last Changed Date: 2017-12-06 08:43:21.000000002 +0100 ./src/qTabSettings.cpp Last Changed Date: 2017-12-06 08:45:14.000000002 +0100 ./src/qTabSettings.cpp

View File

@ -1,6 +1,6 @@
#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git" #define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git"
#define GITREPUUID "b498043ea612fa3148bf1d7ea2a39c46092addf8" #define GITREPUUID "c4a242e10a4aafd102cc9a2a7ddae4ac92b8ba99"
#define GITAUTH "Dhanya_Maliakal" #define GITAUTH "Dhanya_Maliakal"
#define GITREV 0x3185 #define GITREV 0x3187
#define GITDATE 0x20171206 #define GITDATE 0x20171206
#define GITBRANCH "blabla" #define GITBRANCH "3.0.1"

View File

@ -55,10 +55,11 @@ public:
* This is mainly used to create detector object and all the tabs * This is mainly used to create detector object and all the tabs
* @param argc number of command line arguments for server options * @param argc number of command line arguments for server options
* @param argv server options * @param argv server options
* @param app the qapplication * @param app the qapplication3
* @param ret OK or FAIL of constructor (from command line arguments)
* @param parent makes the parent window 0 by default * @param parent makes the parent window 0 by default
* */ * */
qDetectorMain(int argc, char **argv, QApplication *app, QWidget *parent = 0); qDetectorMain(int argc, char **argv, QApplication *app, int& ret, QWidget *parent = 0);
/**Destructor /**Destructor
* */ * */

View File

@ -36,7 +36,10 @@ int main (int argc, char **argv) {
// QApplication *theApp = new QApplication(argc, argv); // QApplication *theApp = new QApplication(argc, argv);
theApp->setStyle(new QPlastiqueStyle);//not default when desktop is windows theApp->setStyle(new QPlastiqueStyle);//not default when desktop is windows
theApp->setWindowIcon(QIcon( ":/icons/images/mountain.png" )); theApp->setWindowIcon(QIcon( ":/icons/images/mountain.png" ));
qDetectorMain *det=new qDetectorMain(argc, argv, theApp,0); int ret = 1;
qDetectorMain *det=new qDetectorMain(argc, argv, theApp,ret,0);
if (ret == 1)
return EXIT_FAILURE;
det->show(); det->show();
//theApp->connect( theApp, SIGNAL(lastWindowClosed()), theApp, SLOT(quit())); //theApp->connect( theApp, SIGNAL(lastWindowClosed()), theApp, SLOT(quit()));
return theApp->exec(); return theApp->exec();
@ -46,75 +49,82 @@ int main (int argc, char **argv) {
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget *parent) : qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, int& ret, QWidget *parent) :
QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(0),tabs(0),isDeveloper(0){ QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(0),tabs(0),isDeveloper(0){
// bool found;
int c; // options
string configFName = ""; string fname = "";
optind=1; int64_t tempval = 0;
// Getting all the command line arguments
while(1) { //parse command line for config
static struct option long_options[] = { static struct option long_options[] = {
// These options set a flag.
//{"verbose", no_argument, &verbose_flag, 1},
// These options dont set a flag. We distinguish them by their indices.
{ "developer", no_argument, 0, 'd' }, { "developer", no_argument, 0, 'd' },
{ "config", required_argument, 0, 'f' }, { "config", required_argument, 0, 'f' },
{ "id", required_argument, 0, 'i' }, { "id", required_argument, 0, 'i' },
{ "f", required_argument, 0, 'f' }, {"version", no_argument, 0, 'v'},
{ "help", no_argument, 0, 'h' }, { "help", no_argument, 0, 'h' },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
c = getopt_long (argc, argv, "hdf:i:", long_options, NULL);
if (c == -1) break;
// getopt_long stores the option index here.
int option_index = 0;
int c = 0;
while ( c != -1 ){
c = getopt_long (argc, argv, "hvdf:i:", long_options, &option_index);
// Detect the end of the options.
if (c == -1)
break;
switch(c){ switch(c){
case 'f':
fname=string(optarg);
#ifdef VERYVERBOSE
cout << long_options[option_index].name << " " << optarg << endl;
#endif
break;
case 'd' : case 'd' :
isDeveloper = 1; isDeveloper = 1;
break; break;
case 'f' :
configFName=string(optarg);
break;
case 'i' : case 'i' :
detID=atoi(optarg); detID=atoi(optarg);
break; break;
case 'v':
tempval = GITREV;
tempval = (tempval <<32) | GITDATE;
cout << "SLS Detector GUI " << GITBRANCH << " (0x" << hex << tempval << ")" << endl;
return;
case 'h': case 'h':
default: default:
cout << endl; string help_message = "\n"
cout << "\t" << argv[0] << " [ARGUMENT]..." << endl; + string(argv[0]) + "\n"
cout << endl; + "Usage: " + string(argv[0]) + " [arguments]\n"
cout << "Possible Arguments are:" << endl; + "Possible arguments are:\n"
cout << "\t-d, --developer \t\t : \t Enables the developer tab" << endl; + "\t-d, --developer : Enables the developer tab\n"
cout << "\t-f, --f, --config fname\t\t : \t Loads config file fname" << endl; + "\t-f, --f, --config <fname> : Loads config from file\n"
cout << "\t-i, --id NUMBER \t\t : \t Sets the multi detector id to NUMBER (the default is 0). " + "\t-i, --id <i> : Sets the multi detector id to i. Default: 0. Required \n"
"Required only when more than one multi detector object is needed." << endl; + "\t only when more than one multi detector object is needed.\n\n";
exit(-1); cout << help_message << endl;
return;
} }
} }
if (optind < argc) {
cout << "invalid option, try --help" << endl;
exit(-1);
}
/*
for(int iarg=1; iarg<argc; iarg++){
found = false;
if(!strcasecmp(argv[iarg],"--developer")) {isDeveloper=1;found = true;}
if((!strcasecmp(argv[iarg],"--id")) && (iarg+1 < argc)) {detID=atoi(argv[iarg+1]);iarg++;found = true;}
if((!strcasecmp(argv[iarg],"--config")) && (iarg+1 < argc)) {configFName=string(argv[iarg+1]);iarg++;found = true;}
if((!strcasecmp(argv[iarg],"--f")) && (iarg+1 < argc)) {configFName=string(argv[iarg+1]);iarg++;found = true;}
if(!found){
cout << "Possible Arguments are:" << endl;
cout << "--developer \t\t : \t Enables the developer tab" << endl;
cout << "--f [fname]\t\t : \t Loads config file fname" << endl;
cout << "--config [fname]\t : \t Loads config file fname" << endl;
cout << "--id [i] \t\t : \t Sets the multi detector id to i (the default is 0). "
"Required only when more than one multi detector object is needed." << endl;
exit(-1);
}
}
*/
setupUi(this); setupUi(this);
SetUpDetector(configFName); SetUpDetector(fname);
SetUpWidgetWindow(); SetUpWidgetWindow();
Initialization(); Initialization();
ret = 0;
} }

View File

@ -18,9 +18,9 @@ NEWDATE=${NEWDATE/#/0x}
#get old date from INCLFILE #get old date from INCLFILE
OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}') OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}')
#update INCLFILE if changes #update INCLFILE if changes
if [ "$OLDDATE" != "$NEWDATE" ]; then #if [ "$OLDDATE" != "$NEWDATE" ]; then
echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt
cd .. cd ..
./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE
cd $WD cd $WD
fi #fi

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware Path: slsDetectorsPackage/slsDetectorSoftware
URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git URL: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git Repository Root: origin git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git
Repsitory UUID: b498043ea612fa3148bf1d7ea2a39c46092addf8 Repsitory UUID: c4a242e10a4aafd102cc9a2a7ddae4ac92b8ba99
Revision: 1627 Revision: 1629
Branch: 3.0.1 Branch: 3.0.1
Last Changed Author: Dhanya_Maliakal Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 3185 Last Changed Rev: 3187
Last Changed Date: 2017-12-06 08:43:21.000000002 +0100 ./slsDetector/slsDetectorUtils.h Last Changed Date: 2017-12-06 19:00:50.000000002 +0100 ./threadFiles/ThreadPool.o

View File

@ -1,6 +1,6 @@
#define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git" #define GITURL "git@git.psi.ch:sls_detectors_software/slsDetectorPackage.git"
#define GITREPUUID "b498043ea612fa3148bf1d7ea2a39c46092addf8" #define GITREPUUID "c4a242e10a4aafd102cc9a2a7ddae4ac92b8ba99"
#define GITAUTH "Dhanya_Maliakal" #define GITAUTH "Dhanya_Maliakal"
#define GITREV 0x3185 #define GITREV 0x3187
#define GITDATE 0x20171206 #define GITDATE 0x20171206
#define GITBRANCH "blabla" #define GITBRANCH "3.0.1"

View File

@ -1,4 +1,5 @@
#include "multiSlsDetectorClient.h" #include "multiSlsDetectorClient.h"
#include "gitInfoLib.h"
#include <stdlib.h> #include <stdlib.h>
@ -7,6 +8,15 @@ using namespace std;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
for (int i = 1; i < argc; ++i ) {
if (!(strcmp (argv[i],"--version")) || !(strcmp (argv[i],"-v"))) {
int64_t tempval = GITREV;
tempval = (tempval <<32) | GITDATE;
cout << argv[0] << " " << GITBRANCH << " (0x" << hex << tempval << ")" << endl;
return 0;
}
}
#ifdef PUT #ifdef PUT
int action=slsDetectorDefs::PUT_ACTION; int action=slsDetectorDefs::PUT_ACTION;
#endif #endif

View File

@ -20,9 +20,9 @@ OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}')
#update INCLFILE if changes #update INCLFILE if changes
if [ "$OLDDATE" != "$NEWDATE" ]; then #if [ "$OLDDATE" != "$NEWDATE" ]; then
echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt
cd .. cd ..
./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE
cd $WD cd $WD
fi #fi

View File

@ -28,6 +28,7 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success):
map<string, string> configuration_map; map<string, string> configuration_map;
int tcpip_port_no = 1954; int tcpip_port_no = 1954;
string fname = ""; string fname = "";
int64_t tempval = 0;
//parse command line for config //parse command line for config
static struct option long_options[] = { static struct option long_options[] = {
@ -40,12 +41,11 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success):
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
// getopt_long stores the option index here. // getopt_long stores the option index here.
int option_index = 0; int option_index = 0;
int c = 0; int c = 0;
optind = 1;
int64_t tempval = 0;
while ( c != -1 ){ while ( c != -1 ){
c = getopt_long (argc, argv, "hvf:t:", long_options, &option_index); c = getopt_long (argc, argv, "hvf:t:", long_options, &option_index);
@ -63,6 +63,10 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success):
#endif #endif
break; break;
case 't':
sscanf(optarg, "%d", &tcpip_port_no);
break;
case 'v': case 'v':
tempval = GITREV; tempval = GITREV;
tempval = (tempval <<32) | GITDATE; tempval = (tempval <<32) | GITDATE;
@ -70,16 +74,16 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success):
success = FAIL; // to exit success = FAIL; // to exit
break; break;
case 't':
sscanf(optarg, "%d", &tcpip_port_no);
break;
case 'h': case 'h':
string help_message = "\nSLS Receiver Server\n\n"; default:
help_message += "Usage: slsReceiver [arguments]\nPossible arguments are:\n"; string help_message = "\n"
help_message += "\t-f, --config: Configuration filename\n"; + string(argv[0]) + "\n"
help_message += "\t-t, --rx_tcpport: TCP Port with the client. Default: 1954.\n" + "Usage: " + string(argv[0]) + " [arguments]\n"
"\t Required for multiple receivers\n\n"; + "Possible arguments are:\n"
+ "\t-f, --config <fname> : Loads config from file\n"
+ "\t-t, --rx_tcpport <port> : TCP Communication Port with client. \n"
+ "\t Default: 1954. Required for multiple \n"
+ "\t receivers\n\n";
FILE_LOG(logINFO) << help_message << endl; FILE_LOG(logINFO) << help_message << endl;
break; break;