@@ -171,17 +171,18 @@ phonyRules prefix executableName prof buildFolder examples = do
171171 phony (prefix <> " all-binaries" ) $ need =<< allBinaries buildFolder executableName
172172--------------------------------------------------------------------------------
173173type OutputFolder = FilePath
174+ type CWD = FilePath
174175
175176data MkBuildRules buildSystem = MkBuildRules
176177 { -- | Return the path to the GHC executable to use for the project found in the cwd
177- findGhc :: buildSystem -> FilePath -> IO FilePath
178+ findGhc :: buildSystem -> Maybe CWD -> IO FilePath
178179 -- | Name of the binary produced by 'buildProject'
179180 , executableName :: String
180181 -- | An action that captures the source dependencies, used for the HEAD build
181182 , projectDepends :: Action ()
182183 -- | Build the project found in the cwd and save the build artifacts in the output folder
183184 , buildProject :: buildSystem
184- -> [ CmdOption ]
185+ -> Maybe CWD
185186 -> OutputFolder
186187 -> Action ()
187188 }
@@ -209,8 +210,8 @@ buildRules build MkBuildRules{..} = do
209210 projectDepends
210211 liftIO $ createDirectoryIfMissing True $ dropFileName out
211212 buildSystem <- askOracle $ GetBuildSystem ()
212- buildProject buildSystem [ Cwd " . " ] (takeDirectory out)
213- ghcLoc <- liftIO $ findGhc buildSystem " . "
213+ buildProject buildSystem Nothing (takeDirectory out)
214+ ghcLoc <- liftIO $ findGhc buildSystem Nothing
214215 writeFile' ghcpath ghcLoc
215216
216217 -- build rules for non HEAD revisions
@@ -223,8 +224,8 @@ buildRules build MkBuildRules{..} = do
223224 cmd_ $ " git worktree add bench-temp-" ++ ver ++ " " ++ commitid
224225 buildSystem <- askOracle $ GetBuildSystem ()
225226 flip actionFinally (cmd_ (" git worktree remove bench-temp-" <> ver <> " --force" :: String )) $ do
226- ghcLoc <- liftIO $ findGhc buildSystem ver
227- buildProject buildSystem [ Cwd $ " bench-temp-" <> ver] (" .." </> takeDirectory out)
227+ ghcLoc <- liftIO $ findGhc buildSystem ( Just ver)
228+ buildProject buildSystem ( Just $ " bench-temp-" <> ver) (" .." </> takeDirectory out)
228229 writeFile' ghcPath ghcLoc
229230
230231--------------------------------------------------------------------------------
@@ -461,11 +462,11 @@ data BuildSystem = Cabal | Stack
461462 deriving (Eq , Read , Show , Generic )
462463 deriving (Binary , Hashable , NFData )
463464
464- findGhcForBuildSystem :: BuildSystem -> FilePath -> IO FilePath
465+ findGhcForBuildSystem :: BuildSystem -> Maybe FilePath -> IO FilePath
465466findGhcForBuildSystem Cabal _cwd =
466467 liftIO $ fromMaybe (error " ghc is not in the PATH" ) <$> findExecutable " ghc"
467468findGhcForBuildSystem Stack cwd = do
468- Stdout ghcLoc <- cmd [ Cwd cwd] (" stack exec which ghc" :: String )
469+ Stdout ghcLoc <- cmd ( maybe [] ( pure . Cwd ) cwd) (" stack exec which ghc" :: String )
469470 return ghcLoc
470471
471472instance FromJSON BuildSystem where
0 commit comments