Skip to content

Commit

Permalink
Merge pull request #190 from rpking42/server_git_version
Browse files Browse the repository at this point in the history
Return the git hash for `croquery serverversion`
  • Loading branch information
mklight authored May 8, 2019
2 parents d7ed0b5 + c55f35e commit 0086361
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions dllNetwork/server/ControlInstruction.C
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <git_version.H>

#ifdef OTHER_USE
#include <OutputLite.H>
Expand Down Expand Up @@ -282,6 +283,7 @@ uint32_t ControlInstruction::execute(ecmdDataBuffer & o_data, InstructionStatus
std::ostringstream oss;
oss << "Server Version" << std::endl;
oss << "Date: " << __DATE__ << " " << __TIME__ << std::endl;
oss << "Git Version: " << git_version << std::endl;
std::map<std::string, uint32_t>::iterator versionIterator = controls->global_version_map_pointer->begin();
while (versionIterator != controls->global_version_map_pointer->end()) {
oss << std::left << std::setw(24) << versionIterator->first << " : " << versionIterator->second << std::endl;
Expand Down
4 changes: 4 additions & 0 deletions dllNetwork/server/git_version.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef _GIT_VERSION_H
#define _GIT_VERSION_H
extern const char *git_version;
#endif // _GIT_VERSION_H
17 changes: 15 additions & 2 deletions dllNetwork/server/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ TGT_INCLUDES += PNORInstruction.H
TGT_INCLUDES += fd_impl.H
TGT_INCLUDES += ServerSBEFIFOInstruction.H
TGT_INCLUDES += SBEFIFOInstruction.H
TGT_INCLUDES += git_version.H

TGT_SOURCE := Instruction.C
TGT_SOURCE += InstructionStatus.C
Expand All @@ -57,6 +58,7 @@ TGT_SOURCE += PNORInstruction.C
TGT_SOURCE += fd_impl.C
TGT_SOURCE += ServerSBEFIFOInstruction.C
TGT_SOURCE += SBEFIFOInstruction.C
TGT_SOURCE += git_version.C
TGT_SOURCE += server1p.C

TGT_SOURCE_C := adal_base.c
Expand All @@ -80,8 +82,7 @@ LDFLAGS += -ldl -lpthread -lz
all:
${run-all}

generate:
# Do nothing
generate: git_version.C

build: ${TARGET}

Expand Down Expand Up @@ -115,6 +116,18 @@ ${TGT_SOURCE_C_OBJS}: ${OBJPATH}%.o : %.c ${INCLUDES}
@echo Compiling $<
${VERBOSE}${CXX} -c ${CXXFLAGS} $< -o $@ ${DEFINES}

# *****************************************************************************
# Create a .C file containing the git hash to print out as part of the
# serverversion. If we are building from a .zip download, the .git
# folder doesn't exist. Create empty targets for the .git folder so
# make doesn't try to create them. If we build in this situation, the
# version is an empty string, which is the best we can do.
# *****************************************************************************
../../.git/HEAD:
../../.git/index:
git_version.C: ../../.git/HEAD ../../.git/index
@echo "const char *git_version = \"$(shell git describe --dirty --always --tags)\";" > ${SRCPATH}/$@

# *****************************************************************************
# Create the Target
# *****************************************************************************
Expand Down

0 comments on commit 0086361

Please sign in to comment.