mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Simplify CoreRT build
This commit is contained in:
parent
3c7f1692b7
commit
857bde67ee
4 changed files with 54 additions and 54 deletions
|
@ -7,7 +7,6 @@ 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 Nuke.Common;
|
using Nuke.Common;
|
||||||
using Nuke.Common.CI.AppVeyor;
|
using Nuke.Common.CI.AppVeyor;
|
||||||
|
@ -43,10 +42,9 @@ namespace LibHacBuild
|
||||||
AbsolutePath TempDirectory => RootDirectory / ".tmp";
|
AbsolutePath TempDirectory => RootDirectory / ".tmp";
|
||||||
AbsolutePath CliCoreDir => TempDirectory / "hactoolnet_netcoreapp3.1";
|
AbsolutePath CliCoreDir => TempDirectory / "hactoolnet_netcoreapp3.1";
|
||||||
AbsolutePath CliNativeDir => TempDirectory / $"hactoolnet_{HostOsName}";
|
AbsolutePath CliNativeDir => TempDirectory / $"hactoolnet_{HostOsName}";
|
||||||
AbsolutePath CliNativeExe => CliNativeDir / $"hactoolnet_native{NativeProgramExtension}";
|
AbsolutePath CliNativeExe => CliNativeDir / $"hactoolnet{NativeProgramExtension}";
|
||||||
AbsolutePath CliCoreZip => ArtifactsDirectory / $"hactoolnet-{VersionString}-netcore.zip";
|
AbsolutePath CliCoreZip => ArtifactsDirectory / $"hactoolnet-{VersionString}-netcore.zip";
|
||||||
AbsolutePath CliNativeZip => ArtifactsDirectory / $"hactoolnet-{VersionString}-{HostOsName}.zip";
|
AbsolutePath CliNativeZip => ArtifactsDirectory / $"hactoolnet-{VersionString}-{HostOsName}.zip";
|
||||||
AbsolutePath NugetConfig => RootDirectory / "nuget.config";
|
|
||||||
|
|
||||||
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();
|
||||||
|
@ -61,7 +59,6 @@ namespace LibHacBuild
|
||||||
string VersionString { get; set; }
|
string VersionString { 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";
|
|
||||||
const string CertFileName = "cert.pfx";
|
const string CertFileName = "cert.pfx";
|
||||||
|
|
||||||
public Build()
|
public Build()
|
||||||
|
@ -270,6 +267,8 @@ namespace LibHacBuild
|
||||||
.Concat(Directory.EnumerateFiles(CliCoreDir, "*.dll"))
|
.Concat(Directory.EnumerateFiles(CliCoreDir, "*.dll"))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
EnsureExistingDirectory(ArtifactsDirectory);
|
||||||
|
|
||||||
ZipFiles(CliCoreZip, namesCore);
|
ZipFiles(CliCoreZip, namesCore);
|
||||||
Logger.Normal($"Created {CliCoreZip}");
|
Logger.Normal($"Created {CliCoreZip}");
|
||||||
|
|
||||||
|
@ -352,46 +351,26 @@ namespace LibHacBuild
|
||||||
[SuppressMessage("ReSharper", "PossibleNullReferenceException")]
|
[SuppressMessage("ReSharper", "PossibleNullReferenceException")]
|
||||||
public void BuildNative()
|
public void BuildNative()
|
||||||
{
|
{
|
||||||
AbsolutePath nativeProject = HactoolnetProject.Path.Parent / "hactoolnet_native.csproj";
|
string buildType = Untrimmed ? "native-untrimmed" : "native";
|
||||||
|
|
||||||
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", DotNetFeedSource)));
|
|
||||||
|
|
||||||
doc.Save(NugetConfig);
|
|
||||||
|
|
||||||
DotNet($"add {nativeProject} package Microsoft.DotNet.ILCompiler --version 1.0.0-alpha-*");
|
|
||||||
|
|
||||||
DotNetPublishSettings publishSettings = new DotNetPublishSettings()
|
DotNetPublishSettings publishSettings = new DotNetPublishSettings()
|
||||||
.SetConfiguration(Configuration)
|
.SetConfiguration(Configuration)
|
||||||
.SetProject(nativeProject)
|
.SetProject(HactoolnetProject)
|
||||||
.SetFramework("netcoreapp3.1")
|
|
||||||
.SetRuntime(NativeRuntime)
|
.SetRuntime(NativeRuntime)
|
||||||
.SetOutput(CliNativeDir)
|
.SetOutput(CliNativeDir)
|
||||||
.SetProperties(VersionProps);
|
.SetProperties(VersionProps)
|
||||||
|
.AddProperty("BuildType", buildType);
|
||||||
if (!Untrimmed)
|
|
||||||
{
|
|
||||||
publishSettings = publishSettings
|
|
||||||
.AddProperty("RootAllApplicationAssemblies", false)
|
|
||||||
.AddProperty("IlcGenerateCompleteTypeMetadata", false)
|
|
||||||
.AddProperty("IlcGenerateStackTraceData", false)
|
|
||||||
.AddProperty("IlcFoldIdenticalMethodBodies", true)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
DotNetPublish(publishSettings);
|
DotNetPublish(publishSettings);
|
||||||
|
|
||||||
if (EnvironmentInfo.IsUnix && !Untrimmed)
|
if (EnvironmentInfo.IsUnix && !Untrimmed)
|
||||||
{
|
{
|
||||||
|
File.Copy(CliNativeExe, CliNativeExe + "_unstripped");
|
||||||
ProcessTasks.StartProcess("strip", CliNativeExe).AssertZeroExitCode();
|
ProcessTasks.StartProcess("strip", CliNativeExe).AssertZeroExitCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnsureExistingDirectory(ArtifactsDirectory);
|
||||||
|
|
||||||
ZipFile(CliNativeZip, CliNativeExe, $"hactoolnet{NativeProgramExtension}");
|
ZipFile(CliNativeZip, CliNativeExe, $"hactoolnet{NativeProgramExtension}");
|
||||||
Logger.Normal($"Created {CliNativeZip}");
|
Logger.Normal($"Created {CliNativeZip}");
|
||||||
|
|
||||||
|
@ -400,12 +379,6 @@ namespace LibHacBuild
|
||||||
PushArtifact(CliNativeZip);
|
PushArtifact(CliNativeZip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
File.Delete(nativeProject);
|
|
||||||
File.Delete(NugetConfig);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ZipFiles(string outFile, IEnumerable<string> files)
|
public static void ZipFiles(string outFile, IEnumerable<string> files)
|
||||||
{
|
{
|
||||||
|
|
6
nuget.config
Normal file
6
nuget.config
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<LangVersion>8.0</LangVersion>
|
<LangVersion>8.0</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -20,4 +20,25 @@
|
||||||
<ProjectReference Include="..\LibHac\LibHac.csproj" />
|
<ProjectReference Include="..\LibHac\LibHac.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Options for use with CoreRT -->
|
||||||
|
<ItemGroup Condition=" $(BuildType.StartsWith('native')) ">
|
||||||
|
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-*" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" $(BuildType.StartsWith('native')) and '$(BuildType)' != 'native-untrimmed' ">
|
||||||
|
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies>
|
||||||
|
<IlcGenerateCompleteTypeMetadata>false</IlcGenerateCompleteTypeMetadata>
|
||||||
|
<IlcOptimizationPreference>Speed</IlcOptimizationPreference>
|
||||||
|
<RootAllApplicationAssemblies>false</RootAllApplicationAssemblies>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup Condition=" $(BuildType.StartsWith('native')) and '$(BuildType)' != 'native-untrimmed' ">
|
||||||
|
<IlcArg Include="--removefeature:EventSource" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- No-reflection mode doesn't work yet -->
|
||||||
|
<PropertyGroup Condition=" '$(BuildType)' == 'native-noreflection' ">
|
||||||
|
<IlcDisableReflection>true</IlcDisableReflection>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
Loading…
Reference in a new issue