Skip to content

Commit e771ccb

Browse files
committed
Check ghc supports -hiedir flag
1 parent 7b047d4 commit e771ccb

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

Cabal/src/Distribution/Simple/GHC/ImplInfo.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ data GhcImplInfo = GhcImplInfo
5252
-- ^ use package-conf instead of package-db
5353
, flagDebugInfo :: Bool
5454
-- ^ -g flag supported
55+
, flagHie :: Bool
56+
-- ^ -hiedir flag supported
5557
, supportsDebugLevels :: Bool
5658
-- ^ supports numeric @-g@ levels
5759
, supportsPkgEnvFiles :: Bool
@@ -93,6 +95,7 @@ ghcVersionImplInfo ver =
9395
, flagProfLate = v >= [9, 4]
9496
, flagPackageConf = v < [7, 5]
9597
, flagDebugInfo = v >= [7, 10]
98+
, flagHie = v >= [8, 8]
9699
, supportsDebugLevels = v >= [8, 0]
97100
, supportsPkgEnvFiles = v >= [8, 0, 1, 20160901] -- broken in 8.0.1, fixed in 8.0.2
98101
, flagWarnMissingHomeModules = v >= [8, 2]
@@ -118,6 +121,7 @@ ghcjsVersionImplInfo _ghcjsver ghcver =
118121
, flagProfLate = True
119122
, flagPackageConf = False
120123
, flagDebugInfo = False
124+
, flagHie = False
121125
, supportsDebugLevels = ghcv >= [8, 0]
122126
, supportsPkgEnvFiles = ghcv >= [8, 0, 2] -- TODO: check this works in ghcjs
123127
, flagWarnMissingHomeModules = ghcv >= [8, 2]

Cabal/src/Distribution/Simple/GHC/Internal.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ import qualified Data.ByteString.Lazy.Char8 as BS
8282
import qualified Data.Map as Map
8383
import qualified Data.Set as Set
8484
import Distribution.Types.ComponentId (ComponentId)
85+
import Data.Bool (bool)
8586
import System.Directory (getDirectoryContents, getTemporaryDirectory)
8687
import System.Environment (getEnv)
8788
import System.FilePath
@@ -576,7 +577,7 @@ componentGhcOptions verbosity implInfo lbi bi clbi odir =
576577
, ghcOptFfiIncludes = toNubListR $ includes bi
577578
, ghcOptObjDir = toFlag odir
578579
, ghcOptHiDir = toFlag odir
579-
, ghcOptHieDir = toFlag $ odir </> "extra-compilation-artifacts"
580+
, ghcOptHieDir = toFlag $ bool Nothing (Just $ odir </> "extra-compilation-artifacts") $ flagHie implInfo
580581
, ghcOptStubDir = toFlag odir
581582
, ghcOptOutputDir = toFlag odir
582583
, ghcOptOptimisation = toGhcOptimisation (withOptimization lbi)

Cabal/src/Distribution/Simple/Program/GHC.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ data GhcOptions = GhcOptions
532532
, ghcOptDynObjSuffix :: Flag String
533533
-- ^ only in 'GhcStaticAndDynamic' mode
534534
, ghcOptHiDir :: Flag FilePath
535-
, ghcOptHieDir :: Flag FilePath
535+
, ghcOptHieDir :: Flag (Maybe FilePath)
536536
, ghcOptObjDir :: Flag FilePath
537537
, ghcOptOutputDir :: Flag FilePath
538538
, ghcOptStubDir :: Flag FilePath
@@ -717,7 +717,7 @@ renderGhcOptions comp _platform@(Platform _arch os) opts
717717
, concat [["-outputdir", dir] | dir <- flag ghcOptOutputDir]
718718
, concat [["-odir", dir] | dir <- flag ghcOptObjDir]
719719
, concat [["-hidir", dir] | dir <- flag ghcOptHiDir]
720-
, concat [["-hiedir", dir] | dir <- flag ghcOptHieDir]
720+
, concat [ maybe [] (\dir -> ["-hiedir", dir]) mdir | mdir <- flag ghcOptHieDir]
721721
, concat [["-stubdir", dir] | dir <- flag ghcOptStubDir]
722722
, -----------------------
723723
-- Source search path

cabal-testsuite/PackageTests/CopyHie/cabal.test.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Test.Cabal.Prelude
22

33
main = withShorterPathForNewBuildStore $ \storeDir -> cabalTest $ withRepo "repo" $ do
4+
skipUnlessGhcVersion ">= 8.8"
45
cabalG ["--store-dir=" ++ storeDir] "v2-build" ["hie"]
56
liftIO $ do
67
installedDependencyLibDir <- findDependencyInStore storeDir "hie-dependency"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Test.Cabal.Prelude
22

33
main = setupAndCabalTest $ withPackageDb $ do
4+
skipUnlessGhcVersion ">= 8.8"
45
setup_install ["hie-local"]
56
env <- getTestEnv
67
shouldExist $ testLibInstallDir env </> "hie-local-0.1.0.0" </> "extra-compilation-artifacts" </> "HieLocal.hie"

0 commit comments

Comments
 (0)