Commit 663ad019 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Build program executables directly in inplace/bin.

parent f5d4e7b9
......@@ -5,29 +5,29 @@
#===================
system-ghc = @WithGhc@
ghc-stage1 = @hardtop@/inplace/bin/ghc-stage1
ghc-stage2 = @hardtop@/inplace/bin/ghc-stage2
ghc-stage3 = @hardtop@/inplace/bin/ghc-stage3
ghc-stage1 = inplace/bin/ghc-stage1
ghc-stage2 = inplace/bin/ghc-stage2
ghc-stage3 = inplace/bin/ghc-stage3
system-gcc = @CC_STAGE0@
gcc = @WhatGccIsCalled@
system-ghc-pkg = @GhcPkgCmd@
ghc-pkg = @hardtop@/inplace/bin/ghc-pkg
ghc-pkg = inplace/bin/ghc-pkg
ghc-cabal = @hardtop@/inplace/bin/ghc-cabal
ghc-cabal = inplace/bin/ghc-cabal
haddock = @hardtop@/inplace/bin/haddock
haddock = inplace/bin/haddock
hsc2hs = @hardtop@/inplace/bin/hsc2hs
hsc2hs = inplace/bin/hsc2hs
genprimopcode = @hardtop@/inplace/bin/genprimopcode
genprimopcode = inplace/bin/genprimopcode
hs-cpp = @HaskellCPPCmd@
hs-cpp-args = @HaskellCPPArgs@
unlit = @hardtop@/inplace/lib/unlit
ghc-split = @hardtop@/inplace/lib/ghc-split
unlit = inplace/lib/unlit
ghc-split = inplace/lib/ghc-split
ld = @LdCmd@
ar = @ArCmd@
......
......@@ -17,7 +17,8 @@ module Base (
module Development.Shake.Util,
-- * Paths
shakeFilesPath, configPath, bootPackageConstraints, packageDependencies,
shakeFilesPath, configPath, programInplacePath,
bootPackageConstraints, packageDependencies,
-- * Output
putColoured, putOracle, putBuild, putSuccess, putError, renderBox,
......@@ -56,6 +57,10 @@ shakeFilesPath = shakePath -/- ".db"
configPath :: FilePath
configPath = shakePath -/- "cfg"
-- TODO: shall we read this from system.config instead?
programInplacePath :: FilePath
programInplacePath = "inplace/bin"
bootPackageConstraints :: FilePath
bootPackageConstraints = shakeFilesPath -/- "boot-package-constraints"
......
......@@ -66,6 +66,7 @@ builderKey builder = case builder of
Ld -> "ld"
Unlit -> "unlit"
-- TODO: Paths to some builders should be determined using defaultProgramPath
builderPath :: Builder -> Action FilePath
builderPath builder = do
path <- askConfigWithDefault (builderKey builder) $
......
......@@ -105,25 +105,19 @@ defaultTargetDirectory stage pkg
| stage == Stage0 = "dist-boot"
| otherwise = "dist-install"
-- TODO: simplify
-- | Returns a relative path to the program executable
defaultProgramPath :: Stage -> Package -> Maybe FilePath
defaultProgramPath stage pkg
| pkg == compareSizes = program $ pkgName pkg
| pkg == deriveConstants = program $ pkgName pkg
| pkg == dllSplit = program $ pkgName pkg
| pkg == genapply = program $ pkgName pkg
| pkg == genprimopcode = program $ pkgName pkg
| pkg == ghc = program $ "ghc-stage" ++ show (fromEnum stage + 1)
| pkg == ghcCabal = program $ pkgName pkg
| pkg == ghcPkg = program $ pkgName pkg
| pkg == ghcPwd = program $ pkgName pkg
| pkg == ghcTags = program $ pkgName pkg
| pkg == haddock = program $ pkgName pkg
| pkg == hsc2hs = program $ pkgName pkg
| pkg == hp2ps = program $ pkgName pkg
| pkg == hpcBin = program $ pkgName pkg
| pkg == mkUserGuidePart = program $ pkgName pkg
| pkg == runghc = program $ pkgName pkg
| otherwise = Nothing
| pkg == ghc = Just . inplaceProgram $ "ghc-stage" ++ show (fromEnum stage + 1)
| pkg == haddock = case stage of
Stage2 -> Just . inplaceProgram $ pkgName pkg
_ -> Nothing
| isProgram pkg = case stage of
Stage0 -> Just . inplaceProgram $ pkgName pkg
_ -> Just . installProgram $ pkgName pkg
| otherwise = Nothing
where
program name = Just $ pkgPath pkg -/- defaultTargetDirectory stage pkg
inplaceProgram name = programInplacePath -/- name <.> exe
installProgram name = pkgPath pkg -/- defaultTargetDirectory stage pkg
-/- "build/tmp" -/- name <.> exe
......@@ -5,7 +5,8 @@ import Rules.Package
import Rules.Resources
import Settings
-- generateTargets needs top-level build targets
-- TODO: not all program targets should be needed explicitly
-- | generateTargets needs top-level build targets
generateTargets :: Rules ()
generateTargets = action $ do
targets <- fmap concat . forM [Stage0 ..] $ \stage -> do
......@@ -17,7 +18,7 @@ generateTargets = action $ do
return [ pkgHaddockFile pkg | needHaddock && stage == Stage1 ]
let programTargets = [ prog | Just prog <- programPath stage <$> pkgs ]
return $ libTargets ++ programTargets
need $ reverse targets
need targets
-- TODO: use stage 2 compiler for building stage 2 packages (instead of stage 1)
packageRules :: Rules ()
......
......@@ -184,9 +184,10 @@ withBuilderKey b = case b of
-- Expression 'with Gcc' appends "--with-gcc=/path/to/gcc" and needs Gcc.
with :: Builder -> Args
with b = specified b ? do
top <- getSetting GhcSourcePath
path <- getBuilderPath b
lift $ needBuilder laxDependencies b
append [withBuilderKey b ++ path]
append [withBuilderKey b ++ top -/- path]
withStaged :: (Stage -> Builder) -> Args
withStaged sb = (with . sb) =<< getStage
......
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