Skip to content

Commit 4fe5eec

Browse files
committed
use static char[] for version, better comments in sc_version_string.cmake
1 parent cac6c3f commit 4fe5eec

File tree

6 files changed

+23
-20
lines changed

6 files changed

+23
-20
lines changed

cmake/sc_version_string.cmake

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
#use git for a pretty commit id
2-
#uses 'git describe --tags', so tags are required in the repo
3-
#create a tag with 'git tag <name>' and 'git push --tags'
1+
# creates sc_version_string.h, which defines sc_version()
2+
# sc_version() returns a pretty commit description and a build timestamp.
43

54
# http://stackoverflow.com/questions/3780667
65
# http://www.cmake.org/pipermail/cmake/2009-February/027014.html
76

8-
#sc_version_string.h defines sc_version() which returns a pretty commit description and a build timestamp.
97

108
set(SC_IS_SUBBUILD "@SC_IS_SUBBUILD@")
119

12-
#---------- find version ------------------
10+
#---------- find commit id ------------------
11+
#use git for a pretty commit id
12+
#uses 'git describe --tags', so tags are required in the repo
13+
#create a tag with 'git tag <name>' and 'git push --tags'
14+
#if git can't be found, uses contents of SC_VERSION.txt
15+
1316
set(VERS_FILE ${SOURCE_DIR}/SC_VERSION.txt )
1417
if( EXISTS ${SOURCE_DIR}/.git )
1518
find_package(Git QUIET)
@@ -36,8 +39,8 @@ else()
3639
endif()
3740
string( REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID} )
3841

39-
#-------------- Date and time ---------------
40-
#cmake 2.8.11 and up only
42+
#-------------- date and time ---------------
43+
#once cmake_minimum_required is >= 2.8.11, we can use TIMESTAMP:
4144
#string( TIMESTAMP date_time_string )
4245

4346
if( UNIX )
@@ -56,13 +59,14 @@ endif()
5659
set( header_string "/* sc_version_string.h - written by cmake. Changes will be lost! */\n"
5760
"#ifndef SC_VERSION_STRING\n"
5861
"#define SC_VERSION_STRING\n\n"
59-
"/*\n** Returns a string like \"test-1-g5e1fb47, build timestamp <timestamp>\", where test is the\n"
62+
"/*\n** The git commit id looks like \"test-1-g5e1fb47\", where test is the\n"
6063
"** name of the last tagged git revision, 1 is the number of commits since that tag,\n"
61-
"** 'g' is unknown, 5e1fb47 is the first 7 chars of the git sha1 commit id, and <timestamp>\n"
62-
"** is a string on known platforms and preprocessor macros elsewhere.\n*/\n\n"
63-
"const char* sc_version() {\n"
64-
" return \"git commit id ${GIT_COMMIT_ID}, build timestamp ${date_time_string}\"\;\n"
65-
"}\n\n"
64+
"** 'g' is unknown, and 5e1fb47 is the first 7 chars of the git sha1 commit id.\n"
65+
"** timestamp is created from date/time commands on known platforms, and uses\n"
66+
"** preprocessor macros elsewhere.\n*/\n\n"
67+
"static char sc_version[512] = {\n"
68+
" \"git commit id: ${GIT_COMMIT_ID}, build timestamp ${date_time_string}\"\n"
69+
"}\;\n\n"
6670
"#endif\n"
6771
)
6872

src/exp2cxx/classes_misc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "classes.h"
55

66
#include <sc_trace_fprintf.h>
7+
#include "sc_version_string.h"
78

89
/*******************************************************************
910
** FedEx parser output module for generating C++ class definitions
@@ -22,8 +23,6 @@ for the STEP Standard Data Access Interface as defined in document
2223
N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7.
2324
*******************************************************************/
2425

25-
extern char * sc_version();
26-
2726
extern int multiple_inheritance;
2827

2928
/******************************************************************
@@ -132,7 +131,7 @@ FILE * FILEcreate( const char * filename ) {
132131
fprintf( file, "#ifndef %s\n", fn );
133132
fprintf( file, "#define %s\n\n", fn );
134133

135-
fprintf( file, "// This file was generated by exp2cxx,\n// %s.\n", sc_version() );
134+
fprintf( file, "// This file was generated by exp2cxx,\n// %s.\n", sc_version );
136135
fprintf( file, "// You probably don't want to edit it since your modifications\n" );
137136
fprintf( file, "// will be lost if exp2cxx is used to regenerate it.\n" );
138137
return ( file );

src/exppp/exppp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ char * SCHEMAout( Schema s ) {
312312
for( hp = expheader; *hp; hp++ ) {
313313
if( ( **hp == '\0' ) && ( **(hp + 1) == '\0' ) ) {
314314
/* if this and the next lines are blank, put version string on this line */
315-
raw( "%s\n", sc_version() );
315+
raw( "%s\n", sc_version );
316316
} else {
317317
raw( "%s\n", *hp );
318318
}

src/express/express.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ char * EXPRESSversion( void ) {
255255
void EXPRESSusage( int _exit ) {
256256
fprintf( stderr, "usage: %s [-v] [-d #] [-p <object_type>] {-w|-i <warning>} express_file\n", EXPRESSprogram_name );
257257
fprintf( stderr, "where\t-v produces the following version description:\n" );
258-
fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, sc_version() );
258+
fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, sc_version );
259259
fprintf( stderr, "\t-d turns on debugging (\"-d 0\" describes this further\n" );
260260
fprintf( stderr, "\t-p turns on printing when processing certain objects (see below)\n" );
261261
fprintf( stderr, "\t-w warning enable\n" );

src/express/fedex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ char EXPRESSgetopt_options[256] = "Bbd:e:i:w:p:rvz"; /* larger than the string b
9090
static int no_need_to_work = 0; /* TRUE if we can exit gracefully without doing any work */
9191

9292
void print_fedex_version( void ) {
93-
fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, sc_version() );
93+
fprintf( stderr, "Build info for %s: %s\nhttp://github.com/stepcode/stepcode\n", EXPRESSprogram_name, sc_version );
9494
no_need_to_work = 1;
9595
}
9696

src/test/p21read/p21read.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void checkSchemaName( Registry & reg, STEPfile & sf, bool ignoreErr ) {
9191
}
9292

9393
void printVersion( const char * exe ) {
94-
std::cout << exe << " build info: " << sc_version() << std::endl;
94+
std::cout << exe << " build info: " << sc_version << std::endl;
9595
}
9696

9797
void printUse( const char * exe ) {

0 commit comments

Comments
 (0)