Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit cf758bd

Browse files
committed
Install hoogle only if not found
1 parent 0fdf478 commit cf758bd

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

install.hs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,19 @@ cabalInstallHie versionNumber = do
198198
(localBin </> "hie-" ++ dropExtension versionNumber <.> exe)
199199

200200
cabalBuildDoc :: Action ()
201-
cabalBuildDoc = do
202-
execCabal_ ["new-install", "hoogle"]
201+
cabalBuildDoc = generateHoogleDatabase $ do
202+
localBin <- getLocalBin
203+
execCabal_ ["new-install", "--symlink-bindir=" ++ localBin, "hoogle"]
203204
execCabal_ ["new-exec", "hoogle", "generate"]
204205

206+
generateHoogleDatabase :: Action () -> Action ()
207+
generateHoogleDatabase installIfNecessary = do
208+
mayHoogle <- liftIO $ findExecutable "hoogle"
209+
case mayHoogle of
210+
Nothing -> installIfNecessary
211+
Just hoogle -> command_ [] "hoogle" ["generate"]
212+
213+
205214
cabalTest :: VersionNumber -> Action ()
206215
cabalTest versionNumber = do
207216
configureCabal versionNumber
@@ -238,7 +247,7 @@ stackTest :: VersionNumber -> Action ()
238247
stackTest versionNumber = execStackWithYaml_ versionNumber ["test"]
239248

240249
stackBuildDoc :: Action ()
241-
stackBuildDoc = do
250+
stackBuildDoc = generateHoogleDatabase $ do
242251
execStack_ ["--stack-yaml=shake.yaml", "install", "hoogle"]
243252
execStack_ ["--stack-yaml=shake.yaml", "exec", "hoogle", "generate"]
244253

0 commit comments

Comments
 (0)