Skip to content

Libgit2 dll naming #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions LibGit2Sharp/Core/NativeDllName.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

namespace LibGit2Sharp.Core
{
internal static partial class NativeMethods
{
private const string libgit2 = "git2_b641c00";
}
}

3 changes: 1 addition & 2 deletions LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
// ReSharper disable InconsistentNaming
namespace LibGit2Sharp.Core
{
internal static class NativeMethods
internal static partial class NativeMethods
{
public const uint GIT_PATH_MAX = 4096;
private const string libgit2 = "git2";
private static readonly LibraryLifetimeObject lifetimeObject;
private static int handlesCount;

Expand Down
4 changes: 4 additions & 0 deletions LibGit2Sharp/LibGit2Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<Compile Include="Changes.cs" />
<Compile Include="CheckoutCallbacks.cs" />
<Compile Include="CheckoutOptions.cs" />
<Compile Include="Core\NativeDllName.cs" />
<Compile Include="ObjectType.cs" />
<Compile Include="ReferenceExtensions.cs" />
<Compile Include="Conflict.cs" />
Expand Down Expand Up @@ -258,6 +259,9 @@
<ItemGroup>
<EmbeddedResource Include="libgit2sharp_hash.txt" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a letfover from the T4 tryout. You're right, it should be removed.

</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
Expand Down
23 changes: 22 additions & 1 deletion UpdateLibgit2ToSha.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Param(
[switch]$debug
)


Set-StrictMode -Version Latest

$self = Split-Path -Leaf $MyInvocation.MyCommand.Path
Expand Down Expand Up @@ -89,6 +90,12 @@ function Find-Git {
throw "Error: Can't find git"
}

function Rename-Binaries ([string]$extension) {
ls | foreach {
mv $_ ($_.BaseName + "_" + $extension + $_.Extension)
}
}

Push-Location $libgit2Directory

& {
Expand All @@ -111,6 +118,7 @@ Push-Location $libgit2Directory
popd
break
}
$shortsha = $sha.Substring(0,7)

Write-Output "Checking out $sha..."
Run-Command -Quiet -Fatal { & $git checkout $sha }
Expand All @@ -124,6 +132,7 @@ Push-Location $libgit2Directory
if ($test.IsPresent) { Run-Command -Quiet -Fatal { & $ctest -V . } }
cd $configuration
Run-Command -Quiet { & rm *.exp }
Rename-Binaries $shortsha
Run-Command -Quiet -Fatal { & copy -fo * $x86Directory }

Write-Output "Building 64-bit..."
Expand All @@ -135,10 +144,22 @@ Push-Location $libgit2Directory
if ($test.IsPresent) { Run-Command -Quiet -Fatal { & $ctest -V . } }
cd $configuration
Run-Command -Quiet { & rm *.exp }
Rename-Binaries $shortsha
Run-Command -Quiet -Fatal { & copy -fo * $x64Directory }

Write-Output "Done!"
pop-location
$dllNameClass = "
namespace LibGit2Sharp.Core
{
internal static partial class NativeMethods
{
private const string libgit2 = `"git2_$shortsha`";
}
}
"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a "here-string" to avoid escaping:

$dllNameClass = @"
...
    private const string libgit2 = "git2_$shortsha";
...
"@

sc -Encoding UTF8 .\Libgit2sharp\Core\NativeDllName.cs $dllNameClass
sc -Encoding UTF8 libgit2sharp\libgit2_hash.txt $sha
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this one ASCII?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made them all ASCII. BOMs suck, man.


Write-Output "Done!"
}
exit