Skip to content

Commit

Permalink
Separate boot step from getGHCVer
Browse files Browse the repository at this point in the history
  • Loading branch information
dfordivam committed Dec 15, 2024
1 parent 170f0f4 commit 7757dd2
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions lib/GHCup/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
tmpDownload <- lift withGHCupTmpDir
tmpUnpack <- lift mkGhcupTmpDir
tar <- liftE $ download uri Nothing Nothing Nothing (fromGHCupPath tmpDownload) Nothing False
(workdir, tver) <- liftE $ cleanUpOnError @'[UnknownArchive, ArchiveResult, ProcessError, PatchFailed, DownloadFailed, DigestError, ContentLengthError, GPGError] tmpUnpack $ do
(workdir, tver) <- liftE $ cleanUpOnError @'[UnknownArchive, ArchiveResult, ProcessError, PatchFailed, DownloadFailed, DigestError, ContentLengthError, GPGError, NotFoundInPATH] tmpUnpack $ do
liftE $ unpackToDir (fromGHCupPath tmpUnpack) tar

-- bootstrapped ghc renames boot to boot.source
Expand All @@ -883,6 +883,9 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs

liftE $ applyAnyPatch patches (fromGHCupPath workdir)

-- bootstrap, if necessary
liftE $ bootAndGenVersion workdir

tver <- liftE $ catchAllE @_ @'[ProcessError, ParseError, NotFoundInPATH] @'[] (\_ -> pure Nothing) $ fmap Just $ getGHCVer workdir
pure (workdir, tver)

Expand Down Expand Up @@ -937,6 +940,8 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
liftE $ applyAnyPatch patches (fromGHCupPath tmpUnpack)

-- bootstrap
liftE $ bootAndGenVersion tmpUnpack

tver <- liftE $ catchAllE @_ @'[ProcessError, ParseError, NotFoundInPATH] @'[] (\_ -> pure Nothing) $ fmap Just $ getGHCVer
tmpUnpack
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpUnpack)
Expand Down Expand Up @@ -1038,6 +1043,24 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
pure installVer

where
bootAndGenVersion :: ( MonadReader env m
, HasSettings env
, HasDirs env
, HasLog env
, MonadIO m
, MonadThrow m
)
=> GHCupPath
-> Excepts '[ProcessError, NotFoundInPATH] m ()
bootAndGenVersion tmpUnpack = do
let bootFile = fromGHCupPath tmpUnpack </> "boot"
hasBootFile <- liftIO $ doesFileExist bootFile
when hasBootFile $ do
lift $ logDebug "Doing ghc-bootstrap"
lEM $ execLogged "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" Nothing
-- This configure is to generate VERSION file
liftE $ configureWithGhcBoot Nothing [] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"

getGHCVer :: ( MonadReader env m
, HasSettings env
, HasDirs env
Expand All @@ -1048,8 +1071,6 @@ compileGHC targetGhc crossTarget vps bstrap hghc jobs mbuildConfig patches aargs
=> GHCupPath
-> Excepts '[ProcessError, ParseError, NotFoundInPATH] m Version
getGHCVer tmpUnpack = do
lEM $ execLogged "python3" ["./boot"] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap" Nothing
liftE $ configureWithGhcBoot Nothing [] (Just $ fromGHCupPath tmpUnpack) "ghc-bootstrap"
let versionFile = fromGHCupPath tmpUnpack </> "VERSION"
hasVersionFile <- liftIO $ doesFileExist versionFile
if hasVersionFile
Expand Down

0 comments on commit 7757dd2

Please sign in to comment.