mirror of
https://github.com/haskell/haskell-ide-engine.git
synced 2024-09-11 11:05:30 +03:00
Add dev target
This commit is contained in:
parent
66291d655b
commit
3212557fe6
@ -36,7 +36,7 @@ execCabal :: CmdResult r => [String] -> Action r
|
||||
execCabal = command [] "cabal"
|
||||
|
||||
execCabal_ :: [String] -> Action ()
|
||||
execCabal_ = command [] "cabal"
|
||||
execCabal_ = execCabal
|
||||
|
||||
cabalBuildData :: Action ()
|
||||
cabalBuildData = do
|
||||
|
@ -78,7 +78,7 @@ helpMessage versions@BuildableVersions {..} = do
|
||||
[emptyTarget]
|
||||
[ generalTargets
|
||||
, defaultTargets
|
||||
, if isRunFromCabal then [cabalGhcsTarget] else []
|
||||
, if isRunFromCabal then [cabalGhcsTarget] else [stackDevTarget]
|
||||
, [macosIcuTarget]
|
||||
]
|
||||
|
||||
@ -97,13 +97,13 @@ templateTarget = ("<target>", "")
|
||||
|
||||
hieTarget :: String -> TargetDescription
|
||||
hieTarget version =
|
||||
("hie-" ++ version, "Builds hie for GHC version " ++ version)
|
||||
("hie-" ++ version, "Install hie for GHC version " ++ version)
|
||||
|
||||
buildTarget :: TargetDescription
|
||||
buildTarget = ("hie", "Build hie with the latest available GHC and the data files")
|
||||
buildTarget = ("hie", "Install hie with the latest available GHC and the data files")
|
||||
|
||||
buildLatestTarget :: TargetDescription
|
||||
buildLatestTarget = ("latest", "Build hie with the latest available GHC")
|
||||
buildLatestTarget = ("latest", "Install hie with the latest available GHC")
|
||||
|
||||
buildDataTarget :: TargetDescription
|
||||
buildDataTarget =
|
||||
@ -122,3 +122,6 @@ cabalGhcsTarget =
|
||||
( "ghcs"
|
||||
, "Show all GHC versions that can be installed via `cabal-build`."
|
||||
)
|
||||
|
||||
stackDevTarget :: TargetDescription
|
||||
stackDevTarget = ("dev", "Install hie with the default stack.yaml")
|
@ -78,9 +78,8 @@ defaultMain = do
|
||||
(\version -> phony ("hie-" ++ version) $ do
|
||||
need ["submodules"]
|
||||
need ["check"]
|
||||
if isRunFromStack then do
|
||||
stackBuildHie version
|
||||
stackInstallHie version
|
||||
if isRunFromStack then do
|
||||
stackInstallHieWithErrMsg (Just version)
|
||||
else
|
||||
cabalInstallHie version
|
||||
)
|
||||
@ -88,6 +87,11 @@ defaultMain = do
|
||||
phony "latest" (need ["hie-" ++ latestVersion])
|
||||
phony "hie" (need ["data", "latest"])
|
||||
|
||||
-- stack specific targets
|
||||
when isRunFromStack $ do
|
||||
|
||||
phony "dev" $ stackInstallHieWithErrMsg Nothing
|
||||
|
||||
-- cabal specific targets
|
||||
when isRunFromCabal $ do
|
||||
|
||||
|
@ -15,14 +15,23 @@ import Version
|
||||
import Print
|
||||
import Env
|
||||
|
||||
stackBuildHie :: VersionNumber -> Action ()
|
||||
stackBuildHie versionNumber = execStackWithGhc_ versionNumber ["build"]
|
||||
`actionOnException` liftIO (putStrLn stackBuildFailMsg)
|
||||
stackInstallHieWithErrMsg :: Maybe VersionNumber -> Action ()
|
||||
stackInstallHieWithErrMsg mbVersionNumber =
|
||||
stackInstallHie mbVersionNumber
|
||||
`actionOnException` liftIO (putStrLn stackBuildFailMsg)
|
||||
|
||||
-- | copy the built binaries into the localBinDir
|
||||
stackInstallHie :: VersionNumber -> Action ()
|
||||
stackInstallHie versionNumber = do
|
||||
execStackWithGhc_ versionNumber ["install"]
|
||||
stackInstallHie :: Maybe VersionNumber -> Action ()
|
||||
stackInstallHie mbVersionNumber = do
|
||||
versionNumber <-
|
||||
case mbVersionNumber of
|
||||
Nothing -> do
|
||||
execStackWithCfgFile_ "stack.yaml" ["install"]
|
||||
getGhcVersionOfCfgFile "stack.yaml"
|
||||
Just vn -> do
|
||||
execStackWithGhc_ vn ["install"]
|
||||
return vn
|
||||
|
||||
localBinDir <- getLocalBin
|
||||
let hie = "hie" <.> exe
|
||||
liftIO $ do
|
||||
@ -31,6 +40,12 @@ stackInstallHie versionNumber = do
|
||||
copyFile (localBinDir </> hie)
|
||||
(localBinDir </> "hie-" ++ dropExtension versionNumber <.> exe)
|
||||
|
||||
getGhcVersionOfCfgFile :: String -> Action VersionNumber
|
||||
getGhcVersionOfCfgFile stackFile = do
|
||||
Stdout ghcVersion <-
|
||||
execStackWithCfgFile stackFile ["exec", "ghc", "--", "--numeric-version"]
|
||||
return $ trim ghcVersion
|
||||
|
||||
-- | check `stack` has the required version
|
||||
checkStack :: Action ()
|
||||
checkStack = do
|
||||
@ -53,14 +68,22 @@ stackBuildData = do
|
||||
|
||||
-- | Execute a stack command for a specified ghc, discarding the output
|
||||
execStackWithGhc_ :: VersionNumber -> [String] -> Action ()
|
||||
execStackWithGhc_ versionNumber args = do
|
||||
let stackFile = "stack-" ++ versionNumber ++ ".yaml"
|
||||
command_ [] "stack" (("--stack-yaml=" ++ stackFile) : args)
|
||||
execStackWithGhc_ = execStackWithGhc
|
||||
|
||||
-- | Execute a stack command for a specified ghc
|
||||
execStackWithGhc :: CmdResult r => VersionNumber -> [String] -> Action r
|
||||
execStackWithGhc versionNumber args = do
|
||||
let stackFile = "stack-" ++ versionNumber ++ ".yaml"
|
||||
execStackWithCfgFile stackFile args
|
||||
|
||||
-- | Execute a stack command for a specified stack.yaml file, discarding the output
|
||||
execStackWithCfgFile_ :: String -> [String] -> Action ()
|
||||
execStackWithCfgFile_ stackFile args =
|
||||
command_ [] "stack" (("--stack-yaml=" ++ stackFile) : args)
|
||||
|
||||
-- | Execute a stack command for a specified stack.yaml file
|
||||
execStackWithCfgFile :: CmdResult r => String -> [String] -> Action r
|
||||
execStackWithCfgFile stackFile args =
|
||||
command [] "stack" (("--stack-yaml=" ++ stackFile) : args)
|
||||
|
||||
-- | Execute a stack command with the same resolver as the build script
|
||||
@ -69,7 +92,7 @@ execStackShake args = command [] "stack" ("--stack-yaml=install/shake.yaml" : ar
|
||||
|
||||
-- | Execute a stack command with the same resolver as the build script, discarding the output
|
||||
execStackShake_ :: [String] -> Action ()
|
||||
execStackShake_ args = command_ [] "stack" ("--stack-yaml=install/shake.yaml" : args)
|
||||
execStackShake_ = execStackShake
|
||||
|
||||
|
||||
-- | Error message when the `stack` binary is an older version
|
||||
|
Loading…
Reference in New Issue
Block a user