61b134aacd079e2ed67f5bd2e15cee49c46ac551
[hadrian.git] / src / Oracles / PackageDb.hs
1 module Oracles.PackageDb (packageDbOracle) where
2
3 import qualified System.Directory as IO
4
5 import Base
6 import Context
7 import Builder
8 import GHC
9 import Rules.Actions
10 import Settings.Builders.GhcCabal
11 import Settings.Paths
12 import Settings.User
13 import Target
14
15 packageDbOracle :: Rules ()
16 packageDbOracle = void $
17 addOracle $ \(PackageDbKey stage) -> do
18 let dir = packageDbDirectory stage
19 file = dir -/- "package.cache"
20 unlessM (liftIO $ IO.doesFileExist file) $ do
21 removeDirectory dir
22 build $ Target (vanillaContext stage ghcPkg) (GhcPkg stage) [] [dir]
23 putSuccess $ "| Successfully initialised " ++ dir