Skip to content

Commit 7e9326b

Browse files
authored
Write a cabal.project file in the benchmark example (#640)
* Write a cabal.project file As suggested in #617. Taken fron #624 * Write a cabal.project.local Otherwise Cabal still errors out * Override default hie dir Otherwise .hi and .hie files end up in different locations, which causes the getDefinition experiment to fail the second time it's run. This is because we assume in ghcide that .hi and .hie files have the same lifetimes, which is not true when the ..hie files are wiped but the .hi files aren't.
1 parent 0e96f61 commit 7e9326b

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

bench/Main.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,13 @@ setup = do
373373
writeFile
374374
(examplesPath </> examplePackage </> "hie.yaml")
375375
exampleCradle
376+
-- Need this in case there is a parent cabal.project somewhere
377+
writeFile
378+
(examplesPath </> examplePackage </> "cabal.project")
379+
"packages: ."
380+
writeFile
381+
(examplesPath </> examplePackage </> "cabal.project.local")
382+
""
376383

377384
whenJust (shakeProfiling ?config) $ createDirectoryIfMissing True
378385

exe/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ setCacheDir logger prefix hscComponents comps dflags = do
502502
liftIO $ logInfo logger $ "Using interface files cache dir: " <> T.pack cacheDir
503503
pure $ dflags
504504
& setHiDir cacheDir
505-
& setDefaultHieDir cacheDir
505+
& setHieDir cacheDir
506506

507507

508508
renderCradleError :: NormalizedFilePath -> CradleError -> FileDiagnostic

src/Development/IDE/GHC/Compat.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module Development.IDE.GHC.Compat(
1616
writeHieFile,
1717
readHieFile,
1818
supportsHieFiles,
19-
setDefaultHieDir,
19+
setHieDir,
2020
dontWriteHieFiles,
2121
#if !MIN_GHC_API_VERSION(8,8,0)
2222
ml_hie_file,
@@ -67,7 +67,6 @@ import HscTypes (mi_mod_hash)
6767
#endif
6868

6969
#if MIN_GHC_API_VERSION(8,8,0)
70-
import Control.Applicative ((<|>))
7170
import Development.IDE.GHC.HieAst (mkHieFile)
7271
import HieBin
7372
import HieTypes
@@ -191,10 +190,10 @@ pattern IEThingAll a <-
191190
GHC.IEThingAll a
192191
#endif
193192

194-
setDefaultHieDir :: FilePath -> DynFlags -> DynFlags
195-
setDefaultHieDir _f d =
193+
setHieDir :: FilePath -> DynFlags -> DynFlags
194+
setHieDir _f d =
196195
#if MIN_GHC_API_VERSION(8,8,0)
197-
d { hieDir = hieDir d <|> Just _f}
196+
d { hieDir = Just _f}
198197
#else
199198
d
200199
#endif

src/Development/IDE/GHC/Util.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module Development.IDE.GHC.Util(
2525
-- * General utilities
2626
readFileUtf8,
2727
hDuplicateTo',
28-
setDefaultHieDir,
28+
setHieDir,
2929
dontWriteHieFiles
3030
) where
3131

0 commit comments

Comments
 (0)