@@ -261,90 +261,97 @@ withExecuteEnv ::
261261 -> Maybe Int -- ^ largest package name, for nicer interleaved output
262262 -> (ExecuteEnv -> RIO env a )
263263 -> RIO env a
264- withExecuteEnv bopts boptsCli baseConfigOpts locals globalPackages snapshotPackages localPackages mlargestPackageName inner =
265- createTempDirFunction stackProgName $ \ tmpdir -> do
266- installLock <- liftIO $ newMVar ()
267- idMap <- liftIO $ newTVarIO Map. empty
268- config <- view configL
269-
270- customBuiltRef <- newIORef Set. empty
271-
272- -- Create files for simple setup and setup shim, if necessary
273- let setupSrcDir =
274- view stackRootL config </>
275- relDirSetupExeSrc
276- ensureDir setupSrcDir
277- let setupStub = " setup-" ++ simpleSetupHash
278- setupFileName <- parseRelFile (setupStub ++ " .hs" )
279- setupHiName <- parseRelFile (setupStub ++ " .hi" )
280- setupOName <- parseRelFile (setupStub ++ " .o" )
281- let setupHs = setupSrcDir </> setupFileName
282- setupHi = setupSrcDir </> setupHiName
283- setupO = setupSrcDir </> setupOName
284- setupHsExists <- doesFileExist setupHs
285- unless setupHsExists $ writeBinaryFileAtomic setupHs simpleSetupCode
286- -- See https://github.com/commercialhaskell/stack/issues/6267. Remove any
287- -- historical *.hi or *.o files. This can be dropped when Stack drops
288- -- support for the problematic versions of GHC.
289- ignoringAbsence (removeFile setupHi)
290- ignoringAbsence (removeFile setupO)
291- let setupShimStub = " setup-shim-" ++ simpleSetupHash
292- setupShimFileName <- parseRelFile (setupShimStub ++ " .hs" )
293- setupShimHiName <- parseRelFile (setupShimStub ++ " .hi" )
294- setupShimOName <- parseRelFile (setupShimStub ++ " .o" )
295- let setupShimHs = setupSrcDir </> setupShimFileName
296- setupShimHi = setupSrcDir </> setupShimHiName
297- setupShimO = setupSrcDir </> setupShimOName
298- setupShimHsExists <- doesFileExist setupShimHs
299- unless setupShimHsExists $
300- writeBinaryFileAtomic setupShimHs setupGhciShimCode
301- -- See https://github.com/commercialhaskell/stack/issues/6267. Remove any
302- -- historical *.hi or *.o files. This can be dropped when Stack drops
303- -- support for the problematic versions of GHC.
304- ignoringAbsence (removeFile setupShimHi)
305- ignoringAbsence (removeFile setupShimO)
306- setupExe <- getSetupExe setupHs setupShimHs tmpdir
307-
308- cabalPkgVer <- view cabalVersionL
309- globalDB <- view $ compilerPathsL . to (. globalDB)
310- snapshotPackagesTVar <-
311- liftIO $ newTVarIO (toDumpPackagesByGhcPkgId snapshotPackages)
312- localPackagesTVar <-
313- liftIO $ newTVarIO (toDumpPackagesByGhcPkgId localPackages)
314- logFilesTChan <- liftIO $ atomically newTChan
315- let totalWanted = length $ filter (. wanted) locals
316- pathEnvVar <- liftIO $ maybe mempty T. pack <$> lookupEnv " PATH"
317- inner ExecuteEnv
318- { buildOpts = bopts
319- , buildOptsCLI = boptsCli
320- -- Uncertain as to why we cannot run configures in parallel. This
321- -- appears to be a Cabal library bug. Original issue:
322- -- https://github.com/commercialhaskell/stack/issues/84. Ideally
323- -- we'd be able to remove this.
324- , installLock = installLock
325- , baseConfigOpts = baseConfigOpts
326- , ghcPkgIds = idMap
327- , tempDir = tmpdir
328- , setupHs = setupHs
329- , setupShimHs = setupShimHs
330- , setupExe = setupExe
331- , cabalPkgVer = cabalPkgVer
332- , totalWanted = totalWanted
333- , locals = locals
334- , globalDB = globalDB
335- , globalDumpPkgs = toDumpPackagesByGhcPkgId globalPackages
336- , snapshotDumpPkgs = snapshotPackagesTVar
337- , localDumpPkgs = localPackagesTVar
338- , logFiles = logFilesTChan
339- , customBuilt = customBuiltRef
340- , largestPackageName = mlargestPackageName
341- , pathEnvVar = pathEnvVar
342- } `finally` dumpLogs logFilesTChan totalWanted
264+ withExecuteEnv
265+ buildOpts
266+ buildOptsCLI
267+ baseConfigOpts
268+ locals
269+ globalPackages
270+ snapshotPackages
271+ localPackages
272+ largestPackageName
273+ inner
274+ = createTempDirFunction stackProgName $ \ tempDir -> do
275+ installLock <- liftIO $ newMVar ()
276+ ghcPkgIds <- liftIO $ newTVarIO Map. empty
277+ config <- view configL
278+ customBuilt <- newIORef Set. empty
279+ -- Create files for simple setup and setup shim, if necessary
280+ let setupSrcDir =
281+ view stackRootL config </>
282+ relDirSetupExeSrc
283+ ensureDir setupSrcDir
284+ let setupStub = " setup-" ++ simpleSetupHash
285+ setupFileName <- parseRelFile (setupStub ++ " .hs" )
286+ setupHiName <- parseRelFile (setupStub ++ " .hi" )
287+ setupOName <- parseRelFile (setupStub ++ " .o" )
288+ let setupHs = setupSrcDir </> setupFileName
289+ setupHi = setupSrcDir </> setupHiName
290+ setupO = setupSrcDir </> setupOName
291+ setupHsExists <- doesFileExist setupHs
292+ unless setupHsExists $ writeBinaryFileAtomic setupHs simpleSetupCode
293+ -- See https://github.com/commercialhaskell/stack/issues/6267. Remove any
294+ -- historical *.hi or *.o files. This can be dropped when Stack drops
295+ -- support for the problematic versions of GHC.
296+ ignoringAbsence (removeFile setupHi)
297+ ignoringAbsence (removeFile setupO)
298+ let setupShimStub = " setup-shim-" ++ simpleSetupHash
299+ setupShimFileName <- parseRelFile (setupShimStub ++ " .hs" )
300+ setupShimHiName <- parseRelFile (setupShimStub ++ " .hi" )
301+ setupShimOName <- parseRelFile (setupShimStub ++ " .o" )
302+ let setupShimHs = setupSrcDir </> setupShimFileName
303+ setupShimHi = setupSrcDir </> setupShimHiName
304+ setupShimO = setupSrcDir </> setupShimOName
305+ setupShimHsExists <- doesFileExist setupShimHs
306+ unless setupShimHsExists $
307+ writeBinaryFileAtomic setupShimHs setupGhciShimCode
308+ -- See https://github.com/commercialhaskell/stack/issues/6267. Remove any
309+ -- historical *.hi or *.o files. This can be dropped when Stack drops
310+ -- support for the problematic versions of GHC.
311+ ignoringAbsence (removeFile setupShimHi)
312+ ignoringAbsence (removeFile setupShimO)
313+ setupExe <- getSetupExe setupHs setupShimHs tempDir
314+ cabalPkgVer <- view cabalVersionL
315+ globalDB <- view $ compilerPathsL . to (. globalDB)
316+ let globalDumpPkgs = toDumpPackagesByGhcPkgId globalPackages
317+ snapshotDumpPkgs <-
318+ liftIO $ newTVarIO (toDumpPackagesByGhcPkgId snapshotPackages)
319+ localDumpPkgs <-
320+ liftIO $ newTVarIO (toDumpPackagesByGhcPkgId localPackages)
321+ logFiles <- liftIO $ atomically newTChan
322+ let totalWanted = length $ filter (. wanted) locals
323+ pathEnvVar <- liftIO $ maybe mempty T. pack <$> lookupEnv " PATH"
324+ inner ExecuteEnv
325+ { buildOpts
326+ , buildOptsCLI
327+ -- Uncertain as to why we cannot run configures in parallel. This
328+ -- appears to be a Cabal library bug. Original issue:
329+ -- https://github.com/commercialhaskell/stack/issues/84. Ideally
330+ -- we'd be able to remove this.
331+ , installLock
332+ , baseConfigOpts
333+ , ghcPkgIds
334+ , tempDir
335+ , setupHs
336+ , setupShimHs
337+ , setupExe
338+ , cabalPkgVer
339+ , totalWanted
340+ , locals
341+ , globalDB
342+ , globalDumpPkgs
343+ , snapshotDumpPkgs
344+ , localDumpPkgs
345+ , logFiles
346+ , customBuilt
347+ , largestPackageName
348+ , pathEnvVar
349+ } `finally` dumpLogs logFiles totalWanted
343350 where
344351 toDumpPackagesByGhcPkgId = Map. fromList . map (\ dp -> (dp. ghcPkgId, dp))
345352
346353 createTempDirFunction
347- | bopts . keepTmpFiles = withKeepSystemTempDir
354+ | buildOpts . keepTmpFiles = withKeepSystemTempDir
348355 | otherwise = withSystemTempDir
349356
350357 dumpLogs :: TChan (Path Abs Dir , Path Abs File ) -> Int -> RIO env ()
0 commit comments