mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Add CoreRT build option (#63)
This commit is contained in:
parent
e8847243d9
commit
b361567977
1 changed files with 60 additions and 2 deletions
|
@ -1,11 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Xml.Linq;
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
using ILRepacking;
|
using ILRepacking;
|
||||||
using Nuke.Common;
|
using Nuke.Common;
|
||||||
|
@ -43,10 +45,13 @@ namespace LibHacBuild
|
||||||
AbsolutePath TempDirectory => RootDirectory / ".tmp";
|
AbsolutePath TempDirectory => RootDirectory / ".tmp";
|
||||||
AbsolutePath CliCoreDir => TempDirectory / "hactoolnet_netcoreapp2.1";
|
AbsolutePath CliCoreDir => TempDirectory / "hactoolnet_netcoreapp2.1";
|
||||||
AbsolutePath CliFrameworkDir => TempDirectory / "hactoolnet_net46";
|
AbsolutePath CliFrameworkDir => TempDirectory / "hactoolnet_net46";
|
||||||
|
AbsolutePath CliNativeDir => TempDirectory / "hactoolnet_native";
|
||||||
AbsolutePath CliFrameworkZip => ArtifactsDirectory / "hactoolnet.zip";
|
AbsolutePath CliFrameworkZip => ArtifactsDirectory / "hactoolnet.zip";
|
||||||
AbsolutePath CliCoreZip => ArtifactsDirectory / "hactoolnet_netcore.zip";
|
AbsolutePath CliCoreZip => ArtifactsDirectory / "hactoolnet_netcore.zip";
|
||||||
|
AbsolutePath NugetConfig => RootDirectory / "nuget.config";
|
||||||
|
|
||||||
AbsolutePath CliMergedExe => ArtifactsDirectory / "hactoolnet.exe";
|
AbsolutePath CliMergedExe => ArtifactsDirectory / "hactoolnet.exe";
|
||||||
|
AbsolutePath CliNativeExe => ArtifactsDirectory / "hactoolnet_native.exe";
|
||||||
|
|
||||||
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();
|
||||||
|
@ -55,8 +60,11 @@ namespace LibHacBuild
|
||||||
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 MyGetSource = "https://dotnet.myget.org/F/dotnet-core/api/v3/index.json";
|
||||||
const string CertFileName = "cert.pfx";
|
const string CertFileName = "cert.pfx";
|
||||||
|
|
||||||
|
private bool IsMasterBranch => _gitVersion?.BranchName.Equals("master") ?? false;
|
||||||
|
|
||||||
Target SetVersion => _ => _
|
Target SetVersion => _ => _
|
||||||
.OnlyWhenStatic(() => _gitRepository != null)
|
.OnlyWhenStatic(() => _gitRepository != null)
|
||||||
.Executes(() =>
|
.Executes(() =>
|
||||||
|
@ -107,6 +115,7 @@ namespace LibHacBuild
|
||||||
EnsureCleanDirectory(ArtifactsDirectory);
|
EnsureCleanDirectory(ArtifactsDirectory);
|
||||||
EnsureCleanDirectory(CliCoreDir);
|
EnsureCleanDirectory(CliCoreDir);
|
||||||
EnsureCleanDirectory(CliFrameworkDir);
|
EnsureCleanDirectory(CliFrameworkDir);
|
||||||
|
EnsureCleanDirectory(CliNativeDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
Target Restore => _ => _
|
Target Restore => _ => _
|
||||||
|
@ -268,7 +277,6 @@ namespace LibHacBuild
|
||||||
|
|
||||||
Target Publish => _ => _
|
Target Publish => _ => _
|
||||||
.DependsOn(Test)
|
.DependsOn(Test)
|
||||||
.OnlyWhenStatic(() => Host == HostType.AppVeyor)
|
|
||||||
.OnlyWhenStatic(() => AppVeyor.Instance != null && AppVeyor.Instance.PullRequestTitle == null)
|
.OnlyWhenStatic(() => AppVeyor.Instance != null && AppVeyor.Instance.PullRequestTitle == null)
|
||||||
.Executes(() =>
|
.Executes(() =>
|
||||||
{
|
{
|
||||||
|
@ -286,8 +294,58 @@ namespace LibHacBuild
|
||||||
DotNetNuGetPush(settings.SetTargetPath(snupkgFile));
|
DotNetNuGetPush(settings.SetTargetPath(snupkgFile));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
[SuppressMessage("ReSharper", "PossibleNullReferenceException")]
|
||||||
|
Target Native => _ => _
|
||||||
|
.DependsOn(SetVersion)
|
||||||
|
.OnlyWhenStatic(() => AppVeyor.Instance != null && IsMasterBranch)
|
||||||
|
.Executes(() =>
|
||||||
|
{
|
||||||
|
AbsolutePath nativeProject = HactoolnetProject.Path.Parent / "hactoolnet_native.csproj";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Copy(HactoolnetProject, nativeProject, true);
|
||||||
|
DotNet("new nuget --force");
|
||||||
|
|
||||||
|
XDocument doc = XDocument.Load(NugetConfig);
|
||||||
|
doc.Element("configuration").Element("packageSources").Add(new XElement("add",
|
||||||
|
new XAttribute("key", "myget"), new XAttribute("value", MyGetSource)));
|
||||||
|
|
||||||
|
doc.Save(NugetConfig);
|
||||||
|
|
||||||
|
DotNet($"add {nativeProject} package Microsoft.DotNet.ILCompiler --version 1.0.0-alpha-*");
|
||||||
|
|
||||||
|
DotNetPublishSettings publishSettings = new DotNetPublishSettings()
|
||||||
|
.SetConfiguration(Configuration);
|
||||||
|
|
||||||
|
DotNetPublish(s => publishSettings
|
||||||
|
.SetProject(nativeProject)
|
||||||
|
.SetFramework("netcoreapp2.1")
|
||||||
|
.SetRuntime("win-x64")
|
||||||
|
.SetOutput(CliNativeDir)
|
||||||
|
.SetProperties(VersionProps));
|
||||||
|
|
||||||
|
AbsolutePath tempExe = CliNativeDir / "hactoolnet_native.exe";
|
||||||
|
|
||||||
|
File.Copy(tempExe, CliNativeExe, true);
|
||||||
|
|
||||||
|
if (Host == HostType.AppVeyor)
|
||||||
|
{
|
||||||
|
AbsolutePath zipFile = CliNativeExe.Parent / "hactoolnet_native.zip";
|
||||||
|
ZipFiles(zipFile, new[] { CliNativeExe.ToString() });
|
||||||
|
|
||||||
|
PushArtifact(zipFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
File.Delete(nativeProject);
|
||||||
|
File.Delete(NugetConfig);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Target Results => _ => _
|
Target Results => _ => _
|
||||||
.DependsOn(Test, Zip, Merge, Sign, Publish)
|
.DependsOn(Test, Zip, Merge, Sign, Native, Publish)
|
||||||
.Executes(() =>
|
.Executes(() =>
|
||||||
{
|
{
|
||||||
Console.WriteLine("SHA-1:");
|
Console.WriteLine("SHA-1:");
|
||||||
|
|
Loading…
Reference in a new issue