Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit-binary.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Ungureanu <marius.ungureanu@xamarin.com>2015-06-28 18:25:33 +0300
committerMarius Ungureanu <marius.ungureanu@xamarin.com>2015-06-28 19:05:45 +0300
commitd5e38737e3549ed07a0382821a88ecb7583ffd28 (patch)
tree7e132a8a081564dee276efad48a2e3564b68328b
parent04ec6079ed1d6ac8d95bc26add4595d0d0a53e93 (diff)
Initial scripts.
-rw-r--r--build.libgit2.ps1132
-rw-r--r--build.libgit2.sh47
2 files changed, 179 insertions, 0 deletions
diff --git a/build.libgit2.ps1 b/build.libgit2.ps1
new file mode 100644
index 0000000..f989f4f
--- /dev/null
+++ b/build.libgit2.ps1
@@ -0,0 +1,132 @@
+<#
+.SYNOPSIS
+ Builds a version of libgit2 and copies it to the nuget packaging directory.
+.PARAMETER vs
+ Version of Visual Studio project files to generate. Cmake supports "10", "11" and "12" (default).
+#>
+
+Param(
+ [string]$vs = '12'
+)
+
+Set-StrictMode -Version Latest
+
+$projectDirectory = Split-Path $MyInvocation.MyCommand.Path
+$libgit2Directory = Join-Path $projectDirectory "external\libgit2"
+$x86Directory = Join-Path $projectDirectory "windows"
+#$x64Directory = Join-Path $projectDirectory "windows64"
+$hashFile = Join-Path $projectDirectory "libgit2_hash.txt"
+$sha = Get-Content $hashFile
+$binaryFilename = "git2-" + $sha.Substring(0,7)
+$configuration = "RelWithDebInfo"
+
+function Run-Command([scriptblock]$Command, [switch]$Fatal, [switch]$Quiet) {
+ $output = ""
+ if ($Quiet) {
+ $output = & $Command 2>&1
+ } else {
+ & $Command
+ }
+
+ if (!$Fatal) {
+ return
+ }
+
+ $exitCode = 0
+ if ($LastExitCode -ne 0) {
+ $exitCode = $LastExitCode
+ } elseif (!$?) {
+ $exitCode = 1
+ } else {
+ return
+ }
+
+ $error = "``$Command`` failed"
+ if ($output) {
+ Write-Host -ForegroundColor yellow $output
+ $error += ". See output above."
+ }
+ Throw $error
+}
+
+function Find-CMake {
+ # Look for cmake.exe in $Env:PATH.
+ $cmake = @(Get-Command cmake.exe)[0] 2>$null
+ if ($cmake) {
+ $cmake = $cmake.Definition
+ } else {
+ # Look for the highest-versioned cmake.exe in its default location.
+ $cmake = @(Resolve-Path (Join-Path ${Env:ProgramFiles(x86)} "CMake *\bin\cmake.exe"))
+ if ($cmake) {
+ $cmake = $cmake[-1].Path
+ }
+ }
+ if (!$cmake) {
+ throw "Error: Can't find cmake.exe"
+ }
+ $cmake
+}
+
+function Ensure-Property($expected, $propertyValue, $propertyName, $path) {
+ if ($propertyValue -eq $expected) {
+ return
+ }
+
+ throw "Error: Invalid '$propertyName' property in generated '$path' (Expected: $expected - Actual: $propertyValue)"
+}
+
+function Assert-Consistent-Naming($expected, $path) {
+ $dll = get-item $path
+
+ Ensure-Property $expected $dll.Name "Name" $dll.Fullname
+ Ensure-Property $expected $dll.VersionInfo.InternalName "VersionInfo.InternalName" $dll.Fullname
+ Ensure-Property $expected $dll.VersionInfo.OriginalFilename "VersionInfo.OriginalFilename" $dll.Fullname
+}
+
+if (Test-Path(Join-Path $x86Directory "$binaryFilename.dll")) {
+ Write-Output "Binaries don't need rebuilding!"
+ Exit
+}
+
+try {
+ Push-Location $libgit2Directory
+
+ $cmake = Find-CMake
+
+ Write-Output "Building 32-bit..."
+ Run-Command { & remove-item build -recurse -force }
+ Run-Command { & mkdir build }
+ cd build
+ Run-Command -Fatal { & $cmake -G "Visual Studio $vs" -D ENABLE_TRACE=ON -D "LIBGIT2_FILENAME=$binaryFilename" -DSTDCALL=ON -D "EMBED_SSH_PATH=../libssh2" -DBUILD_CLAR:BOOL=OFF \ .. }
+ Run-Command -Fatal { & $cmake --build . --config $configuration }
+ cd $configuration
+ Assert-Consistent-Naming "$binaryFilename.dll" "*.dll"
+
+ Pop-Location
+
+ Run-Command { & rm "$libgit2Directory\build\$configuration\*.exp" }
+ if (Test-Path "$x86Directory\*") {
+ Run-Command { & git rm "$x86Directory\*" }
+ }
+ Run-Command { & mkdir -fo "$x86Directory" }
+ Run-Command { & copy -fo "$libgit2Directory\build\$configuration\*" -Destination $x86Directory -Exclude *.lib }
+ Run-Command { & git add "$x86Directory" }
+
+ #Write-Output "Building 64-bit..."
+ #cd ..
+ #Run-Command { & mkdir build64 }
+ #cd build64
+ #Run-Command -Fatal { & $cmake -G "Visual Studio $vs Win64" -D THREADSAFE=ON -D ENABLE_TRACE=ON -D "LIBGIT2_FILENAME=$binaryFilename" -DSTDCALL=ON ../.. }
+ #Run-Command -Fatal { & $cmake --build . --config $configuration }
+ #cd $configuration
+ #Assert-Consistent-Naming "$binaryFilename.dll" "*.dll"
+ #Run-Command { & rm *.exp }
+ #Run-Command { & rm $x64Directory\* }
+ #Run-Command { & mkdir -fo $x64Directory }
+ #Run-Command -Fatal { & copy -fo * $x64Directory -Exclude *.lib }
+
+ Write-Output "Done!"
+}
+finally {
+ Pop-Location
+}
diff --git a/build.libgit2.sh b/build.libgit2.sh
new file mode 100644
index 0000000..b948793
--- /dev/null
+++ b/build.libgit2.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+LIBGIT2SHA=`cat ./libgit2_hash.txt`
+SHORTSHA=${LIBGIT2SHA:0:7}
+
+if [[ -d external/libgit2/build ]]
+then
+ if [[ -n $(ls libgit2-${SHORTSHA}.*) ]]
+ then
+ exit 0
+ fi
+fi
+
+rm -rf external/libgit2/build
+mkdir external/libgit2/build
+pushd external/libgit2/build
+
+export _BINPATH=`pwd`
+
+cmake -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
+ -DBUILD_CLAR:BOOL=OFF \
+ -DUSE_SSH=ON \
+ -DENABLE_TRACE=ON \
+ -DLIBGIT2_FILENAME=git2-$SHORTSHA \
+ -DCMAKE_OSX_ARCHITECTURES="i386" \
+ -DCMAKE_SKIP_RPATH=TRUE
+ ..
+cmake --build .
+
+popd
+
+OS=`uname`
+ARCH=`uname -m`
+
+if [ $OS == "Darwin" ]; then
+ PKGPATH="./mac"
+ LIBEXT="dylib"
+else
+ exit 0
+fi
+
+git rm $PKGPATH/*
+mkdir -p $PKGPATH
+
+cp external/libgit2/build/libgit2-$SHORTSHA.$LIBEXT $PKGPATH/
+
+exit $?