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

Add comments.

parent 7d53e6b4
......@@ -24,7 +24,7 @@ data Environment = Environment
getStage :: Stage,
getPackage :: Package,
getBuilder :: Builder,
getFile :: FilePath,
getFile :: FilePath, -- TODO: handle multple files?
getWay :: Way
}
......
......@@ -13,29 +13,6 @@ import Settings.GhcPkg
import Settings.GhcCabal
import Util
-- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
-- 1) Drop lines containing '$'
-- For example, get rid of
-- libraries/Win32_dist-install_CMM_SRCS := $(addprefix cbits/,$(notdir ...
-- Reason: we don't need them and we can't parse them.
-- 2) Replace '/' and '\' with '_' before '='
-- For example libraries/deepseq/dist-install_VERSION = 1.4.0.0
-- is replaced by libraries_deepseq_dist-install_VERSION = 1.4.0.0
-- Reason: Shake's built-in makefile parser doesn't recognise slashes
postProcessPackageData :: FilePath -> Action ()
postProcessPackageData file = do
pkgData <- (filter ('$' `notElem`) . lines) <$> liftIO (readFile file)
length pkgData `seq` writeFileLines file $ map processLine pkgData
where
processLine line = replaceSeparators '_' prefix ++ suffix
where
(prefix, suffix) = break (== '=') line
-- this is a positional argument, hence:
-- * if it is empty, we need to emit one empty string argument
-- * otherwise, we must collapse it into one space-separated string
-- Build package-data.mk by using GhcCabal to process pkgCabal file
buildPackageData :: Environment -> Rules ()
buildPackageData env =
......@@ -53,6 +30,8 @@ buildPackageData env =
-- , "build" </> "autogen" </> ("Paths_" ++ name) <.> "hs"
] &%> \_ -> do
let configure = pkgPath pkg </> "configure"
-- TODO: 1) how to automate this? 2) handle multiple files?
newEnv = env { getFile = dir </> "package-data.mk" }
-- GhcCabal will run the configure script, so we depend on it
need [pkgPath pkg </> pkgCabal pkg]
-- We still don't know who built the configure script from configure.ac
......@@ -62,37 +41,28 @@ buildPackageData env =
run' env (GhcPkg stage)
postProcessPackageData $ dir </> "package-data.mk"
-- TODO: This should probably go to Oracles.Builder
run' :: Environment -> Builder -> Action ()
run' env builder = do
args <- interpret (env {getBuilder = builder}) $ fromDiff settings
putColoured Green (show args)
run builder args
--buildRule :: Package -> TodoItem -> Rules ()
--buildRule pkg @ (Package name path cabal _) todo @ (stage, dist, settings) =
-- let pathDist = path </> dist
-- cabalPath = path </> cabal
-- configure = path </> "configure"
-- in
-- -- All these files are produced by a single run of GhcCabal
-- (pathDist </>) <$>
-- [ "package-data.mk"
-- , "haddock-prologue.txt"
-- , "inplace-pkg-config"
-- , "setup-config"
-- , "build" </> "autogen" </> "cabal_macros.h"
-- -- TODO: Is this needed? Also check out Paths_cpsa.hs.
-- -- , "build" </> "autogen" </> ("Paths_" ++ name) <.> "hs"
-- ] &%> \_ -> do
-- need [cabalPath]
-- when (doesFileExist $ configure <.> "ac") $ need [configure]
-- -- GhcCabal will run the configure script, so we depend on it
-- -- We still don't know who build the configure script from configure.ac
-- run GhcCabal $ cabalArgs pkg todo
-- when (registerPackage settings) $
-- run (GhcPkg stage) $ ghcPkgArgs pkg todo
-- postProcessPackageData $ pathDist </> "package-data.mk"
-- buildSettings = + builder Gcc ? ccSettings
-- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
-- 1) Drop lines containing '$'
-- For example, get rid of
-- libraries/Win32_dist-install_CMM_SRCS := $(addprefix cbits/,$(notdir ...
-- Reason: we don't need them and we can't parse them.
-- 2) Replace '/' and '\' with '_' before '='
-- For example libraries/deepseq/dist-install_VERSION = 1.4.0.0
-- is replaced by libraries_deepseq_dist-install_VERSION = 1.4.0.0
-- Reason: Shake's built-in makefile parser doesn't recognise slashes
-- builder Gcc ? "-tricky-flag"
postProcessPackageData :: FilePath -> Action ()
postProcessPackageData file = do
pkgData <- (filter ('$' `notElem`) . lines) <$> liftIO (readFile file)
length pkgData `seq` writeFileLines file $ map processLine pkgData
where
processLine line = replaceSeparators '_' prefix ++ suffix
where
(prefix, suffix) = break (== '=') line
......@@ -83,6 +83,9 @@ bootPackageDbSettings = do
sourcePath <- lift $ askConfig "ghc-source-path"
arg $ "--package-db=" ++ sourcePath </> "libraries/bootstrapping.conf"
-- this is a positional argument, hence:
-- * if it is empty, we need to emit one empty string argument
-- * otherwise, we must collapse it into one space-separated string
dllSettings :: Settings
dllSettings = arg ""
......
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