From 605004e69da64b8e0d2db369a8b6809edbc08b7e Mon Sep 17 00:00:00 2001 From: Max Hunter Date: Tue, 9 Dec 2014 22:22:31 +0000 Subject: [PATCH 1/3] Print tag/short commit hash to screen and logfile. Fixes #23 --- klustakwik.cpp | 1 + makefile | 3 +++ 2 files changed, 4 insertions(+) diff --git a/klustakwik.cpp b/klustakwik.cpp index 9565119..3ad81fe 100644 --- a/klustakwik.cpp +++ b/klustakwik.cpp @@ -1814,6 +1814,7 @@ int main(int argc, char **argv) scalar BestScore = HugeScore; integer p, i; SetupParams((integer)argc, argv); // This function is defined in parameters.cpp + Output("Starting KlustaKwik. Version: %s\n", VERSION); if (RamLimitGB == 0.0) { RamLimitGB = (1.0*available_physical_memory()) / (1024.0*1024.0*1024.0); diff --git a/makefile b/makefile index 5612dc4..b0d799c 100644 --- a/makefile +++ b/makefile @@ -15,6 +15,9 @@ endif CFLAGS = -Wall -c -Wno-write-strings $(OPTIMISATIONS) $(OPENMPFLAG) LFLAGS = -Wall $(OPENMPFLAG) +GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags) +CFLAGS = -Wall -c -Wno-write-strings $(OPTIMISATIONS) -DVERSION=\"$(GIT_VERSION)\" +LFLAGS = -Wall all: executable From 3c57da49375764202605a8c2a060a11235da1df6 Mon Sep 17 00:00:00 2001 From: Max Hunter Date: Thu, 8 Jan 2015 12:23:54 +0000 Subject: [PATCH 2/3] Cleaner version string fallback for users with no git --- makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index b0d799c..bdae1eb 100644 --- a/makefile +++ b/makefile @@ -15,7 +15,8 @@ endif CFLAGS = -Wall -c -Wno-write-strings $(OPTIMISATIONS) $(OPENMPFLAG) LFLAGS = -Wall $(OPENMPFLAG) -GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags) +FALLBACK_VERSION = "0.3.0-no-git" +GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags || echo "$(FALLBACK_VERSION)") CFLAGS = -Wall -c -Wno-write-strings $(OPTIMISATIONS) -DVERSION=\"$(GIT_VERSION)\" LFLAGS = -Wall From 8190dcc70206f50c5d85a59a86274fa6a759884a Mon Sep 17 00:00:00 2001 From: Max Hunter Date: Tue, 13 Jan 2015 18:13:21 +0000 Subject: [PATCH 3/3] Added version ifndef fallback in klustakwik.cpp to deal with makefile-ignoring compilers --- klustakwik.cpp | 4 ++++ makefile | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/klustakwik.cpp b/klustakwik.cpp index 3ad81fe..3faa4d9 100644 --- a/klustakwik.cpp +++ b/klustakwik.cpp @@ -2,6 +2,10 @@ // // Fast clustering using the CEM algorithm with Masks. +#ifndef VERSION +#define VERSION "0.3.0-nogit" +#endif + // Disable some Visual Studio warnings #define _CRT_SECURE_NO_WARNINGS diff --git a/makefile b/makefile index bdae1eb..3d4bdba 100644 --- a/makefile +++ b/makefile @@ -6,6 +6,7 @@ CC = g++ DEBUG = -g PROFILE = -pg OPTIMISATIONS = -O3 -ffast-math -march=native +GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags) ifdef NOOPENMP OPENMPFLAG = @@ -13,12 +14,14 @@ else OPENMPFLAG = -fopenmp endif +# If the git command failed, GIT_VERSION will be empty, so don't pass a DVERSION flag (fallback) +ifeq ($(strip $(GIT_VERSION)),) CFLAGS = -Wall -c -Wno-write-strings $(OPTIMISATIONS) $(OPENMPFLAG) +else +CFLAGS = -Wall -c -Wno-write-strings $(OPTIMISATIONS) $(OPENMPFLAG) -DVERSION=\"$(GIT_VERSION)\" +endif + LFLAGS = -Wall $(OPENMPFLAG) -FALLBACK_VERSION = "0.3.0-no-git" -GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags || echo "$(FALLBACK_VERSION)") -CFLAGS = -Wall -c -Wno-write-strings $(OPTIMISATIONS) -DVERSION=\"$(GIT_VERSION)\" -LFLAGS = -Wall all: executable