diff options
Diffstat (limited to 'driver/ghci/ghci.c')
-rw-r--r-- | driver/ghci/ghci.c | 13 |
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); } |