8000 Introduce SSH linking in the scripts. · GiTechLab/libgit2sharp@8000ec8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8000ec8

Browse files
committed
Introduce SSH linking in the scripts.
1 parent 2e3b534 commit 8000ec8

9 files changed

+35
-4
lines changed
0 Bytes
Binary file not shown.
-32 KB
Binary file not shown.
0 Bytes
Binary file not shown.
-48 KB
Binary file not shown.

LibGit2Sharp.Tests/GlobalSettingsFixture.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Text.RegularExpressions;
22
using LibGit2Sharp.Tests.TestHelpers;
33
using Xunit;
4+
using System.Globalization;
5+
using System.IO;
46

57
namespace LibGit2Sharp.Tests
68
{
@@ -13,6 +15,14 @@ public void CanGetMinimumCompiledInFeatures()
1315

1416
Assert.True(features.HasFlag(BuiltInFeatures.Threads));
1517
Assert.True(features.HasFlag(BuiltInFeatures.Https));
18+
19+
bool hasSsh;
20+
using (var sr = new StreamReader(typeof(GlobalSettingsFixture).Assembly.GetManifestResourceStream("LibGit2Sharp.Tests.ssh_used.txt")))
21+
{
22+
if (!bool.TryParse(sr.ReadLine(), out hasSsh))
23+
hasSsh = false;
24+
}
25+
Assert.Equal(hasSsh, features.HasFlag(BuiltInFeatures.Ssh));
1626
}
1727

1828
[Fact]

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,7 @@
157157
<Target Name="AfterBuild">
158158
</Target>
159159
-->
160+
<ItemGroup>
161+
<EmbeddedResource Include="ssh_used.txt" />
162+
</ItemGroup>
160163
</Project>

LibGit2Sharp.Tests/ssh_used.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
False

UpdateLibgit2ToSha.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
If set, run the libgit2 tests on the desired version.
1212
.PARAMETER debug
1313
If set, build the "Debug" configuration of libgit2, rather than "RelWithDebInfo" (default).
14+
.PARAMETER ssh
15+
If set embeds SSH at the path pointed to by the value.
1416
#>
1517

1618
Param(
1719
[string]$sha = 'HEAD',
1820
[string]$vs = '10',
1921
[string]$libgit2Name = '',
2022
[switch]$test,
21-
[switch]$debug
23+
[switch]$debug,
24+
[string]$ssh = ''
2225
)
2326

2427
Set-StrictMode -Version Latest
@@ -28,12 +31,19 @@ $libgit2sharpDirectory = Split-Path $MyInvocation.MyCommand.Path
2831
$libgit2Directory = Join-Path $libgit2sharpDirectory "libgit2"
2932
$x86Directory = Join-Path $libgit2sharpDirectory "Lib\NativeBinaries\x86"
3033
$x64Directory = Join-Path $libgit2sharpDirectory "Lib\NativeBinaries\amd64"
34+
$sshFile = Join-Path $libgit2sharpDirectory "LibGit2Sharp.Tests\ssh_used.txt"
3135

3236
$build_clar = 'OFF'
3337
if ($test.IsPresent) { $build_clar = 'ON' }
3438
$configuration = "RelWithDebInfo"
3539
if ($debug.IsPresent) { $configuration = "Debug" }
3640

41+
if (![string]::IsNullOrEmpty($libgit2Name)) {
42+
$embed_ssh = '-DEMBED_SSH_PATH="$ssh"'
43+
} else {
44+
$embed_ssh = ''
45+
}
46+
3747
function Run-Command([scriptblock]$Command, [switch]$Fatal, [switch]$Quiet) {
3848
$output = ""
3949
if ($Quiet) {
@@ -144,7 +154,7 @@ function Assert-Consistent-Naming($expected, $path) {
144154
Run-Command -Quiet { & remove-item build -recurse -force }
145155
Run-Command -Quiet { & mkdir build }
146156
cd build
147-
Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs" -D ENABLE_TRACE=ON -D "BUILD_CLAR=$build_clar" -D "LIBGIT2_FILENAME=$binaryFilename" -DSTDCALL=ON .. }
157+
Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs" -D THREADSAFE=ON -D ENABLE_TRACE=ON -D "BUILD_CLAR=$build_clar" -D "LIBGIT2_FILENAME=$binaryFilename" -DSTDCALL=ON $embed_ssh .. }
148158
Run-Command -Quiet -Fatal { & $cmake --build . --config $configuration }
149159
if ($test.IsPresent) { Run-Command -Quiet -Fatal { & $ctest -V . } }
150160
cd $configuration
@@ -157,7 +167,7 @@ function Assert-Consistent-Naming($expected, $path) {
157167
cd ..
158168
Run-Command -Quiet { & mkdir build64 }
159169
cd build64
160-
Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs Win64" -D THREADSAFE=ON -D ENABLE_TRACE=ON -D "BUILD_CLAR=$build_clar" -D "LIBGIT2_FILENAME=$binaryFilename" -DSTDCALL=ON ../.. }
170+
Run-Command -Quiet -Fatal { & $cmake -G "Visual Studio $vs Win64" -D THREADSAFE=ON -D ENABLE_TRACE=ON -D "BUILD_CLAR=$build_clar" -D "LIBGIT2_FILENAME=$binaryFilename" -DSTDCALL=ON $embed_ssh ../.. }
161171
Run-Command -Quiet -Fatal { & $cmake --build . --config $configuration }
162172
if ($test.IsPresent) { Run-Command -Quiet -Fatal { & $ctest -V . } }
163173
cd $configuration
@@ -180,6 +190,7 @@ namespace LibGit2Sharp.Core
180190

181191
sc -Encoding ASCII (Join-Path $libgit2sharpDirectory "Libgit2sharp\Core\NativeDllName.cs") $dllNameClass
182192
sc -Encoding ASCII (Join-Path $libgit2sharpDirectory "Libgit2sharp\libgit2_hash.txt") $sha
193+
sc -Encoding ASCII (Join-Path $libgit2sharpDirectory "Libgit2sharp.Tests\ssh_used.txt") (![string]::IsNullOrEmpty($ssh))
183194

184195
$buildProperties = @"
185196
<?xml version="1.0" encoding="utf-8"?>

build.libgit2sharp.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
LIBGIT2SHA=`cat ./LibGit2Sharp/libgit2_hash.txt`
44
SHORTSHA=${LIBGIT2SHA:0:7}
55
EXTRADEFINE="$1"
6+
USESSH=${1-OFF}
7+
SSH_FILE="LibGit2Sharp.Tests/ssh_used.txt"
68

79
rm -rf libgit2/build
810
mkdir libgit2/build
@@ -11,13 +13,17 @@ export _BINPATH=`pwd`
1113

1214
cmake -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
1315
-DBUILD_CLAR:BOOL=OFF \
14-
-DUSE_SSH=OFF \
16+
-DUSE_SSH=$USESSH \
1517
-DENABLE_TRACE=ON \
1618
-DLIBGIT2_FILENAME=git2-$SHORTSHA \
1719
-DCMAKE_OSX_ARCHITECTURES="i386;x86_64" \
1820
..
1921
cmake --build .
2022

23+
shopt -s nocasematch
24+
[[ USESSH == "ON" ]] && echo "True" > $SSH_FILE || echo "False" > $SSH_FILE
25+
shopt -u nocasematch
26+
2127
export LD_LIBRARY_PATH=$_BINPATH:$LD_LIBRARY_PATH
2228
export DYLD_LIBRARY_PATH=$_BINPATH:$DYLD_LIBRARY_PATH
2329

0 commit comments

Comments
 (0)
0