@@ -28,7 +28,6 @@ import Data.Text.Encoding (encodeUtf8)
2828import Distribution.Package (Dependency (.. ))
2929import Distribution.Version (anyVersion ,
3030 intersectVersionRanges )
31- import Path
3231import Prelude hiding (FilePath , pi , writeFile )
3332import Stack.Build.Cache
3433import Stack.Build.Installed
@@ -38,7 +37,6 @@ import Stack.BuildPlan
3837
3938import Stack.Package
4039import Stack.Types
41- import System.Directory
4240
4341data PackageInfo
4442 = PIOnlyInstalled Version Location Installed
@@ -152,10 +150,7 @@ mkUnregisterLocal tasks locallyRegistered =
152150 toUnregister gid =
153151 case M. lookup name tasks of
154152 Nothing -> False
155- Just task ->
156- case taskType task of
157- TTLocal _ JustFinal -> False
158- _ -> True
153+ Just _ -> True
159154 where
160155 ident = ghcPkgIdPackageIdentifier gid
161156 name = packageIdentifierName ident
@@ -191,13 +186,13 @@ addDep'' name = do
191186 return $ Right $ ADRFound version installed
192187 Just (PIOnlySource ps) -> do
193188 tellExecutables name ps
194- installPackage Nothing name ps
189+ installPackage name ps
195190 Just (PIBoth ps installed) -> do
196191 tellExecutables name ps
197- mneededSteps <- checkNeededSteps name ps installed
198- case mneededSteps of
199- Nothing -> return $ Right $ ADRFound (piiVersion ps) installed
200- Just neededSteps -> installPackage ( Just neededSteps) name ps
192+ needInstall <- checkNeedInstall name ps installed
193+ if needInstall
194+ then installPackage name ps
195+ else return $ Right $ ADRFound (piiVersion ps) installed
201196
202197tellExecutables :: PackageName -> PackageSource -> M ()
203198tellExecutables _ (PSLocal lp)
@@ -222,12 +217,11 @@ tellExecutablesPackage loc p =
222217-- TODO There are a lot of duplicated computations below. I've kept that for
223218-- simplicity right now
224219
225- installPackage :: Maybe NeededSteps -> PackageName -> PackageSource -> M (Either ConstructPlanException AddDepRes )
226- installPackage mneededSteps name ps = do
220+ installPackage :: PackageName -> PackageSource -> M (Either ConstructPlanException AddDepRes )
221+ installPackage name ps = do
227222 ctx <- ask
228223 package <- psPackage name ps
229224 depsRes <- addPackageDeps package
230- mtime <- packageSourceCabalModTime ps
231225 case depsRes of
232226 Left e -> return $ Left e
233227 Right (missing, present) -> do
@@ -247,41 +241,18 @@ installPackage mneededSteps name ps = do
247241 , taskType =
248242 case ps of
249243 PSLocal lp -> TTLocal lp
250- $ case mneededSteps of
251- Just neededSteps -> neededSteps
252- Nothing ->
253- case lpLastConfigOpts lp of
254- Nothing -> AllSteps
255- Just configOpts
256- | not $ Set. null missing -> AllSteps
257- | otherwise -> do
258-
259- let newOpts = configureOpts
260- (baseConfigOpts ctx)
261- present
262- (psWanted ps)
263- (piiLocation ps)
264- (packageFlags package)
265- configCache = ConfigCache
266- { configCacheOpts = map encodeUtf8 newOpts
267- , configCacheDeps = present
268- , configCabalFileModTime = mtime
269- }
270- in if configCache == configOpts
271- then SkipConfig
272- else AllSteps
273244 PSUpstream _ loc _ -> TTUpstream package loc
274245 }
275246
276- checkNeededSteps :: PackageName -> PackageSource -> Installed -> M ( Maybe NeededSteps )
277- checkNeededSteps name ps installed = assert (piiLocation ps == Local ) $ do
247+ checkNeedInstall :: PackageName -> PackageSource -> Installed -> M Bool
248+ checkNeedInstall name ps installed = assert (piiLocation ps == Local ) $ do
278249 package <- psPackage name ps
279250 depsRes <- addPackageDeps package
280251 case depsRes of
281- Left _e -> return $ Just AllSteps -- installPackage will find the error again
252+ Left _e -> return True -- installPackage will find the error again
282253 Right (missing, present)
283254 | Set. null missing -> checkDirtiness ps installed package present
284- | otherwise -> return $ Just AllSteps
255+ | otherwise -> return True
285256
286257addPackageDeps :: Package -> M (Either ConstructPlanException (Set PackageIdentifier , Set GhcPkgId ))
287258addPackageDeps package = do
@@ -314,20 +285,13 @@ addPackageDeps package = do
314285 adrVersion (ADRToInstall task) = packageIdentifierVersion $ taskProvides task
315286 adrVersion (ADRFound v _) = v
316287
317- packageSourceCabalModTime :: MonadIO m => PackageSource -> m (Maybe ModTime )
318- packageSourceCabalModTime (PSLocal lp) | lpWanted lp = do
319- now <-
320- liftIO (getModificationTime
321- (toFilePath (lpCabalFile lp)))
322- return (Just (modTime now))
323- packageSourceCabalModTime _ = return Nothing
324-
325288checkDirtiness :: PackageSource
326289 -> Installed
327290 -> Package
328291 -> Set GhcPkgId
329- -> M (Maybe NeededSteps )
330- checkDirtiness ps@ (PSLocal lp) Executable package present = do
292+ -> M Bool
293+ checkDirtiness _ps@ (PSLocal _lp) Executable _package _present = do
294+ {- FIXME proper dirtiness checking on executables
331295 ctx <- ask
332296 mtime <- packageSourceCabalModTime ps
333297 let configOpts = configureOpts
@@ -343,15 +307,16 @@ checkDirtiness ps@(PSLocal lp) Executable package present = do
343307 }
344308 let moldOpts = lpLastConfigOpts lp
345309 case moldOpts of
346- Nothing -> return $ Just AllSteps
310+ Nothing -> return True
347311 Just oldOpts
348- | oldOpts /= configCache -> return $ Just AllSteps
312+ | oldOpts /= configCache -> return True
349313 | psDirty ps -> return $ Just SkipConfig
350314 | otherwise -> return Nothing
351- checkDirtiness (PSUpstream _ _ _) Executable _ _ = return Nothing -- TODO reinstall executables in the future
315+ -}
316+ return False
317+ checkDirtiness (PSUpstream _ _ _) Executable _ _ = return False -- TODO reinstall executables in the future
352318checkDirtiness ps (Library installed) package present = do
353319 ctx <- ask
354- mtime <- packageSourceCabalModTime ps
355320 let configOpts = configureOpts
356321 (baseConfigOpts ctx)
357322 present
@@ -361,17 +326,19 @@ checkDirtiness ps (Library installed) package present = do
361326 configCache = ConfigCache
362327 { configCacheOpts = map encodeUtf8 configOpts
363328 , configCacheDeps = present
364- , configCabalFileModTime = mtime
329+ , configCabalFileModTime = Nothing
365330 }
366- moldOpts <- psOldOpts ps installed
331+ moldOpts <- tryGetFlagCache installed
367332 case moldOpts of
368- Nothing -> return $ Just AllSteps
333+ Nothing -> return True
369334 Just oldOpts
370- | oldOpts /= configCache -> return $ Just AllSteps
371- | psDirty ps -> return $ Just SkipConfig
335+ | oldOpts /= configCache -> return True
336+ | psDirty ps -> return True
372337 | otherwise -> do
373338 case ps of
339+ {- FIXME need to track finals completely differently now
374340 PSLocal lp | lpWanted lp -> do
341+
375342 -- track the fact that we need to perform a JustFinal. But
376343 -- don't put this in the main State Map, as that would
377344 -- trigger dependencies to rebuild also.
@@ -386,17 +353,14 @@ checkDirtiness ps (Library installed) package present = do
386353 }
387354 tell (Map.singleton (packageName package) task, Map.empty)
388355 -- FIXME need to force reconfigure when GhcPkgId for dependencies change
356+ -}
389357 _ -> return ()
390- return Nothing
358+ return False
391359
392360psDirty :: PackageSource -> Bool
393361psDirty (PSLocal lp) = lpDirtyFiles lp
394362psDirty (PSUpstream _ _ _) = False -- files never change in an upstream package
395363
396- psOldOpts :: PackageSource -> GhcPkgId -> M (Maybe ConfigCache )
397- psOldOpts (PSLocal lp) _ = return $ lpLastConfigOpts lp
398- psOldOpts (PSUpstream _ _ _) installed = tryGetFlagCache installed
399-
400364psWanted :: PackageSource -> Bool
401365psWanted (PSLocal lp) = lpWanted lp
402366psWanted (PSUpstream _ _ _) = False
0 commit comments