diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2019-04-01 20:40:05 +0200 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2019-04-01 21:00:45 +0200 |
commit | a078ea73f07f95b0e55d13b51c104be749d0ed3d (patch) | |
tree | 5f4773ae0c245bc920ebb80be63d9019be1b0912 | |
parent | 8111c0d83bb2619a68d72ff5d65e6ae81786b7e5 (diff) |
Add ProjLocV1Dir for easier forward porting
-rw-r--r-- | lib/Distribution/Helper.hs | 16 | ||||
-rw-r--r-- | src/CabalHelper/Compiletime/Types.hs | 10 | ||||
-rw-r--r-- | tests/GhcSession.hs | 2 |
3 files changed, 18 insertions, 10 deletions
diff --git a/lib/Distribution/Helper.hs b/lib/Distribution/Helper.hs index d25786c..38f819f 100644 --- a/lib/Distribution/Helper.hs +++ b/lib/Distribution/Helper.hs @@ -209,18 +209,20 @@ mkQueryEnv projloc distdir = do } -- | Construct paths to project configuration files given where the project is. -projConf :: ProjLoc pt -> ProjConf pt -projConf (ProjLocCabalFile cabal_file) = - ProjConfV1 cabal_file +projConf :: ProjLoc pt -> IO (ProjConf pt) +projConf (ProjLocV1Dir pkgdir) = + ProjConfV1 <$> findCabalFile pkgdir +projConf (ProjLocV1CabalFile cabal_file) = return $ + ProjConfV1 cabal_file projConf (ProjLocV2Dir projdir_path) = projConf $ ProjLocV2File $ projdir_path </> "cabal.project" -projConf (ProjLocV2File proj_file) = +projConf (ProjLocV2File proj_file) = return $ ProjConfV2 { pcV2CabalProjFile = proj_file , pcV2CabalProjLocalFile = proj_file <.> "local" , pcV2CabalProjFreezeFile = proj_file <.> "freeze" } -projConf (ProjLocStackYaml stack_yaml) = +projConf (ProjLocStackYaml stack_yaml) = return $ ProjConfStack { pcStackYaml = stack_yaml } @@ -313,7 +315,7 @@ checkUpdateProjInfo -> Maybe (ProjInfo pt) -> IO (ProjInfo pt) checkUpdateProjInfo qe mproj_info = do - let proj_conf = projConf (qeProjLoc qe) + proj_conf <- projConf (qeProjLoc qe) mtime <- getProjConfModTime proj_conf case mproj_info of Nothing -> reconf proj_conf mtime @@ -374,7 +376,7 @@ discardInactiveUnitInfos active_units uis0 = -- system (@cabal@ or @stack@). shallowReconfigureProject :: QueryEnvI c pt -> IO () shallowReconfigureProject QueryEnv - { qeProjLoc = ProjLocCabalFile _cabal_file + { qeProjLoc = _ , qeDistDir = DistDirV1 _distdirv1 } = return () shallowReconfigureProject QueryEnv diff --git a/src/CabalHelper/Compiletime/Types.hs b/src/CabalHelper/Compiletime/Types.hs index 95eea9f..cffa663 100644 --- a/src/CabalHelper/Compiletime/Types.hs +++ b/src/CabalHelper/Compiletime/Types.hs @@ -66,7 +66,12 @@ data ProjLoc (pt :: ProjType) where -- ending in @.cabal@ existing in the directory. More than one such files -- existing is a user error. Note: For this project type the concepts of -- project and package coincide. - ProjLocCabalFile :: { plCabalFile :: !FilePath } -> ProjLoc 'V1 + ProjLocV1CabalFile :: { plCabalFile :: !FilePath } -> ProjLoc 'V1 + + -- | A @cabal v1-build@ project directory. Same as 'ProjLocV1CabalFile' but + -- will search for the cabal file for you. If more than one @.cabal@ file + -- exists it will shamelessly throw an obscure exception. + ProjLocV1Dir :: { plPackageDir :: !FilePath } -> ProjLoc 'V1 -- | A @cabal v2-build@ project\'s marker file is called -- @cabal.project@. This configuration file points to the packages that make @@ -81,7 +86,8 @@ data ProjLoc (pt :: ProjType) where deriving instance Show (ProjLoc pt) plV1Dir :: ProjLoc 'V1 -> FilePath -plV1Dir (ProjLocCabalFile cabal_file) = takeDirectory cabal_file +plV1Dir (ProjLocV1CabalFile cabal_file) = takeDirectory cabal_file +plV1Dir (ProjLocV1Dir pkgdir) = pkgdir data DistDir (pt :: ProjType) where -- | Build directory for cabal /old-build/ aka. /v1-build/ aka. just diff --git a/tests/GhcSession.hs b/tests/GhcSession.hs index 2fda204..91e30aa 100644 --- a/tests/GhcSession.hs +++ b/tests/GhcSession.hs @@ -347,7 +347,7 @@ oldBuildProjSetup :: ProjSetup0 oldBuildProjSetup = ProjSetupDescr "cabal-v1" $ Right $ Ex $ ProjSetupImpl { psiProjType = SV1 , psiDistDir = \dir -> DistDirV1 (dir </> "dist") - , psiProjLoc = \(CabalFile cf) _projdir -> ProjLocCabalFile cf + , psiProjLoc = \(CabalFile cf) _projdir -> ProjLocV1CabalFile cf , psiConfigure = \dir -> runWithCwd dir "cabal" [ "configure" ] , psiBuild = \dir -> |