Add lastest, change default to it add warn about build-all

This commit is contained in:
jneira 2019-11-12 14:52:34 +01:00
parent 6a8f89cdb8
commit 78fdd5ba98
3 changed files with 49 additions and 12 deletions

View File

@ -12,13 +12,23 @@ import Version
import BuildSystem
import Cabal
stackCommand :: String -> String
stackCommand target = "stack install.hs " ++ target
cabalCommand :: String -> String
cabalCommand target = "cabal new-run install.hs --project-file install/shake.project " ++ target
buildCommand :: String -> String
buildCommand | isRunFromCabal = cabalCommand
| otherwise = stackCommand
printUsage :: Action ()
printUsage = do
printLine ""
printLine "Usage:"
printLineIndented "stack install.hs <target>"
printLineIndented (stackCommand "<target>")
printLineIndented "or"
printLineIndented "cabal new-run install.hs --project-file install/shake.project <target>"
printLineIndented (cabalCommand "<target>")
-- | short help message is printed by default
shortHelpMessage :: Action ()
@ -76,7 +86,7 @@ helpMessage versions@BuildableVersions {..} = do
-- All targets with their respective help message.
generalTargets = [helpTarget]
defaultTargets = [buildTarget, buildAllTarget, buildDataTarget]
defaultTargets = [buildTarget, buildLastestTarget, buildAllTarget, buildDataTarget]
++ map hieTarget (getDefaultBuildSystemVersions versions)
stackTargets =
@ -114,7 +124,10 @@ hieTarget version =
("hie-" ++ version, "Builds hie for GHC version " ++ version)
buildTarget :: TargetDescription
buildTarget = ("build", "Builds hie with all installed GHCs")
buildTarget = ("build", "Build hie with the lastest available GHC and the data files")
buildLastestTarget :: TargetDescription
buildLastestTarget = ("build-lastest", "Build hie with the lastest available GHC")
buildDataTarget :: TargetDescription
buildDataTarget =
@ -122,9 +135,20 @@ buildDataTarget =
buildAllTarget :: TargetDescription
buildAllTarget =
("build-all", "Builds hie for all installed GHC versions and the data files")
( "build-all"
, "Builds hie for all installed GHC versions and the data files. "
++ buildAllWarning)
-- speical targets
buildAllWarning :: String
buildAllWarning = "WARNING: This command may take a long time and computer resources"
buildAllWarningAlt :: String
buildAllWarningAlt = "Consider build only the needed ghc versions using:\n"
++ " " ++ buildCommand "build-${ghcVersion}\n"
++ "or the lastest available one with:\n"
++ " " ++ buildCommand "build-lastest\n"
-- special targets
macosIcuTarget :: TargetDescription
macosIcuTarget = ("icu-macos-fix", "Fixes icu related problems in MacOS")
@ -141,7 +165,9 @@ cabalGhcsTarget =
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"
, "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.

View File

@ -57,6 +57,8 @@ defaultMain = do
, cabalVersions = ghcVersions
}
let lastestVersion = last hieVersions
putStrLn $ "run from: " ++ buildSystem
shakeArgs shakeOptions { shakeFiles = "_build" } $ do
@ -82,6 +84,7 @@ defaultMain = do
-- default-targets
phony "build" $ need [buildSystem ++ "-build"]
phony "build-lastest" $ need [buildSystem ++ "-build-lastest"]
phony "build-all" $ need [buildSystem ++ "-build-all"]
phony "build-data" $ need [buildSystem ++ "-build-data"]
forM_
@ -92,8 +95,12 @@ 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-lastest" (need ["stack-hie-" ++ last hieVersions])
phony "stack-build" (need ["build-data", "stack-build-lastest"])
phony "stack-build-all" $ do
printInStars (buildAllWarning ++ ".\n" ++ buildAllWarningAlt)
need (["build-data"] ++ (reverse $ map ("stack-hie-" ++) hieVersions))
phony "stack-build-data" $ do
need ["submodules"]
need ["check-stack"]
@ -108,8 +115,12 @@ defaultMain = do
)
-- cabal specific targets
phony "cabal-build" (need (map ("cabal-hie-" ++) ghcVersions))
phony "cabal-build-all" (need ["cabal-build-data", "cabal-build"])
phony "cabal-build-lastest" (need ["cabal-hie-" ++ last ghcVersions])
phony "cabal-build" (need ["build-data", "cabal-build-lastest"])
phony "cabal-build-all" $ do
printInStars (buildAllWarning ++ ".\n" ++ buildAllWarningAlt)
need (["cabal-build-data"] ++ (map ("cabal-hie-" ++) ghcVersions))
phony "cabal-build-data" $ do
need ["submodules"]
need ["cabal"]

View File

@ -18,7 +18,7 @@ printLineIndented = printLine . (" " ++)
embedInStars :: String -> String
embedInStars str =
let starsLine = "\n" <> replicate 30 '*' <> "\n"
let starsLine = "\n" <> replicate 80 '*' <> "\n"
in starsLine <> str <> starsLine
printInStars :: MonadIO m => String -> m ()