Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
address more feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alpmestan committed Mar 28, 2018
1 parent 7f5753c commit 6df0c57
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 33 deletions.
2 changes: 0 additions & 2 deletions cfg/system.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ conf-ld-linker-args-stage0 = @CONF_LD_LINKER_OPTS_STAGE0@
conf-ld-linker-args-stage1 = @CONF_LD_LINKER_OPTS_STAGE1@
conf-ld-linker-args-stage2 = @CONF_LD_LINKER_OPTS_STAGE2@

conf-hs-cpp-args = @HaskellCPPArgs@

# Include and library directories:
#=================================

Expand Down
23 changes: 21 additions & 2 deletions src/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,27 @@ data Builder = Alex
| Tar TarMode
| Unlit
| Xelatex
| CabalFlags Stage -- ^ a virtual builder to use the Arg predicate logic
-- to collect cabal flags. +x, -x
| CabalFlags Stage
-- ^ A \"virtual\" builder (not backed by a program),
-- used a lot in Settings.Packages, that allows us to
-- toggle cabal flags of packages depending on some `Args`
-- predicates, and then collect all those when we are about to
-- configure the said packages, in Hadrian.Haskell.Cabal.Parse,
-- so that we end up passing the appropriate flags to the Cabal
-- library. For example:
--
-- > package rts
-- > ? builder CabalFlags
-- > ? any (wayUnit Profiling) rtsWays
-- > ? arg "profiling"
--
-- (from Settings.Packages) specifies that if we're
-- processing the rts package with the `CabalFlag` builder,
-- and if we're building a profiling-enabled way of the rts,
-- then we pass the @profiling@ argument to the builder. This
-- argument is then collected by the code that performs the
-- package configuration, and @rts.cabal@ is processed as if
-- we were passing @-fprofiling@ to our build tool.

deriving (Eq, Generic, Show)

Expand Down
8 changes: 1 addition & 7 deletions src/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Context (

-- * Paths
contextDir, buildPath, buildDir,
pkgInplaceConfig, pkgDataFile, pkgSetupConfigFile,
pkgInplaceConfig, pkgSetupConfigFile,
pkgHaddockFile, pkgLibraryFile, pkgLibraryFile0, pkgGhciLibraryFile,
pkgConfFile, objectPath, contextPath, getContextPath,
libDir, libPath
Expand Down Expand Up @@ -80,12 +80,6 @@ pkgInplaceConfig context = do
path <- contextPath context
return $ path -/- "inplace-pkg-config"

-- | Path to the @package-data.mk@ of a given 'Context'.
pkgDataFile :: Context -> Action FilePath
pkgDataFile context = do
path <- contextPath context
return $ path -/- "package-data.mk"

-- | Path to the @setup-config@ of a given 'Context'.
pkgSetupConfigFile :: Context -> Action FilePath
pkgSetupConfigFile context = do
Expand Down
2 changes: 0 additions & 2 deletions src/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ stage1Packages = do
++ [ haddock | not cross ]
++ [ runGhc | not cross ]
++ [ hpcBin | not cross ]
-- ++ [ libiserv | not win, not cross ]
-- TODO: ^^^ fix this
++ [ iservBin | not win, not cross ]
++ [ unix | not win ]
++ [ win32 | win ]
Expand Down
3 changes: 1 addition & 2 deletions src/GHC/Packages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ghcPackages =
, ghcTags, haddock, haskeline, hsc2hs, hp2ps, hpc, hpcBin, integerGmp
, integerSimple, iservBin, libffi, mtl, parsec, parallel, pretty, primitive
, process, rts, runGhc, stm, templateHaskell, terminfo, text, time, touchy
, transformers, unlit, unix, win32, xhtml --, libiserv
, transformers, unlit, unix, win32, xhtml
]

-- TODO: Optimise by switching to sets of packages.
Expand Down Expand Up @@ -78,7 +78,6 @@ unlit = hsUtil "unlit"
unix = hsLib "unix"
win32 = hsLib "Win32"
xhtml = hsLib "xhtml"
-- libiserv = hsLib "libiserv"


-- | Construct a Haskell library package, e.g. @array@.
Expand Down
4 changes: 2 additions & 2 deletions src/Oracles/Setting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ data SettingList = ConfCcArgs Stage
| ConfCppArgs Stage
| ConfGccLinkerArgs Stage
| ConfLdLinkerArgs Stage
| ConfHsCppArgs
| HsCppArgs

-- | Maps 'Setting's to names in @cfg/system.config.in@.
setting :: Setting -> Action String
Expand Down Expand Up @@ -130,7 +130,7 @@ settingList key = fmap words $ lookupValueOrError configFile $ case key of
ConfCppArgs stage -> "conf-cpp-args-" ++ stageString stage
ConfGccLinkerArgs stage -> "conf-gcc-linker-args-" ++ stageString stage
ConfLdLinkerArgs stage -> "conf-ld-linker-args-" ++ stageString stage
ConfHsCppArgs -> "conf-hs-cpp-args"
HsCppArgs -> "hs-cpp-args"

-- | Get a configuration setting.
getSetting :: Setting -> Expr c b String
Expand Down
13 changes: 9 additions & 4 deletions src/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ allStages = [minBound .. maxBound]
topLevelTargets :: Rules ()
topLevelTargets = do
phony "stage2" $ do
putNormal "Building stage2"
(programs, libraries) <- partition isProgram <$> stagePackages Stage1
pgmNames <- mapM (g Stage1) programs
libNames <- mapM (g Stage1) libraries
putNormal . unlines $
["| Building Programs: " ++ intercalate ", " pgmNames
,"| Building Libraries: " ++ intercalate ", " libNames]

verbosity <- getVerbosity
when (verbosity >= Loud) $ do
putNormal "Building stage2"
putNormal . unlines $
[ "| Building Programs: " ++ intercalate ", " pgmNames
, "| Building Libraries: " ++ intercalate ", " libNames
]

targets <- mapM (f Stage1) =<< stagePackages Stage1
need targets

where
-- either the package database config file for libraries or
-- the programPath for programs. However this still does
Expand Down
1 change: 0 additions & 1 deletion src/Rules/Dependencies.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ buildPackageDependencies rs context@Context {..} = do
removeFile $ mk <.> "bak"

root -/- contextDir context -/- ".dependencies" %> \deps -> do
need [deps <.> "mk"]
mkDeps <- readFile' (deps <.> "mk")
writeFileChanged deps . unlines
. map (\(src, deps) -> unwords $ src : deps)
Expand Down
13 changes: 7 additions & 6 deletions src/Rules/Documentation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ documentationRules = do
archives = map pathArchive docPaths
pdfs = map pathPdf $ docPaths \\ [ "libraries" ]
need $ map (root -/-) $ [html] ++ archives ++ pdfs
need [ root -/- htmlRoot -/- "libraries" -/- "gen_contents_index" ]
need [ root -/- htmlRoot -/- "libraries" -/- "prologue.txt" ]
need [ root -/- manPagePath ]
need [ root -/- htmlRoot -/- "libraries" -/- "gen_contents_index"
, root -/- htmlRoot -/- "libraries" -/- "prologue.txt"
, root -/- manPageBuildPath
]

manPagePath :: FilePath
manPagePath = "docs/users_guide/build-man/ghc.1"
manPageBuildPath :: FilePath
manPageBuildPath = "docs/users_guide/build-man/ghc.1"

-- TODO: Add support for Documentation Packages so we can
-- run the builders without this hack.
Expand Down Expand Up @@ -211,7 +212,7 @@ buildArchive path = do
buildManPage :: Rules ()
buildManPage = do
root <- buildRootRules
root -/- manPagePath %> \file -> do
root -/- manPageBuildPath %> \file -> do
need ["docs/users_guide/ghc.rst"]
let context = vanillaContext Stage1 docPackage
withTempDir $ \dir -> do
Expand Down
7 changes: 3 additions & 4 deletions src/Rules/PackageData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ import Utilities

import Hadrian.Haskell.Cabal.Parse (configurePackage)

-- | Build @package-data.mk@ by using ghc-cabal utility to process .cabal files.
-- | Build @setup-config@ and @inplace-pkg-config@ files
-- for packages. Look at the "Rules" module to see this
-- instantiated against all the packages.
buildPackageData :: Context -> Rules ()
buildPackageData context@Context {..} = do
root <- buildRootRules
let dir = root -/- contextDir context
-- TODO: Get rid of hardcoded file paths.
dir -/- "setup-config" %> \_ -> configurePackage context

dir -/- "inplace-pkg-config" %> \conf -> do
dataFile <- pkgDataFile context
need [dataFile]
when (package == rts) $ do
genPath <- buildRoot <&> (-/- generatedDir)
rtsPath <- rtsBuildPath
Expand Down
2 changes: 1 addition & 1 deletion src/Settings/Builders/HsCpp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ hsCppBuilderArgs = builder HsCpp ? do
stage <- getStage
root <- getBuildRoot
ghcPath <- expr $ buildPath (vanillaContext stage compiler)
mconcat [ getSettingList ConfHsCppArgs
mconcat [ getSettingList HsCppArgs
, arg "-P"
, arg "-Iincludes"
, arg $ "-I" ++ root -/- generatedDir
Expand Down

0 comments on commit 6df0c57

Please sign in to comment.