Commit 3579324b authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Clean up.

parent 4c715acd
......@@ -18,7 +18,8 @@ buildPackage pkg todoItem = do
packageRules :: Rules ()
packageRules = do
want ["libraries/deepseq/dist-install/build/deepseq.m"] -- TODO: control targets from commang line arguments
-- TODO: control targets from commang line arguments
want ["libraries/deepseq/dist-install/build/deepseq.m"]
forM_ packages $ \pkg -> do
forM_ (pkgTodo pkg) $ \todoItem -> do
buildPackage pkg todoItem
{-# LANGUAGE NoImplicitPrelude, ScopedTypeVariables #-}
module Package.Data (buildPackageData) where
import Package.Base
libraryArgs :: [Way] -> Args
......@@ -18,7 +19,10 @@ configureArgs stage settings =
s <- unwords <$> arg as
unless (null s) $ arg $ "--configure-option=" ++ key ++ "=" ++ s
cflags = commonCcArgs `filterOut` "-Werror" <+> ConfCcArgs stage <+> customCcArgs settings <+> commonCcWarninigArgs
cflags = commonCcArgs `filterOut` "-Werror"
<+> ConfCcArgs stage
<+> customCcArgs settings
<+> commonCcWarninigArgs
ldflags = commonLdArgs <+> ConfGccLinkerArgs stage <+> customLdArgs settings
cppflags = commonCppArgs <+> ConfCppArgs stage <+> customCppArgs settings
......
......@@ -3,18 +3,17 @@ module Package.Dependencies (buildPackageDependencies) where
import Package.Base
packageKeyArgs :: Stage -> FilePath -> Args
packageKeyArgs stage pkgData =
arg "-hide-all-packages" <>
(pkgArgs =<< SupportsPackageKey || stage /= Stage0)
packageArgs :: Stage -> FilePath -> Args
packageArgs stage pkgData = do
usePackageKey <- SupportsPackageKey || stage /= Stage0
arg ["-hide-all-packages", "-no-user-package-db", "-include-pkg-deps"]
<> when (stage == Stage0) (arg "-package-db libraries/bootstrapping.conf")
<> keyArgs usePackageKey
where
pkgArgs True = "-this-package-key"
<+> PackageKey pkgData
<+> prepend "-package-key " (DepKeys pkgData)
pkgArgs _ = "-package-name"
<+> PackageKey pkgData
<+> prepend "-package " (Deps pkgData)
prepend pref = (map (pref ++) <$>) . arg
keyArgs True = prefixArgs "-this-package-key" (PackageKey pkgData) <>
prefixArgs "-package-key" (DepKeys pkgData)
keyArgs False = prefixArgs "-package-name" (PackageKey pkgData) <>
prefixArgs "-package" (Deps pkgData)
includeArgs :: ShowArgs a => String -> FilePath -> a -> Args
includeArgs prefix path as = map includePath <$> arg as
......@@ -26,7 +25,7 @@ srcArgs :: FilePath -> FilePath -> Args
srcArgs path pkgData = do
mods <- map (replaceEq '.' pathSeparator) <$> arg (Modules pkgData)
dirs <- arg (SrcDirs pkgData)
srcs <- getDirectoryFiles "" $
srcs <- getDirectoryFiles ""
[path </> dir </> mPath <.> ext | dir <- dirs, mPath <- mods, ext <- ["hs", "lhs"]]
arg (map normalise srcs)
......@@ -38,20 +37,18 @@ buildPackageDependencies pkg @ (Package name path _) (stage, dist, settings) =
(buildDir </> "build" </> name <.> "m") %> \out -> do
need ["shake/src/Package/Dependencies.hs"] -- Track changes in this file
run (Ghc stage) $ arg "-M"
<> when (stage == Stage0) (arg "-package-db libraries/bootstrapping.conf")
<> packageKeyArgs stage pkgData
<> packageArgs stage pkgData
<> arg "-i"
<> includeArgs "-i" path (SrcDirs pkgData)
<> includeArgs "-i" buildDir ["build", "build/autogen"]
<> includeArgs "-I" buildDir ["build", "build/autogen"]
<> includeArgs "-I" path (IncludeDirs pkgData)
<> arg ["-optP-include", "-optP" ++ buildDir </> "build/autogen/cabal_macros.h"]
<> arg "-no-user-package-db"
<> arg ["-odir" , buildDir </> "build"]
<> arg ["-stubdir", buildDir </> "build"]
<> arg ("-dep-makefile " ++ out)
<> (concatMap (\w -> ["-dep-suffix", suffix w]) <$> ways settings)
<> arg "-include-pkg-deps"
<> arg "-optP-include" -- TODO: Shall we also add -cpp?
<> arg ("-optP" ++ buildDir </> "build/autogen/cabal_macros.h")
<> arg ["-odir" , buildDir </> "build"]
<> arg ["-stubdir" , buildDir </> "build"]
<> arg ["-dep-makefile", out ]
<> prefixArgs "-dep-suffix" (map suffix <$> ways settings)
<> srcArgs path pkgData
-- <> arg SrcHcOpts -- TODO: Check that skipping all _HC_OPTS is safe.
-- <> wayHcOpts vanilla -- TODO: i) is this needed? ii) shall we run GHC -M multiple times?
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