From f1e337c222164ea50cad56f6a29b198620081fd3 Mon Sep 17 00:00:00 2001
From: Sebastian Wilzbach <seb@wilzba.ch>
Date: Sat, 10 Jun 2017 18:10:44 +0200
Subject: [PATCH 1/5] Enable testing on Windows with AppVeyor

---
 appveyor.yml | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++
 build.bat    |  91 +++++++++++++++++++------------------
 2 files changed, 170 insertions(+), 44 deletions(-)
 create mode 100644 appveyor.yml

diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..8a2469b
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,123 @@
+platform: x64
+environment:
+ matrix:
+  - DC: dmd
+    DVersion: nightly
+    arch: x64
+  - DC: dmd
+    DVersion: nightly
+    arch: x86
+  - DC: dmd
+    DVersion: beta
+    arch: x64
+  - DC: dmd
+    DVersion: beta
+    arch: x86
+  - DC: dmd
+    DVersion: stable
+    arch: x64
+  - DC: dmd
+    DVersion: stable
+    arch: x86
+  - DC: ldc
+    DVersion: beta
+    arch: x86
+  - DC: ldc
+    DVersion: beta
+    arch: x64
+  - DC: ldc
+    DVersion: stable
+    arch: x86
+  - DC: ldc
+    DVersion: stable
+    arch: x64
+
+skip_tags: false
+branches:
+  only:
+    - master
+
+install:
+  - ps: function ResolveLatestDMD
+        {
+            $version = $env:DVersion;
+            if($version -eq "stable") {
+                $latest = (Invoke-WebRequest "http://downloads.dlang.org/releases/LATEST").toString();
+                $url = "http://downloads.dlang.org/releases/2.x/$($latest)/dmd.$($latest).windows.7z";
+            }elseif($version -eq "beta") {
+                $latest = (Invoke-WebRequest "http://downloads.dlang.org/pre-releases/LATEST").toString();
+                $latestVersion = $latest.split("-")[0].split("~")[0];
+                $url = "http://downloads.dlang.org/pre-releases/2.x/$($latestVersion)/dmd.$($latest).windows.7z";
+            }elseif($version -eq "nightly") {
+                $url = "http://nightlies.dlang.org/dmd-master-2017-05-20/dmd.master.windows.7z"
+            }else {
+                $url = "http://downloads.dlang.org/releases/2.x/$($version)/dmd.$($version).windows.7z";
+            }
+            $env:PATH += ";C:\dmd2\windows\bin;";
+            return $url;
+        }
+  - ps: function ResolveLatestLDC
+        {
+            $version = $env:DVersion;
+            if($version -eq "stable") {
+                $latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST").toString().replace("`n","").replace("`r","");
+                $url = "https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-win64-msvc.zip";
+            }elseif($version -eq "beta") {
+                $latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST_BETA").toString().replace("`n","").replace("`r","");
+                $url = "https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-win64-msvc.zip";
+            } else {
+                $latest = $version;
+                $url = "https://github.com/ldc-developers/ldc/releases/download/v$($version)/ldc2-$($version)-win64-msvc.zip";
+            }
+            $env:PATH += ";C:\ldc2-$($latest)-win64-msvc\bin";
+            $env:DC = "ldc2";
+            return $url;
+        }
+  - ps: function SetUpDCompiler
+        {
+            $env:toolchain = "msvc";
+            if($env:DC -eq "dmd"){
+              echo "downloading ...";
+              $url = ResolveLatestDMD;
+              echo $url;
+              Invoke-WebRequest $url -OutFile "c:\dmd.7z";
+              echo "finished.";
+              pushd c:\\;
+              7z x dmd.7z > $null;
+              popd;
+            }
+            elseif($env:DC -eq "ldc"){
+              echo "downloading ...";
+              $url = ResolveLatestLDC;
+              echo $url;
+              Invoke-WebRequest $url -OutFile "c:\ldc.zip";
+              echo "finished.";
+              pushd c:\\;
+              7z x ldc.zip > $null;
+              popd;
+            }
+        }
+  - ps: SetUpDCompiler
+
+build_script:
+  - ps: if($env:arch -eq "x86"){
+            $env:compilersetupargs = "x86";
+            $env:Darch = "x86";
+            $env:DConf = "m32";
+        }elseif($env:arch -eq "x64"){
+            $env:compilersetupargs = "amd64";
+            $env:Darch = "x86_64";
+            $env:DConf = "m64";
+        }
+  - ps: $env:compilersetup = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall";
+  - '"%compilersetup%" %compilersetupargs%'
+
+test_script:
+ - echo %PLATFORM%
+ - echo %Darch%
+ - echo %DC%
+ - echo %PATH%
+ - '%DC% --version'
+ - dub test --arch=%Darch% --compiler=%DC%
+ - git submodule update --init --recursive
+ - build.bat test
diff --git a/build.bat b/build.bat
index 04a988b..51cdf16 100644
--- a/build.bat
+++ b/build.bat
@@ -1,44 +1,47 @@
-@echo off
-setlocal enabledelayedexpansion
-
-set DFLAGS=-O -release -inline -version=StdLoggerDisableWarning
-set TESTFLAGS=-g -w -version=StdLoggerDisableWarning
-set CORE=
-set LIBDPARSE=
-set STD=
-set ANALYSIS=
-set INIFILED=
-set DSYMBOL=
-set CONTAINERS=
-set LIBDDOC=
-
-for %%x in (src\*.d) do set CORE=!CORE! %%x
-for %%x in (src\analysis\*.d) do set ANALYSIS=!ANALYSIS! %%x
-for %%x in (libdparse\src\dparse\*.d) do set LIBDPARSE=!LIBDPARSE! %%x
-for %%x in (libdparse\src\std\experimental\*.d) do set LIBDPARSE=!LIBDPARSE! %%x
-for %%x in (libddoc\src\ddoc\*.d) do set LIBDDOC=!LIBDDOC! %%x
-for %%x in (inifiled\source\*.d) do set INIFILED=!INIFILED! %%x
-for %%x in (dsymbol\src\dsymbol\*.d) do set DSYMBOL=!DSYMBOL! %%x
-for %%x in (dsymbol\src\dsymbol\builtin\*.d) do set DSYMBOL=!DSYMBOL! %%x
-for %%x in (dsymbol\src\dsymbol\conversion\*.d) do set DSYMBOL=!DSYMBOL! %%x
-for %%x in (containers\src\containers\*.d) do set CONTAINERS=!CONTAINERS! %%x
-for %%x in (containers\src\containers\internal\*.d) do set CONTAINERS=!CONTAINERS! %%x
-
-if "%1" == "test" goto test_cmd
-
-@echo on
-dmd %CORE% %STD% %LIBDPARSE% %LIBDDOC% %ANALYSIS% %INIFILED% %DSYMBOL% %CONTAINERS% %DFLAGS% -I"libdparse\src" -I"dsymbol\src" -I"containers\src" -I"libddoc\src" -ofbin\dscanner.exe
-goto eof
-
-:test_cmd
-@echo on
-set TESTNAME="bin\dscanner-unittest"
-dmd %STD% %LIBDPARSE% %LIBDDOC% %INIFILED% %DSYMBOL% %CONTAINERS% -I"libdparse\src" -I"dsymbol\src" -I"containers\src" -I"libddoc\src" -lib %TESTFLAGS% -of%TESTNAME%.lib
-if exist %TESTNAME%.lib dmd %CORE% %ANALYSIS% %TESTNAME%.lib -I"src" -I"inifiled\source" -I"libdparse\src" -I"dsymbol\src" -I"containers\src" -I"libddoc\src" -unittest %TESTFLAGS% -of%TESTNAME%.exe
-if exist %TESTNAME%.exe %TESTNAME%.exe
-
-if exist %TESTNAME%.obj del %TESTNAME%.obj
-if exist %TESTNAME%.lib del %TESTNAME%.lib
-if exist %TESTNAME%.exe del %TESTNAME%.exe
-
-:eof
+@echo off
+setlocal enabledelayedexpansion
+
+IF "%DC%"=="" SET DC="dmd"
+IF "%DC%"=="ldc2" SET DC="ldmd2"
+
+set DFLAGS=-O -release -inline -version=StdLoggerDisableWarning
+set TESTFLAGS=-g -w -version=StdLoggerDisableWarning
+set CORE=
+set LIBDPARSE=
+set STD=
+set ANALYSIS=
+set INIFILED=
+set DSYMBOL=
+set CONTAINERS=
+set LIBDDOC=
+
+for %%x in (src\*.d) do set CORE=!CORE! %%x
+for %%x in (src\analysis\*.d) do set ANALYSIS=!ANALYSIS! %%x
+for %%x in (libdparse\src\dparse\*.d) do set LIBDPARSE=!LIBDPARSE! %%x
+for %%x in (libdparse\src\std\experimental\*.d) do set LIBDPARSE=!LIBDPARSE! %%x
+for %%x in (libddoc\src\ddoc\*.d) do set LIBDDOC=!LIBDDOC! %%x
+for %%x in (inifiled\source\*.d) do set INIFILED=!INIFILED! %%x
+for %%x in (dsymbol\src\dsymbol\*.d) do set DSYMBOL=!DSYMBOL! %%x
+for %%x in (dsymbol\src\dsymbol\builtin\*.d) do set DSYMBOL=!DSYMBOL! %%x
+for %%x in (dsymbol\src\dsymbol\conversion\*.d) do set DSYMBOL=!DSYMBOL! %%x
+for %%x in (containers\src\containers\*.d) do set CONTAINERS=!CONTAINERS! %%x
+for %%x in (containers\src\containers\internal\*.d) do set CONTAINERS=!CONTAINERS! %%x
+
+if "%1" == "test" goto test_cmd
+
+@echo on
+%DC% %CORE% %STD% %LIBDPARSE% %LIBDDOC% %ANALYSIS% %INIFILED% %DSYMBOL% %CONTAINERS% %DFLAGS% -I"libdparse\src" -I"dsymbol\src" -I"containers\src" -I"libddoc\src" -ofbin\dscanner.exe
+goto eof
+
+:test_cmd
+@echo on
+set TESTNAME="bin\dscanner-unittest"
+%DC% %STD% %LIBDPARSE% %LIBDDOC% %INIFILED% %DSYMBOL% %CONTAINERS% -I"libdparse\src" -I"dsymbol\src" -I"containers\src" -I"libddoc\src" -lib %TESTFLAGS% -of%TESTNAME%.lib
+if exist %TESTNAME%.lib %DC% %CORE% %ANALYSIS% %TESTNAME%.lib -I"src" -I"inifiled\source" -I"libdparse\src" -I"dsymbol\src" -I"containers\src" -I"libddoc\src" -unittest %TESTFLAGS% -of%TESTNAME%.exe
+if exist %TESTNAME%.exe %TESTNAME%.exe
+
+if exist %TESTNAME%.obj del %TESTNAME%.obj
+if exist %TESTNAME%.lib del %TESTNAME%.lib
+if exist %TESTNAME%.exe del %TESTNAME%.exe
+
+:eof

From 84e49521e2d5c19e82720b7cfd010cb68d760f02 Mon Sep 17 00:00:00 2001
From: Sebastian Wilzbach <seb@wilzba.ch>
Date: Mon, 4 Dec 2017 04:32:46 +0100
Subject: [PATCH 2/5] Enable automatic releases for Windows

---
 appveyor.yml | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/appveyor.yml b/appveyor.yml
index 8a2469b..19aa110 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -121,3 +121,17 @@ test_script:
  - dub test --arch=%Darch% --compiler=%DC%
  - git submodule update --init --recursive
  - build.bat test
+ - build.bat
+
+deploy:
+  release: dscanner-v$(appveyor_build_version)
+  description: 'DScanner release'
+  provider: GitHub
+  auth_token:
+    secure: FhQH4pdE0v2jKANNhX5wlm1oKBfizXyArWUskWfL/bmxaTaLjeyduTzotBTzNQ4p
+  artifact: bin\dscanner.exe            # upload D-Scanner binary
+  draft: false
+  prerelease: true
+  on:
+    branch: master                 # release from master branch only
+    appveyor_repo_tag: true        # deploy on tag push only

From 67b9697be9a419b9430b7034970f7ab0b3d49120 Mon Sep 17 00:00:00 2001
From: Sebastian Wilzbach <seb@wilzba.ch>
Date: Mon, 4 Dec 2017 04:34:14 +0100
Subject: [PATCH 3/5] Remove nightly from AppVeyor

---
 appveyor.yml | 6 ------
 build.bat    | 4 ++--
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index 19aa110..e208809 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,12 +1,6 @@
 platform: x64
 environment:
  matrix:
-  - DC: dmd
-    DVersion: nightly
-    arch: x64
-  - DC: dmd
-    DVersion: nightly
-    arch: x86
   - DC: dmd
     DVersion: beta
     arch: x64
diff --git a/build.bat b/build.bat
index 51cdf16..4d35502 100644
--- a/build.bat
+++ b/build.bat
@@ -1,8 +1,8 @@
 @echo off
 setlocal enabledelayedexpansion
 
-IF "%DC%"=="" SET DC="dmd"
-IF "%DC%"=="ldc2" SET DC="ldmd2"
+if "%DC%"=="" set DC="dmd"
+if "%DC%"=="ldc2" set DC="ldmd2"
 
 set DFLAGS=-O -release -inline -version=StdLoggerDisableWarning
 set TESTFLAGS=-g -w -version=StdLoggerDisableWarning

From 7830eddc6166ab2fff02c462ca297fe79a88ff07 Mon Sep 17 00:00:00 2001
From: skl131313 <skl131313@users.noreply.github.com>
Date: Sat, 16 Dec 2017 10:05:27 -0500
Subject: [PATCH 4/5] Fix line endings of code being checked out for Appveyor.

---
 appveyor.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/appveyor.yml b/appveyor.yml
index e208809..d992c87 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -31,6 +31,9 @@ branches:
   only:
     - master
 
+init:
+  - git config --global core.autocrlf true
+
 install:
   - ps: function ResolveLatestDMD
         {

From c908c8d10f54d462e1faa1c53c85c17a1b502e27 Mon Sep 17 00:00:00 2001
From: Sebastian Wilzbach <seb@wilzba.ch>
Date: Sun, 17 Dec 2017 06:40:57 +0100
Subject: [PATCH 5/5] Temporarily disable ldc beta + ldc stable x86

---
 appveyor.yml | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/appveyor.yml b/appveyor.yml
index d992c87..2be4e70 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -13,15 +13,15 @@ environment:
   - DC: dmd
     DVersion: stable
     arch: x86
-  - DC: ldc
-    DVersion: beta
-    arch: x86
-  - DC: ldc
-    DVersion: beta
-    arch: x64
-  - DC: ldc
-    DVersion: stable
-    arch: x86
+  #- DC: ldc
+    #DVersion: beta
+    #arch: x86
+  #- DC: ldc
+    #DVersion: beta
+    #arch: x64
+  #- DC: ldc
+    #DVersion: stable
+    #arch: x86
   - DC: ldc
     DVersion: stable
     arch: x64