Skip to content

Commit c927569

Browse files
Alexander OvchinnikovAlexander Ovchinnikov
authored andcommitted
Enable loading arm64 libgit2
1 parent e706a66 commit c927569

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

LibGit2Sharp.Tests/GlobalSettingsFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void CanGetMinimumCompiledInFeatures()
2222
public void CanRetrieveValidVersionString()
2323
{
2424
// Version string format is:
25-
// Major.Minor.Patch[-previewTag]+{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64 - features)
25+
// Major.Minor.Patch[-previewTag]+{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64|arm64 - features)
2626
// Example output:
2727
// "0.25.0-preview.52+871d13a67f.libgit2-15e1193 (x86 - Threads, Https)"
2828

@@ -31,7 +31,7 @@ public void CanRetrieveValidVersionString()
3131
// The GlobalSettings.Version returned string should contain :
3232
// version: '0.25.0[-previewTag]' LibGit2Sharp version number.
3333
// git2SharpHash: '871d13a67f' LibGit2Sharp hash.
34-
// arch: 'x86' or 'x64' libgit2 target.
34+
// arch: 'x86', 'x64' or 'arm64' libgit2 target.
3535
// git2Features: 'Threads, Ssh' libgit2 features compiled with.
3636
string regex = @"^(?<version>\d+\.\d+\.\d+(-[\w\-\.]+)?\+((?<git2SharpHash>[a-f0-9]{10})\.)?libgit2-[a-f0-9]{7}) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$";
3737

@@ -40,7 +40,7 @@ public void CanRetrieveValidVersionString()
4040
Match regexResult = Regex.Match(versionInfo, regex);
4141

4242
Assert.True(regexResult.Success, "The following version string format is enforced:" +
43-
"Major.Minor.Patch[-previewTag]+{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64 - features). " +
43+
"Major.Minor.Patch[-previewTag]+{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64|arm64 - features). " +
4444
"But found \"" + versionInfo + "\" instead.");
4545
}
4646

LibGit2Sharp/Core/Platform.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,28 @@ internal enum OperatingSystemType
1212

1313
internal static class Platform
1414
{
15-
public static string ProcessorArchitecture => IntPtr.Size == 8 ? "x64" : "x86";
15+
public static string ProcessorArchitecture
16+
{
17+
get
18+
{
19+
if (RuntimeInformation.ProcessArchitecture == Architecture.X86)
20+
{
21+
return "x86";
22+
}
23+
24+
if (RuntimeInformation.ProcessArchitecture == Architecture.X64)
25+
{
26+
return "x64";
27+
}
28+
29+
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
30+
{
31+
return "arm64";
32+
}
33+
34+
throw new PlatformNotSupportedException();
35+
}
36+
}
1637

1738
public static OperatingSystemType OperatingSystem
1839
{

LibGit2Sharp/GlobalSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public static LogConfiguration LogConfiguration
159159
/// <summary>
160160
/// Sets a path for loading native binaries on .NET Framework or .NET Core.
161161
/// When specified, native library will first be searched under the given path.
162-
/// On .NET Framework a subdirectory corresponding to the architecture ("x86" or "x64") is appended,
162+
/// On .NET Framework a subdirectory corresponding to the architecture ("x86", "x64" or "arm64") is appended,
163163
/// otherwise the native library is expected to be found in the directory as specified.
164164
///
165165
/// If the library is not found it will be searched in standard search paths:

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</ItemGroup>
3535

3636
<ItemGroup>
37-
<PackageReference Include="Mendix.LibGit2Sharp.NativeBinaries" Version="[1.110.1]" PrivateAssets="none" />
37+
<PackageReference Include="Mendix.LibGit2Sharp.NativeBinaries" Version="[1.110.10]" PrivateAssets="none" />
3838
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
3939
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.50" PrivateAssets="all" />
4040
</ItemGroup>

LibGit2Sharp/Version.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private string RetrieveAbbrevShaFrom(string sha)
5555
/// </summary>
5656
/// <para>
5757
/// The format of the version number is as follows:
58-
/// <para>Major.Minor.Patch[-previewTag]+{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64 - features)</para>
58+
/// <para>Major.Minor.Patch[-previewTag]+{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64|arm64 - features)</para>
5959
/// </para>
6060
/// <returns></returns>
6161
public override string ToString()

0 commit comments

Comments
 (0)