Skip to content

Commit a59a505

Browse files
committed
tweak script used to build candidate ghcide in benchmarks
The goal is to convince Cabal to apply the ghc options only to the ghcide binary and not to all the dependencies, which causes massive rebuilds and leads to benchmarks timeouts
1 parent aa5fc7f commit a59a505

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

ghcide/bench/hist/Main.hs

+19-7
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import System.Console.GetOpt
5656
import Data.Maybe
5757
import Control.Monad.Extra
5858
import System.FilePath
59+
import System.Directory as IO
5960

6061

6162
configPath :: FilePath
@@ -138,20 +139,31 @@ type instance RuleResult GetSamples = Natural
138139

139140
--------------------------------------------------------------------------------
140141

141-
buildGhcide :: BuildSystem -> [CmdOption] -> FilePath -> Action ()
142-
buildGhcide Cabal args out = do
143-
command_ args "cabal"
142+
buildGhcide
143+
:: BuildSystem
144+
-> FilePath -- ^ working directory
145+
-> FilePath -- ^ output folder
146+
-> Action ()
147+
buildGhcide Cabal cwd out = do
148+
let cabalLocal = cwd </> "cabal.project.local"
149+
previousValue <- liftIO $ do
150+
itExisted <- IO.doesFileExist cabalLocal
151+
if itExisted then Just <$> readFile cabalLocal else pure Nothing
152+
liftIO $ writeFile cabalLocal $ unlines
153+
[ "package ghcide"
154+
, " ghc-options: -eventlog -rtsopts"]
155+
command_ [Cwd cwd] "cabal"
144156
["install"
145157
,"exe:ghcide"
146158
,"--installdir=" ++ out
147159
,"--install-method=copy"
148160
,"--overwrite-policy=always"
149-
,"--ghc-options=-rtsopts"
150-
,"--ghc-options=-eventlog"
151161
]
162+
liftIO $ removeFile cabalLocal
163+
liftIO $ whenJust previousValue $ writeFile cabalLocal
152164

153-
buildGhcide Stack args out =
154-
command_ args "stack"
165+
buildGhcide Stack cwd out =
166+
command_ [Cwd cwd] "stack"
155167
["--local-bin-path=" <> out
156168
,"build"
157169
,"ghcide:ghcide"

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ data MkBuildRules buildSystem = MkBuildRules
181181
, projectDepends :: Action ()
182182
-- | Build the project found in the cwd and save the build artifacts in the output folder
183183
, buildProject :: buildSystem
184-
-> [CmdOption]
184+
-> FilePath
185185
-> OutputFolder
186186
-> Action ()
187187
}
@@ -209,7 +209,7 @@ buildRules build MkBuildRules{..} = do
209209
projectDepends
210210
liftIO $ createDirectoryIfMissing True $ dropFileName out
211211
buildSystem <- askOracle $ GetBuildSystem ()
212-
buildProject buildSystem [Cwd "."] (takeDirectory out)
212+
buildProject buildSystem "." (takeDirectory out)
213213
ghcLoc <- liftIO $ findGhc buildSystem "."
214214
writeFile' ghcpath ghcLoc
215215

@@ -224,7 +224,7 @@ buildRules build MkBuildRules{..} = do
224224
buildSystem <- askOracle $ GetBuildSystem ()
225225
flip actionFinally (cmd_ ("git worktree remove bench-temp-" <> ver <> " --force" :: String)) $ do
226226
ghcLoc <- liftIO $ findGhc buildSystem ver
227-
buildProject buildSystem [Cwd $ "bench-temp-" <> ver] (".." </> takeDirectory out)
227+
buildProject buildSystem ("bench-temp-" <> ver) (".." </> takeDirectory out)
228228
writeFile' ghcPath ghcLoc
229229

230230
--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)