mirror of
https://github.com/g4klx/DMRGateway.git
synced 2025-12-06 05:32:01 +01:00
Add compilation time stamp and GitID to binaries
This commit is contained in:
parent
8e56a81cf7
commit
c7a7d0adef
|
|
@ -25,6 +25,7 @@
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#include "Voice.h"
|
#include "Voice.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "GitVersion.h"
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
@ -77,7 +78,7 @@ int main(int argc, char** argv)
|
||||||
for (int currentArg = 1; currentArg < argc; ++currentArg) {
|
for (int currentArg = 1; currentArg < argc; ++currentArg) {
|
||||||
std::string arg = argv[currentArg];
|
std::string arg = argv[currentArg];
|
||||||
if ((arg == "-v") || (arg == "--version")) {
|
if ((arg == "-v") || (arg == "--version")) {
|
||||||
::fprintf(stdout, "DMRGateway version %s\n", VERSION);
|
::fprintf(stdout, "DMRGateway version %s git #%.7s\n", VERSION, gitversion);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (arg.substr(0,1) == "-") {
|
} else if (arg.substr(0,1) == "-") {
|
||||||
::fprintf(stderr, "Usage: DMRGateway [-v|--version] [filename]\n");
|
::fprintf(stderr, "Usage: DMRGateway [-v|--version] [filename]\n");
|
||||||
|
|
@ -231,6 +232,7 @@ int CDMRGateway::run()
|
||||||
LogInfo(HEADER4);
|
LogInfo(HEADER4);
|
||||||
|
|
||||||
LogMessage("DMRGateway-%s is starting", VERSION);
|
LogMessage("DMRGateway-%s is starting", VERSION);
|
||||||
|
LogMessage("Built %s %s (GitID #%.7s)", __TIME__, __DATE__, gitversion);
|
||||||
|
|
||||||
ret = createMMDVM();
|
ret = createMMDVM();
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,12 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>wsock32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>wsock32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
|
<PreBuildEvent>
|
||||||
|
<Command>"$(ProjectDir)prebuild.cmd" $(ProjectDir)</Command>
|
||||||
|
</PreBuildEvent>
|
||||||
|
<PreBuildEvent>
|
||||||
|
<Message>prebuild.cmd generates GitVersion.h from git refs heads master</Message>
|
||||||
|
</PreBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
|
@ -217,4 +223,4 @@
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
13
Makefile
13
Makefile
|
|
@ -10,11 +10,20 @@ OBJECTS = BPTC19696.o Conf.o CRC.o DMRData.o DMREmbeddedData.o DMREMB.o DMRFullL
|
||||||
|
|
||||||
all: DMRGateway
|
all: DMRGateway
|
||||||
|
|
||||||
DMRGateway: $(OBJECTS)
|
DMRGateway: GitVersion.h $(OBJECTS)
|
||||||
$(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o DMRGateway
|
$(CXX) $(OBJECTS) $(CFLAGS) $(LIBS) -o DMRGateway
|
||||||
|
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
$(CXX) $(CFLAGS) -c -o $@ $<
|
$(CXX) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) DMRGateway *.o *.d *.bak *~
|
$(RM) DMRGateway *.o *.d *.bak *~ GitVersion.h
|
||||||
|
|
||||||
|
# Export the current git version if the index file exists, else 000...
|
||||||
|
GitVersion.h:
|
||||||
|
ifneq ("$(wildcard .git/index)","")
|
||||||
|
echo "const char *gitversion = \"$(shell git rev-parse HEAD)\";" > $@
|
||||||
|
else
|
||||||
|
echo "const char *gitversion = \"0000000000000000000000000000000000000000\";" > $@
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
|
||||||
38
prebuild.cmd
Normal file
38
prebuild.cmd
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
@echo off
|
||||||
|
REM This pre-build file is for MSVS VC++. It parses the git master hash and
|
||||||
|
REM converts it into GitVersion.h for compiling into builds. [George M1GEO]
|
||||||
|
|
||||||
|
cd %1
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
set HEADFILE=.git\HEAD
|
||||||
|
set HASHFILE=0
|
||||||
|
if exist %HEADFILE% (
|
||||||
|
for /F "tokens=4 delims=/:" %%a in ('type %HEADFILE%') do set HEADBRANCH=%%a
|
||||||
|
set HASHFILE=.git\refs\heads\!HEADBRANCH!
|
||||||
|
echo Found Git HEAD file: %HEADFILE%
|
||||||
|
echo Git HEAD branch: !HEADBRANCH!
|
||||||
|
echo Git HASH file: !HASHFILE!
|
||||||
|
call :USEHASH
|
||||||
|
) else (
|
||||||
|
echo No head file :(
|
||||||
|
call :USENULL
|
||||||
|
)
|
||||||
|
|
||||||
|
goto :EOF
|
||||||
|
|
||||||
|
:USENULL
|
||||||
|
set GITHASH=0000000000000000000000000000000000000000
|
||||||
|
goto :WRITEGITVERSIONHEADER
|
||||||
|
|
||||||
|
:USEHASH
|
||||||
|
for /f %%i in ('type !HASHFILE!') do set GITHASH=%%i
|
||||||
|
goto :WRITEGITVERSIONHEADER
|
||||||
|
|
||||||
|
:WRITEGITVERSIONHEADER
|
||||||
|
echo // File contains Git commit ID SHA1 present at buildtime (prebuild.cmd) > GitVersion.h
|
||||||
|
echo const char *gitversion = "%GITHASH%"; >> GitVersion.h
|
||||||
|
echo Current Git HASH: %GITHASH%
|
||||||
|
goto :FINISHED
|
||||||
|
|
||||||
|
:FINISHED
|
||||||
|
echo GitVersion.h written...
|
||||||
Loading…
Reference in a new issue