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

Commit

Permalink
Redesigned version stamping
Browse files Browse the repository at this point in the history
  • Loading branch information
nefarius committed Sep 30, 2018
1 parent 91c20e4 commit 394b3ad
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 152 deletions.
9 changes: 1 addition & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
91 changes: 73 additions & 18 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,60 +1,61 @@
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<Build>(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)
.SetNodeReuse(IsLocalBuild)
.SetTargetPlatform(MSBuildTargetPlatform.x64));
MSBuild(s => s
.SetTargetPath(SolutionFile)
.SetTargetPath(Solution)
.SetTargets("Rebuild")
.SetConfiguration(Configuration)
.SetMaxCpuCount(Environment.ProcessorCount)
.SetNodeReuse(IsLocalBuild)
.SetTargetPlatform(MSBuildTargetPlatform.x86));
#region Ugly hack, fix me!
EnsureExistingDirectory(Path.Combine(ArtifactsDirectory, @"x64"));
EnsureExistingDirectory(Path.Combine(ArtifactsDirectory, @"x86"));
Expand Down Expand Up @@ -88,18 +89,72 @@ 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 => _ => _
.DependsOn(Compile)
.Executes(() =>
{
MSBuild(s => s
.SetTargetPath(SolutionFile)
.SetTargetPath(Solution)
.SetTargets("Restore", "Pack")
.SetPackageOutputPath(ArtifactsDirectory)
.SetConfiguration(Configuration)
.EnableIncludeSymbols());
});
}

public static int Main()
{
return Execute<Build>(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);
}
}
5 changes: 5 additions & 0 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nefarius.JsonConfig" Version="1.0.2" />
<PackageReference Include="Nuke.Common" Version="0.9.1" />
<PackageReference Include="GitVersion.CommandLine" Version="3.6.5" />
<PackageReference Include="Vestris.ResourceLib" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<NukeMetadata Include="**\*.json" Exclude="bin\**;obj\**" />
<NukeExternalFiles Include="**\*.*.ext" Exclude="bin\**;obj\**" />
<None Remove="*.csproj.DotSettings;*.ref.*.txt" />
<None Remove="default.json" />
<NukeMetadata Remove="default.json" />
<EmbeddedResource Include="default.json" />

<!-- Common build related files -->
<None Include="..\build.ps1" />
Expand Down
10 changes: 10 additions & 0 deletions build/default.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
100 changes: 0 additions & 100 deletions sys/ViGEmBus.rc

This file was deleted.

4 changes: 0 additions & 4 deletions sys/ViGEmBus.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,12 @@
<ClInclude Include="Context.h" />
<ClInclude Include="Ds4.h" />
<ClInclude Include="Queue.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="trace.h" />
<ClInclude Include="UsbPdo.h" />
<ClInclude Include="Util.h" />
<ClInclude Include="Xgip.h" />
<ClInclude Include="Xusb.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ViGEmBus.rc" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="busenum.c" />
<ClCompile Include="buspdo.c" />
Expand Down
8 changes: 0 additions & 8 deletions sys/ViGEmBus.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
</Inf>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="busenum.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -67,11 +64,6 @@
<Filter>Header Files\Common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ViGEmBus.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="busenum.c">
<Filter>Source Files</Filter>
Expand Down
14 changes: 0 additions & 14 deletions sys/resource.h

This file was deleted.

0 comments on commit 394b3ad

Please sign in to comment.