Commit f7bb4ff80bfa5e5173232685b13f143b572f36de

Edward Thomson 2018-07-26T15:06:01

ci: use a single setup script for mingw

diff --git a/.vsts-ci.yml b/.vsts-ci.yml
index 07c38ee..2731e0a 100644
--- a/.vsts-ci.yml
+++ b/.vsts-ci.yml
@@ -176,10 +176,11 @@ phases:
   queue:
     name: Hosted
   steps:
-  - powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw-amd64.ps1'
+  - powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw.ps1'
     displayName: Setup
     env:
       TEMP: $(Agent.TempDirectory)
+      ARCH: amd64
   - powershell: . '$(Build.SourcesDirectory)\ci\build.ps1'
     displayName: Build
     env:
@@ -193,10 +194,11 @@ phases:
   queue:
     name: Hosted
   steps:
-  - powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw-x86.ps1'
+  - powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw.ps1'
     displayName: Setup
     env:
       TEMP: $(Agent.TempDirectory)
+      ARCH: x86
   - powershell: . '$(Build.SourcesDirectory)\ci\build.ps1'
     displayName: Build
     env:
diff --git a/ci/setup-mingw-amd64.ps1 b/ci/setup-mingw-amd64.ps1
deleted file mode 100644
index eaa6709..0000000
--- a/ci/setup-mingw-amd64.ps1
+++ /dev/null
@@ -1,20 +0,0 @@
-Set-StrictMode -Version Latest
-
-$ErrorActionPreference = "Stop"
-$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
-
-[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
-
-[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem");
-
-Write-Host "##############################################################################"
-Write-Host "## Downloading mingw"
-Write-Host "##############################################################################"
-
-$mingw_uri = "https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-x86_64-8.1.0-release-win32-seh-rt_v6-rev0.zip"
-$platform = "x86_64"
-
-$wc = New-Object net.webclient
-$wc.Downloadfile($mingw_uri, "${Env:TEMP}/mingw-${platform}.zip")
-
-[System.IO.Compression.ZipFile]::ExtractToDirectory("${Env:TEMP}/mingw-${platform}.zip", $Env:TEMP)
diff --git a/ci/setup-mingw-x86.ps1 b/ci/setup-mingw-x86.ps1
deleted file mode 100644
index 832c0f5..0000000
--- a/ci/setup-mingw-x86.ps1
+++ /dev/null
@@ -1,20 +0,0 @@
-Set-StrictMode -Version Latest
-
-$ErrorActionPreference = "Stop"
-$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
-
-[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
-
-[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem");
-
-Write-Host "##############################################################################"
-Write-Host "## Downloading mingw"
-Write-Host "##############################################################################"
-
-$mingw_uri = "https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip"
-$platform = "x86"
-
-$wc = New-Object net.webclient
-$wc.Downloadfile($mingw_uri, "${Env:TEMP}/mingw-${platform}.zip")
-
-[System.IO.Compression.ZipFile]::ExtractToDirectory("${Env:TEMP}/mingw-${platform}.zip", $Env:TEMP)
diff --git a/ci/setup-mingw.ps1 b/ci/setup-mingw.ps1
new file mode 100644
index 0000000..76ecd39
--- /dev/null
+++ b/ci/setup-mingw.ps1
@@ -0,0 +1,25 @@
+Set-StrictMode -Version Latest
+
+$ErrorActionPreference = "Stop"
+$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
+
+[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
+
+[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem");
+
+Write-Host "##############################################################################"
+Write-Host "## Downloading mingw"
+Write-Host "##############################################################################"
+
+if ($env:ARCH -eq "amd64") {
+	$mingw_uri = "https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-x86_64-8.1.0-release-win32-seh-rt_v6-rev0.zip"
+	$platform = "x86_64"
+} else {
+	$mingw_uri = "https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip"
+	$platform = "x86"
+}
+
+$wc = New-Object net.webclient
+$wc.Downloadfile($mingw_uri, "${Env:TEMP}/mingw-${Env:ARCH}.zip")
+
+[System.IO.Compression.ZipFile]::ExtractToDirectory("${Env:TEMP}/mingw-${Env:ARCH}.zip", $Env:TEMP)