aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2019-08-21 17:14:18 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2019-08-21 19:25:22 +0300
commit1579ba28b53e579fc4d24a202ca870c8c29b96d7 (patch)
tree2f8c294486a7260f9be8b22660ef422def380eff
parentignore stack.yaml.lock (diff)
downloadwindows-env-1579ba28b53e579fc4d24a202ca870c8c29b96d7.tar.gz
windows-env-1579ba28b53e579fc4d24a202ca870c8c29b96d7.zip
add AppVeyor configuration
Diffstat (limited to '')
-rw-r--r--.appveyor/build.ps173
-rw-r--r--appveyor.yml8
2 files changed, 81 insertions, 0 deletions
diff --git a/.appveyor/build.ps1 b/.appveyor/build.ps1
new file mode 100644
index 0000000..c4c6117
--- /dev/null
+++ b/.appveyor/build.ps1
@@ -0,0 +1,73 @@
+param(
+ [string] $Platform = $null
+)
+
+$ErrorActionPreference = "Stop";
+
+function Invoke-Exe {
+ param(
+ [ScriptBlock] $Cmd,
+ [int[]] $AllowedExitCodes = @(0)
+ )
+
+ $backupErrorActionPreference = $script:ErrorActionPreference
+ $script:ErrorActionPreference = 'Continue'
+
+ try {
+ & $Cmd
+ if ($AllowedExitCodes -notcontains $LastExitCode) {
+ throw "External command failed with exit code ${LastExitCode}: $Cmd"
+ }
+ } finally {
+ $script:ErrorActionPreference = $backupErrorActionPreference
+ }
+}
+
+function Test-AppVeyor {
+ return Test-Path env:APPVEYOR
+}
+
+function Get-StackUrl {
+ param(
+ [Parameter(Mandatory=$true)]
+ [string] $Platform
+ )
+
+ if ($Platform -eq 'x86_64') {
+ return 'https://get.haskellstack.org/stable/windows-x86_64.zip'
+ } else {
+ return 'https://get.haskellstack.org/stable/windows-i386.zip'
+ }
+}
+
+function Install-Stack {
+ param(
+ [Parameter(Mandatory=$true)]
+ [string] $Platform
+ )
+
+ Invoke-Exe { curl.exe --silent --show-error --output C:\stack.zip --location --insecure -- $(Get-StackUrl -Platform $Platform) }
+ Invoke-Exe { 7z.exe x -oC:\sr C:\stack.zip }
+ $env:STACK_ROOT = 'C:\sr'
+}
+
+function Build-Project {
+ param(
+ [Parameter(Mandatory=$true)]
+ [string] $Platform
+ )
+
+ Invoke-Exe { C:\sr\stack.exe build --install-ghc --arch $Platform }
+}
+
+if (Test-AppVeyor) {
+ $cwd = pwd
+ $Platform = $env:PLATFORM
+}
+
+Install-Stack -Platform $Platform
+Build-Project -Platform $Platform
+
+if (Test-AppVeyor) {
+ cd $cwd
+}
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..930b997
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,8 @@
+version: '{build}'
+
+platform:
+ - i386
+ - x86_64
+
+build_script:
+ - ps: .\.appveyor\build.ps1