aboutsummaryrefslogtreecommitdiff
path: root/autoconfig.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'autoconfig.cpp')
-rw-r--r--autoconfig.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/autoconfig.cpp b/autoconfig.cpp
index 244fedf..96f0eab 100644
--- a/autoconfig.cpp
+++ b/autoconfig.cpp
@@ -126,25 +126,30 @@ int main( int argc, char *argv[] )
126 buf[j] = '\0'; 126 buf[j] = '\0';
127 fclose( fVer ); 127 fclose( fVer );
128 128
129 char *end;
130 int32_t iVer = strtol( buf, &end, 10 );
131 for(; (*end < '1' || *end > '9') && *end; end++ ) { }
132 int32_t iRev = strtol( end, NULL, 10 );
133
129 fOut = fopen( argv[1], "w" ); 134 fOut = fopen( argv[1], "w" );
130 fprintf( fOut, 135 fprintf( fOut,
131 "#ifndef BU_VERSION_H\n" 136 "#ifndef BU_VERSION_H\n"
132 "#define BU_VERSION_H\n\n" 137 "#define BU_VERSION_H\n\n"
133 "#define LIBBU_VERSION 0\n" 138 "#define LIBBU_VERSION %d\n"
134 "#define LIBBU_REVISION 1\n" 139 "#define LIBBU_REVISION %d\n"
135 "#define LIBBU_VERSION_STR \"%s\"\n" 140 "#define LIBBU_VERSION_STR \"%s\"\n"
136 "#define LIBBU_API 0\n" 141 "#define LIBBU_API 0\n"
137 "#define LIBBU_VC_ID \"", 142 "#define LIBBU_VC_ID \"",
143 iVer, iRev,
138 buf 144 buf
139 ); 145 );
140 146
141 char buf2[1024];
142 FILE *psub = popen("git describe --always", "r"); 147 FILE *psub = popen("git describe --always", "r");
143 buf2[fread( buf2, 1, 1024, psub )] = '\0'; 148 buf[fread( buf, 1, 1024, psub )] = '\0';
144 for( int j = 0; buf2[j]; j++ ) 149 for( int j = 0; buf[j]; j++ )
145 if( buf2[j] == '\n' ) 150 if( buf[j] == '\n' )
146 buf2[j] = '\0'; 151 buf[j] = '\0';
147 fwrite( buf2, strlen(buf2), 1, fOut ); 152 fwrite( buf, strlen(buf), 1, fOut );
148 pclose( psub ); 153 pclose( psub );
149 fprintf( fOut, "\"\n\n#endif\n"); 154 fprintf( fOut, "\"\n\n#endif\n");
150 } 155 }