From 394b3ad25148882ffaef932d12772b65d41495e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=B6glinger-Stelzer?= Date: Sun, 30 Sep 2018 20:29:11 +0200 Subject: [PATCH] Redesigned version stamping --- appveyor.yml | 9 +--- build/Build.cs | 91 ++++++++++++++++++++++++------- build/_build.csproj | 5 ++ build/default.json | 10 ++++ sys/ViGEmBus.rc | 100 ----------------------------------- sys/ViGEmBus.vcxproj | 4 -- sys/ViGEmBus.vcxproj.filters | 8 --- sys/resource.h | 14 ----- 8 files changed, 89 insertions(+), 152 deletions(-) create mode 100644 build/default.json delete mode 100644 sys/ViGEmBus.rc delete mode 100644 sys/resource.h diff --git a/appveyor.yml b/appveyor.yml index 3b93a22..b558068 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,14 +5,7 @@ install: build_script: - ps: .\build.ps1 -configuration release after_build: -- ps: | - Invoke-WebRequest "https://downloads.vigem.org/other/pavel-a/ddverpatch/verpatch-1.0.15.1-x86-codeplex.zip" -OutFile verpatch-1.0.15.1-x86-codeplex.zip - Expand-Archive verpatch-1.0.15.1-x86-codeplex.zip -DestinationPath . - .\verpatch.exe .\artifacts\x64\ViGEmBus.sys "$env:APPVEYOR_BUILD_VERSION" - .\verpatch.exe .\artifacts\x64\ViGEmBus.sys /pv "$env:APPVEYOR_BUILD_VERSION" - .\verpatch.exe .\artifacts\x86\ViGEmBus.sys "$env:APPVEYOR_BUILD_VERSION" - .\verpatch.exe .\artifacts\x86\ViGEmBus.sys /pv "$env:APPVEYOR_BUILD_VERSION" - makecab.exe /f ViGEmBus.ddf +- cmd: makecab.exe /f ViGEmBus.ddf artifacts: - path: disk1\ViGEmBus.cab name: ViGEmBus_unsigned_x86_amd64 diff --git a/build/Build.cs b/build/Build.cs index 66ddf8c..cbf0df2 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,45 +1,45 @@ using System; using System.IO; -using System.Linq; +using JsonConfig; using Nuke.Common; +using Nuke.Common.BuildServers; using Nuke.Common.Git; using Nuke.Common.ProjectModel; +using Nuke.Common.Tools.GitVersion; using Nuke.Common.Tools.MSBuild; +using Vestris.ResourceLib; using static Nuke.Common.EnvironmentInfo; using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.IO.PathConstruction; using static Nuke.Common.Tools.MSBuild.MSBuildTasks; -class Build : NukeBuild +internal class Build : NukeBuild { - public static int Main () => Execute(x => x.Compile); + [GitRepository] private readonly GitRepository GitRepository; + [GitVersion] private readonly GitVersion GitVersion; - [Solution] readonly Solution Solution; - [GitRepository] readonly GitRepository GitRepository; + [Solution("ViGEmBus.sln")] private readonly Solution Solution; - AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; + private AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; - Target Clean => _ => _ - .Executes(() => - { - EnsureCleanDirectory(ArtifactsDirectory); - }); + private Target Clean => _ => _ + .Executes(() => { EnsureCleanDirectory(ArtifactsDirectory); }); - Target Restore => _ => _ + private Target Restore => _ => _ .DependsOn(Clean) .Executes(() => { MSBuild(s => s - .SetTargetPath(SolutionFile) + .SetTargetPath(Solution) .SetTargets("Restore")); }); - Target Compile => _ => _ + private Target Compile => _ => _ .DependsOn(Restore) .Executes(() => { MSBuild(s => s - .SetTargetPath(SolutionFile) + .SetTargetPath(Solution) .SetTargets("Rebuild") .SetConfiguration(Configuration) .SetMaxCpuCount(Environment.ProcessorCount) @@ -47,7 +47,7 @@ class Build : NukeBuild .SetTargetPlatform(MSBuildTargetPlatform.x64)); MSBuild(s => s - .SetTargetPath(SolutionFile) + .SetTargetPath(Solution) .SetTargets("Rebuild") .SetConfiguration(Configuration) .SetMaxCpuCount(Environment.ProcessorCount) @@ -55,6 +55,7 @@ class Build : NukeBuild .SetTargetPlatform(MSBuildTargetPlatform.x86)); #region Ugly hack, fix me! + EnsureExistingDirectory(Path.Combine(ArtifactsDirectory, @"x64")); EnsureExistingDirectory(Path.Combine(ArtifactsDirectory, @"x86")); @@ -88,7 +89,22 @@ class Build : NukeBuild Path.Combine(WorkingDirectory, @"bin\x86\ViGEmBus\WdfCoinstaller01009.dll"), Path.Combine(ArtifactsDirectory, @"x86\WdfCoinstaller01009.dll") ); + #endregion + + if (Configuration.Equals("release", StringComparison.InvariantCultureIgnoreCase)) + { + var version = + new Version(IsLocalBuild ? GitVersion.GetNormalizedFileVersion() : AppVeyor.Instance.BuildVersion); + + StampVersion( + Path.Combine(ArtifactsDirectory, @"x64\ViGEmBus.sys"), + version); + + StampVersion( + Path.Combine(ArtifactsDirectory, @"x86\ViGEmBus.sys"), + version); + } }); private Target Pack => _ => _ @@ -96,10 +112,49 @@ class Build : NukeBuild .Executes(() => { MSBuild(s => s - .SetTargetPath(SolutionFile) + .SetTargetPath(Solution) .SetTargets("Restore", "Pack") .SetPackageOutputPath(ArtifactsDirectory) .SetConfiguration(Configuration) .EnableIncludeSymbols()); }); -} + + public static int Main() + { + return Execute(x => x.Compile); + } + + private static void StampVersion(string path, Version version) + { + var versionResource = new VersionResource + { + FileVersion = version.ToString(), + ProductVersion = version.ToString() + }; + + var stringFileInfo = new StringFileInfo(); + versionResource[stringFileInfo.Key] = stringFileInfo; + var stringFileInfoStrings = new StringTable + { + LanguageID = 1033, + CodePage = 1200 + }; + stringFileInfo.Strings.Add(stringFileInfoStrings.Key, stringFileInfoStrings); + stringFileInfoStrings["CompanyName"] = Config.Global.Version.CompanyName; + stringFileInfoStrings["FileDescription"] = Config.Global.Version.FileDescription; + stringFileInfoStrings["FileVersion"] = version.ToString(); + stringFileInfoStrings["InternalName"] = Config.Global.Version.InternalName; + stringFileInfoStrings["LegalCopyright"] = Config.Global.Version.LegalCopyright; + stringFileInfoStrings["OriginalFilename"] = Config.Global.Version.OriginalFilename; + stringFileInfoStrings["ProductName"] = Config.Global.Version.ProductName; + stringFileInfoStrings["ProductVersion"] = version.ToString(); + + var varFileInfo = new VarFileInfo(); + versionResource[varFileInfo.Key] = varFileInfo; + var varFileInfoTranslation = new VarTable("Translation"); + varFileInfo.Vars.Add(varFileInfoTranslation.Key, varFileInfoTranslation); + varFileInfoTranslation[ResourceUtil.USENGLISHLANGID] = 1300; + + versionResource.SaveTo(path); + } +} \ No newline at end of file diff --git a/build/_build.csproj b/build/_build.csproj index 6212d6b..9a3a029 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -10,14 +10,19 @@ + + + + + diff --git a/build/default.json b/build/default.json new file mode 100644 index 0000000..0383e3e --- /dev/null +++ b/build/default.json @@ -0,0 +1,10 @@ +{ + "Version": { + "CompanyName": "Benjamin Hoeglinger-Stelzer", + "FileDescription": "Virtual Gamepad Emulation Framework Bus Driver", + "InternalName": "ViGEmBus.sys", + "LegalCopyright": "Copyright (C) 2016-2018 Benjamin Hoeglinger-Stelzer All Rights Reserved", + "OriginalFilename": "ViGEmBus.sys", + "ProductName": "Virtual Gamepad Emulation Framework Bus Driver" + } +} \ No newline at end of file diff --git a/sys/ViGEmBus.rc b/sys/ViGEmBus.rc deleted file mode 100644 index 77cb42b..0000000 --- a/sys/ViGEmBus.rc +++ /dev/null @@ -1,100 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// German (Austria) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEA) -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,14,3,0 - PRODUCTVERSION 1,14,3,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0xe9L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000904b0" - BEGIN - VALUE "CompanyName", "Benjamin Höglinger-Stelzer" - VALUE "FileDescription", "Virtual Gamepad Emulation Bus Driver" -VALUE "FileVersion", "1.14.3.0" - VALUE "InternalName", "Virtual Gamepad Emulation Bus Driver" - VALUE "LegalCopyright", "Copyright (C) Benjamin Höglinger-Stelzer 2016" - VALUE "OriginalFilename", "vigembus.sys" - VALUE "ProductName", "Virtual Gamepad Emulation Bus Driver" -VALUE "ProductVersion", "1.14.3.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x9, 1200 - END -END - -#endif // German (Austria) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/sys/ViGEmBus.vcxproj b/sys/ViGEmBus.vcxproj index 0248517..feed3c7 100644 --- a/sys/ViGEmBus.vcxproj +++ b/sys/ViGEmBus.vcxproj @@ -185,16 +185,12 @@ - - - - diff --git a/sys/ViGEmBus.vcxproj.filters b/sys/ViGEmBus.vcxproj.filters index c26df81..5897fea 100644 --- a/sys/ViGEmBus.vcxproj.filters +++ b/sys/ViGEmBus.vcxproj.filters @@ -27,9 +27,6 @@ - - Header Files - Header Files @@ -67,11 +64,6 @@ Header Files\Common - - - Resource Files - - Source Files diff --git a/sys/resource.h b/sys/resource.h deleted file mode 100644 index 97b180c..0000000 --- a/sys/resource.h +++ /dev/null @@ -1,14 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by ViGEmBus.rc - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif