Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 25678ff

Browse files
authored
Merge pull request #1405 from jneira/stack-install-cabal
Add stack-install-cabal target and confirmation messages
2 parents 7e36aa3 + fcb30e1 commit 25678ff

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

install/src/Cabal.hs

+17-6
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,20 @@ cabalInstallHie versionNumber = do
5757
, "--overwrite-policy=always"
5858
]
5959
++ installMethod
60+
61+
let minorVerExe = "hie-" ++ versionNumber <.> exe
62+
majorVerExe = "hie-" ++ dropExtension versionNumber <.> exe
63+
6064
liftIO $ do
61-
copyFile (localBin </> "hie" <.> exe)
62-
(localBin </> "hie-" ++ versionNumber <.> exe)
63-
copyFile (localBin </> "hie" <.> exe)
64-
(localBin </> "hie-" ++ dropExtension versionNumber <.> exe)
65+
copyFile (localBin </> "hie" <.> exe) (localBin </> minorVerExe)
66+
copyFile (localBin </> "hie" <.> exe) (localBin </> majorVerExe)
67+
68+
printLine $ "Copied executables "
69+
++ ("hie-wrapper" <.> exe) ++ ", "
70+
++ ("hie" <.> exe) ++ ", "
71+
++ majorVerExe ++ " and "
72+
++ minorVerExe
73+
++ " to " ++ localBin
6574

6675
installCabal :: Action ()
6776
installCabal = do
@@ -70,9 +79,11 @@ installCabal = do
7079
c <- liftIO (findExecutable "cabal")
7180
when (isJust c) checkCabal
7281
return $ isJust c
73-
82+
7483
-- install `cabal-install` if not already installed
75-
unless cabalExeOk $ execStackShake_ ["install", "cabal-install"]
84+
if cabalExeOk
85+
then printLine "There is already a cabal executable in $PATH with the required minimum version."
86+
else execStackShake_ ["install", "cabal-install"]
7687

7788
-- | check `cabal` has the required version
7889
checkCabal :: Action ()

install/src/Help.hs

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Env
1010
import Print
1111
import Version
1212
import BuildSystem
13+
import Cabal
1314

1415
printUsage :: Action ()
1516
printUsage = do
@@ -83,6 +84,7 @@ helpMessage versions@BuildableVersions {..} = do
8384
, stackTarget buildAllTarget
8485
, stackTarget buildDataTarget
8586
]
87+
++ (if isRunFromStack then [stackTarget installCabalTarget] else [])
8688
++ map (stackTarget . hieTarget) stackVersions
8789

8890
cabalTargets =
@@ -136,6 +138,12 @@ cabalGhcsTarget =
136138
, "Show all GHC versions that can be installed via `cabal-build` and `cabal-build-all`."
137139
)
138140

141+
installCabalTarget :: TargetDescription
142+
installCabalTarget =
143+
( "install-cabal"
144+
, "Install the cabal executable. It will install the required minimum version for hie (currently " ++ versionToString requiredCabalVersion ++ ") if it isn't already present in $PATH"
145+
)
146+
139147
-- | Creates a message of the form "a, b, c and d", where a,b,c,d are GHC versions.
140148
-- If there is no GHC in the list of `hieVersions`
141149
allVersionMessage :: [String] -> String

install/src/HieInstall.hs

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ defaultMain = do
9191
)
9292

9393
-- stack specific targets
94+
when isRunFromStack (phony "stack-install-cabal" (need ["cabal"]))
9495
phony "stack-build" (need (reverse $ map ("stack-hie-" ++) hieVersions))
9596
phony "stack-build-all" (need ["build-data", "build"])
9697
phony "stack-build-data" $ do

0 commit comments

Comments
 (0)