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

Collect all arguments for haddock.

parent 2520d7fd
......@@ -7,6 +7,7 @@ import Settings.Builders.Ld
import Settings.Builders.Ghc
import Settings.Builders.Gcc
import Settings.Builders.GhcPkg
import Settings.Builders.Haddock
import Settings.Builders.GhcCabal
args :: Args
......@@ -34,4 +35,6 @@ defaultArgs = mconcat
, gccArgs
, arArgs
, ldArgs
, ghcCabalHsColourArgs
, haddockArgs
, customPackageArgs ]
module Settings.Builders.Ghc (ghcArgs, ghcMArgs) where
module Settings.Builders.Ghc (ghcArgs, ghcMArgs, commonGhcArgs) where
import Way
import Util
......@@ -16,61 +16,50 @@ import Settings.Ways
-- $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
-- $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno
-- $$(addsuffix .$$(dyn_osuf)-boot,$$(basename $$@)))
-- TODO: check code duplication
ghcArgs :: Args
ghcArgs = stagedBuilder Ghc ? do
way <- getWay
hsArgs <- getPkgDataList HsArgs
cppArgs <- getPkgDataList CppArgs
srcs <- getSources
file <- getFile
path <- getTargetPath
let buildPath = path -/- "build"
mconcat
[ arg "-hisuf", arg $ hisuf way
, arg "-osuf" , arg $ osuf way
, arg "-hcsuf", arg $ hcsuf way
, wayHcArgs
, packageGhcArgs
, includeGhcArgs
, append hsArgs
, append . map ("-optP" ++) $ cppArgs
, arg "-odir" , arg buildPath
, arg "-stubdir", arg buildPath
, arg "-hidir" , arg buildPath
, splitObjects ? arg "-split-objs"
, arg "-no-user-package-db" -- TODO: is this needed?
, arg "-rtsopts" -- TODO: is this needed?
, arg "-c", append srcs
, arg "-o", arg file ]
file <- getFile
srcs <- getSources
mconcat [ commonGhcArgs
, arg "-c", append srcs
, arg "-o", arg file ]
ghcMArgs :: Args
ghcMArgs = stagedBuilder GhcM ? do
ways <- getWays
file <- getFile
srcs <- getSources
ways <- getWays
file <- getFile
srcs <- getSources
mconcat [ arg "-M"
, commonGhcArgs
, arg "-dep-makefile", arg file
, append $ concat [ ["-dep-suffix", wayPrefix way] | way <- ways ]
, append srcs ]
-- This is included into ghcArgs, ghcMArgs and haddockArgs.
commonGhcArgs :: Args
commonGhcArgs = do
way <- getWay
hsArgs <- getPkgDataList HsArgs
cppArgs <- getPkgDataList CppArgs
path <- getTargetPath
let buildPath = path -/- "build"
mconcat
[ arg "-M"
, packageGhcArgs
, includeGhcArgs
, append hsArgs
, append . map ("-optP" ++) $ cppArgs
, arg "-odir" , arg buildPath
, arg "-stubdir" , arg buildPath
, arg "-hidir" , arg buildPath
, arg "-dep-makefile", arg file
, append . concatMap (\way -> ["-dep-suffix", wayPrefix way]) $ ways
, arg "-no-user-package-db" -- TODO: is this needed?
, arg "-rtsopts" -- TODO: is this needed?
, append srcs ]
mconcat [ arg "-hisuf", arg $ hisuf way
, arg "-osuf" , arg $ osuf way
, arg "-hcsuf", arg $ hcsuf way
, wayGhcArgs
, packageGhcArgs
, includeGhcArgs
, append hsArgs
, append $ map ("-optP" ++) cppArgs
, arg "-odir" , arg buildPath
, arg "-stubdir" , arg buildPath
, arg "-hidir" , arg buildPath
, splitObjects ? arg "-split-objs"
, arg "-rtsopts" ] -- TODO: is this needed?
-- TODO: do '-ticky' in all debug ways?
wayHcArgs :: Args
wayHcArgs = do
wayGhcArgs :: Args
wayGhcArgs = do
way <- getWay
mconcat [ if (Dynamic `wayUnit` way)
then append ["-fPIC", "-dynamic"]
......@@ -98,9 +87,9 @@ packageGhcArgs = do
, stage0 ? arg "-package-db libraries/bootstrapping.conf"
, if supportsPackageKey || stage /= Stage0
then mconcat [ arg $ "-this-package-key " ++ pkgKey
, append . map ("-package-key " ++) $ pkgDepKeys ]
else mconcat [ arg $ "-package-name" ++ pkgKey
, append . map ("-package " ++) $ pkgDeps ]]
, append $ map ("-package-key " ++) pkgDepKeys ]
else mconcat [ arg $ "-package-name " ++ pkgKey
, append $ map ("-package " ++) pkgDeps ]]
includeGhcArgs :: Args
includeGhcArgs = do
......@@ -113,11 +102,17 @@ includeGhcArgs = do
autogenPath = buildPath -/- "autogen"
mconcat
[ arg "-i"
, append . map (\dir -> "-i" ++ pkgPath -/- dir) $ srcDirs
, arg $ "-i" ++ buildPath
, arg $ "-i" ++ autogenPath
, arg $ "-I" ++ buildPath
, arg $ "-I" ++ autogenPath
, append . map (\dir -> "-I" ++ pkgPath -/- dir) $ incDirs
, append [ "-i" ++ pkgPath -/- dir | dir <- srcDirs ]
, append [ "-I" ++ pkgPath -/- dir | dir <- incDirs ]
, arg "-optP-include", arg $ "-optP" ++ autogenPath -/- "cabal_macros.h"
, append . map ("-optP" ++) $ cppArgs ]
, append $ map ("-optP" ++) cppArgs ]
-- TODO: see ghc.mk
-- # And then we strip it out again before building the package:
-- define libraries/ghc-prim_PACKAGE_MAGIC
-- libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
-- endef
module Settings.Builders.GhcCabal (
cabalArgs, bootPackageDbArgs, customPackageArgs
cabalArgs, ghcCabalHsColourArgs,
bootPackageDbArgs, customPackageArgs
) where
import Way
......@@ -38,6 +39,14 @@ cabalArgs = builder GhcCabal ? do
, with Alex
, with Happy ]
ghcCabalHsColourArgs :: Args
ghcCabalHsColourArgs = builder GhcCabalHsColour ? do
path <- getPackagePath
dir <- getTargetDirectory
mconcat [ arg "hscolour"
, arg path
, arg dir ]
-- TODO: Isn't vanilla always built? If yes, some conditions are redundant.
-- TODO: Need compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci?
libraryArgs :: Args
......@@ -94,7 +103,7 @@ dllArgs = arg ""
packageConstraints :: Args
packageConstraints = stage0 ? do
constraints <- lift . readFileLines $ bootPackageConstraints
append . concatMap (\c -> ["--constraint", c]) $ constraints
append $ concat [ ["--constraint", c] | c <- constraints ]
-- TODO: should be in a different file
-- TODO: put all validating options together in one file
......@@ -117,8 +126,9 @@ ghcIncludeDirs = [ "includes", "includes/dist"
, "includes/dist-ghcconstants/header" ]
cppArgs :: Args
cppArgs = append . map ("-I" ++ ) $ ghcIncludeDirs
cppArgs = append $ map ("-I" ++) ghcIncludeDirs
-- TODO: move this somewhere
customPackageArgs :: Args
customPackageArgs = do
stage <- getStage
......
module Settings.Builders.Haddock (haddockArgs) where
import Base
import Util
import Builder
import Package
import Switches
import Expression
import Oracles.PackageData
import Settings.Util
import Settings.Packages
import Settings.Builders.Ghc
import Settings.TargetDirectory
haddockArgs :: Args
haddockArgs = builder Haddock ? do
file <- getFile
srcs <- getSources
pkg <- getPackage
path <- getTargetPath
version <- getPkgData Version
synopsis <- getPkgData Synopsis
hidden <- getPkgDataList HiddenModules
deps <- getPkgDataList Deps
depNames <- getPkgDataList DepNames
ghcOpts <- fromDiffExpr commonGhcArgs
mconcat
[ arg $ "--odir=" ++ takeDirectory file
, arg "--no-tmp-comp-dir"
, arg $ "--dump-interface=" ++ file
, arg "--html"
, arg "--hoogle"
, arg $ "--title=" ++ pkgName pkg ++ "-" ++ version ++ ": " ++ synopsis
, arg $ "--prologue=" ++ path -/- "haddock-prologue.txt"
, append $ map ("--hide=" ++) hidden
, append $ [ "--read-interface=../" ++ dep
++ ",../" ++ dep ++ "/src/%{MODULE/./-}.html\\#%{NAME},"
++ pkgHaddockPath depPkg
| (dep, depName) <- zip deps depNames
, Just depPkg <- [findKnownPackage depName] ]
, append [ "--optghc=" ++ opt | opt <- ghcOpts ]
, arg "--source-module=src/%{MODULE/./-}.html"
, arg "--source-entity=src/%{MODULE/./-}.html\\#%{NAME}"
, customPackageArgs
, append srcs
, arg "+RTS"
, arg $ "-t" ++ file <.> "t"
, arg "--machine-readable" ]
customPackageArgs :: Args
customPackageArgs = mconcat
[ package compiler ? stage1 ?
arg "--optghc=-DSTAGE=2" ]
-- , package ghcPrim ? stage1 ?
-- arg "libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs" ]
-- From ghc.mk:
-- # -----------------------------------------------
-- # Haddock-related bits
-- # Build the Haddock contents and index
-- ifeq "$(HADDOCK_DOCS)" "YES"
-- libraries/dist-haddock/index.html: $(haddock_INPLACE) $(ALL_HADDOCK_FILES)
-- cd libraries && sh gen_contents_index --intree
-- ifeq "$(phase)" "final"
-- $(eval $(call all-target,library_doc_index,libraries/dist-haddock/index.html))
-- endif
-- INSTALL_LIBRARY_DOCS += libraries/dist-haddock/*
-- endif
......@@ -4,7 +4,7 @@ module Settings.Util (
argSetting, argSettingList,
getFlag, getSetting, getSettingList,
getPkgData, getPkgDataList,
getPackagePath, getTargetPath, getTargetDirectory,
getPackagePath, getTargetDirectory, getTargetPath, getHaddockPath,
getPackageSources,
appendCcArgs,
needBuilder
......@@ -66,11 +66,14 @@ getPkgDataList key = do
getPackagePath :: Expr FilePath
getPackagePath = liftM pkgPath getPackage
getTargetDirectory :: Expr FilePath
getTargetDirectory = liftM2 targetDirectory getStage getPackage
getTargetPath :: Expr FilePath
getTargetPath = liftM2 targetPath getStage getPackage
getTargetDirectory :: Expr FilePath
getTargetDirectory = liftM2 targetDirectory getStage getPackage
getHaddockPath :: Expr FilePath
getHaddockPath = liftM pkgHaddockPath getPackage
-- Find all Haskell source files for the current target
getPackageSources :: Expr [FilePath]
......
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