Skip to content

Commit

Permalink
Only pass pjUnits to compile module instead of whole PlanJson
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielG committed May 2, 2020
1 parent a953539 commit a969d07
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
7 changes: 3 additions & 4 deletions lib/Distribution/Helper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ mkCompHelperEnv
, cheProjDir = plCabalProjectDir projloc
, cheProjLocalCacheDir = distdir
, chePkgDb = []
, chePlanJson = Nothing
, chePjUnits = Nothing
, cheDistV2 = Nothing
}
mkCompHelperEnv
Expand All @@ -855,9 +855,8 @@ mkCompHelperEnv
cheCabalVer = cabal_ver
cheProjLocalCacheDir = distdir </> "cache"
chePkgDb = []
chePlanJson = Just plan
chePjUnits = Just $ pjUnits plan
cheDistV2 = Just distdir
PlanJson {pjCabalLibVersion=Ver pjCabalLibVersion } = plan
mkCompHelperEnv
(ProjLocStackYaml stack_yaml)
(DistDirStack mworkdir)
Expand All @@ -874,6 +873,6 @@ mkCompHelperEnv
, cheProjDir = projdir
, cheProjLocalCacheDir = projdir </> workdir
, chePkgDb = [sppGlobalPkgDb, sppSnapPkgDb, sppLocalPkgDb]
, chePlanJson = Nothing
, chePjUnits = Nothing
, cheDistV2 = Nothing
}
9 changes: 5 additions & 4 deletions src/CabalHelper/Compiletime/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module CabalHelper.Compiletime.Compile where

import qualified Cabal.Plan as CP
import Cabal.Plan
( PlanJson(..), PkgId(..), PkgName(..), Ver(..), uPId)
( PkgId(..), PkgName(..), Ver(..), uPId)
import Control.Applicative
import Control.Arrow
import Control.Exception as E
Expand All @@ -30,6 +30,7 @@ import Control.Monad.Trans.Maybe
import Control.Monad.IO.Class
import Data.Char
import Data.List
import Data.Map.Strict (Map)
import Data.Maybe
import Data.String
import Data.Version
Expand Down Expand Up @@ -94,7 +95,7 @@ data CompHelperEnv' cv = CompHelperEnv
, chePkgDb :: ![PackageDbDir]
-- ^ A package-db where we are guaranteed to find Cabal-`cheCabalVer`.
, cheProjDir :: !FilePath
, chePlanJson :: !(Maybe PlanJson)
, chePjUnits :: !(Maybe (Map CP.UnitId CP.Unit))
, cheDistV2 :: !(Maybe FilePath)
, cheProjLocalCacheDir :: FilePath
}
Expand Down Expand Up @@ -185,8 +186,8 @@ compileHelper' CompHelperEnv {..} = do
compileWithCabalV2Inplace ghcVer cabalVer = do
-- TODO: Test coverage! Neither compile-test nor ghc-session test out
-- this code path
PlanJson {pjUnits} <- maybe mzero pure chePlanJson
distdir_newstyle <- maybe mzero pure cheDistV2
pjUnits <- maybe mzero pure chePjUnits
distdir_newstyle <- maybe mzero pure cheDistV2
let cabal_pkgid =
PkgId (PkgName (Text.pack "Cabal")) (Ver $ versionBranch cabalVer)
mcabal_unit = listToMaybe $
Expand Down
2 changes: 1 addition & 1 deletion tests/CompileTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ testCabalVersions versions = do
{ cheCabalVer = icv
, chePkgDb = db
, cheProjDir = tmpdir
, chePlanJson = Nothing
, chePjUnits = Nothing
, cheDistV2 = Just $ tmpdir </> "dist-newstyle"
, cheProjLocalCacheDir =
tmpdir </> "dist-newstyle" </> "cache"
Expand Down

0 comments on commit a969d07

Please sign in to comment.