From 57ac9136f527b59c8fad83795e49d14c289ee07a Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Tue, 21 Jul 2015 16:49:35 -0700 Subject: [PATCH] Provide '-hpcdir' option to configure step rather than build --- src/Stack/Build/Execute.hs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Stack/Build/Execute.hs b/src/Stack/Build/Execute.hs index 006d1b5ed0..03df9bb296 100644 --- a/src/Stack/Build/Execute.hs +++ b/src/Stack/Build/Execute.hs @@ -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 @@ -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 @@ -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 @@ -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 <- @@ -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=" <>)) @@ -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]