Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Commit 394b3ad

Browse files
committed
Redesigned version stamping
1 parent 91c20e4 commit 394b3ad

File tree

8 files changed

+89
-152
lines changed

8 files changed

+89
-152
lines changed

appveyor.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@ install:
55
build_script:
66
- ps: .\build.ps1 -configuration release
77
after_build:
8-
- ps: |
9-
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
10-
Expand-Archive verpatch-1.0.15.1-x86-codeplex.zip -DestinationPath .
11-
.\verpatch.exe .\artifacts\x64\ViGEmBus.sys "$env:APPVEYOR_BUILD_VERSION"
12-
.\verpatch.exe .\artifacts\x64\ViGEmBus.sys /pv "$env:APPVEYOR_BUILD_VERSION"
13-
.\verpatch.exe .\artifacts\x86\ViGEmBus.sys "$env:APPVEYOR_BUILD_VERSION"
14-
.\verpatch.exe .\artifacts\x86\ViGEmBus.sys /pv "$env:APPVEYOR_BUILD_VERSION"
15-
makecab.exe /f ViGEmBus.ddf
8+
- cmd: makecab.exe /f ViGEmBus.ddf
169
artifacts:
1710
- path: disk1\ViGEmBus.cab
1811
name: ViGEmBus_unsigned_x86_amd64

build/Build.cs

Lines changed: 73 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,61 @@
11
using System;
22
using System.IO;
3-
using System.Linq;
3+
using JsonConfig;
44
using Nuke.Common;
5+
using Nuke.Common.BuildServers;
56
using Nuke.Common.Git;
67
using Nuke.Common.ProjectModel;
8+
using Nuke.Common.Tools.GitVersion;
79
using Nuke.Common.Tools.MSBuild;
10+
using Vestris.ResourceLib;
811
using static Nuke.Common.EnvironmentInfo;
912
using static Nuke.Common.IO.FileSystemTasks;
1013
using static Nuke.Common.IO.PathConstruction;
1114
using static Nuke.Common.Tools.MSBuild.MSBuildTasks;
1215

13-
class Build : NukeBuild
16+
internal class Build : NukeBuild
1417
{
15-
public static int Main () => Execute<Build>(x => x.Compile);
18+
[GitRepository] private readonly GitRepository GitRepository;
19+
[GitVersion] private readonly GitVersion GitVersion;
1620

17-
[Solution] readonly Solution Solution;
18-
[GitRepository] readonly GitRepository GitRepository;
21+
[Solution("ViGEmBus.sln")] private readonly Solution Solution;
1922

20-
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
23+
private AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
2124

22-
Target Clean => _ => _
23-
.Executes(() =>
24-
{
25-
EnsureCleanDirectory(ArtifactsDirectory);
26-
});
25+
private Target Clean => _ => _
26+
.Executes(() => { EnsureCleanDirectory(ArtifactsDirectory); });
2727

28-
Target Restore => _ => _
28+
private Target Restore => _ => _
2929
.DependsOn(Clean)
3030
.Executes(() =>
3131
{
3232
MSBuild(s => s
33-
.SetTargetPath(SolutionFile)
33+
.SetTargetPath(Solution)
3434
.SetTargets("Restore"));
3535
});
3636

37-
Target Compile => _ => _
37+
private Target Compile => _ => _
3838
.DependsOn(Restore)
3939
.Executes(() =>
4040
{
4141
MSBuild(s => s
42-
.SetTargetPath(SolutionFile)
42+
.SetTargetPath(Solution)
4343
.SetTargets("Rebuild")
4444
.SetConfiguration(Configuration)
4545
.SetMaxCpuCount(Environment.ProcessorCount)
4646
.SetNodeReuse(IsLocalBuild)
4747
.SetTargetPlatform(MSBuildTargetPlatform.x64));
4848

4949
MSBuild(s => s
50-
.SetTargetPath(SolutionFile)
50+
.SetTargetPath(Solution)
5151
.SetTargets("Rebuild")
5252
.SetConfiguration(Configuration)
5353
.SetMaxCpuCount(Environment.ProcessorCount)
5454
.SetNodeReuse(IsLocalBuild)
5555
.SetTargetPlatform(MSBuildTargetPlatform.x86));
5656

5757
#region Ugly hack, fix me!
58+
5859
EnsureExistingDirectory(Path.Combine(ArtifactsDirectory, @"x64"));
5960
EnsureExistingDirectory(Path.Combine(ArtifactsDirectory, @"x86"));
6061

@@ -88,18 +89,72 @@ class Build : NukeBuild
8889
Path.Combine(WorkingDirectory, @"bin\x86\ViGEmBus\WdfCoinstaller01009.dll"),
8990
Path.Combine(ArtifactsDirectory, @"x86\WdfCoinstaller01009.dll")
9091
);
92+
9193
#endregion
94+
95+
if (Configuration.Equals("release", StringComparison.InvariantCultureIgnoreCase))
96+
{
97+
var version =
98+
new Version(IsLocalBuild ? GitVersion.GetNormalizedFileVersion() : AppVeyor.Instance.BuildVersion);
99+
100+
StampVersion(
101+
Path.Combine(ArtifactsDirectory, @"x64\ViGEmBus.sys"),
102+
version);
103+
104+
StampVersion(
105+
Path.Combine(ArtifactsDirectory, @"x86\ViGEmBus.sys"),
106+
version);
107+
}
92108
});
93109

94110
private Target Pack => _ => _
95111
.DependsOn(Compile)
96112
.Executes(() =>
97113
{
98114
MSBuild(s => s
99-
.SetTargetPath(SolutionFile)
115+
.SetTargetPath(Solution)
100116
.SetTargets("Restore", "Pack")
101117
.SetPackageOutputPath(ArtifactsDirectory)
102118
.SetConfiguration(Configuration)
103119
.EnableIncludeSymbols());
104120
});
105-
}
121+
122+
public static int Main()
123+
{
124+
return Execute<Build>(x => x.Compile);
125+
}
126+
127+
private static void StampVersion(string path, Version version)
128+
{
129+
var versionResource = new VersionResource
130+
{
131+
FileVersion = version.ToString(),
132+
ProductVersion = version.ToString()
133+
};
134+
135+
var stringFileInfo = new StringFileInfo();
136+
versionResource[stringFileInfo.Key] = stringFileInfo;
137+
var stringFileInfoStrings = new StringTable
138+
{
139+
LanguageID = 1033,
140+
CodePage = 1200
141+
};
142+
stringFileInfo.Strings.Add(stringFileInfoStrings.Key, stringFileInfoStrings);
143+
stringFileInfoStrings["CompanyName"] = Config.Global.Version.CompanyName;
144+
stringFileInfoStrings["FileDescription"] = Config.Global.Version.FileDescription;
145+
stringFileInfoStrings["FileVersion"] = version.ToString();
146+
stringFileInfoStrings["InternalName"] = Config.Global.Version.InternalName;
147+
stringFileInfoStrings["LegalCopyright"] = Config.Global.Version.LegalCopyright;
148+
stringFileInfoStrings["OriginalFilename"] = Config.Global.Version.OriginalFilename;
149+
stringFileInfoStrings["ProductName"] = Config.Global.Version.ProductName;
150+
stringFileInfoStrings["ProductVersion"] = version.ToString();
151+
152+
var varFileInfo = new VarFileInfo();
153+
versionResource[varFileInfo.Key] = varFileInfo;
154+
var varFileInfoTranslation = new VarTable("Translation");
155+
varFileInfo.Vars.Add(varFileInfoTranslation.Key, varFileInfoTranslation);
156+
varFileInfoTranslation[ResourceUtil.USENGLISHLANGID] = 1300;
157+
158+
versionResource.SaveTo(path);
159+
}
160+
}

build/_build.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13+
<PackageReference Include="Nefarius.JsonConfig" Version="1.0.2" />
1314
<PackageReference Include="Nuke.Common" Version="0.9.1" />
1415
<PackageReference Include="GitVersion.CommandLine" Version="3.6.5" />
16+
<PackageReference Include="Vestris.ResourceLib" Version="2.0.0" />
1517
</ItemGroup>
1618

1719
<ItemGroup>
1820
<NukeMetadata Include="**\*.json" Exclude="bin\**;obj\**" />
1921
<NukeExternalFiles Include="**\*.*.ext" Exclude="bin\**;obj\**" />
2022
<None Remove="*.csproj.DotSettings;*.ref.*.txt" />
23+
<None Remove="default.json" />
24+
<NukeMetadata Remove="default.json" />
25+
<EmbeddedResource Include="default.json" />
2126

2227
<!-- Common build related files -->
2328
<None Include="..\build.ps1" />

build/default.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Version": {
3+
"CompanyName": "Benjamin Hoeglinger-Stelzer",
4+
"FileDescription": "Virtual Gamepad Emulation Framework Bus Driver",
5+
"InternalName": "ViGEmBus.sys",
6+
"LegalCopyright": "Copyright (C) 2016-2018 Benjamin Hoeglinger-Stelzer All Rights Reserved",
7+
"OriginalFilename": "ViGEmBus.sys",
8+
"ProductName": "Virtual Gamepad Emulation Framework Bus Driver"
9+
}
10+
}

sys/ViGEmBus.rc

Lines changed: 0 additions & 100 deletions
This file was deleted.

sys/ViGEmBus.vcxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,12 @@
185185
<ClInclude Include="Context.h" />
186186
<ClInclude Include="Ds4.h" />
187187
<ClInclude Include="Queue.h" />
188-
<ClInclude Include="resource.h" />
189188
<ClInclude Include="trace.h" />
190189
<ClInclude Include="UsbPdo.h" />
191190
<ClInclude Include="Util.h" />
192191
<ClInclude Include="Xgip.h" />
193192
<ClInclude Include="Xusb.h" />
194193
</ItemGroup>
195-
<ItemGroup>
196-
<ResourceCompile Include="ViGEmBus.rc" />
197-
</ItemGroup>
198194
<ItemGroup>
199195
<ClCompile Include="busenum.c" />
200196
<ClCompile Include="buspdo.c" />

sys/ViGEmBus.vcxproj.filters

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
</Inf>
2828
</ItemGroup>
2929
<ItemGroup>
30-
<ClInclude Include="resource.h">
31-
<Filter>Header Files</Filter>
32-
</ClInclude>
3330
<ClInclude Include="busenum.h">
3431
<Filter>Header Files</Filter>
3532
</ClInclude>
@@ -67,11 +64,6 @@
6764
<Filter>Header Files\Common</Filter>
6865
</ClInclude>
6966
</ItemGroup>
70-
<ItemGroup>
71-
<ResourceCompile Include="ViGEmBus.rc">
72-
<Filter>Resource Files</Filter>
73-
</ResourceCompile>
74-
</ItemGroup>
7567
<ItemGroup>
7668
<ClCompile Include="busenum.c">
7769
<Filter>Source Files</Filter>

sys/resource.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)