1- {-# LANGUAGE CPP #-}
21{-# LANGUAGE NoImplicitPrelude #-}
3- {-# LANGUAGE DeriveGeneric #-}
42{-# LANGUAGE MultiParamTypeClasses #-}
5- {-# LANGUAGE TemplateHaskell #-}
6- {-# LANGUAGE TupleSections #-}
73{-# LANGUAGE ConstraintKinds #-}
84{-# LANGUAGE OverloadedStrings #-}
95{-# LANGUAGE DataKinds #-}
@@ -39,30 +35,28 @@ import qualified Data.ByteArray as Mem (convert)
3935import qualified Data.ByteString.Base64.URL as B64URL
4036import qualified Data.ByteString as B
4137import qualified Data.ByteString.Char8 as S8
42- #ifdef mingw32_HOST_OS
4338import Data.Char (ord )
44- #endif
4539import qualified Data.Map as M
4640import qualified Data.Set as Set
4741import qualified Data.Store as Store
48- import Data.Store.VersionTagged
4942import qualified Data.Text as T
5043import Path
5144import Path.IO
45+ import Stack.Constants
5246import Stack.Constants.Config
47+ import Stack.StoreTH
5348import Stack.Types.Build
5449import Stack.Types.Compiler
5550import Stack.Types.Config
5651import Stack.Types.GhcPkgId
5752import Stack.Types.NamedComponent
58- import Stack.Types.Package
5953import qualified System.FilePath as FP
6054
6155-- | Directory containing files to mark an executable as installed
6256exeInstalledDir :: (MonadReader env m , HasEnvConfig env , MonadThrow m )
6357 => InstallLocation -> m (Path Abs Dir )
64- exeInstalledDir Snap = (</> $ (mkRelDir " installed-packages " ) ) `liftM` installationRootDeps
65- exeInstalledDir Local = (</> $ (mkRelDir " installed-packages " ) ) `liftM` installationRootLocal
58+ exeInstalledDir Snap = (</> relDirInstalledPackages ) `liftM` installationRootDeps
59+ exeInstalledDir Local = (</> relDirInstalledPackages ) `liftM` installationRootLocal
6660
6761-- | Get all of the installed executables
6862getInstalledExes :: (MonadReader env m , HasEnvConfig env , MonadIO m , MonadThrow m )
@@ -126,17 +120,17 @@ tryGetBuildCache :: HasEnvConfig env
126120 => Path Abs Dir
127121 -> NamedComponent
128122 -> RIO env (Maybe (Map FilePath FileCacheInfo ))
129- tryGetBuildCache dir component = liftM (fmap buildCacheTimes) . $ (versionedDecodeFile buildCacheVC) =<< buildCacheFile dir component
123+ tryGetBuildCache dir component = liftM (fmap buildCacheTimes) . decodeBuildCache =<< buildCacheFile dir component
130124
131125-- | Try to read the dirtiness cache for the given package directory.
132126tryGetConfigCache :: HasEnvConfig env
133127 => Path Abs Dir -> RIO env (Maybe ConfigCache )
134- tryGetConfigCache dir = $ (versionedDecodeFile configCacheVC) =<< configCacheFile dir
128+ tryGetConfigCache dir = decodeConfigCache =<< configCacheFile dir
135129
136130-- | Try to read the mod time of the cabal file from the last build
137131tryGetCabalMod :: HasEnvConfig env
138132 => Path Abs Dir -> RIO env (Maybe ModTime )
139- tryGetCabalMod dir = $ (versionedDecodeFile modTimeVC) =<< configCabalMod dir
133+ tryGetCabalMod dir = decodeModTime =<< configCabalMod dir
140134
141135-- | Write the dirtiness cache for this package's files.
142136writeBuildCache :: HasEnvConfig env
@@ -145,7 +139,7 @@ writeBuildCache :: HasEnvConfig env
145139 -> Map FilePath FileCacheInfo -> RIO env ()
146140writeBuildCache dir component times = do
147141 fp <- buildCacheFile dir component
148- $ (versionedEncodeFile buildCacheVC) fp BuildCache
142+ encodeBuildCache fp BuildCache
149143 { buildCacheTimes = times
150144 }
151145
@@ -156,7 +150,7 @@ writeConfigCache :: HasEnvConfig env
156150 -> RIO env ()
157151writeConfigCache dir x = do
158152 fp <- configCacheFile dir
159- $ (versionedEncodeFile configCacheVC) fp x
153+ encodeConfigCache fp x
160154
161155-- | See 'tryGetCabalMod'
162156writeCabalMod :: HasEnvConfig env
@@ -165,7 +159,7 @@ writeCabalMod :: HasEnvConfig env
165159 -> RIO env ()
166160writeCabalMod dir x = do
167161 fp <- configCabalMod dir
168- $ (versionedEncodeFile modTimeVC) fp x
162+ encodeModTime fp x
169163
170164-- | Delete the caches for the project.
171165deleteCaches :: (MonadIO m , MonadReader env m , HasEnvConfig env , MonadThrow m )
@@ -195,7 +189,7 @@ tryGetFlagCache :: HasEnvConfig env
195189 -> RIO env (Maybe ConfigCache )
196190tryGetFlagCache gid = do
197191 fp <- flagCacheFile gid
198- $ (versionedDecodeFile configCacheVC) fp
192+ decodeConfigCache fp
199193
200194writeFlagCache :: HasEnvConfig env
201195 => Installed
@@ -204,23 +198,23 @@ writeFlagCache :: HasEnvConfig env
204198writeFlagCache gid cache = do
205199 file <- flagCacheFile gid
206200 ensureDir (parent file)
207- $ (versionedEncodeFile configCacheVC) file cache
201+ encodeConfigCache file cache
208202
209203-- | Mark a test suite as having succeeded
210204setTestSuccess :: HasEnvConfig env
211205 => Path Abs Dir
212206 -> RIO env ()
213207setTestSuccess dir = do
214208 fp <- testSuccessFile dir
215- $ (versionedEncodeFile testSuccessVC) fp True
209+ encodeTestSuccess fp True
216210
217211-- | Mark a test suite as not having succeeded
218212unsetTestSuccess :: HasEnvConfig env
219213 => Path Abs Dir
220214 -> RIO env ()
221215unsetTestSuccess dir = do
222216 fp <- testSuccessFile dir
223- $ (versionedEncodeFile testSuccessVC) fp False
217+ encodeTestSuccess fp False
224218
225219-- | Check if the test suite already passed
226220checkTestSuccess :: HasEnvConfig env
@@ -229,7 +223,7 @@ checkTestSuccess :: HasEnvConfig env
229223checkTestSuccess dir =
230224 liftM
231225 (fromMaybe False )
232- ($ (versionedDecodeFile testSuccessVC) =<< testSuccessFile dir)
226+ (decodeTestSuccess =<< testSuccessFile dir)
233227
234228--------------------------------------
235229-- Precompiled Cache
@@ -268,7 +262,7 @@ precompiledCacheFile loc copts installedPackageIDs = do
268262 platformRelDir <- platformGhcRelDir
269263 let precompiledDir =
270264 view stackRootL ec
271- </> $ (mkRelDir " precompiled " )
265+ </> relDirPrecompiled
272266 </> platformRelDir
273267 </> compiler
274268 </> cabal
@@ -317,7 +311,7 @@ writePrecompiledCache baseConfigOpts loc copts depIDs mghcPkgId sublibs exes = d
317311 name <- parseRelFile $ T. unpack exe
318312 relPath <- stackRootRelative $ bcoSnapInstallRoot baseConfigOpts </> bindirSuffix </> name
319313 return $ toFilePath relPath
320- $ (versionedEncodeFile precompiledCacheVC) file PrecompiledCache
314+ encodePrecompiledCache file PrecompiledCache
321315 { pcLibrary = mlibpath
322316 , pcSubLibs = sublibpaths
323317 , pcExes = exes'
@@ -337,7 +331,7 @@ readPrecompiledCache :: forall env. HasEnvConfig env
337331 -> RIO env (Maybe PrecompiledCache )
338332readPrecompiledCache loc copts depIDs = do
339333 file <- precompiledCacheFile loc copts depIDs
340- mcache <- $ (versionedDecodeFile precompiledCacheVC) file
334+ mcache <- decodePrecompiledCache file
341335 maybe (pure Nothing ) (fmap Just . mkAbs) mcache
342336 where
343337 -- Since commit ed9ccc08f327bad68dd2d09a1851ce0d055c0422,
@@ -358,8 +352,9 @@ readPrecompiledCache loc copts depIDs = do
358352
359353-- | Check if a filesystem path is too long.
360354pathTooLong :: FilePath -> Bool
361- #ifdef mingw32_HOST_OS
362- pathTooLong path = utf16StringLength path >= win32MaxPath
355+ pathTooLong
356+ | osIsWindows = \ path -> utf16StringLength path >= win32MaxPath
357+ | otherwise = const False
363358 where
364359 win32MaxPath = 260
365360 -- Calculate the length of a string in 16-bit units
@@ -369,6 +364,3 @@ pathTooLong path = utf16StringLength path >= win32MaxPath
369364 where
370365 utf16CharLength c | ord c < 0x10000 = 1
371366 | otherwise = 2
372- #else
373- pathTooLong _ = False
374- #endif
0 commit comments