mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Build for the current OS when doing a CoreRT build
This commit is contained in:
parent
62d2b79d19
commit
f304f664f4
1 changed files with 43 additions and 7 deletions
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
@ -31,6 +32,9 @@ namespace LibHacBuild
|
||||||
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
|
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
|
||||||
public readonly string Configuration = IsLocalBuild ? "Debug" : "Release";
|
public readonly string Configuration = IsLocalBuild ? "Debug" : "Release";
|
||||||
|
|
||||||
|
[Parameter("Don't enable any size-reducing settings on native builds.")]
|
||||||
|
public readonly bool Untrimmed;
|
||||||
|
|
||||||
[Solution("LibHac.sln")] readonly Solution _solution;
|
[Solution("LibHac.sln")] readonly Solution _solution;
|
||||||
[GitRepository] readonly GitRepository _gitRepository;
|
[GitRepository] readonly GitRepository _gitRepository;
|
||||||
[GitVersion] readonly GitVersion _gitVersion;
|
[GitVersion] readonly GitVersion _gitVersion;
|
||||||
|
@ -48,18 +52,40 @@ namespace LibHacBuild
|
||||||
AbsolutePath NugetConfig => RootDirectory / "nuget.config";
|
AbsolutePath NugetConfig => RootDirectory / "nuget.config";
|
||||||
|
|
||||||
AbsolutePath CliMergedExe => ArtifactsDirectory / "hactoolnet.exe";
|
AbsolutePath CliMergedExe => ArtifactsDirectory / "hactoolnet.exe";
|
||||||
AbsolutePath CliNativeExe => ArtifactsDirectory / "hactoolnet_native.exe";
|
AbsolutePath CliNativeExe => ArtifactsDirectory / NativeProgramFilename;
|
||||||
|
|
||||||
Project LibHacProject => _solution.GetProject("LibHac").NotNull();
|
Project LibHacProject => _solution.GetProject("LibHac").NotNull();
|
||||||
Project LibHacTestProject => _solution.GetProject("LibHac.Tests").NotNull();
|
Project LibHacTestProject => _solution.GetProject("LibHac.Tests").NotNull();
|
||||||
Project HactoolnetProject => _solution.GetProject("hactoolnet").NotNull();
|
Project HactoolnetProject => _solution.GetProject("hactoolnet").NotNull();
|
||||||
|
|
||||||
|
private string NativeRuntime { get; set; }
|
||||||
|
private string NativeProgramFilename { get; set; }
|
||||||
|
|
||||||
string AppVeyorVersion { get; set; }
|
string AppVeyorVersion { get; set; }
|
||||||
Dictionary<string, object> VersionProps { get; set; } = new Dictionary<string, object>();
|
Dictionary<string, object> VersionProps { get; set; } = new Dictionary<string, object>();
|
||||||
|
|
||||||
private const string DotNetFeedSource = "https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json";
|
private const string DotNetFeedSource = "https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json";
|
||||||
const string CertFileName = "cert.pfx";
|
const string CertFileName = "cert.pfx";
|
||||||
|
|
||||||
|
public Build()
|
||||||
|
{
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
{
|
||||||
|
NativeRuntime = "win-x64";
|
||||||
|
NativeProgramFilename = "hactoolnet_native.exe";
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
{
|
||||||
|
NativeRuntime = "linux-x64";
|
||||||
|
NativeProgramFilename = "hactoolnet_native";
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
|
{
|
||||||
|
NativeRuntime = "osx-x64";
|
||||||
|
NativeProgramFilename = "hactoolnet_native";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool IsMasterBranch => _gitVersion?.BranchName.Equals("master") ?? false;
|
private bool IsMasterBranch => _gitVersion?.BranchName.Equals("master") ?? false;
|
||||||
|
|
||||||
Target SetVersion => _ => _
|
Target SetVersion => _ => _
|
||||||
|
@ -305,16 +331,26 @@ namespace LibHacBuild
|
||||||
DotNet($"add {nativeProject} package Microsoft.DotNet.ILCompiler --version 1.0.0-alpha-*");
|
DotNet($"add {nativeProject} package Microsoft.DotNet.ILCompiler --version 1.0.0-alpha-*");
|
||||||
|
|
||||||
DotNetPublishSettings publishSettings = new DotNetPublishSettings()
|
DotNetPublishSettings publishSettings = new DotNetPublishSettings()
|
||||||
.SetConfiguration(Configuration);
|
.SetConfiguration(Configuration)
|
||||||
|
|
||||||
DotNetPublish(s => publishSettings
|
|
||||||
.SetProject(nativeProject)
|
.SetProject(nativeProject)
|
||||||
.SetFramework("netcoreapp3.0")
|
.SetFramework("netcoreapp3.0")
|
||||||
.SetRuntime("win-x64")
|
.SetRuntime(NativeRuntime)
|
||||||
.SetOutput(CliNativeDir)
|
.SetOutput(CliNativeDir)
|
||||||
.SetProperties(VersionProps));
|
.SetProperties(VersionProps);
|
||||||
|
|
||||||
AbsolutePath tempExe = CliNativeDir / "hactoolnet_native.exe";
|
if (!Untrimmed)
|
||||||
|
{
|
||||||
|
publishSettings = publishSettings
|
||||||
|
.AddProperty("RootAllApplicationAssemblies", false)
|
||||||
|
.AddProperty("IlcGenerateCompleteTypeMetadata", false)
|
||||||
|
.AddProperty("IlcGenerateStackTraceData", false)
|
||||||
|
.AddProperty("IlcFoldIdenticalMethodBodies", true)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
DotNetPublish(publishSettings);
|
||||||
|
|
||||||
|
AbsolutePath tempExe = CliNativeDir / NativeProgramFilename;
|
||||||
|
|
||||||
File.Copy(tempExe, CliNativeExe, true);
|
File.Copy(tempExe, CliNativeExe, true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue