Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build improvements & dynamic Windows SDK resolution (backport from 3.0) #661

Merged
merged 9 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 30 additions & 0 deletions Silk.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.DXVA", "src\Micros
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.Core.Win32Extras", "src\Core\Silk.NET.Core.Win32Extras\Silk.NET.Core.Win32Extras.csproj", "{3E30D674-9282-4297-AD1F-9B233A166308}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.ALMALENCE", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.ALMALENCE\Silk.NET.OpenXR.Extensions.ALMALENCE.csproj", "{606214B8-07FC-436F-9523-02AF32E1AB1E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silk.NET.OpenXR.Extensions.HTCX", "src\OpenXR\Extensions\Silk.NET.OpenXR.Extensions.HTCX\Silk.NET.OpenXR.Extensions.HTCX.csproj", "{782B6A7E-9F04-429A-9DCD-D7273AA3882E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -2766,6 +2770,30 @@ Global
{3E30D674-9282-4297-AD1F-9B233A166308}.Release|x64.Build.0 = Release|Any CPU
{3E30D674-9282-4297-AD1F-9B233A166308}.Release|x86.ActiveCfg = Release|Any CPU
{3E30D674-9282-4297-AD1F-9B233A166308}.Release|x86.Build.0 = Release|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Debug|x64.ActiveCfg = Debug|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Debug|x64.Build.0 = Debug|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Debug|x86.ActiveCfg = Debug|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Debug|x86.Build.0 = Debug|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Release|Any CPU.Build.0 = Release|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Release|x64.ActiveCfg = Release|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Release|x64.Build.0 = Release|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Release|x86.ActiveCfg = Release|Any CPU
{606214B8-07FC-436F-9523-02AF32E1AB1E}.Release|x86.Build.0 = Release|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Debug|x64.ActiveCfg = Debug|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Debug|x64.Build.0 = Debug|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Debug|x86.ActiveCfg = Debug|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Debug|x86.Build.0 = Debug|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Release|Any CPU.Build.0 = Release|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Release|x64.ActiveCfg = Release|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Release|x64.Build.0 = Release|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Release|x86.ActiveCfg = Release|Any CPU
{782B6A7E-9F04-429A-9DCD-D7273AA3882E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2990,6 +3018,8 @@ Global
{58E7EE89-B67C-482D-9605-04B3BCC5CFBB} = {2F547104-C74A-4A84-8980-D1B973CC40C1}
{28D863B1-B60C-4C08-8661-EB820A5B78D2} = {F2CF5D32-4B41-425E-B229-8FFC48F88063}
{3E30D674-9282-4297-AD1F-9B233A166308} = {0651C5EF-50AA-4598-8D9C-8F210ADD8490}
{606214B8-07FC-436F-9523-02AF32E1AB1E} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0}
{782B6A7E-9F04-429A-9DCD-D7273AA3882E} = {90471225-AC23-424E-B62E-F6EC4C6ECAC0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F5273D7F-3334-48DF-94E3-41AE6816CD4D}
Expand Down
Binary file modified build/cache/assimp.json.gz
Binary file not shown.
Binary file modified build/cache/cl.json.gz
Binary file not shown.
Binary file modified build/cache/core.json.gz
Binary file not shown.
Binary file modified build/cache/d3d11.json.gz
Binary file not shown.
Binary file modified build/cache/d3d12.json.gz
Binary file not shown.
Binary file modified build/cache/d3d9.json.gz
Binary file not shown.
Binary file modified build/cache/d3dcompiler.json.gz
Binary file not shown.
Binary file modified build/cache/dxc.json.gz
Binary file not shown.
Binary file modified build/cache/dxgi.json.gz
Binary file not shown.
Binary file modified build/cache/dxva.json.gz
Binary file not shown.
Binary file modified build/cache/gl.json.gz
Binary file not shown.
Binary file modified build/cache/glcore.json.gz
Binary file not shown.
Binary file modified build/cache/gles2.json.gz
Binary file not shown.
Binary file modified build/cache/openxr.json.gz
Binary file not shown.
Binary file modified build/cache/sdl.json.gz
Binary file not shown.
Binary file modified build/cache/vulkan.json.gz
Binary file not shown.
Binary file modified build/cache/vulkan_video.json.gz
Binary file not shown.
Binary file modified build/cache/win32extras.json.gz
Binary file not shown.
Binary file modified build/cache/xaudio.json.gz
Binary file not shown.
Binary file modified build/cache/xinput.json.gz
Binary file not shown.
124 changes: 74 additions & 50 deletions build/nuke/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using JetBrains.Annotations;

using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.IO;
Expand Down Expand Up @@ -92,7 +92,7 @@ bool HasDesktopMsBuild

[Solution] readonly Solution Solution;

[CanBeNull] Dictionary<string, (Solution Solution, bool UseDesktopMSBuild)> SolutionsValue;
Dictionary<string, (Solution Solution, bool UseDesktopMSBuild)>? SolutionsValue;

Dictionary<string, (Solution Solution, bool UseDesktopMSBuild)> Solutions
=> SolutionsValue ??= Projects.ProcessSolution(Solution, FeatureSets, HasDesktopMsBuild);
Expand Down Expand Up @@ -157,7 +157,7 @@ bool HasDesktopMsBuild
"extension) to the AllowedExclusions array in the NUKE Build.cs file."
);

missedOut.Add(file);
missedOut.Add(Path.GetRelativePath(RootDirectory, file));
}
}

Expand All @@ -180,6 +180,7 @@ bool HasDesktopMsBuild
(
() =>
{
var outputs = Enumerable.Empty<Output>();
if (!HasProcessedSolutions)
{
var slnDir = Path.Combine(Solution.Directory!, "build", "sln");
Expand All @@ -202,21 +203,27 @@ bool HasDesktopMsBuild
Logger.Info($"Cleaning feature set \"{key}\" ({sln})");
if (useDesktopMsBuild)
{
MSBuild
outputs = outputs.Concat
(
s => s.SetTargets("Clean")
.SetMaxCpuCount(Environment.ProcessorCount)
.SetProperties(ProcessedMsbuildProperties)
.SetTargetPath(sln)
MSBuild
(
s => s.SetTargets("Clean")
.SetMaxCpuCount(Environment.ProcessorCount)
.SetProperties(ProcessedMsbuildProperties)
.SetTargetPath(sln)
)
);
}
else
{
DotNetClean
outputs = outputs.Concat
(
s => s.SetProject(sln)
.SetConfiguration(Configuration)
.SetProperties(ProcessedMsbuildProperties)
DotNetClean
(
s => s.SetProject(sln)
.SetConfiguration(Configuration)
.SetProperties(ProcessedMsbuildProperties)
)
);
}
}
Expand All @@ -228,12 +235,21 @@ bool HasDesktopMsBuild

Directory.CreateDirectory(RootDirectory / "build" / "output_packages");

var silkDroid = SourceDirectory / "Windowing" / "Android" / "SilkDroid";
using var process = RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
? StartProcess("bash", "-c \"./gradlew clean\"", silkDroid)
: StartProcess("cmd", "/c \".\\gradlew clean\"", silkDroid);
process.AssertZeroExitCode();
return process.Output;
if (FeatureSets.Any(x => x.Equals("native", StringComparison.OrdinalIgnoreCase)))
{
var silkDroid = SourceDirectory / "Windowing" / "Android" / "SilkDroid";
using var process = RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
? StartProcess("bash", "-c \"./gradlew clean\"", silkDroid)
: StartProcess("cmd", "/c \".\\gradlew clean\"", silkDroid);
process.AssertZeroExitCode();
outputs = outputs.Concat(process.Output);
}
else
{
Logger.Warn("Skipping gradlew clean as the \"native\" feature-set has not been specified.");
}

return outputs;
}
);

Expand Down Expand Up @@ -300,7 +316,7 @@ bool HasDesktopMsBuild
s => s
.SetProjectFile(sln)
.SetConfiguration(Configuration)
.SetNoRestore(true)
.EnableNoRestore()
.SetProperties(ProcessedMsbuildProperties)
);
}
Expand Down Expand Up @@ -357,6 +373,12 @@ bool HasDesktopMsBuild
(
() =>
{
if (!FeatureSets.Any(x => x.Equals("native", StringComparison.OrdinalIgnoreCase)))
{
Logger.Warn("Skipping gradlew build as the \"native\" feature-set has not been specified.");
return Enumerable.Empty<Output>();
}

var sdl = RootDirectory / "build" / "submodules" / "SDL";
var silkDroid = SourceDirectory / "Windowing" / "Android" / "SilkDroid";
var xcopy = new (string, string)[]
Expand Down Expand Up @@ -425,7 +447,7 @@ bool HasDesktopMsBuild
s => s
.SetProject(sln)
.SetConfiguration(Configuration)
.SetNoRestore(true)
.EnableNoRestore()
.SetProperties(ProcessedMsbuildProperties)
);
}
Expand All @@ -448,21 +470,25 @@ bool HasDesktopMsBuild
static IEnumerable<string> Packages => Directory.GetFiles(PackageDirectory, "*.nupkg")
.Where(x => Path.GetFileName(x).StartsWith("Silk.NET") || Path.GetFileName(x).StartsWith("Ultz.Native"));

async Task PushPackages()
async Task<IEnumerable<Output>> PushPackages()
{
var outputs = Enumerable.Empty<Output>();
const int rateLimit = 300;
if (!string.IsNullOrWhiteSpace(SignUsername) && !string.IsNullOrWhiteSpace(SignPassword))
{
var basePath = RootDirectory / "build" / "codesigning";
var execPath = basePath / "tool" / (OperatingSystem.IsWindows() ? "SignClient.exe" : "SignClient");
if (!File.Exists(execPath))
{
DotNetToolInstall(s => s.SetToolInstallationPath(basePath / "tool").SetPackageName("SignClient"));
outputs = outputs.Concat
(
DotNetToolInstall(s => s.SetToolInstallationPath(basePath / "tool").SetPackageName("SignClient"))
);
}

foreach (var pkg in Packages)
{
StartProcess
var proc = StartProcess
(
execPath,
"sign " +
Expand All @@ -475,7 +501,10 @@ async Task PushPackages()
"--name \"Silk.NET\" " +
"--description \"Silk.NET\" " +
"--descriptionUrl \"https://github.com/dotnet/Silk.NET\""
).AssertZeroExitCode();
);

proc.AssertZeroExitCode();
outputs = outputs.Concat(proc.Output);
}
}

Expand All @@ -484,11 +513,6 @@ async Task PushPackages()
.Select(x => x.Select(v => v.Value).ToList())
.ToList();
var first = true;
var pushed = 0;
var feed = NuGetInterface.OpenNuGetFeed(NugetFeed, NugetUsername, NugetPassword);
var uploadResource = await NuGetInterface.GetUploadResourceAsync(feed);
var symbolsResource = await NuGetInterface.GetSymbolsUploadResourceAsync(feed);
var exceptions = new List<Exception>();
Logger.Info($"Searching for packages in \"{RootDirectory / "build" / "output_packages"}\"...");
foreach (var files in allFiles)
{
Expand All @@ -501,33 +525,33 @@ async Task PushPackages()
await Task.Delay(TimeSpan.FromHours(1));
}

foreach (var file in files)
var srcSettings = new DotNetNuGetAddSourceSettings().SetName("Silk-PushPackages").SetSource(NugetFeed);
if (NugetUsername is not null || NugetPassword is not null)
{
try
{
await NuGetInterface.UploadPackageAsync
(uploadResource, NugetNoServiceEndpoint, file, NugetApiKey, symbolsResource);
pushed++;
}
catch (Exception ex)
if (NugetUsername is null || NugetPassword is null)
{
if (file.Contains(".Native.")) // native packages have their own update cycle
{
Logger.Warn(ex);
}
else
{
exceptions.Add(new Exception($"Failed to push package \"{file}\"", ex));
}
ControlFlow.Fail
(
"Both \"NugetUsername\" and \"NugetPassword\" must be specified if either are used."
);
}

srcSettings = srcSettings.SetUsername(NugetUsername).SetPassword(NugetPassword);
}
}

outputs = outputs.Concat(DotNetNuGetAddSource(srcSettings));

Logger.Success($"Successfully pushed {pushed} packages.");
foreach (var pushSettings in files.Select(file => new DotNetNuGetPushSettings()
.SetNoServiceEndpoint(NugetNoServiceEndpoint)
.EnableSkipDuplicate()
.SetTargetPath(file)))
{
outputs = outputs.Concat(DotNetNuGetPush(pushSettings));
}

if (exceptions.Count > 0)
{
throw new AggregateException(exceptions);
outputs = outputs.Concat(DotNet($"dotnet nuget remove source \"Silk-PushPackages\""));
}

return outputs;
}
}
8 changes: 6 additions & 2 deletions build/nuke/Projects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using JetBrains.Annotations;

using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
Expand Down Expand Up @@ -65,7 +65,11 @@ bool hasDesktopMsBuild
}

var sln = ParseSolution(originalSolutionPath);
featureSetSpecificSolutions[featureSet.Name] = (sln, featureSet.RequiresDesktopMsBuild);
if (featureSetUsed)
{
featureSetSpecificSolutions[featureSet.Name] = (sln, featureSet.RequiresDesktopMsBuild);
}

foreach (var removal in rm)
{
sln.RemoveProject(sln.GetProject(removal));
Expand Down
Loading