Skip to content

Commit

Permalink
Skip symlink only for haddock
Browse files Browse the repository at this point in the history
  • Loading branch information
jneira committed Feb 10, 2020
1 parent 87f41cf commit 257273c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/CabalHelper/Compiletime/CompPrograms.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,23 @@ patchBuildToolProgs SStack progs = do
-- being able to pass executable paths straight through to stack but
-- currently there is no option to let us do that.
withSystemTempDirectory "cabal-helper-symlinks" $ \bindir -> do
when (ghcProgram progs /= "ghc") $
createProgSymlink bindir $ ghcProgram progs
when (ghcPkgProgram progs /= "ghc-pkg") $
createProgSymlink bindir $ ghcPkgProgram progs
when (haddockProgram progs /= "haddock") $
createProgSymlink bindir $ haddockProgram progs
createProgSymlink True bindir $ ghcProgram progs
createProgSymlink True bindir $ ghcPkgProgram progs
createProgSymlink False bindir $ haddockProgram progs
return $ progs
{ stackEnv =
[("PATH", EnvPrepend $ bindir ++ [searchPathSeparator])] ++
stackEnv progs
}

createProgSymlink :: FilePath -> FilePath -> IO ()
createProgSymlink bindir target
createProgSymlink :: Bool -> FilePath -> FilePath -> IO ()
createProgSymlink required bindir target
| [exe] <- splitPath target = do
mb_exe_path <- findExecutable exe
case mb_exe_path of
Just exe_path -> createSymbolicLink exe_path (bindir </> takeFileName target)
Nothing -> error $ "Error trying to create symlink to " ++ target ++ ": "
++ exe ++ " executable not found."
Nothing -> when required $ error $ "Error trying to create symlink to " ++ target ++ ": "
++ exe ++ " executable not found."
| otherwise = do
cwd <- getCurrentDirectory
createSymbolicLink (cwd </> target) (bindir </> takeFileName target)

0 comments on commit 257273c

Please sign in to comment.