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

Reorder source arguments

parent 71b2b968
......@@ -90,7 +90,6 @@ executable hadrian
, Settings.Flavours.Profiled
, Settings.Flavours.Quick
, Settings.Flavours.Quickest
, Settings.SourceArgs
, Settings.Packages.Base
, Settings.Packages.Compiler
, Settings.Packages.Ghc
......
module Settings.Builders.Ghc (ghcBuilderArgs, ghcMBuilderArgs, commonGhcArgs) where
module Settings.Builders.Ghc (ghcBuilderArgs, ghcMBuilderArgs, haddockGhcArgs) where
import Flavour
import GHC
......@@ -52,7 +52,10 @@ ghcMBuilderArgs = builder (Ghc FindHsDependencies) ? do
, append $ concat [ ["-dep-suffix", wayPrefix w] | w <- ways ]
, append =<< getInputs ]
-- This is included into ghcBuilderArgs, ghcMBuilderArgs and haddockBuilderArgs.
haddockGhcArgs :: Args
haddockGhcArgs = mconcat [ commonGhcArgs, append =<< getPkgDataList HsArgs ]
-- This is included into ghcBuilderArgs, ghcMBuilderArgs and haddockGhcArgs.
commonGhcArgs :: Args
commonGhcArgs = do
way <- getWay
......@@ -66,7 +69,6 @@ commonGhcArgs = do
, wayGhcArgs
, packageGhcArgs
, includeGhcArgs
, append =<< getPkgDataList HsArgs
, append $ map ("-optc" ++) confCc
, append $ map ("-optP" ++) confCpp
, append $ map ("-optP" ++) cppArgs
......
......@@ -19,7 +19,7 @@ haddockBuilderArgs = builder Haddock ? do
deps <- getPkgDataList Deps
depNames <- getPkgDataList DepNames
hVersion <- lift . pkgData . Version $ buildPath (vanillaContext Stage2 haddock)
ghcOpts <- fromDiffExpr commonGhcArgs
ghcOpts <- fromDiffExpr haddockGhcArgs
mconcat
[ arg $ "--odir=" ++ takeDirectory output
, arg "--verbosity=0"
......
module Settings.Default (
defaultBuilderArgs, defaultPackageArgs, defaultArgs, defaultPackages,
defaultLibraryWays, defaultRtsWays, defaultFlavour, defaultSplitObjects
SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs,
defaultArgs, defaultPackages, defaultLibraryWays, defaultRtsWays,
defaultFlavour, defaultSplitObjects
) where
import Base
......@@ -9,6 +10,7 @@ import Flavour
import GHC
import Oracles.Config.Flag
import Oracles.Config.Setting
import Oracles.PackageData
import Predicate
import Settings
import Settings.Builders.Alex
......@@ -27,7 +29,6 @@ import Settings.Builders.HsCpp
import Settings.Builders.Ld
import Settings.Builders.Make
import Settings.Builders.Tar
import Settings.SourceArgs
import Settings.Packages.Base
import Settings.Packages.Compiler
import Settings.Packages.Ghc
......@@ -39,6 +40,24 @@ import Settings.Packages.IntegerGmp
import Settings.Packages.Rts
import Settings.Packages.RunGhc
-- TODO: Move C source arguments here
-- | Default and package-specific source arguments.
data SourceArgs = SourceArgs
{ hsDefault :: Args
, hsLibrary :: Args
, hsCompiler :: Args
, hsGhc :: Args }
-- | Concatenate source arguments in appropriate order.
sourceArgs :: SourceArgs -> Args
sourceArgs SourceArgs {..} = builder Ghc ? do
pkg <- getPackage
mconcat [ hsDefault
, append =<< getPkgDataList HsArgs
, isLibrary pkg ? hsLibrary
, package compiler ? hsCompiler
, package ghc ? hsGhc ]
-- | All default command line arguments.
defaultArgs :: Args
defaultArgs = mconcat
......@@ -46,7 +65,7 @@ defaultArgs = mconcat
, sourceArgs defaultSourceArgs
, defaultPackageArgs ]
-- | Default optimisation settings.
-- | Default source arguments, e.g. optimisation settings.
defaultSourceArgs :: SourceArgs
defaultSourceArgs = SourceArgs
{ hsDefault = mconcat [stage0 ? arg "-O", notStage0 ? arg "-O2", arg "-H32m"]
......
module Settings.Default (
defaultBuilderArgs, defaultPackageArgs, defaultArgs, defaultPackages,
defaultLibraryWays, defaultRtsWays, defaultFlavour, defaultSplitObjects
SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs,
defaultArgs, defaultPackages, defaultLibraryWays, defaultRtsWays,
defaultFlavour, defaultSplitObjects
) where
import Flavour
import Predicate
data SourceArgs = SourceArgs
{ hsDefault :: Args
, hsLibrary :: Args
, hsCompiler :: Args
, hsGhc :: Args }
sourceArgs :: SourceArgs -> Args
defaultBuilderArgs, defaultPackageArgs, defaultArgs :: Args
defaultPackages :: Packages
defaultLibraryWays, defaultRtsWays :: Ways
......
......@@ -3,7 +3,6 @@ module Settings.Flavours.Development (developmentFlavour) where
import Flavour
import Predicate
import {-# SOURCE #-} Settings.Default
import Settings.SourceArgs
-- TODO: Implement an equivalent of LAX_DEPENDENCIES = YES setting, see #250.
developmentFlavour :: Stage -> Flavour
......
......@@ -3,7 +3,6 @@ module Settings.Flavours.Performance (performanceFlavour) where
import Flavour
import Predicate
import {-# SOURCE #-} Settings.Default
import Settings.SourceArgs
performanceFlavour :: Flavour
performanceFlavour = defaultFlavour
......
......@@ -3,7 +3,6 @@ module Settings.Flavours.Profiled (profiledFlavour) where
import Flavour
import Predicate
import {-# SOURCE #-} Settings.Default
import Settings.SourceArgs
profiledFlavour :: Flavour
profiledFlavour = defaultFlavour
......
......@@ -3,7 +3,6 @@ module Settings.Flavours.Quick (quickFlavour) where
import Flavour
import Predicate
import {-# SOURCE #-} Settings.Default
import Settings.SourceArgs
quickFlavour :: Flavour
quickFlavour = defaultFlavour
......@@ -11,7 +10,6 @@ quickFlavour = defaultFlavour
, args = defaultBuilderArgs <> quickArgs <> defaultPackageArgs
, libraryWays = append [vanilla] }
-- TODO: the hsLibrary setting seems wrong, but it matches mk/flavours/quick.mk
quickArgs :: Args
quickArgs = sourceArgs $ SourceArgs
{ hsDefault = append ["-O0", "-H64m"]
......
......@@ -3,7 +3,6 @@ module Settings.Flavours.Quickest (quickestFlavour) where
import Flavour
import Predicate
import {-# SOURCE #-} Settings.Default
import Settings.SourceArgs
quickestFlavour :: Flavour
quickestFlavour = defaultFlavour
......
module Settings.SourceArgs (SourceArgs (..), sourceArgs) where
import GHC
import Predicate
-- TODO: Move C source arguments here
data SourceArgs = SourceArgs
{ hsDefault :: Args
, hsLibrary :: Args
, hsCompiler :: Args
, hsGhc :: Args }
sourceArgs :: SourceArgs -> Args
sourceArgs SourceArgs {..} = do
hsCompile <- builder $ Ghc CompileHs
hsLink <- builder $ Ghc LinkHs
pkg <- getPackage
mconcat [ (hsCompile || hsLink) ? hsDefault
, hsCompile ? isLibrary pkg ? hsLibrary
, hsCompile ? package compiler ? hsCompiler
, (hsCompile || hsLink) ? package ghc ? hsGhc ]
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