From c8723e171bed26fea66ba8208162d893e2b80fa7 Mon Sep 17 00:00:00 2001 From: narzoul Date: Mon, 5 Apr 2021 23:53:37 +0200 Subject: [PATCH] Added version info to DLL --- DDrawCompat/DDrawCompat.rc | 38 +++++++++++++++++++++++++ DDrawCompat/DDrawCompat.vcxproj | 36 +++++++++++++++++++++++ DDrawCompat/DDrawCompat.vcxproj.filters | 10 +++++++ DDrawCompat/genversion.ps1 | 35 +++++++++++++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 DDrawCompat/DDrawCompat.rc create mode 100644 DDrawCompat/genversion.ps1 diff --git a/DDrawCompat/DDrawCompat.rc b/DDrawCompat/DDrawCompat.rc new file mode 100644 index 0000000..65767ff --- /dev/null +++ b/DDrawCompat/DDrawCompat.rc @@ -0,0 +1,38 @@ +#include +#include + +#ifdef SPECIALBUILD +#define VERSION_PRODUCT_NAME "DDrawCompat (" SPECIALBUILD ")" +#else +#define VERSION_PRODUCT_NAME "DDrawCompat" +#endif + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VERSION_NUMBER +PRODUCTVERSION VERSION_NUMBER +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_DLL +FILESUBTYPE VFT2_UNKNOWN +{ + BLOCK "StringFileInfo" + { + BLOCK "04090000" + { + VALUE "CompanyName", "" + VALUE "FileDescription", "https://github.com/narzoul/DDrawCompat" + VALUE "FileVersion", VERSION_STRING + VALUE "InternalName", "ddraw.dll" + VALUE "LegalCopyright", "BSD Zero Clause License" + VALUE "OriginalFilename", "ddraw.dll" + VALUE "ProductName", VERSION_PRODUCT_NAME + VALUE "ProductVersion", VERSION_STRING + } + } + + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x409, 0 + } +} diff --git a/DDrawCompat/DDrawCompat.vcxproj b/DDrawCompat/DDrawCompat.vcxproj index 888fc8d..9877609 100644 --- a/DDrawCompat/DDrawCompat.vcxproj +++ b/DDrawCompat/DDrawCompat.vcxproj @@ -19,6 +19,7 @@ Win32Proj DDrawCompat 10.0.19041.0 + true @@ -62,18 +63,24 @@ false $(ProjectDir);$(IncludePath) $(LibraryPath) + false + $(SolutionDir)Build\$(Configuration)\ ddraw $(ProjectDir);$(IncludePath) $(LibraryPath) false + false + $(SolutionDir)Build\$(Configuration)\ ddraw $(ProjectDir);$(IncludePath) $(LibraryPath) false + false + $(SolutionDir)Build\$(Configuration)\ @@ -94,6 +101,14 @@ true $(IntDir)$(TargetName).lib + + powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -File genversion.ps1 "$(IntDir)version.h" + Generating version information + + + $(IntDir) + SPECIALBUILD=\"$(Configuration)\" + @@ -112,6 +127,13 @@ true $(IntDir)$(TargetName).lib + + powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -File genversion.ps1 "$(IntDir)version.h" + Generating version information + + + $(IntDir) + @@ -130,6 +152,14 @@ true $(IntDir)$(TargetName).lib + + powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -File genversion.ps1 "$(IntDir)version.h" + Generating version information + + + $(IntDir) + SPECIALBUILD=\"$(Configuration)\" + @@ -309,6 +339,12 @@ + + + + + + diff --git a/DDrawCompat/DDrawCompat.vcxproj.filters b/DDrawCompat/DDrawCompat.vcxproj.filters index f050508..06566b6 100644 --- a/DDrawCompat/DDrawCompat.vcxproj.filters +++ b/DDrawCompat/DDrawCompat.vcxproj.filters @@ -606,4 +606,14 @@ Source Files\Gdi + + + Resource Files + + + + + Resource Files + + \ No newline at end of file diff --git a/DDrawCompat/genversion.ps1 b/DDrawCompat/genversion.ps1 new file mode 100644 index 0000000..d7a3e79 --- /dev/null +++ b/DDrawCompat/genversion.ps1 @@ -0,0 +1,35 @@ +Param ($VersionFile) + +Try { + $VersionString = git describe --tags --dirty --match v[0-9]* +} +Catch [System.Management.Automation.CommandNotFoundException] { + Write-Host 'warning: Git was not found in the system PATH. Version info will be missing from the DLL.' +} + +If ( ($VersionString -is [String]) -and ($VersionString -match '^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$') ) { + $VersionNumber = $VersionString.Split('-', 2)[0].Substring(1).Replace('.', ',') + ",0" +} +Else { + $VersionString = 'unknown' + $VersionNumber = '0,0,0,0' +} + +$FileContent = @" +#define VERSION_NUMBER $VersionNumber +#define VERSION_STRING "$VersionString" +"@ + +Try { + $PrevFileContent = [System.IO.File]::ReadAllText($VersionFile).Trim() +} +Catch [System.IO.FileNotFoundException] { +} + +If ( $FileContent -eq $PrevFileContent ) { + Write-Host "Version: $VersionString (same as previous build)" +} +Else { + Write-Host "Version: $VersionString (differs from previous build)" + $FileContent | Out-File -FilePath $VersionFile +}