aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2019-07-30 02:16:19 +0200
committerDaniel Gröber (dxld) <dxld@darkboxed.org>2019-09-17 17:48:26 +0200
commit8c9361e4ba6e2257f2bd9d354a56005318477ed6 (patch)
treedc62b3396268a11550669aa7f43933ca4e4899b7
parent1b05d896884a8c02306f73f82658e7c6f3825fff (diff)
Support cabal-file not being in pkgdir with cabal-v1
-rw-r--r--lib/Distribution/Helper.hs6
-rw-r--r--lib/Distribution/Helper/Discover.hs4
-rw-r--r--src/CabalHelper/Compiletime/Types.hs6
-rw-r--r--tests/GhcSession.hs2
4 files changed, 9 insertions, 9 deletions
diff --git a/lib/Distribution/Helper.hs b/lib/Distribution/Helper.hs
index 1505063..d9c9285 100644
--- a/lib/Distribution/Helper.hs
+++ b/lib/Distribution/Helper.hs
@@ -213,7 +213,7 @@ mkQueryEnv projloc distdir = do
projConf :: ProjLoc pt -> IO (ProjConf pt)
projConf (ProjLocV1Dir pkgdir) =
ProjConfV1 <$> findCabalFile pkgdir
-projConf (ProjLocV1CabalFile cabal_file) = return $
+projConf (ProjLocV1CabalFile cabal_file _) = return $
ProjConfV1 cabal_file
projConf (ProjLocV2Dir projdir_path) =
projConf $ ProjLocV2File $ projdir_path </> "cabal.project"
@@ -435,7 +435,7 @@ readProjInfo qe pc pcm = withVerbosity $ do
let projloc = qeProjLoc qe
case (qeDistDir qe, pc) of
(DistDirV1 distdir, ProjConfV1{pcV1CabalFile}) -> do
- let projdir = plV1Dir projloc
+ let pkgdir = plV1Dir projloc
setup_config_path <- canonicalizePath (distdir </> "setup-config")
mhdr <- readSetupConfigHeader setup_config_path
case mhdr of
@@ -445,7 +445,7 @@ readProjInfo qe pc pcm = withVerbosity $ do
, piProjConfModTimes = pcm
, piUnits = (:|[]) $ Unit
{ uUnitId = UnitId ""
- , uPackageDir = projdir
+ , uPackageDir = pkgdir
, uCabalFile = CabalFile pcV1CabalFile
, uDistDir = DistDirLib distdir
, uImpl = UnitImplV1
diff --git a/lib/Distribution/Helper/Discover.hs b/lib/Distribution/Helper/Discover.hs
index a748b25..635474d 100644
--- a/lib/Distribution/Helper/Discover.hs
+++ b/lib/Distribution/Helper/Discover.hs
@@ -52,10 +52,10 @@ findProjects dir = execWriterT $ do
let stackYaml = dir </> "stack.yaml"
whenM (liftIO $ doesFileExist stackYaml) $
tell [Ex $ ProjLocStackYaml stackYaml]
- join $ traverse (tell . pure . Ex . ProjLocV1CabalFile) <$>
+ join $ traverse (tell . pure . Ex . ProjLocV1Dir . takeDirectory) <$>
liftIO (findCabalFiles dir)
-findDistDirs (ProjLocV1CabalFile cabal) =
+findDistDirs (ProjLocV1CabalFile cabal _) =
[DistDirV1 $ replaceFileName cabal "dist/"]
findDistDirs (ProjLocV1Dir dir) = [DistDirV1 $ dir </> "dist/"]
findDistDirs (ProjLocV2File cabal) =
diff --git a/src/CabalHelper/Compiletime/Types.hs b/src/CabalHelper/Compiletime/Types.hs
index ec24f2d..f9900bb 100644
--- a/src/CabalHelper/Compiletime/Types.hs
+++ b/src/CabalHelper/Compiletime/Types.hs
@@ -66,7 +66,7 @@ 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.
- ProjLocV1CabalFile :: { plCabalFile :: !FilePath } -> ProjLoc 'V1
+ ProjLocV1CabalFile :: { plCabalFile :: !FilePath, plPackageDir :: !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
@@ -86,8 +86,8 @@ data ProjLoc (pt :: ProjType) where
deriving instance Show (ProjLoc pt)
plV1Dir :: ProjLoc 'V1 -> FilePath
-plV1Dir (ProjLocV1CabalFile cabal_file) = takeDirectory cabal_file
-plV1Dir (ProjLocV1Dir pkgdir) = pkgdir
+plV1Dir ProjLocV1CabalFile {plPackageDir} = plPackageDir
+plV1Dir ProjLocV1Dir {plPackageDir} = plPackageDir
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 db06c87..871fddd 100644
--- a/tests/GhcSession.hs
+++ b/tests/GhcSession.hs
@@ -421,7 +421,7 @@ oldBuildProjSetup :: ProjSetup0
oldBuildProjSetup = ProjSetupDescr "cabal-v1" $ Right $ Ex $ ProjSetupImpl
{ psiProjType = SV1
, psiDistDir = \dir -> DistDirV1 (dir </> "dist")
- , psiProjLoc = \(CabalFile cf) _projdir -> ProjLocV1CabalFile cf
+ , psiProjLoc = \(CabalFile cf) projdir -> ProjLocV1CabalFile cf projdir
, psiConfigure = \progs dir ->
runWithCwd dir (cabalProgram progs) [ "configure" ]
, psiBuild = \progs dir ->