mirror of
https://github.com/haskell/haskell-ide-engine.git
synced 2024-10-26 19:29:32 +03:00
Code cleanup, including reformatting
This commit is contained in:
parent
acfa2ca822
commit
80f2614646
164
Shakefile.hs
164
Shakefile.hs
@ -12,137 +12,125 @@ import System.Environment
|
||||
type VersionNumber = String
|
||||
type GhcPath = String
|
||||
|
||||
hies :: [FilePath]
|
||||
hies = [ "hie-8.2.1"
|
||||
, "hie-8.2.2"
|
||||
, "hie-8.4.2"
|
||||
, "hie-8.4.3"
|
||||
, "hie-8.4.4"
|
||||
, "hie-8.6.1"
|
||||
, "hie-8.6.2"
|
||||
]
|
||||
hieVersions :: [FilePath]
|
||||
hieVersions = ["8.2.1", "8.2.2", "8.4.2", "8.4.3", "8.4.4", "8.6.1", "8.6.2"]
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
-- unset GHC_PACKAGE_PATH for cabal
|
||||
unsetEnv "GHC_PACKAGE_PATH"
|
||||
shakeArgs shakeOptions { shakeFiles = "_build" } $ do
|
||||
phony "ghc" $ do
|
||||
ghc <- readGhcPath
|
||||
command_ [] ghc ["--version"]
|
||||
putNormal "GHC"
|
||||
unsetEnv "GHC_PACKAGE_PATH"
|
||||
shakeArgs shakeOptions { shakeFiles = "_build" } $ do
|
||||
phony "ghc" $ do
|
||||
ghc <- readGhcPath
|
||||
command_ [] ghc ["--version"]
|
||||
putNormal "GHC"
|
||||
|
||||
phony "submodules" buildSubmodules
|
||||
phony "cabal" $ readGhcPath >>= installCabal
|
||||
phony "submodules" buildSubmodules
|
||||
phony "cabal" $ readGhcPath >>= installCabal
|
||||
|
||||
phony "all" helpMessage
|
||||
phony "help" helpMessage
|
||||
phony "all" helpMessage
|
||||
phony "help" helpMessage
|
||||
|
||||
phony "build" (need hies)
|
||||
phony "build" (need (map ("hie-" ++) hieVersions))
|
||||
|
||||
phony "build-all" (need ["build", "build-docs"])
|
||||
phony "build-all" (need ["build"] >> need ["build-docs"])
|
||||
|
||||
forM_
|
||||
hies
|
||||
(\hie -> phony hie $ do
|
||||
need ["submodules"]
|
||||
need ["cabal"]
|
||||
stackLocalDir <- getLocalBin
|
||||
let versionNumber = drop 4 hie
|
||||
buildHie stackLocalDir versionNumber
|
||||
)
|
||||
forM_
|
||||
hieVersions
|
||||
(\version -> phony ("hie-" ++ version) $ do
|
||||
need ["submodules"]
|
||||
need ["cabal"]
|
||||
stackLocalDir <- getLocalBin
|
||||
buildHie stackLocalDir version
|
||||
)
|
||||
|
||||
phony "build-docs" $ forM_ hies $ \hie -> do
|
||||
let versionNumber = drop 4 hie
|
||||
buildDoc versionNumber
|
||||
phony "build-docs" $ forM_ hieVersions buildDoc
|
||||
|
||||
phony "build-copy-compiler-tool" $ forM_ hies $ \hie -> do
|
||||
let versionNumber = drop 4 hie
|
||||
buildCopyCompilerTool versionNumber
|
||||
phony "build-copy-compiler-tool" $ forM_ hieVersions buildCopyCompilerTool
|
||||
|
||||
phony "test" $ forM_ hies $ \hie -> do
|
||||
let versionNumber = drop 4 hie
|
||||
test versionNumber
|
||||
phony "test" $ forM_ hieVersions test
|
||||
|
||||
readGhcPath :: Action GhcPath
|
||||
readGhcPath = do
|
||||
Stdout ghc' <- execStack ["path", "--compiler-exe"]
|
||||
return (init ghc')
|
||||
Stdout ghc' <- execStack ["path", "--compiler-exe"]
|
||||
return (init ghc')
|
||||
|
||||
getLocalBin :: Action FilePath
|
||||
getLocalBin = do
|
||||
Stdout stackLocalDir' <- execStack ["path", "--local-bin"]
|
||||
return (init stackLocalDir')
|
||||
Stdout stackLocalDir' <- execStack ["path", "--local-bin"]
|
||||
return (init stackLocalDir')
|
||||
|
||||
buildSubmodules :: Action ()
|
||||
buildSubmodules = do
|
||||
command_ [] "git" ["submodule", "sync"]
|
||||
command_ [] "git" ["submodule", "update", "--init"]
|
||||
command_ [] "git" ["submodule", "sync"]
|
||||
command_ [] "git" ["submodule", "update", "--init"]
|
||||
|
||||
installCabal :: GhcPath -> Action ()
|
||||
installCabal ghc = do
|
||||
execStack_ ["install", "cabal-install"]
|
||||
execCabal_ ["v1-update"]
|
||||
execCabal_ ["v1-install", "Cabal-2.4.1.0", "--with-compiler=" ++ ghc]
|
||||
execStack_ ["install", "cabal-install"]
|
||||
execCabal_ ["v1-update"]
|
||||
execCabal_ ["v1-install", "Cabal-2.4.1.0", "--with-compiler=" ++ ghc]
|
||||
|
||||
installHappy :: VersionNumber -> Action ()
|
||||
installHappy versionNumber = execStackWithYaml versionNumber [ "install", "happy"]
|
||||
installHappy versionNumber =
|
||||
execStackWithYaml versionNumber ["install", "happy"]
|
||||
|
||||
buildHie :: FilePath -> VersionNumber -> Action ()
|
||||
buildHie localBinDir versionNumber = do
|
||||
when (versionNumber `elem` ["hie-8.2.2", "hie-8.2.1"]) $
|
||||
execStackWithYaml versionNumber ["install", "happy"]
|
||||
execStackWithYaml versionNumber [ "build"]
|
||||
execStackWithYaml versionNumber [ "install"]
|
||||
cmd_
|
||||
"cp"
|
||||
[ localBinDir </> "hie" <.> exe]
|
||||
[ localBinDir </> "hie-" ++ versionNumber <.> exe
|
||||
]
|
||||
when (versionNumber `elem` ["hie-8.2.2", "hie-8.2.1"])
|
||||
$ execStackWithYaml versionNumber ["install", "happy"]
|
||||
execStackWithYaml versionNumber ["build"]
|
||||
execStackWithYaml versionNumber ["install"]
|
||||
cmd_ "cp"
|
||||
[localBinDir </> "hie" <.> exe]
|
||||
[localBinDir </> "hie-" ++ versionNumber <.> exe]
|
||||
|
||||
buildCopyCompilerTool :: VersionNumber -> Action ()
|
||||
buildCopyCompilerTool versionNumber = do
|
||||
execStackWithYaml versionNumber ["build", "--copy-compiler-tool"]
|
||||
buildCopyCompilerTool versionNumber =
|
||||
execStackWithYaml versionNumber ["build", "--copy-compiler-tool"]
|
||||
|
||||
test :: VersionNumber -> Action ()
|
||||
test versionNumber = execStackWithYaml versionNumber ["test"]
|
||||
|
||||
buildDoc :: VersionNumber -> Action ()
|
||||
buildDoc versionNumber = do
|
||||
execStackWithYaml versionNumber ["install", "hoogle"]
|
||||
execStackWithYaml versionNumber ["exec", "hoogle", "generate"]
|
||||
execStackWithYaml versionNumber ["install", "hoogle"]
|
||||
execStackWithYaml versionNumber ["exec", "hoogle", "generate"]
|
||||
|
||||
helpMessage :: Action ()
|
||||
helpMessage = do
|
||||
putNormal ""
|
||||
putNormal "Usage:"
|
||||
putNormal " make <target>"
|
||||
putNormal ""
|
||||
putNormal "Targets:"
|
||||
putNormal " build Builds hie for all supported GHC versions (8.2.1, 8.2.2, 8.4.2 and 8.4.3, 8.4.4)"
|
||||
putNormal " build-all Builds hie and hoogle databases for all supported GHC versions"
|
||||
putNormal " hie-8.2.1 Builds hie for GHC version 8.2.1 only"
|
||||
putNormal " hie-8.2.2 Builds hie for GHC version 8.2.2 only"
|
||||
putNormal " hie-8.4.2 Builds hie for GHC version 8.4.2 only"
|
||||
putNormal " hie-8.4.3 Builds hie for GHC version 8.4.3 only"
|
||||
putNormal " hie-8.4.4 Builds hie for GHC version 8.4.4 only"
|
||||
putNormal " hie-8.6.1 Builds hie for GHC version 8.6.1 only"
|
||||
putNormal " hie-8.6.2 Builds hie for GHC version 8.6.2 only"
|
||||
putNormal " submodules Updates local git submodules"
|
||||
putNormal " cabal NOTE 3: This is needed for stack only projects too"
|
||||
putNormal " build-docs Builds the Hoogle database for all supported GHC versions"
|
||||
putNormal " test Runs hie tests"
|
||||
putNormal " icu-macos-fix Fixes icu related problems in MacOS"
|
||||
putNormal " dist Creates a tarball containing all the hie binaries"
|
||||
putNormal " help Show help"
|
||||
putNormal ""
|
||||
putNormal ""
|
||||
putNormal "Usage:"
|
||||
putNormal " make <target>"
|
||||
putNormal ""
|
||||
putNormal "Targets:"
|
||||
putNormal
|
||||
" build Builds hie for all supported GHC versions (8.2.1, 8.2.2, 8.4.2 and 8.4.3, 8.4.4)"
|
||||
putNormal
|
||||
" build-all Builds hie and hoogle databases for all supported GHC versions"
|
||||
putNormal " hie-8.2.1 Builds hie for GHC version 8.2.1 only"
|
||||
putNormal " hie-8.2.2 Builds hie for GHC version 8.2.2 only"
|
||||
putNormal " hie-8.4.2 Builds hie for GHC version 8.4.2 only"
|
||||
putNormal " hie-8.4.3 Builds hie for GHC version 8.4.3 only"
|
||||
putNormal " hie-8.4.4 Builds hie for GHC version 8.4.4 only"
|
||||
putNormal " hie-8.6.1 Builds hie for GHC version 8.6.1 only"
|
||||
putNormal " hie-8.6.2 Builds hie for GHC version 8.6.2 only"
|
||||
putNormal " submodules Updates local git submodules"
|
||||
putNormal
|
||||
" cabal NOTE 3: This is needed for stack only projects too"
|
||||
putNormal
|
||||
" build-docs Builds the Hoogle database for all supported GHC versions"
|
||||
putNormal " test Runs hie tests"
|
||||
putNormal " icu-macos-fix Fixes icu related problems in MacOS"
|
||||
putNormal
|
||||
" dist Creates a tarball containing all the hie binaries"
|
||||
putNormal " help Show help"
|
||||
putNormal ""
|
||||
|
||||
execStackWithYaml :: VersionNumber -> [String] -> Action ()
|
||||
execStackWithYaml versionNumber args = do
|
||||
let stackFile = "stack-" ++ versionNumber ++ ".yaml"
|
||||
command_ []
|
||||
"stack"
|
||||
(["--stack-yaml=" ++ stackFile] ++ args)
|
||||
let stackFile = "stack-" ++ versionNumber ++ ".yaml"
|
||||
command_ [] "stack" (("--stack-yaml=" ++ stackFile) : args)
|
||||
|
||||
execStack :: CmdResult r => [String] -> Action r
|
||||
execStack = command [] "stack"
|
||||
|
Loading…
Reference in New Issue
Block a user