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

Commit b875e8d

Browse files
authored
Merge pull request #1151 from fendor/shake-remove-redundant-hoogle
Only generate hoogle database once
2 parents 70c2420 + cf758bd commit b875e8d

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

install.hs

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ type GhcPath = String
2929
-- If they are edited, make sure to maintain the order of the versions.
3030
hieVersions :: [VersionNumber]
3131
hieVersions =
32-
["8.2.1", "8.2.2", "8.4.2", "8.4.3", "8.4.4", "8.6.1", "8.6.2", "8.6.3", "8.6.4"]
32+
[ "8.2.1"
33+
, "8.2.2"
34+
, "8.4.2"
35+
, "8.4.3"
36+
, "8.4.4"
37+
, "8.6.1"
38+
, "8.6.2"
39+
, "8.6.3"
40+
, "8.6.4"
41+
]
3342

3443
-- |Most recent version of hie.
3544
-- Shown in the more concise help message.
@@ -74,9 +83,15 @@ main = do
7483
forM_ hieVersions stackTest
7584

7685
phony "build-copy-compiler-tool" $ forM_ hieVersions buildCopyCompilerTool
86+
87+
phony "stack-build-doc" stackBuildDoc
7788
forM_
7889
hieVersions
79-
(\version -> phony ("build-doc-" ++ version) $ stackBuildDoc version)
90+
(\version -> phony ("build-doc-" ++ version) $ do
91+
need ["submodules"]
92+
need ["cabal"]
93+
need ["stack-build-doc"]
94+
)
8095
forM_
8196
hieVersions
8297
(\version -> phony ("hie-" ++ version) $ do
@@ -96,12 +111,13 @@ main = do
96111
need ["cabal"]
97112
forM_ ghcVersions cabalTest
98113

114+
phony "cabal-doc" cabalBuildDoc
99115
forM_
100116
hieVersions
101117
(\version -> phony ("cabal-build-doc-" ++ version) $ do
102118
need ["submodules"]
103119
need ["cabal"]
104-
cabalBuildDoc version
120+
need ["cabal-doc"]
105121
)
106122
forM_
107123
hieVersions
@@ -181,12 +197,20 @@ cabalInstallHie versionNumber = do
181197
copyFile' (localBin </> "hie" <.> exe)
182198
(localBin </> "hie-" ++ dropExtension versionNumber <.> exe)
183199

184-
cabalBuildDoc :: VersionNumber -> Action ()
185-
cabalBuildDoc versionNumber = do
186-
configureCabal versionNumber
187-
execCabal_ ["new-install", "hoogle"]
200+
cabalBuildDoc :: Action ()
201+
cabalBuildDoc = generateHoogleDatabase $ do
202+
localBin <- getLocalBin
203+
execCabal_ ["new-install", "--symlink-bindir=" ++ localBin, "hoogle"]
188204
execCabal_ ["new-exec", "hoogle", "generate"]
189205

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+
190214
cabalTest :: VersionNumber -> Action ()
191215
cabalTest versionNumber = do
192216
configureCabal versionNumber
@@ -222,10 +246,10 @@ buildCopyCompilerTool versionNumber =
222246
stackTest :: VersionNumber -> Action ()
223247
stackTest versionNumber = execStackWithYaml_ versionNumber ["test"]
224248

225-
stackBuildDoc :: VersionNumber -> Action ()
226-
stackBuildDoc versionNumber = do
227-
execStackWithYaml_ versionNumber ["install", "hoogle"]
228-
execStackWithYaml_ versionNumber ["exec", "hoogle", "generate"]
249+
stackBuildDoc :: Action ()
250+
stackBuildDoc = generateHoogleDatabase $ do
251+
execStack_ ["--stack-yaml=shake.yaml", "install", "hoogle"]
252+
execStack_ ["--stack-yaml=shake.yaml", "exec", "hoogle", "generate"]
229253

230254
shortHelpMessage :: Action ()
231255
shortHelpMessage = do

0 commit comments

Comments
 (0)