[commit: ghc] master: Fall back on ghc-stage2 when using Windows' GHCi driver (f01eb54)
git at git.haskell.org
git at git.haskell.org
Wed Jan 6 22:10:50 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/f01eb5410d7980567bf2731b9cded9a4894a3ef5/ghc
>---------------------------------------------------------------
commit f01eb5410d7980567bf2731b9cded9a4894a3ef5
Author: RyanGlScott <ryan.gl.scott at gmail.com>
Date: Wed Jan 6 23:10:54 2016 +0100
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
>---------------------------------------------------------------
f01eb5410d7980567bf2731b9cded9a4894a3ef5
driver/ghci/ghci.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/driver/ghci/ghci.c b/driver/ghci/ghci.c
index 414521f..f358d96 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);
}
More information about the ghc-commits
mailing list