@@ -407,7 +407,7 @@ loadSession dir = liftIO $ do
407
407
modifyVar_ fileToFlags $ \ var -> do
408
408
pure $ Map. insert hieYaml (HM. fromList (cs ++ cached_targets)) var
409
409
410
- return res
410
+ return (cs, res)
411
411
412
412
lock <- newLock
413
413
@@ -431,7 +431,7 @@ loadSession dir = liftIO $ do
431
431
case HM. lookup (toNormalizedFilePath' cfp) v of
432
432
Just opts -> do
433
433
-- putStrLn $ "Cached component of " <> show file
434
- pure (fst opts)
434
+ pure ([] , fst opts)
435
435
Nothing -> do
436
436
finished_barrier <- newBarrier
437
437
-- fork a new thread here which won't be killed by shake
@@ -441,8 +441,8 @@ loadSession dir = liftIO $ do
441
441
cradle <- maybe (loadImplicitCradle $ addTrailingPathSeparator dir) loadCradle hieYaml
442
442
opts <- cradleToSessionOpts cradle cfp
443
443
print opts
444
- res <- fst <$> session (hieYaml, toNormalizedFilePath' cfp, opts)
445
- signalBarrier finished_barrier res
444
+ (cs, res) <- session (hieYaml, toNormalizedFilePath' cfp, opts)
445
+ signalBarrier finished_barrier (cs, fst res)
446
446
waitBarrier finished_barrier
447
447
448
448
dummyAs <- async $ return (error " Uninitialised" )
@@ -453,18 +453,30 @@ loadSession dir = liftIO $ do
453
453
hieYaml <- cradleLoc file
454
454
sessionOpts (hieYaml, file)
455
455
-- The lock is on the `runningCradle` resource
456
- return $ \ file -> liftIO $ withLock lock $ do
457
- as <- readIORef runningCradle
458
- finished <- poll as
459
- case finished of
460
- Just {} -> do
461
- as <- async $ getOptions file
462
- writeIORef runningCradle as
463
- wait as
464
- -- If it's not finished then wait and then get options, this could of course be killed still
465
- Nothing -> do
466
- _ <- wait as
467
- getOptions file
456
+ return $ \ file -> do
457
+ (cs, opts) <-
458
+ liftIO $ withLock lock $ do
459
+ as <- readIORef runningCradle
460
+ finished <- poll as
461
+ case finished of
462
+ Just {} -> do
463
+ as <- async $ getOptions file
464
+ writeIORef runningCradle as
465
+ wait as
466
+ -- If it's not finished then wait and then get options, this could of course be killed still
467
+ Nothing -> do
468
+ _ <- wait as
469
+ getOptions file
470
+ let cfps = map fst cs
471
+ -- Delayed to avoid recursion and only run if something changed.
472
+ unless (null cs) (
473
+ delay " InitialLoad" $ void $ do
474
+ cfps' <- liftIO $ filterM (IO. doesFileExist . fromNormalizedFilePath) cfps
475
+ mmt <- uses GetModificationTime cfps'
476
+ let cs_exist = catMaybes (zipWith (<$) cfps' mmt)
477
+ uses GetModIface cs_exist)
478
+ return opts
479
+
468
480
469
481
470
482
0 commit comments