Expression: Don't re-export Base
[hadrian.git] / src / Settings.hs
1 module Settings (
2 module Settings.Packages,
3 module Settings.TargetDirectory,
4 module Settings.User,
5 module Settings.Ways,
6 getPkgData, getPkgDataList, programPath, isLibrary,
7 getPackagePath, getTargetDirectory, getTargetPath, getPackageSources
8 ) where
9
10 import Base
11 import Expression
12 import Oracles
13 import Oracles.ModuleFiles
14 import Settings.Packages
15 import Settings.TargetDirectory
16 import Settings.User
17 import Settings.Ways
18
19 getPackagePath :: Expr FilePath
20 getPackagePath = pkgPath <$> getPackage
21
22 getTargetDirectory :: Expr FilePath
23 getTargetDirectory = targetDirectory <$> getStage <*> getPackage
24
25 getTargetPath :: Expr FilePath
26 getTargetPath = targetPath <$> getStage <*> getPackage
27
28 getPkgData :: (FilePath -> PackageData) -> Expr String
29 getPkgData key = lift . pkgData . key =<< getTargetPath
30
31 getPkgDataList :: (FilePath -> PackageDataList) -> Expr [String]
32 getPkgDataList key = lift . pkgDataList . key =<< getTargetPath
33
34 programPath :: Stage -> Package -> Maybe FilePath
35 programPath = userProgramPath
36
37 -- | Find all Haskell source files for the current target
38 getPackageSources :: Expr [FilePath]
39 getPackageSources = do
40 stage <- getStage
41 pkg <- getPackage
42 path <- getTargetPath
43 let buildPath = path -/- "build"
44 autogen = buildPath -/- "autogen"
45 (found, missingMods) <- lift $ haskellModuleFiles stage pkg
46 -- Generated source files live in buildPath and have extension "hs"...
47 let generated = [ buildPath -/- (replaceEq '.' '/' m) <.> "hs" | m <- missingMods ]
48 -- ...except that GHC/Prim.hs lives in autogen. TODO: fix the inconsistency?
49 fixGhcPrim = replaceEq (buildPath -/- "GHC/Prim.hs") (autogen -/- "GHC/Prim.hs")
50 return $ found ++ fixGhcPrim generated