Skip to content

Commit

Permalink
Merge pull request #5753 from hvr/pr/findexe-win32
Browse files Browse the repository at this point in the history
Fix `--with-compiler` failing to locate compiler on Windows
  • Loading branch information
23Skidoo authored Dec 5, 2018
2 parents 202b3ed + a0d7bc8 commit c25a223
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Cabal/Distribution/Simple/Program/Find.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ findProgramOnSearchPath verbosity searchpath prog = do
-- On windows, getSystemSearchPath is not guaranteed 100% correct so we
-- use findExecutable and then approximate the not-found-at locations.
tryPathElem ProgramSearchPathDefault | buildOS == Windows = do
mExe <- findExecutable prog
mExe <- firstJustM [ findExecutable (prog <.> ext) | ext <- exeExtensions ]
syspath <- getSystemSearchPath
case mExe of
Nothing ->
Expand Down Expand Up @@ -130,6 +130,15 @@ findProgramOnSearchPath verbosity searchpath prog = do
then return (Just f, reverse fs')
else go (f:fs') fs

-- Helper for evaluating actions until the first one returns 'Just'
firstJustM :: Monad m => [m (Maybe a)] -> m (Maybe a)
firstJustM [] = return Nothing
firstJustM (ma:mas) = do
a <- ma
case a of
Just _ -> return a
Nothing -> firstJustM mas

-- | Interpret a 'ProgramSearchPath' to construct a new @$PATH@ env var.
-- Note that this is close but not perfect because on Windows the search
-- algorithm looks at more than just the @%PATH%@.
Expand Down

0 comments on commit c25a223

Please sign in to comment.