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.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Linq;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using Nuke.Common;
|
||||
using Nuke.Common.CI.AppVeyor;
|
||||
|
@ -43,10 +42,9 @@ namespace LibHacBuild
|
|||
AbsolutePath TempDirectory => RootDirectory / ".tmp";
|
||||
AbsolutePath CliCoreDir => TempDirectory / "hactoolnet_netcoreapp3.1";
|
||||
AbsolutePath CliNativeDir => TempDirectory / $"hactoolnet_{HostOsName}";
|
||||
AbsolutePath CliNativeExe => CliNativeDir / $"hactoolnet_native{NativeProgramExtension}";
|
||||
AbsolutePath CliNativeExe => CliNativeDir / $"hactoolnet{NativeProgramExtension}";
|
||||
AbsolutePath CliCoreZip => ArtifactsDirectory / $"hactoolnet-{VersionString}-netcore.zip";
|
||||
AbsolutePath CliNativeZip => ArtifactsDirectory / $"hactoolnet-{VersionString}-{HostOsName}.zip";
|
||||
AbsolutePath NugetConfig => RootDirectory / "nuget.config";
|
||||
|
||||
Project LibHacProject => _solution.GetProject("LibHac").NotNull();
|
||||
Project LibHacTestProject => _solution.GetProject("LibHac.Tests").NotNull();
|
||||
|
@ -61,7 +59,6 @@ namespace LibHacBuild
|
|||
string VersionString { get; set; }
|
||||
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";
|
||||
|
||||
public Build()
|
||||
|
@ -270,6 +267,8 @@ namespace LibHacBuild
|
|||
.Concat(Directory.EnumerateFiles(CliCoreDir, "*.dll"))
|
||||
.ToArray();
|
||||
|
||||
EnsureExistingDirectory(ArtifactsDirectory);
|
||||
|
||||
ZipFiles(CliCoreZip, namesCore);
|
||||
Logger.Normal($"Created {CliCoreZip}");
|
||||
|
||||
|
@ -352,46 +351,26 @@ namespace LibHacBuild
|
|||
[SuppressMessage("ReSharper", "PossibleNullReferenceException")]
|
||||
public void BuildNative()
|
||||
{
|
||||
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", DotNetFeedSource)));
|
||||
|
||||
doc.Save(NugetConfig);
|
||||
|
||||
DotNet($"add {nativeProject} package Microsoft.DotNet.ILCompiler --version 1.0.0-alpha-*");
|
||||
string buildType = Untrimmed ? "native-untrimmed" : "native";
|
||||
|
||||
DotNetPublishSettings publishSettings = new DotNetPublishSettings()
|
||||
.SetConfiguration(Configuration)
|
||||
.SetProject(nativeProject)
|
||||
.SetFramework("netcoreapp3.1")
|
||||
.SetProject(HactoolnetProject)
|
||||
.SetRuntime(NativeRuntime)
|
||||
.SetOutput(CliNativeDir)
|
||||
.SetProperties(VersionProps);
|
||||
|
||||
if (!Untrimmed)
|
||||
{
|
||||
publishSettings = publishSettings
|
||||
.AddProperty("RootAllApplicationAssemblies", false)
|
||||
.AddProperty("IlcGenerateCompleteTypeMetadata", false)
|
||||
.AddProperty("IlcGenerateStackTraceData", false)
|
||||
.AddProperty("IlcFoldIdenticalMethodBodies", true)
|
||||
;
|
||||
}
|
||||
.SetProperties(VersionProps)
|
||||
.AddProperty("BuildType", buildType);
|
||||
|
||||
DotNetPublish(publishSettings);
|
||||
|
||||
if (EnvironmentInfo.IsUnix && !Untrimmed)
|
||||
{
|
||||
File.Copy(CliNativeExe, CliNativeExe + "_unstripped");
|
||||
ProcessTasks.StartProcess("strip", CliNativeExe).AssertZeroExitCode();
|
||||
}
|
||||
|
||||
EnsureExistingDirectory(ArtifactsDirectory);
|
||||
|
||||
ZipFile(CliNativeZip, CliNativeExe, $"hactoolnet{NativeProgramExtension}");
|
||||
Logger.Normal($"Created {CliNativeZip}");
|
||||
|
||||
|
@ -400,12 +379,6 @@ namespace LibHacBuild
|
|||
PushArtifact(CliNativeZip);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(nativeProject);
|
||||
File.Delete(NugetConfig);
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -20,4 +20,25 @@
|
|||
<ProjectReference Include="..\LibHac\LibHac.csproj" />
|
||||
</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>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
|
Loading…
Reference in a new issue