add the git prefix to the long version output
Tested on MacOS, written and not tested for Linux, not attempted for Windows
This commit is contained in:
@@ -386,6 +386,7 @@ struct nomakedefs_s {
|
||||
const char *copyright_banner_c;
|
||||
const char *git_sha;
|
||||
const char *git_branch;
|
||||
const char *git_prefix;
|
||||
const char *version_string;
|
||||
const char *version_id;
|
||||
unsigned long version_number;
|
||||
|
||||
@@ -29,6 +29,7 @@ struct nomakedefs_s nomakedefs = {
|
||||
"Version 1.0, built Jul 28 13:18:57 1987.",
|
||||
(const char *) 0, /* git_sha */
|
||||
(const char *) 0, /* git_branch */
|
||||
(const char *) 0, /* git_prefix */
|
||||
"1.0.0-0",
|
||||
"NetHack Version 1.0.0-0 - last build Tue Jul 28 13:18:57 1987.",
|
||||
0x01010000UL,
|
||||
@@ -125,6 +126,9 @@ populate_nomakedefs(struct version_info *version)
|
||||
#ifdef NETHACK_GIT_BRANCH
|
||||
nomakedefs.git_branch = dupstr(NETHACK_GIT_BRANCH);
|
||||
#endif
|
||||
#ifdef NETHACK_GIT_PREFIX
|
||||
nomakedefs.git_prefix = dupstr(NETHACK_GIT_PREFIX);
|
||||
#endif
|
||||
|
||||
nomakedefs_populated = 1;
|
||||
return;
|
||||
@@ -161,6 +165,11 @@ free_nomakedefs(void)
|
||||
free((genericptr_t) nomakedefs.git_branch),
|
||||
nomakedefs.git_branch = 0;
|
||||
#endif
|
||||
#ifdef NETHACK_GIT_PREFIX
|
||||
if (nomakedefs.git_prefix)
|
||||
free((genericptr_t) nomakedefs.git_prefix),
|
||||
nomakedefs.git_prefix = 0;
|
||||
#endif
|
||||
|
||||
/* values are Null now; dynamic vs static doesn't really matter anymore */
|
||||
nomakedefs_populated = 0;
|
||||
|
||||
@@ -58,6 +58,10 @@ getversionstring(char *buf, size_t bufsz)
|
||||
"%sbranch:%s",
|
||||
c++ ? "," : "", nomakedefs.git_branch);
|
||||
#endif
|
||||
if (nomakedefs.git_prefix)
|
||||
Snprintf(eos(buf), (bufsz - strlen(buf)) - 1,
|
||||
"%sprefix:%s",
|
||||
c++ ? "," : "", nomakedefs.git_prefix);
|
||||
if (c)
|
||||
Snprintf(eos(buf), (bufsz - strlen(buf)) - 1,
|
||||
"%s", ")");
|
||||
|
||||
@@ -765,7 +765,7 @@ $(TARGETPFX)sfstruct.o: sfstruct.c $(HACK_H)
|
||||
# date.c should be recompiled any time any of the source or include code
|
||||
# is modified.
|
||||
$(TARGETPFX)date.o: date.c $(HACK_H) $(HACKCSRC) $(HOBJ) $(TARGET_HACKLIB)
|
||||
$(TARGET_CC) $(TARGET_CFLAGS) $(GITHASH) $(GITBRANCH) -c -o $@ date.c
|
||||
$(TARGET_CC) $(TARGET_CFLAGS) $(GITHASH) $(GITBRANCH) $(GITPREFIX) -c -o $@ date.c
|
||||
|
||||
# date.h should be remade any time any of the source or include code
|
||||
# is modified. Unfortunately, this would make the contents of this
|
||||
|
||||
@@ -288,6 +288,7 @@ VARDATND += $(sort $(VARDATND0))
|
||||
|
||||
GIT_HASH := $(shell echo `git rev-parse --verify HEAD` 2>&1)
|
||||
GIT_BRANCH := $(shell echo `git rev-parse --abbrev-ref HEAD` 2>&1)
|
||||
GIT_PREFIX := $(shell echo `git config nethack.substprefix` 2>&1)
|
||||
|
||||
ifdef GIT_HASH
|
||||
GITHASH = -DNETHACK_GIT_SHA=\"$(GIT_HASH)\"
|
||||
@@ -295,6 +296,9 @@ endif
|
||||
ifdef GIT_BRANCH
|
||||
GITBRANCH = -DNETHACK_GIT_BRANCH=\"$(GIT_BRANCH)\"
|
||||
endif
|
||||
ifdef GIT_PREFIX
|
||||
GITPREFIX = -DNETHACK_GIT_PREFIX=\"$(GIT_PREFIX)\"
|
||||
endif
|
||||
|
||||
ifdef WANT_LIBNH
|
||||
CFLAGS += -DSHIM_GRAPHICS -DNOTTYGRAPHICS -DNOSHELL -DLIBNH -fpic
|
||||
|
||||
@@ -285,6 +285,7 @@ VARDATND += $(sort $(VARDATND0))
|
||||
|
||||
GIT_HASH := $(shell echo `git rev-parse --verify HEAD` 2>&1)
|
||||
GIT_BRANCH := $(shell echo `git rev-parse --abbrev-ref HEAD` 2>&1)
|
||||
GIT_PREFIX := $(shell echo `git config nethack.substprefix` 2>&1)
|
||||
|
||||
ifdef GIT_HASH
|
||||
GITHASH = -DNETHACK_GIT_SHA=\"$(GIT_HASH)\"
|
||||
@@ -292,6 +293,9 @@ endif
|
||||
ifdef GIT_BRANCH
|
||||
GITBRANCH = -DNETHACK_GIT_BRANCH=\"$(GIT_BRANCH)\"
|
||||
endif
|
||||
ifdef GIT_PREFIX
|
||||
GITPREFIX = -DNETHACK_GIT_PREFIX=\"$(GIT_PREFIX)\"
|
||||
endif
|
||||
|
||||
ifdef WANT_LIBNH
|
||||
CFLAGS += -DSHIM_GRAPHICS -DNOTTYGRAPHICS -DNOSHELL -DLIBNH
|
||||
|
||||
Reference in New Issue
Block a user