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 all 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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ _ReSharper*/
*.pidb
*.userprefs
*.swp
*.DotSettings
*.DotSettings

!Lib/NativeBinaries/x86/*.pdb
!Lib/NativeBinaries/amd64/*.pdb
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "libgit2"]
path = libgit2
url = https://github.com/libgit2/libgit2.git
url = https://github.com/carlosmn/libgit2.git
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ install:
script:
- git submodule update --init
- mkdir cmake-build
- LIBGIT2SHA=`cat ./LibGit2Sharp/libgit2_hash.txt`
- SHORTSHA=${LIBGIT2SHA:0:7}
- cd cmake-build
- cmake -DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./libgit2-bin ../libgit2
- cmake -DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_CLAR=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./libgit2-bin -DSONAME_APPEND=$SHORTSHA ../libgit2
- export LD_LIBRARY_PATH=$PWD/libgit2-bin/lib
- cmake --build . --target install
- cd ..
Expand Down
5 changes: 5 additions & 0 deletions Lib/Libgit2sharp.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<configuration>
<dllmap os="!windows,osx" dll="git2.3bbc87d" target="git2.so"/>
<dllmap os="osx" dll="git2.3bbc87d" target="git2.dylib"/>
<dllmap os="windows" dll="git2.3bbc87d" target="git2.3bbc87d.dll"/>
</configuration>
Binary file added Lib/NativeBinaries/amd64/git2-3bbc87d.dll
Binary file not shown.
Binary file not shown.
Binary file removed Lib/NativeBinaries/amd64/git2.dll
Binary file not shown.
Binary file added Lib/NativeBinaries/x86/git2-3bbc87d.dll
Binary file not shown.
Binary file not shown.
Binary file removed Lib/NativeBinaries/x86/git2.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@
</CreateItem>
<Copy SourceFiles="@(NativeBinaries)" DestinationFiles="@(NativeBinaries->'$(OutputPath)NativeBinaries\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
</Project>
</Project>
7 changes: 7 additions & 0 deletions LibGit2Sharp/Core/NativeDllName.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace LibGit2Sharp.Core
{
internal static class NativeDllName
{
public const string Name = "git2-3bbc87d";
}
}
2 changes: 1 addition & 1 deletion LibGit2Sharp/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace LibGit2Sharp.Core
internal static class NativeMethods
{
public const uint GIT_PATH_MAX = 4096;
private const string libgit2 = "git2";
private const string libgit2 = NativeDllName.Name;
private static readonly LibraryLifetimeObject lifetimeObject;
private static int handlesCount;

Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/Core/UnSafeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace LibGit2Sharp.Core
{
internal static unsafe class UnSafeNativeMethods
{
private const string libgit2 = "git2";
private const string libgit2 = NativeDllName.Name;

[DllImport(libgit2)]
internal static extern int git_reference_list(out git_strarray array, RepositorySafeHandle repo, GitReferenceType flags);
Expand Down
3 changes: 2 additions & 1 deletion 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 @@ -271,4 +272,4 @@
</CreateItem>
<Copy SourceFiles="@(NativeBinaries)" DestinationFiles="@(NativeBinaries->'$(OutputPath)NativeBinaries\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
</Project>
</Project>
2 changes: 1 addition & 1 deletion LibGit2Sharp/libgit2_hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b641c00eebb3c60e8719c0dfc55dde91ca30a5d2
3bbc87d697b24725beb8dcd41fa83ca604d3a9e2
33 changes: 29 additions & 4 deletions 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 @@ -111,6 +112,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 @@ -119,26 +121,49 @@ Push-Location $libgit2Directory
Run-Command -Quiet { & remove-item build -recurse -force }
Run-Command -Quiet { & mkdir build }
cd build
Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs" -D THREADSAFE=ON -D "BUILD_CLAR=$build_clar" .. }
Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs" -D THREADSAFE=ON -D "BUILD_CLAR=$build_clar" -D "SONAME_APPEND=$shortsha" .. }
Run-Command -Quiet -Fatal { & $cmake --build . --config $configuration }
if ($test.IsPresent) { Run-Command -Quiet -Fatal { & $ctest -V . } }
cd $configuration
Run-Command -Quiet { & rm *.exp }
Run-Command -Quiet { & rm $x86Directory\* }
Run-Command -Quiet -Fatal { & copy -fo * $x86Directory }

Write-Output "Building 64-bit..."
cd ..
Run-Command -Quiet { & mkdir build64 }
cd build64
Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs Win64" -D THREADSAFE=ON -D "BUILD_CLAR=$build_clar" ../.. }
Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs Win64" -D THREADSAFE=ON -D "BUILD_CLAR=$build_clar" -D "SONAME_APPEND=$shortsha" ../.. }
Run-Command -Quiet -Fatal { & $cmake --build . --config $configuration }
if ($test.IsPresent) { Run-Command -Quiet -Fatal { & $ctest -V . } }
cd $configuration
Run-Command -Quiet { & rm *.exp }
Run-Command -Quiet { & rm $x64Directory\* }
Run-Command -Quiet -Fatal { & copy -fo * $x64Directory }

Write-Output "Done!"
pop-location
sc -Encoding UTF8 libgit2sharp\libgit2_hash.txt $sha

$dllMap = @"
<configuration>
<dllmap os="!windows,osx" dll="git2.$shortsha" target="git2.so"/>
<dllmap os="osx" dll="git2.$shortsha" target="git2.dylib"/>
<dllmap os="windows" dll="git2.$shortsha" target="git2.$shortsha.dll"/>
</configuration>
"@
$dllNameClass = @"
namespace LibGit2Sharp.Core
{
internal static class NativeDllName
{
public const string Name = "git2-$shortsha";
}
}
"@

sc -Encoding ASCII .\Libgit2sharp\Core\NativeDllName.cs $dllNameClass
sc -Encoding ASCII .\Lib\Libgit2sharp.dll.config $dllMap
sc -Encoding ASCII libgit2sharp\libgit2_hash.txt $sha

Write-Output "Done!"
}
exit
6 changes: 5 additions & 1 deletion build.libgit2sharp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

PREVIOUS_LD=$LD_LIBRARY_PATH

LIBGIT2SHA=`cat ./LibGit2Sharp/libgit2_hash.txt`
SHORTSHA=${LIBGIT2SHA:0:7}
echo $SHORTSHA

rm -rf cmake-build
mkdir cmake-build && cd cmake-build

cmake -DBUILD_SHARED_LIBS:BOOL=ON -DTHREADSAFE:BOOL=ON -DBUILD_CLAR:BOOL=OFF -DCMAKE_INSTALL_PREFIX=./libgit2-bin ../libgit2
cmake -DBUILD_SHARED_LIBS:BOOL=ON -DTHREADSAFE:BOOL=ON -DBUILD_CLAR:BOOL=OFF -DCMAKE_INSTALL_PREFIX=./libgit2-bin -DSONAME_APPEND=$SHORTSHA ../libgit2
cmake --build . --target install

LD_LIBRARY_PATH=$PWD/libgit2-bin/lib:$LD_LIBRARY_PATH
Expand Down
2 changes: 1 addition & 1 deletion libgit2
Submodule libgit2 updated 122 files