kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 8aaf7aaf797781f30f6154740729363c1bb36c4d
parent d5ca2b42c614cda5042a067a63c3a349217b381a
Author: Joris Vink <joris@coders.se>
Date:   Tue, 19 Jun 2018 19:05:55 +0200

Alter where the version number comes from.

Now if we are a git repo we fetch the branch name and
commitid to build the version string. If there is no
git repo we'll look at the RELEASE file.

Diffstat:
.gitignore | 1+
Makefile | 26++++++++++++++++++++++----
include/kore/kore.h | 6+-----
kodev/Makefile | 2+-
src/http.c | 3+--
src/kore.c | 3+--
6 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -9,3 +9,4 @@ obj .lvimrc kodev/kodev kore.features +src/version.c diff --git a/Makefile b/Makefile @@ -1,6 +1,6 @@ # Kore Makefile -CC?=gcc +CC?=cc PREFIX?=/usr/local OBJDIR?=obj KORE=kore @@ -10,10 +10,12 @@ MAN_DIR=$(PREFIX)/share/man SHARE_DIR=$(PREFIX)/share/kore INCLUDE_DIR=$(PREFIX)/include/kore +VERSION=src/version.c + S_SRC= src/kore.c src/buf.c src/config.c src/connection.c \ src/domain.c src/mem.c src/msg.c src/module.c src/net.c \ src/pool.c src/runtime.c src/timer.c src/utils.c src/worker.c \ - src/keymgr.c + src/keymgr.c $(VERSION) FEATURES= FEATURES_INC= @@ -114,7 +116,22 @@ endif S_OBJS= $(S_SRC:src/%.c=$(OBJDIR)/%.o) -all: $(KORE) $(KODEV) +all: $(VERSION) $(KORE) $(KODEV) + +$(VERSION): force + @if [ -d .git ]; then \ + GIT_REVISION=`git rev-parse --short=8 HEAD`; \ + GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`; \ + rm -f $(VERSION); \ + printf "const char *kore_version = \"%s-%s\";\n" \ + $$GIT_BRANCH $$GIT_REVISION > $(VERSION); \ + elif [ -f RELEASE ]; then \ + printf "const char *kore_version = \"%s\";\n" \ + `cat RELEASE` > $(VERSION); \ + else \ + echo "No version information found (no .git or RELEASE)"; \ + exit 1; \ + fi $(KODEV): $(MAKE) -C kodev @@ -151,8 +168,9 @@ $(OBJDIR)/%.o: src/%.c $(CC) $(CFLAGS) -c $< -o $@ clean: + rm -f $(VERSION); \ find . -type f -name \*.o -exec rm {} \; rm -rf $(KORE) $(OBJDIR) kore.features $(MAKE) -C kodev clean -.PHONY: all clean +.PHONY: all clean force diff --git a/include/kore/kore.h b/include/kore/kore.h @@ -57,11 +57,6 @@ extern int daemon(int, int); #define KORE_RESULT_OK 1 #define KORE_RESULT_RETRY 2 -#define KORE_VERSION_MAJOR 3 -#define KORE_VERSION_MINOR 0 -#define KORE_VERSION_PATCH 0 -#define KORE_VERSION_STATE "devel" - #define KORE_TLS_VERSION_1_2 0 #define KORE_TLS_VERSION_1_0 1 #define KORE_TLS_VERSION_BOTH 2 @@ -473,6 +468,7 @@ extern char *rand_file; extern u_int8_t nlisteners; extern u_int16_t cpu_count; extern u_int8_t worker_count; +extern const char *kore_version; extern u_int8_t worker_set_affinity; extern u_int32_t worker_rlimit_nofiles; extern u_int32_t worker_max_connections; diff --git a/kodev/Makefile b/kodev/Makefile @@ -1,6 +1,6 @@ # kodev Makefile -CC?=gcc +CC?=cc PREFIX?=/usr/local OBJDIR?=obj KODEV=kodev diff --git a/src/http.c b/src/http.c @@ -95,8 +95,7 @@ http_init(void) ckhdr_buf = kore_buf_alloc(HTTP_COOKIE_BUFSIZE); l = snprintf(http_version, sizeof(http_version), - "server: kore (%d.%d.%d-%s)\r\n", KORE_VERSION_MAJOR, - KORE_VERSION_MINOR, KORE_VERSION_PATCH, KORE_VERSION_STATE); + "server: kore (%s)\r\n", kore_version); if (l == -1 || (size_t)l >= sizeof(http_version)) fatal("http_init(): http_version buffer too small"); diff --git a/src/kore.c b/src/kore.c @@ -89,8 +89,7 @@ usage(void) static void version(void) { - printf("%d.%d.%d-%s ", KORE_VERSION_MAJOR, KORE_VERSION_MINOR, - KORE_VERSION_PATCH, KORE_VERSION_STATE); + printf("%s ", kore_version); #if defined(KORE_NO_TLS) printf("no-tls "); #endif