@@ -171,17 +171,18 @@ phonyRules prefix executableName prof buildFolder examples = do
171
171
phony (prefix <> " all-binaries" ) $ need =<< allBinaries buildFolder executableName
172
172
--------------------------------------------------------------------------------
173
173
type OutputFolder = FilePath
174
+ type CWD = FilePath
174
175
175
176
data MkBuildRules buildSystem = MkBuildRules
176
177
{ -- | 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
178
179
-- | Name of the binary produced by 'buildProject'
179
180
, executableName :: String
180
181
-- | An action that captures the source dependencies, used for the HEAD build
181
182
, projectDepends :: Action ()
182
183
-- | Build the project found in the cwd and save the build artifacts in the output folder
183
184
, buildProject :: buildSystem
184
- -> [ CmdOption ]
185
+ -> Maybe CWD
185
186
-> OutputFolder
186
187
-> Action ()
187
188
}
@@ -209,8 +210,8 @@ buildRules build MkBuildRules{..} = do
209
210
projectDepends
210
211
liftIO $ createDirectoryIfMissing True $ dropFileName out
211
212
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
214
215
writeFile' ghcpath ghcLoc
215
216
216
217
-- build rules for non HEAD revisions
@@ -223,8 +224,8 @@ buildRules build MkBuildRules{..} = do
223
224
cmd_ $ " git worktree add bench-temp-" ++ ver ++ " " ++ commitid
224
225
buildSystem <- askOracle $ GetBuildSystem ()
225
226
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)
228
229
writeFile' ghcPath ghcLoc
229
230
230
231
--------------------------------------------------------------------------------
@@ -461,11 +462,11 @@ data BuildSystem = Cabal | Stack
461
462
deriving (Eq , Read , Show , Generic )
462
463
deriving (Binary , Hashable , NFData )
463
464
464
- findGhcForBuildSystem :: BuildSystem -> FilePath -> IO FilePath
465
+ findGhcForBuildSystem :: BuildSystem -> Maybe FilePath -> IO FilePath
465
466
findGhcForBuildSystem Cabal _cwd =
466
467
liftIO $ fromMaybe (error " ghc is not in the PATH" ) <$> findExecutable " ghc"
467
468
findGhcForBuildSystem 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 )
469
470
return ghcLoc
470
471
471
472
instance FromJSON BuildSystem where
0 commit comments