diff options
author | Mike Buland <mbuland@penny-arcade.com> | 2018-12-10 06:57:07 -0800 |
---|---|---|
committer | Mike Buland <mbuland@penny-arcade.com> | 2018-12-10 06:57:07 -0800 |
commit | b8184b41882a9670447f0d99b35a48d24c091b25 (patch) | |
tree | 70bc20ae89be4737e4cd67c5921c0e1a21cec67b /autoconfig.cpp | |
parent | fcfa8b28157a95a4cde6e656af6c6ce79cf548f0 (diff) | |
download | libbu++-b8184b41882a9670447f0d99b35a48d24c091b25.tar.gz libbu++-b8184b41882a9670447f0d99b35a48d24c091b25.tar.bz2 libbu++-b8184b41882a9670447f0d99b35a48d24c091b25.tar.xz libbu++-b8184b41882a9670447f0d99b35a48d24c091b25.zip |
Made versioning nicer.
Diffstat (limited to '')
-rw-r--r-- | autoconfig.cpp | 21 |
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 | } |