Commit 72965574 authored by Andreas Klebinger's avatar Andreas Klebinger

Create empty package db if there are no dependencies.

This allows for a uniform ghc invocation where we always pass the same
db.
parent 216a7062
......@@ -13,6 +13,7 @@ import Data.List
import Data.Maybe
import qualified Data.Map.Strict as M
import qualified System.Directory as IO
import qualified System.FilePath as FP
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import System.Info hiding (compilerVersion)
......@@ -21,7 +22,7 @@ import Data.String
import Options.Applicative
-- Shake - build system
import Development.Shake hiding ((*>))
import Development.Shake
import Development.Shake.FilePath hiding (exe)
import qualified Measurements as Ms
......@@ -187,6 +188,9 @@ main = do
when clean $
removeDirectoryRecursive output
-- Turns "ghc" into /usr/bin/../ghc
compiler_path <- fromMaybe (error "Couldn't find GHC at" ++ compiler) <$> IO.findExecutable compiler
tests' <- getTestDirs tests
putStrLn $ "Running: " ++ unwords (map unTestName tests')
......@@ -198,7 +202,7 @@ main = do
, shakeVerbosity = Development.Shake.Loud
}
shake shakeOpts $ buildRules (args {tests = tests'})
shake shakeOpts $ buildRules (args {tests = tests', compiler = compiler_path})
putStrLn "Build completed"
......@@ -262,9 +266,12 @@ buildRules nofib@Build{..} = do
(output </> "cachegrind.results.tsv") %> aggregateTarget ["Main.cachegrind.results.tsv"]
(output </> "run.results.tsv") %> aggregateTarget ["Main" <.> "link.tsv", "Main.run.results.tsv"]
let ghcPkg = let (path, _ghcExec) = (FP.splitFileName compiler)
in path </> "ghc-pkg" <> IO.exeExtension
-- Build dependency installation
let buildDepsRoot = output </> "dep-packages"
buildDepsStamp = buildDepsRoot </> ".stamp"
let buildDepsRoot = output </> "dep-packages" :: FilePath
buildDepsStamp = buildDepsRoot </> ".stamp" :: FilePath
let buildDepsPkgDb = do
need [buildDepsStamp]
compilerVer <- liftIO $ compilerVersion compiler
......@@ -273,9 +280,13 @@ buildRules nofib@Build{..} = do
-- convince cabal v2-install to create such a file.
-- The cabal env interface described here looks handy:
-- https://github.com/haskell/cabal/issues/6481#issuecomment-620865817
return $ buildDepsRoot </> ("ghc-" <> compilerVer) </> "package.db"
let pkgdb_path = buildDepsRoot </> ("ghc-" <> compilerVer) </> "package.db"
return $ pkgdb_path
buildDepsArgs _test = do
pkgdb <- buildDepsPkgDb
db_exists <- liftIO $ IO.doesPathExist pkgdb
unless (db_exists) $ do
cmd_ ghcPkg "init" pkgdb
return [ "-package-db", pkgdb, "-no-user-package-db" ]
buildDepsStamp %> \out -> do
......@@ -283,7 +294,8 @@ buildRules nofib@Build{..} = do
let deps = foldMap (\config -> words $ config "SRC_DEPS") configs
-- TODO: Invoking cabal in the way we do without any package argument fails.
root <- liftIO $ IO.makeAbsolute buildDepsRoot
cmd_ "cabal" ("--store-dir=" <> root) "v2-install" "--lib" "-w" compiler "--allow-newer" ("hashmap":deps)
unless (null deps) $ cmd_ "cabal" ("--store-dir=" <> root) "v2-install" "--lib" "-w" compiler "--allow-newer" deps
-- cmd_ "cabal" ("--store-dir=" <> root) "v2-install" "--lib" "-w" compiler "--allow-newer" deps
liftIO $ writeFile out ""
-- Benchmark rules
......
......@@ -37,6 +37,7 @@ executable nofib-run
containers,
bytestring,
directory >=1.3 && <1.4,
filepath,
process >=1.6 && <1.7,
text,
optparse-applicative,
......
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