diff --git a/CHANGELOG.md b/CHANGELOG.md index 35b3c4e..2ad827f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Add date to GHC bindist names created by ghcup * Warn when /tmp doesn't have 5GB or more of disk space * Allow to compile GHC from git repo wrt [#126](https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/126) +* Allow to set custom ghc version when running 'ghcup compile ghc' wrt [#136](https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/136) * Add stack support ## 0.1.14.2 -- 2021-05-12 diff --git a/app/ghcup/Main.hs b/app/ghcup/Main.hs index f0497f3..cf10529 100644 --- a/app/ghcup/Main.hs +++ b/app/ghcup/Main.hs @@ -174,6 +174,7 @@ data GHCCompileOptions = GHCCompileOptions , crossTarget :: Maybe Text , addConfArgs :: [Text] , setCompile :: Bool + , ovewrwiteVer :: Maybe Version } data UpgradeOpts = UpgradeInplace @@ -762,6 +763,15 @@ ghcCompileOpts = (long "set" <> help "Set as active version after install" ) + <*> optional + (option + (eitherReader + (first (const "Not a valid version") . version . T.pack) + ) + (short 'o' <> long "overwrite-version" <> metavar "OVERWRITE_VERSION" <> help + "Allows to overwrite the finally installed VERSION with a different one, e.g. when you build 8.10.4 with your own patches, you might want to set this to '8.10.4-p1'" + ) + ) toolVersionParser :: Parser ToolVersion @@ -1571,6 +1581,7 @@ Report bugs at |] Right _ -> pure () targetVer <- liftE $ compileGHC (first (GHCTargetVersion crossTarget) targetGhc) + ovewrwiteVer bootstrapGhc jobs buildConfig diff --git a/lib/GHCup.hs b/lib/GHCup.hs index b6821b5..47729dc 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -1324,6 +1324,7 @@ compileGHC :: ( MonadMask m , MonadFail m ) => Either GHCTargetVersion GitBranch -- ^ version to install + -> Maybe Version -- ^ overwrite version -> Either Version FilePath -- ^ version to bootstrap with -> Maybe Int -- ^ jobs -> Maybe FilePath -- ^ build config @@ -1347,7 +1348,7 @@ compileGHC :: ( MonadMask m ] m GHCTargetVersion -compileGHC targetGhc bstrap jobs mbuildConfig patchdir aargs +compileGHC targetGhc ov bstrap jobs mbuildConfig patchdir aargs = do AppState { pfreq = PlatformRequest {..} , ghcupInfo = GHCupInfo { _ghcupDownloads = dls } @@ -1411,8 +1412,11 @@ compileGHC targetGhc bstrap jobs mbuildConfig patchdir aargs lift $ $(logInfo) [i|Git version #{ref} corresponds to GHC version #{prettyVer tver}|] pure (tmpUnpack, tmpUnpack, GHCTargetVersion Nothing tver) + -- the version that's installed may differ from the + -- compiled version, so the user can overwrite it + let installVer = maybe tver (\ov' -> tver { _tvVersion = ov' }) ov - alreadyInstalled <- lift $ ghcInstalled tver + alreadyInstalled <- lift $ ghcInstalled installVer alreadySet <- fmap (== Just tver) $ lift $ ghcSet (_tvTarget tver) when alreadyInstalled $ do lift $ $(logWarn) [i|GHC #{prettyShow tver} already installed. Will overwrite existing version.|] @@ -1420,7 +1424,7 @@ compileGHC targetGhc bstrap jobs mbuildConfig patchdir aargs "...waiting for 10 seconds before continuing, you can still abort..." liftIO $ threadDelay 10000000 -- give the user a sec to intervene - ghcdir <- lift $ ghcupGHCDir tver + ghcdir <- lift $ ghcupGHCDir installVer bghc <- case bstrap of Right g -> pure $ Right g