From c70e8076803bd29d7675ed493ebb1ca246891b34 Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Tue, 6 Aug 2019 01:54:29 +0200 Subject: Fix ProjLoc to source directory correspondence We cannot always assume `takeDirectory cfg_file` will be the project source directory! --- src/CabalHelper/Compiletime/Types.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/CabalHelper') diff --git a/src/CabalHelper/Compiletime/Types.hs b/src/CabalHelper/Compiletime/Types.hs index b30e107..748b8d1 100644 --- a/src/CabalHelper/Compiletime/Types.hs +++ b/src/CabalHelper/Compiletime/Types.hs @@ -32,6 +32,7 @@ import Data.IORef import Data.Version import Data.Typeable import GHC.Generics +import System.FilePath (takeDirectory) import System.Posix.Types import CabalHelper.Compiletime.Types.RelativePath import CabalHelper.Shared.InterfaceTypes @@ -146,7 +147,7 @@ data ProjLoc (pt :: ProjType) where -- configuration file then points to the packages that make up this -- project. This corresponds to the @--cabal-project=PATH@ flag on the -- @cabal@ command line. - ProjLocV2File :: { plCabalProjectFile :: !FilePath } -> ProjLoc ('Cabal 'CV2) + ProjLocV2File :: { plCabalProjectFile :: !FilePath, plProjectDirV2 :: !FilePath } -> ProjLoc ('Cabal 'CV2) -- | This is equivalent to 'ProjLocV2File' but using the default -- @cabal.project@ file name. @@ -164,6 +165,15 @@ plV1Dir :: ProjLoc ('Cabal 'CV1) -> FilePath plV1Dir ProjLocV1CabalFile {plProjectDirV1} = plProjectDirV1 plV1Dir ProjLocV1Dir {plProjectDirV1} = plProjectDirV1 +plCabalProjectDir :: ProjLoc ('Cabal cpt) -> FilePath +plCabalProjectDir ProjLocV1CabalFile {plProjectDirV1} = plProjectDirV1 +plCabalProjectDir ProjLocV1Dir {plProjectDirV1} = plProjectDirV1 +plCabalProjectDir ProjLocV2File {plProjectDirV2} = plProjectDirV2 +plCabalProjectDir ProjLocV2Dir {plProjectDirV2} = plProjectDirV2 + +plStackProjectDir :: ProjLoc 'Stack -> FilePath +plStackProjectDir ProjLocStackYaml {plStackYaml} = takeDirectory plStackYaml + projTypeOfProjLoc :: ProjLoc pt -> SProjType pt projTypeOfProjLoc ProjLocV1CabalFile{} = SCabal SCV1 projTypeOfProjLoc ProjLocV1Dir{} = SCabal SCV1 -- cgit v1.2.3