Commit c488f65d authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Add support for non-library packages.

parent 07dbd291
......@@ -4,9 +4,10 @@ module GHC (
integerGmp, integerSimple, parallel, pretty, primitive, process, stm,
templateHaskell, terminfo, time, transformers, unix, win32, xhtml,
defaultKnownPackages, defaultTargetDirectory
defaultKnownPackages, defaultTargetDirectory, defaultProgramPath
) where
import Base
import Package
import Stage
......@@ -66,8 +67,16 @@ xhtml = library "xhtml"
-- * package-data.mk : contains output of ghc-cabal applied to pkgCabal
-- TODO: simplify to just 'show stage'?
defaultTargetDirectory :: Stage -> Package -> FilePath
defaultTargetDirectory stage package
| package == compiler = "stage" ++ show (fromEnum stage + 1)
| package == ghc = "stage" ++ show (fromEnum stage + 1)
| stage == Stage0 = "dist-boot"
| otherwise = "dist-install"
defaultTargetDirectory stage pkg
| pkg == compiler = "stage" ++ show (fromEnum stage + 1)
| pkg == ghc = "stage" ++ show (fromEnum stage + 1)
| stage == Stage0 = "dist-boot"
| otherwise = "dist-install"
defaultProgramPath :: Stage -> Package -> Maybe FilePath
defaultProgramPath stage pkg
| pkg == ghc = program $ "ghc-stage" ++ show (fromEnum stage + 1)
| otherwise = Nothing
where
program name = Just $ pkgPath pkg -/- defaultTargetDirectory stage pkg
-/- "build/tmp" -/- name <.> exe
......@@ -11,7 +11,8 @@ generateTargets :: Rules ()
generateTargets = action $ do
targets <- fmap concat . forM [Stage0 ..] $ \stage -> do
pkgs <- interpretWithStage stage getPackages
fmap concat . forM pkgs $ \pkg -> do
let (libPkgs, programPkgs) = partition isLibrary pkgs
libTargets <- fmap concat . forM libPkgs $ \pkg -> do
let target = PartialTarget stage pkg
buildPath = targetPath stage pkg -/- "build"
libName <- interpretPartial target $ getPkgData LibName
......@@ -28,6 +29,10 @@ generateTargets = action $ do
++ [ haddock | needHaddock && stage == Stage1 ]
++ libs
let programTargets = map (fromJust . programPath stage) programPkgs
return $ libTargets ++ programTargets
need $ reverse targets
-- TODO: add Stage2 (compiler only?)
......
......@@ -17,7 +17,6 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
fmap (path -/-)
[ "package-data.mk"
, "haddock-prologue.txt"
, "inplace-pkg-config"
, "setup-config"
, "build" -/- "autogen" -/- "cabal_macros.h"
-- TODO: Is this needed? Also check out Paths_cpsa.hs.
......@@ -39,7 +38,8 @@ buildPackageData rs target @ (PartialTarget stage pkg) = do
fullTarget target GhcCabal [cabalFile] outs
-- TODO: find out of ghc-cabal can be concurrent with ghc-pkg
whenM (interpretPartial target registerPackage) .
when (isLibrary pkg) .
whenM (interpretPartial target registerPackage) .
buildWithResources [(ghcPkg rs, 1)] $
fullTarget target (GhcPkg stage) [cabalFile] outs
......
......@@ -3,7 +3,7 @@ module Settings (
module Settings.TargetDirectory,
module Settings.User,
module Settings.Ways,
getPkgData, getPkgDataList,
getPkgData, getPkgDataList, programPath, isLibrary,
getPackagePath, getTargetDirectory, getTargetPath, getPackageSources,
) where
......@@ -29,6 +29,12 @@ getPkgData key = lift . pkgData . key =<< getTargetPath
getPkgDataList :: (FilePath -> PackageDataList) -> Expr [String]
getPkgDataList key = lift . pkgDataList . key =<< getTargetPath
programPath :: Stage -> Package -> Maybe FilePath
programPath = userProgramPath
isLibrary :: Package -> Bool
isLibrary pkg = programPath Stage0 pkg == Nothing
-- Find all Haskell source files for the current target. TODO: simplify.
getPackageSources :: Expr [FilePath]
getPackageSources = do
......
......@@ -16,16 +16,16 @@ defaultPackages = mconcat
packagesStage0 :: Packages
packagesStage0 = mconcat
[ append [ binPackageDb, binary, cabal, compiler, ghc, hoopl, hpc, transformers ]
[ append [ binPackageDb, binary, cabal, compiler, ghc, hoopl, hpc
, templateHaskell, transformers ]
, notM windowsHost ? notM (anyHostOs ["ios"]) ? append [terminfo] ]
-- TODO: what do we do with parallel, stm, random, primitive, vector and dph?
packagesStage1 :: Packages
packagesStage1 = mconcat
[ packagesStage0
, append [ array, base, bytestring, containers, deepseq, directory
, filepath, ghc, ghcPrim, haskeline, integerLibrary, pretty
, process, templateHaskell, time ]
, append [ array, base, bytestring, containers, deepseq, directory, filepath
, ghcPrim, haskeline, integerLibrary, pretty, process, time ]
, windowsHost ? append [win32]
, notM windowsHost ? append [unix]
, buildHaddock ? append [xhtml] ]
......
......@@ -5,6 +5,8 @@ module Settings.TargetDirectory (
import Expression
import Settings.User
-- TODO: move to Settings.hs?
-- User can override the default target directory settings given below
targetDirectory :: Stage -> Package -> FilePath
targetDirectory = userTargetDirectory
......
module Settings.User (
userArgs, userPackages, userLibWays, userRtsWays, userTargetDirectory,
userKnownPackages, integerLibrary,
userProgramPath, userKnownPackages, integerLibrary,
trackBuildSystem, buildHaddock, validating, ghciWithDebugger, ghcProfiled,
ghcDebugged, dynamicGhcPrograms, laxDependencies
) where
......@@ -15,7 +15,7 @@ userArgs = mempty
-- Control which packages get to be built
userPackages :: Packages
userPackages = remove [ghc]
userPackages = mempty
-- Add new user-defined packages
userKnownPackages :: [Package]
......@@ -28,10 +28,14 @@ userLibWays = mempty
userRtsWays :: Ways
userRtsWays = mempty
-- Control where build results go (see Settings.Default for an example)
-- Control where build results go (see GHC.hs for defaults)
userTargetDirectory :: Stage -> Package -> FilePath
userTargetDirectory = defaultTargetDirectory
-- Control how built programs are called (see GHC.hs for defaults)
userProgramPath :: Stage -> Package -> Maybe FilePath
userProgramPath = defaultProgramPath
-- Choose integer library: integerGmp, integerGmp2 or integerSimple
integerLibrary :: Package
integerLibrary = integerGmp
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment