Skip to content

Commit 21cdce2

Browse files
[shake-bench] extract project dependencies action (for the HEAD binary) (#1325)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 762838d commit 21cdce2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

ghcide/bench/hist/Main.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import Development.Shake.Classes
5555
import System.Console.GetOpt
5656
import Data.Maybe
5757
import Control.Monad.Extra
58+
import System.FilePath
5859

5960

6061
configPath :: FilePath
@@ -84,7 +85,12 @@ main = shakeArgsWith shakeOpts [configOpt] $ \configs wants -> pure $ Just $ do
8485
_ -> want wants
8586

8687
ghcideBuildRules :: MkBuildRules BuildSystem
87-
ghcideBuildRules = MkBuildRules findGhcForBuildSystem "ghcide" buildGhcide
88+
ghcideBuildRules = MkBuildRules findGhcForBuildSystem "ghcide" projectDepends buildGhcide
89+
where
90+
projectDepends = do
91+
need . map ("src" </>) =<< getDirectoryFiles "src" ["//*.hs"]
92+
need . map ("session-loader" </>) =<< getDirectoryFiles "session-loader" ["//*.hs"]
93+
need =<< getDirectoryFiles "." ["*.cabal"]
8894

8995
--------------------------------------------------------------------------------
9096

shake-bench/src/Development/Benchmark/Rules.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ data MkBuildRules buildSystem = MkBuildRules
177177
findGhc :: buildSystem -> FilePath -> IO FilePath
178178
-- | Name of the binary produced by 'buildProject'
179179
, executableName :: String
180+
-- | An action that captures the source dependencies, used for the HEAD build
181+
, projectDepends :: Action ()
180182
-- | Build the project found in the cwd and save the build artifacts in the output folder
181183
, buildProject :: buildSystem
182184
-> [CmdOption]
@@ -204,9 +206,8 @@ buildRules build MkBuildRules{..} = do
204206
, build -/- "binaries/HEAD/ghc.path"
205207
]
206208
&%> \[out, ghcpath] -> do
209+
projectDepends
207210
liftIO $ createDirectoryIfMissing True $ dropFileName out
208-
-- TOOD more precise dependency tracking
209-
need =<< getDirectoryFiles "." ["//*.hs", "*.cabal"]
210211
buildSystem <- askOracle $ GetBuildSystem ()
211212
buildProject buildSystem [Cwd "."] (takeDirectory out)
212213
ghcLoc <- liftIO $ findGhc buildSystem "."

0 commit comments

Comments
 (0)