summaryrefslogtreecommitdiff
path: root/driver/ghci
diff options
context:
space:
mode:
authorRyanGlScott <ryan.gl.scott@gmail.com>2016-01-06 23:10:54 +0100
committerBen Gamari <ben@smart-cactus.org>2016-01-06 23:11:35 +0100
commitf01eb5410d7980567bf2731b9cded9a4894a3ef5 (patch)
treec5e9811c7ed16944a01734077f879481a1ad2dc9 /driver/ghci
parent7861a22561846eef9a6415a93d79e121dca9c05f (diff)
downloadhaskell-f01eb5410d7980567bf2731b9cded9a4894a3ef5.tar.gz
Fall back on ghc-stage2 when using Windows' GHCi driver
Reviewers: austin, hvr, bgamari, thomie Reviewed By: thomie Differential Revision: https://phabricator.haskell.org/D1721
Diffstat (limited to 'driver/ghci')
-rw-r--r--driver/ghci/ghci.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/driver/ghci/ghci.c b/driver/ghci/ghci.c
index 414521f97d..f358d960d7 100644
--- a/driver/ghci/ghci.c
+++ b/driver/ghci/ghci.c
@@ -3,6 +3,12 @@
#include "getLocation.h"
#include <stdio.h>
#include <stdlib.h>
+#include <windows.h>
+
+BOOL fileExists(const char *path) {
+ const DWORD r = GetFileAttributesA(path);
+ return r != INVALID_FILE_ATTRIBUTES && !(r & FILE_ATTRIBUTE_DIRECTORY);
+}
int main(int argc, char** argv) {
char *binDir;
@@ -19,6 +25,13 @@ int main(int argc, char** argv) {
exePath = mkString("%s/ghc.exe", binDir);
preArgv[0] = "--interactive";
+ /* If ghc.exe can't be found, we assume that we're building ghc from
+ * source, in which case we fall back on ghc-stage2.
+ */
+ if (!fileExists(exePath)) {
+ exePath = mkString("%s/ghc-stage2.exe", binDir);
+ }
+
run(exePath, 1, preArgv, argc - 1, argv + 1);
}