From 08b7ab1dd4d12c5fd5420a0e22e26d57bf684fe2 Mon Sep 17 00:00:00 2001 From: elbandi Date: Sun, 4 May 2014 01:29:28 +0200 Subject: [PATCH] Add build_number to version string --- Makefile.am | 4 ++++ api.c | 2 +- configure.ac | 7 +++++++ miner.h | 11 +++++++++++ sgminer.c | 9 ++------- util.c | 6 +++--- 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 95b8fd41..57bb2ad7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,6 +31,10 @@ GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty') sgminer_CPPFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" endif +if USE_BUILD_NUMBER +sgminer_CPPFLAGS += -DBUILD_NUMBER=\"$(BUILD_NUMBER)\" +endif + sgminer_SOURCES := sgminer.c sgminer_SOURCES += api.c sgminer_SOURCES += elist.h miner.h compat.h bench_block.h diff --git a/api.c b/api.c index 8a6a28c1..e2cb6965 100644 --- a/api.c +++ b/api.c @@ -1555,7 +1555,7 @@ static void apiversion(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m message(io_data, MSG_VERSION, 0, NULL, isjson); io_open = io_add(io_data, isjson ? COMSTR JSON_VERSION : _VERSION COMSTR); - root = api_add_string(root, "SGMiner", VERSION, false); + root = api_add_string(root, "SGMiner", CGMINER_VERSION, false); root = api_add_const(root, "API", APIVERSION, false); root = print_data(root, buf, isjson, false); diff --git a/configure.ac b/configure.ac index 2266045e..221e3652 100644 --- a/configure.ac +++ b/configure.ac @@ -219,6 +219,13 @@ AC_ARG_ENABLE([git-version], [Disable use of git version in version string even if available]), [wantgitver=$enableval], [wantgitver=yes]) +AC_ARG_WITH([build_number], + [AC_HELP_STRING([--with-build-number], [Specify a build number.])], + [BUILD_NUMBER="$withval"] + ) +AC_SUBST([BUILD_NUMBER]) +AM_CONDITIONAL([USE_BUILD_NUMBER], [test x$BUILD_NUMBER != x]) + curses="auto" AC_ARG_WITH([curses], diff --git a/miner.h b/miner.h index 6094e7f2..109714d3 100644 --- a/miner.h +++ b/miner.h @@ -3,6 +3,17 @@ #include "config.h" +#ifdef GIT_VERSION +#undef VERSION +#define VERSION GIT_VERSION +#endif + +#ifdef BUILD_NUMBER +#define CGMINER_VERSION VERSION "-" BUILD_NUMBER +#else +#define CGMINER_VERSION VERSION +#endif + #include "algorithm.h" #include diff --git a/sgminer.c b/sgminer.c index d187e7b9..50d9d4bf 100644 --- a/sgminer.c +++ b/sgminer.c @@ -65,11 +65,6 @@ char *curly = ":D"; #include #endif -#ifdef GIT_VERSION -#undef VERSION -#define VERSION GIT_VERSION -#endif - struct strategies strategies[] = { { "Failover" }, { "Round Robin" }, @@ -2271,7 +2266,7 @@ static void curses_print_status(void) unsigned short int line = 0; wattron(statuswin, A_BOLD); - cg_mvwprintw(statuswin, line, 0, PACKAGE " " VERSION " - Started: %s", datestamp); + cg_mvwprintw(statuswin, line, 0, PACKAGE " " CGMINER_VERSION " - Started: %s", datestamp); wattroff(statuswin, A_BOLD); mvwhline(statuswin, ++line, 0, '-', 80); @@ -8007,7 +8002,7 @@ int main(int argc, char *argv[]) /* We use the getq mutex as the staged lock */ stgd_lock = &getq->mutex; - snprintf(packagename, sizeof(packagename), "%s %s", PACKAGE, VERSION); + snprintf(packagename, sizeof(packagename), "%s %s", PACKAGE, CGMINER_VERSION); #ifndef WIN32 signal(SIGPIPE, SIG_IGN); diff --git a/util.c b/util.c index 8d78481c..a7d24107 100644 --- a/util.c +++ b/util.c @@ -1759,7 +1759,7 @@ static bool send_version(struct pool *pool, json_t *val) if (!id) return false; - sprintf(s, "{\"id\": %d, \"result\": \""PACKAGE"/"VERSION"\", \"error\": null}", id); + sprintf(s, "{\"id\": %d, \"result\": \""PACKAGE"/"CGMINER_VERSION"\", \"error\": null}", id); if (!stratum_send(pool, s, strlen(s))) return false; @@ -2443,9 +2443,9 @@ resend: sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": []}", swork_id++); } else { if (pool->sessionid) - sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"VERSION"\", \"%s\"]}", swork_id++, pool->sessionid); + sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"CGMINER_VERSION"\", \"%s\"]}", swork_id++, pool->sessionid); else - sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"VERSION"\"]}", swork_id++); + sprintf(s, "{\"id\": %d, \"method\": \"mining.subscribe\", \"params\": [\""PACKAGE"/"CGMINER_VERSION"\"]}", swork_id++); } if (__stratum_send(pool, s, strlen(s)) != SEND_OK) {