Skip to content

Commit

Permalink
Provide '-hpcdir' option to configure step rather than build
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Jul 22, 2015
1 parent d3e3568 commit 57ac913
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ ensureConfig pkgDir ExecuteEnv {..} Task {..} announce cabal cabalfp extra = do
mOldCabalMod <- tryGetCabalMod pkgDir
newCabalMod <- liftIO (fmap modTime (D.getModificationTime (toFilePath cabalfp)))

hpcIndexDir <- toFilePath . (</> dotHpc) <$> hpcRelativeDir
idMap <- liftIO $ readTVarIO eeGhcPkgIds
let getMissing ident =
case Map.lookup ident idMap of
Expand All @@ -466,7 +467,8 @@ ensureConfig pkgDir ExecuteEnv {..} Task {..} announce cabal cabalfp extra = do
Just (Executable _) -> Nothing
missing' = Set.fromList $ mapMaybe getMissing $ Set.toList missing
TaskConfigOpts missing mkOpts = taskConfigOpts
configOpts = mkOpts missing' ++ extra
configOpts = mkOpts missing' ++ extra ++
["--ghc-options", "-hpcdir " <> T.pack hpcIndexDir]
allDeps = Set.union missing' taskPresent
newConfigCache = ConfigCache
{ configCacheOpts = map encodeUtf8 configOpts
Expand Down Expand Up @@ -662,11 +664,10 @@ singleBuild ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} =

announce "build"
config <- asks getConfig
extraOpts <- extraBuildOptions
cabal (console && configHideTHLoading config) $
(case taskType of
case taskType of
TTLocal lp -> "build" : map T.unpack (Set.toList $ lpComponents lp)
TTUpstream _ _ -> ["build"]) ++ extraOpts
TTUpstream _ _ -> ["build"]

let doHaddock = shouldHaddockPackage eeBuildOpts eeWanted (packageName package) &&
-- Works around haddock failing on bytestring-builder since it has no modules
Expand Down Expand Up @@ -744,9 +745,8 @@ singleTest topts ac ee task =
case taskType task of
TTLocal lp -> writeBuildCache pkgDir $ lpNewBuildCache lp
TTUpstream _ _ -> assert False $ return ()
extraOpts <- extraBuildOptions
cabal (console && configHideTHLoading config) $
"build" : (extraOpts ++ components)
"build" : components
setTestBuilt pkgDir

toRun <-
Expand Down Expand Up @@ -933,8 +933,7 @@ singleBench beopts ac ee task =
TTLocal lp -> writeBuildCache pkgDir $ lpNewBuildCache lp
TTUpstream _ _ -> assert False $ return ()
config <- asks getConfig
extraOpts <- extraBuildOptions
cabal (console && configHideTHLoading config) ("build" : extraOpts)
cabal (console && configHideTHLoading config) ["build"]
setBenchBuilt pkgDir
let args = maybe []
((:[]) . ("--benchmark-options=" <>))
Expand Down Expand Up @@ -1019,8 +1018,3 @@ getSetupHs dir = do
where
fp1 = dir </> $(mkRelFile "Setup.hs")
fp2 = dir </> $(mkRelFile "Setup.lhs")

extraBuildOptions :: M env m => m [String]
extraBuildOptions = do
hpcIndexDir <- toFilePath . (</> dotHpc) <$> hpcRelativeDir
return ["--ghc-options", "-hpcdir " ++ hpcIndexDir]

0 comments on commit 57ac913

Please sign in to comment.