Skip to content

[shake-bench] extract project dependencies action (for the HEAD binary) #1325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ghcide/bench/hist/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import Development.Shake.Classes
import System.Console.GetOpt
import Data.Maybe
import Control.Monad.Extra
import System.FilePath


configPath :: FilePath
Expand Down Expand Up @@ -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"]

--------------------------------------------------------------------------------

Expand Down
5 changes: 3 additions & 2 deletions shake-bench/src/Development/Benchmark/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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 "."
Expand Down