From 2ca7474ca6bf8a92e225a26c3dfb024c529d0737 Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 8 Oct 2019 12:02:07 +0200 Subject: [PATCH 1/2] Add confirmation messages to install cabal and install hie with cabal --- install/src/Cabal.hs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/install/src/Cabal.hs b/install/src/Cabal.hs index 68f530049..f4699416d 100644 --- a/install/src/Cabal.hs +++ b/install/src/Cabal.hs @@ -57,11 +57,20 @@ cabalInstallHie versionNumber = do , "--overwrite-policy=always" ] ++ installMethod + + let minorVerExe = "hie-" ++ versionNumber <.> exe + majorVerExe = "hie-" ++ dropExtension versionNumber <.> exe + liftIO $ do - copyFile (localBin "hie" <.> exe) - (localBin "hie-" ++ versionNumber <.> exe) - copyFile (localBin "hie" <.> exe) - (localBin "hie-" ++ dropExtension versionNumber <.> exe) + copyFile (localBin "hie" <.> exe) (localBin minorVerExe) + copyFile (localBin "hie" <.> exe) (localBin majorVerExe) + + printLine $ "Copied executables " + ++ ("hie-wrapper" <.> exe) ++ ", " + ++ ("hie" <.> exe) ++ ", " + ++ majorVerExe ++ " and " + ++ minorVerExe + ++ " to " ++ localBin installCabal :: Action () installCabal = do @@ -70,9 +79,11 @@ installCabal = do c <- liftIO (findExecutable "cabal") when (isJust c) checkCabal return $ isJust c - + -- install `cabal-install` if not already installed - unless cabalExeOk $ execStackShake_ ["install", "cabal-install"] + if cabalExeOk + then printLine "There is already a cabal executable in $PATH with the required minimum version." + else execStackShake_ ["install", "cabal-install"] -- | check `cabal` has the required version checkCabal :: Action () From fcb30e1f792206c70122dd52e228eb6fea53332e Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 8 Oct 2019 12:02:46 +0200 Subject: [PATCH 2/2] Add stack-install-cabal target --- install/src/Help.hs | 8 ++++++++ install/src/HieInstall.hs | 1 + 2 files changed, 9 insertions(+) diff --git a/install/src/Help.hs b/install/src/Help.hs index bb9e65363..7a8b347e6 100644 --- a/install/src/Help.hs +++ b/install/src/Help.hs @@ -10,6 +10,7 @@ import Env import Print import Version import BuildSystem +import Cabal printUsage :: Action () printUsage = do @@ -83,6 +84,7 @@ helpMessage versions@BuildableVersions {..} = do , stackTarget buildAllTarget , stackTarget buildDataTarget ] + ++ (if isRunFromStack then [stackTarget installCabalTarget] else []) ++ map (stackTarget . hieTarget) stackVersions cabalTargets = @@ -136,6 +138,12 @@ cabalGhcsTarget = , "Show all GHC versions that can be installed via `cabal-build` and `cabal-build-all`." ) +installCabalTarget :: TargetDescription +installCabalTarget = + ( "install-cabal" + , "Install the cabal executable. It will install the required minimum version for hie (currently " ++ versionToString requiredCabalVersion ++ ") if it isn't already present in $PATH" + ) + -- | Creates a message of the form "a, b, c and d", where a,b,c,d are GHC versions. -- If there is no GHC in the list of `hieVersions` allVersionMessage :: [String] -> String diff --git a/install/src/HieInstall.hs b/install/src/HieInstall.hs index 223dde39b..58ed14138 100644 --- a/install/src/HieInstall.hs +++ b/install/src/HieInstall.hs @@ -91,6 +91,7 @@ defaultMain = do ) -- stack specific targets + when isRunFromStack (phony "stack-install-cabal" (need ["cabal"])) phony "stack-build" (need (reverse $ map ("stack-hie-" ++) hieVersions)) phony "stack-build-all" (need ["build-data", "build"]) phony "stack-build-data" $ do