Skip to content

Commit 6851b27

Browse files
committed
include git commit description in fedex_plus version output
1 parent 219957d commit 6851b27

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,19 @@ CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
200200

201201
CHECK_TYPE_SIZE("ssize_t" SSIZE_T)
202202

203-
203+
#set GIT_COMMIT_ID to the output of `git describe`
204+
find_package(Git)
205+
if(GIT_FOUND)
206+
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags RESULT_VARIABLE res_var OUTPUT_VARIABLE GIT_COM_ID )
207+
if( NOT ${res_var} EQUAL 0 )
208+
set( GIT_COMMIT_ID "unknown (git failed!)")
209+
message( WARNING "Git failed (not a repo?). Build will not contain git revision info." )
210+
endif()
211+
string( REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COM_ID} )
212+
else()
213+
set( GIT_COMMIT_ID "unknown (git not found!)")
214+
message( WARNING "Git not found. Build will not contain git revision info." )
215+
endif()
204216

205217
# Now that all the tests are done, configure the scl_cf.h file:
206218
configure_file(${SCL_BINARY_DIR}/include/scl_cf.h.in ${SCL_BINARY_DIR}/include/scl_cf.h)

include/scl_cf_cmake.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
#cmakedefine HAVE_MEMCPY 1
99
#cmakedefine HAVE_MEMMOVE 1
1010
#cmakedefine HAVE_SSIZE_T 1
11+
12+
//cmake updates this at build time
13+
#define SCL_COMMIT_ID "@GIT_COMMIT_ID@"

src/express/fedex.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@
7171
*
7272
*/
7373

74-
char * FEDEXversion( void ) {
75-
return( "V2.11.4-beta CADDETC preval June 8, 1995" );
76-
}
77-
74+
#include "scl_cf.h"
7875
#include <stdlib.h>
7976
#include <stdio.h>
8077
#include <unistd.h>
@@ -91,11 +88,17 @@ extern int yydbg_verbose;
9188

9289
extern int skip_exp_pause;
9390
char EXPRESSgetopt_options[256] = "Bbd:e:i:w:p:u:l:nrvz";
91+
int no_need_to_work = 0; /* TRUE if we can exit gracefully without doing any work */
92+
93+
void print_fedex_version( void ) {
94+
printf( "%s\nSCL version id (from git): %s\nhttp://github.com/mpictor/StepClassLibrary\n", EXPRESSprogram_name, SCL_COMMIT_ID );
95+
no_need_to_work = 1;
96+
}
9497

95-
static void
96-
usage() {
98+
static void usage() {
9799
fprintf( stderr, "usage: %s [-v] [-d # | -d 9 [-l nnn | -u nnn]] [-n] [-p <object_type>] {-w|-i <warning>} express_file\n", EXPRESSprogram_name );
98-
fprintf( stderr, "where\t-v produces a version description\n" );
100+
fprintf( stderr, "where\t-v produces the following version description:\n" );
101+
print_fedex_version();
99102
fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" );
100103
fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" );
101104
fprintf( stderr, "\t-n do not pause for internal errors (useful with delta script)\n" );
@@ -124,8 +127,6 @@ int main( int argc, char ** argv ) {
124127
char * cp;
125128
int no_warnings = 1;
126129
int resolve = 1;
127-
int no_need_to_work = 0;/* TRUE if we can exit gracefully without */
128-
/* doing any work */
129130

130131
bool buffer_messages = false;
131132
char * filename = 0;
@@ -231,8 +232,7 @@ int main( int argc, char ** argv ) {
231232
}
232233
break;
233234
case 'v':
234-
printf( "%s %s\n%s\n", EXPRESSprogram_name, FEDEXversion(), EXPRESSversion() );
235-
no_need_to_work = 1;
235+
print_fedex_version();
236236
break;
237237
case 'z': /* to allow user to attach debugger and continue */
238238
printf( "pid = %d\n", getpid() );

src/fedex_plus/fedex_main.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,15 @@
7777
#include "../express/express.h"
7878
#include "../express/resolve.h"
7979

80-
static void
81-
fedex_plus_usage() {
80+
extern void print_fedex_version( void );
81+
82+
static void fedex_plus_usage() {
8283
fprintf( stderr, "usage: %s [-s|-S] [-a|-A] [-c|-C] [-L] [-v] [-d # | -d 9 -l nnn -u nnn] [-n] [-p <object_type>] {-w|-i <warning>} express_file\n", EXPRESSprogram_name );
8384
fprintf( stderr, "where\t-s or -S uses only single inheritance in the generated C++ classes\n" );
8485
fprintf( stderr, "\t-a or -A generates the early bound access functions for entity classes the old way (without an underscore)\n" );
8586
fprintf( stderr, "\t-c or -C generates C++ classes for use with CORBA (Orbix)\n" );
8687
fprintf( stderr, "\t-L prints logging code in the generated C++ classes\n" );
87-
fprintf( stderr, "\t-v produces a version description\n" );
88+
fprintf( stderr, "\t-v produces the version description below\n" );
8889
fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" );
8990
fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" );
9091
fprintf( stderr, "\t-n do not pause for internal errors (useful with delta script)\n" );
@@ -104,6 +105,7 @@ fedex_plus_usage() {
104105
fprintf( stderr, " s schema or file\n" );
105106
fprintf( stderr, " # pass #\n" );
106107
fprintf( stderr, " E everything (all of the above)\n" );
108+
print_fedex_version();
107109
exit( 2 );
108110
}
109111

@@ -121,8 +123,7 @@ int success( Express model ) {
121123

122124
/* This function is called from main() which is part of the NIST Express
123125
Toolkit. It assigns 2 pointers to functions which are called in main() */
124-
void
125-
EXPRESSinit_init() {
126+
void EXPRESSinit_init() {
126127
EXPRESSbackend = print_file;
127128
EXPRESSsucceed = success;
128129
EXPRESSgetopt = Handle_FedPlus_Args;

0 commit comments

Comments
 (0)