11<#
22. SYNOPSIS
33 Builds a version of libgit2 and copies it to the nuget packaging directory.
4- . PARAMETER vs
5- Version of Visual Studio project files to generate. Cmake supports "10" (default), "11" and "12".
64. PARAMETER test
75 If set, run the libgit2 tests on the desired version.
86. PARAMETER debug
9- If set, build the "Debug" configuration of libgit2, rather than "RelWithDebInfo " (default).
7+ If set, build the "Debug" configuration of libgit2, rather than "Release " (default).
108#>
119
1210Param (
13- [string ]$vs = ' 10' ,
1411 [string ]$libgit2Name = ' ' ,
1512 [switch ]$test ,
16- [switch ]$debug
13+ [switch ]$debug ,
14+ [switch ]$x86 ,
15+ [switch ]$x64
1716)
1817
1918Set-StrictMode - Version Latest
@@ -34,7 +33,7 @@ if (![string]::IsNullOrEmpty($libgit2Name)) {
3433$build_clar = ' OFF'
3534if ($test.IsPresent ) { $build_clar = ' ON' }
3635
37- $configuration = " RelWithDebInfo "
36+ $configuration = " Release "
3837if ($debug.IsPresent ) { $configuration = " Debug" }
3938
4039function Run-Command ([scriptblock ]$Command , [switch ]$Fatal , [switch ]$Quiet ) {
@@ -106,33 +105,38 @@ try {
106105 $cmake = Find-CMake
107106 $ctest = Join-Path (Split-Path - Parent $cmake ) " ctest.exe"
108107
109- Write-Output " Building 32-bit..."
110- Run- Command - Quiet { & remove-item build - recurse - force }
108+ Run- Command - Quiet { & remove-item build - recurse - force - ErrorAction Ignore }
111109 Run- Command - Quiet { & mkdir build }
112110 cd build
113- Run- Command - Quiet - Fatal { & $cmake - G " Visual Studio $vs " - D ENABLE_TRACE= ON - D " BUILD_CLAR=$build_clar " - D " LIBGIT2_FILENAME=$binaryFilename " .. }
114- Run- Command - Quiet - Fatal { & $cmake -- build . -- config $configuration }
115- if ($test.IsPresent ) { Run- Command - Quiet - Fatal { & $ctest - V . } }
116- cd $configuration
117- Assert-Consistent - Naming " $binaryFilename .dll" " *.dll"
118- Run- Command - Quiet { & rm * .exp }
119- Run- Command - Quiet { & rm $x86Directory \* }
120- Run- Command - Quiet { & mkdir - fo $x86Directory }
121- Run- Command - Quiet - Fatal { & copy - fo * $x86Directory - Exclude * .lib }
122-
123- Write-Output " Building 64-bit..."
124- cd ..
125- Run- Command - Quiet { & mkdir build64 }
126- cd build64
127- Run- Command - Quiet - Fatal { & $cmake - G " Visual Studio $vs " - A x64 - D THREADSAFE= ON - D ENABLE_TRACE= ON - D " BUILD_CLAR=$build_clar " - D " LIBGIT2_FILENAME=$binaryFilename " ../ .. }
128- Run- Command - Quiet - Fatal { & $cmake -- build . -- config $configuration }
129- if ($test.IsPresent ) { Run- Command - Quiet - Fatal { & $ctest - V . } }
130- cd $configuration
131- Assert-Consistent - Naming " $binaryFilename .dll" " *.dll"
132- Run- Command - Quiet { & rm * .exp }
133- Run- Command - Quiet { & rm $x64Directory \* }
134- Run- Command - Quiet { & mkdir - fo $x64Directory }
135- Run- Command - Quiet - Fatal { & copy - fo * $x64Directory - Exclude * .lib }
111+
112+ if ($x86.IsPresent ) {
113+ Write-Output " Building 32-bit..."
114+ Run- Command - Fatal { & $cmake - G " Visual Studio 16 2019" - D ENABLE_TRACE= ON - D USE_SSH= OFF - D " BUILD_CLAR=$build_clar " - D " LIBGIT2_FILENAME=$binaryFilename " .. }
115+ Run- Command - Fatal { & $cmake -- build . -- config $configuration }
116+ if ($test.IsPresent ) { Run- Command - Quiet - Fatal { & $ctest - V . } }
117+ cd $configuration
118+ Assert-Consistent - Naming " $binaryFilename .dll" " *.dll"
119+ Run- Command - Quiet { & rm * .exp }
120+ Run- Command - Quiet { & rm $x86Directory \* - ErrorAction Ignore }
121+ Run- Command - Quiet { & mkdir - fo $x86Directory }
122+ Run- Command - Quiet - Fatal { & copy - fo * $x86Directory - Exclude * .lib }
123+ cd ..
124+ }
125+
126+ if ($x64.IsPresent ) {
127+ Write-Output " Building 64-bit..."
128+ Run- Command - Quiet { & mkdir build64 }
129+ cd build64
130+ Run- Command - Fatal { & $cmake - G " Visual Studio 16 2019" - A x64 - D THREADSAFE= ON - D USE_SSH= OFF - D ENABLE_TRACE= ON - D " BUILD_CLAR=$build_clar " - D " LIBGIT2_FILENAME=$binaryFilename " ../ .. }
131+ Run- Command - Fatal { & $cmake -- build . -- config $configuration }
132+ if ($test.IsPresent ) { Run- Command - Quiet - Fatal { & $ctest - V . } }
133+ cd $configuration
134+ Assert-Consistent - Naming " $binaryFilename .dll" " *.dll"
135+ Run- Command - Quiet { & rm * .exp }
136+ Run- Command - Quiet { & rm $x64Directory \* - ErrorAction Ignore }
137+ Run- Command - Quiet { & mkdir - fo $x64Directory }
138+ Run- Command - Quiet - Fatal { & copy - fo * $x64Directory - Exclude * .lib }
139+ }
136140
137141 Write-Output " Done!"
138142}
0 commit comments