From 5580f1714ef0b1bf5ca67426d1fcdaceb9e320e7 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Tue, 2 Feb 2021 11:47:34 +0000 Subject: [PATCH] [shake-bench] extract project dependencies action (for the HEAD binary) --- ghcide/bench/hist/Main.hs | 8 +++++++- shake-bench/src/Development/Benchmark/Rules.hs | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ghcide/bench/hist/Main.hs b/ghcide/bench/hist/Main.hs index c34e2529a1..f621113362 100644 --- a/ghcide/bench/hist/Main.hs +++ b/ghcide/bench/hist/Main.hs @@ -55,6 +55,7 @@ import Development.Shake.Classes import System.Console.GetOpt import Data.Maybe import Control.Monad.Extra +import System.FilePath configPath :: FilePath @@ -84,7 +85,12 @@ main = shakeArgsWith shakeOpts [configOpt] $ \configs wants -> pure $ Just $ do _ -> want wants ghcideBuildRules :: MkBuildRules BuildSystem -ghcideBuildRules = MkBuildRules findGhcForBuildSystem "ghcide" buildGhcide +ghcideBuildRules = MkBuildRules findGhcForBuildSystem "ghcide" projectDepends buildGhcide + where + projectDepends = do + need . map ("src" ) =<< getDirectoryFiles "src" ["//*.hs"] + need . map ("session-loader" ) =<< getDirectoryFiles "session-loader" ["//*.hs"] + need =<< getDirectoryFiles "." ["*.cabal"] -------------------------------------------------------------------------------- diff --git a/shake-bench/src/Development/Benchmark/Rules.hs b/shake-bench/src/Development/Benchmark/Rules.hs index cca1e7fa24..e57c7f4ca7 100644 --- a/shake-bench/src/Development/Benchmark/Rules.hs +++ b/shake-bench/src/Development/Benchmark/Rules.hs @@ -177,6 +177,8 @@ data MkBuildRules buildSystem = MkBuildRules findGhc :: buildSystem -> FilePath -> IO FilePath -- | Name of the binary produced by 'buildProject' , executableName :: String + -- | An action that captures the source dependencies, used for the HEAD build + , projectDepends :: Action () -- | Build the project found in the cwd and save the build artifacts in the output folder , buildProject :: buildSystem -> [CmdOption] @@ -204,9 +206,8 @@ buildRules build MkBuildRules{..} = do , build -/- "binaries/HEAD/ghc.path" ] &%> \[out, ghcpath] -> do + projectDepends liftIO $ createDirectoryIfMissing True $ dropFileName out - -- TOOD more precise dependency tracking - need =<< getDirectoryFiles "." ["//*.hs", "*.cabal"] buildSystem <- askOracle $ GetBuildSystem () buildProject buildSystem [Cwd "."] (takeDirectory out) ghcLoc <- liftIO $ findGhc buildSystem "."