From b8184b41882a9670447f0d99b35a48d24c091b25 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 10 Dec 2018 06:57:07 -0800 Subject: Made versioning nicer. --- .gitignore | 2 ++ autoconfig.cpp | 21 +++++++++++++-------- default.bld | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 45013c8..c6cd97f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,11 +5,13 @@ /bin2cpp.exe /mkunit.exe /myriad.exe +/jsontool.exe /autoconfig /bin2cpp /mkunit /myriad /viewcsv +/jsontool .*.swp .*.un~ /src/autoconfig.h 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[] ) buf[j] = '\0'; fclose( fVer ); + char *end; + int32_t iVer = strtol( buf, &end, 10 ); + for(; (*end < '1' || *end > '9') && *end; end++ ) { } + int32_t iRev = strtol( end, NULL, 10 ); + fOut = fopen( argv[1], "w" ); fprintf( fOut, "#ifndef BU_VERSION_H\n" "#define BU_VERSION_H\n\n" - "#define LIBBU_VERSION 0\n" - "#define LIBBU_REVISION 1\n" + "#define LIBBU_VERSION %d\n" + "#define LIBBU_REVISION %d\n" "#define LIBBU_VERSION_STR \"%s\"\n" "#define LIBBU_API 0\n" "#define LIBBU_VC_ID \"", + iVer, iRev, buf ); - char buf2[1024]; FILE *psub = popen("git describe --always", "r"); - buf2[fread( buf2, 1, 1024, psub )] = '\0'; - for( int j = 0; buf2[j]; j++ ) - if( buf2[j] == '\n' ) - buf2[j] = '\0'; - fwrite( buf2, strlen(buf2), 1, fOut ); + buf[fread( buf, 1, 1024, psub )] = '\0'; + for( int j = 0; buf[j]; j++ ) + if( buf[j] == '\n' ) + buf[j] = '\0'; + fwrite( buf, strlen(buf), 1, fOut ); pclose( psub ); fprintf( fOut, "\"\n\n#endif\n"); } diff --git a/default.bld b/default.bld index 68bd049..e140bee 100644 --- a/default.bld +++ b/default.bld @@ -61,7 +61,7 @@ target ["src/autoconfig.h", "src/version.h"] target "src/version.h" { - input ".git"; + input [".git", "version"]; } target "src/signals.h" -- cgit v1.2.3