diff --git a/DAPNETGateway.cpp b/DAPNETGateway.cpp index 834c5ba..a66b521 100644 --- a/DAPNETGateway.cpp +++ b/DAPNETGateway.cpp @@ -22,6 +22,8 @@ #include "Thread.h" #include "Timer.h" #include "Log.h" +#include "GitVersion.h" + #include "REGEX.h" #include @@ -80,7 +82,7 @@ int main(int argc, char** argv) for (int currentArg = 1; currentArg < argc; ++currentArg) { std::string arg = argv[currentArg]; if ((arg == "-v") || (arg == "--version")) { - ::fprintf(stdout, "DAPNETGateway version %s\n", VERSION); + ::fprintf(stdout, "DAPNETGateway version %s git #%.7s\n", VERSION, gitversion); return 0; } else if (arg.substr(0, 1) == "-") { ::fprintf(stderr, "Usage: DAPNETGateway [-v|--version] [filename]\n"); diff --git a/DAPNETGateway.vcxproj b/DAPNETGateway.vcxproj index dc023f7..0a39333 100644 --- a/DAPNETGateway.vcxproj +++ b/DAPNETGateway.vcxproj @@ -127,6 +127,9 @@ true ws2_32.lib;%(AdditionalDependencies) + + prebuild.cmd + @@ -142,6 +145,9 @@ true ws2_32.lib;%(AdditionalDependencies) + + prebuild.cmd + @@ -161,6 +167,9 @@ true ws2_32.lib;%(AdditionalDependencies) + + prebuild.cmd + @@ -180,6 +189,9 @@ true ws2_32.lib;%(AdditionalDependencies) + + prebuild.cmd + diff --git a/UDPSocket.h b/UDPSocket.h index 28e350c..75228a3 100644 --- a/UDPSocket.h +++ b/UDPSocket.h @@ -69,10 +69,11 @@ private: unsigned short m_localPort; #if defined(_WIN32) || defined(_WIN64) SOCKET m_fd; + int m_af; #else int m_fd; -#endif sa_family_t m_af; +#endif }; #endif diff --git a/prebuild.cmd b/prebuild.cmd new file mode 100644 index 0000000..2dc5f9d --- /dev/null +++ b/prebuild.cmd @@ -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...