From 6a8f89cdb8757b045b91b36699e91dd6eae0ca18 Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 12 Nov 2019 14:51:30 +0100 Subject: [PATCH 01/28] Use explicit list of ghc supported versions --- install/src/Env.hs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/install/src/Env.hs b/install/src/Env.hs index b7d232c37..bdc69b858 100644 --- a/install/src/Env.hs +++ b/install/src/Env.hs @@ -40,6 +40,15 @@ existsExecutable executable = liftIO $ isJust <$> findExecutable executable isWindowsSystem :: Bool isWindowsSystem = os `elem` ["mingw32", "win32"] +-- | Defines all different hie versions that are supported. +-- On windows, `8.6.3` is excluded as this version of ghc does not work there +supportedGhcVersions :: [VersionNumber] +supportedGhcVersions = sort (commonVersions ++ osVersions) + where commonVersions = ["8.4.2", "8.4.3", "8.4.4", "8.6.1", "8.6.2", "8.6.4", "8.6.5"] + -- the following lines exclude `8.6.3` on windows systems + osVersions | isWindowsSystem = [] + | otherwise = ["8.6.3"] + findInstalledGhcs :: IO [(VersionNumber, GhcPath)] findInstalledGhcs = do hieVersions <- getHieVersions :: IO [VersionNumber] @@ -49,7 +58,8 @@ findInstalledGhcs = do Just p -> return $ Just (version, p) ) (reverse hieVersions) - availableGhcs <- getGhcPaths + -- filter out not supported ghc versions + availableGhcs <- filter ((`elem` supportedGhcVersions) . fst) <$> getGhcPaths return -- nub by version. knownGhcs takes precedence. $ nubBy ((==) `on` fst) @@ -99,8 +109,7 @@ getHieVersions = do & mapMaybe (T.stripPrefix stackYamlPrefix >=> T.stripSuffix stackYamlSuffix) & map T.unpack - -- the following line excludes `8.6.3` on windows systems - & filter (\p -> not isWindowsSystem || p /= "8.6.3") + & filter (\p -> p `elem` supportedGhcVersions) & sort return hieVersions From 78fdd5ba983296e898ce6ee5c43da92302c7c8fa Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 12 Nov 2019 14:52:34 +0100 Subject: [PATCH 02/28] Add lastest, change default to it add warn about build-all --- install/src/Help.hs | 40 ++++++++++++++++++++++++++++++++------- install/src/HieInstall.hs | 19 +++++++++++++++---- install/src/Print.hs | 2 +- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/install/src/Help.hs b/install/src/Help.hs index 7a8b347e6..3328cf3e1 100644 --- a/install/src/Help.hs +++ b/install/src/Help.hs @@ -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 " + printLineIndented (stackCommand "") printLineIndented "or" - printLineIndented "cabal new-run install.hs --project-file install/shake.project " + printLineIndented (cabalCommand "") -- | 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) + +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" --- speical targets +-- 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. diff --git a/install/src/HieInstall.hs b/install/src/HieInstall.hs index b05f1714d..0928aa989 100644 --- a/install/src/HieInstall.hs +++ b/install/src/HieInstall.hs @@ -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"] diff --git a/install/src/Print.hs b/install/src/Print.hs index 82904491f..41216022b 100644 --- a/install/src/Print.hs +++ b/install/src/Print.hs @@ -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 () From 0e2646bfb81c5ebd7103e503eb38120b90bc2407 Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 13 Nov 2019 08:27:25 +0100 Subject: [PATCH 03/28] Fix getGhcPathOf for windows --- install/src/Env.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/install/src/Env.hs b/install/src/Env.hs index bdc69b858..642a8ab47 100644 --- a/install/src/Env.hs +++ b/install/src/Env.hs @@ -54,8 +54,8 @@ findInstalledGhcs = do hieVersions <- getHieVersions :: IO [VersionNumber] knownGhcs <- mapMaybeM (\version -> getGhcPathOf version >>= \case - Nothing -> return Nothing - Just p -> return $ Just (version, p) + Nothing -> return Nothing + Just p -> return $ Just (version, p) ) (reverse hieVersions) -- filter out not supported ghc versions @@ -63,7 +63,7 @@ findInstalledGhcs = do return -- nub by version. knownGhcs takes precedence. $ nubBy ((==) `on` fst) - -- filter out stack provided GHCs + -- filter out stack provided GHCs (assuming that stack programs path is the default one in linux) $ filter (not . isInfixOf ".stack" . snd) (knownGhcs ++ availableGhcs) -- | Get the path to a GHC that has the version specified by `VersionNumber` @@ -73,9 +73,11 @@ findInstalledGhcs = do -- command fits to the desired version. getGhcPathOf :: MonadIO m => VersionNumber -> m (Maybe GhcPath) getGhcPathOf ghcVersion = - liftIO $ findExecutable ("ghc-" ++ ghcVersion) >>= \case + liftIO $ findExecutable ("ghc-" ++ ghcVersion <.> exe) >>= \case Nothing -> lookup ghcVersion <$> getGhcPaths path -> return path + where exe | isWindowsSystem = "exe" + | otherwise = "" -- | Get a list of GHCs that are available in $PATH getGhcPaths :: MonadIO m => m [(VersionNumber, GhcPath)] @@ -97,7 +99,6 @@ ghcVersionNotFoundFailMsg versionNumber = -- | Defines all different hie versions that are buildable. -- -- The current directory is scanned for `stack-*.yaml` files. --- On windows, `8.6.3` is excluded as this version of ghc does not work there getHieVersions :: MonadIO m => m [VersionNumber] getHieVersions = do let stackYamlPrefix = T.pack "stack-" From 16be8e7381302d62b6c0a2c4654b3d8993a919a6 Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 13 Nov 2019 08:38:43 +0100 Subject: [PATCH 04/28] Sort installed ghcs to fix the lastest target --- install/src/Env.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install/src/Env.hs b/install/src/Env.hs index 642a8ab47..45e9ebc01 100644 --- a/install/src/Env.hs +++ b/install/src/Env.hs @@ -17,9 +17,11 @@ import Data.Function ( (&) , on ) import Data.List ( sort + , sortBy , isInfixOf , nubBy ) +import Data.Ord ( comparing ) import Control.Monad.Extra ( mapMaybeM ) import Data.Maybe ( isNothing , mapMaybe @@ -61,6 +63,8 @@ findInstalledGhcs = do -- filter out not supported ghc versions availableGhcs <- filter ((`elem` supportedGhcVersions) . fst) <$> getGhcPaths return + -- sort by version to make it coherent with getHieVersions + $ sortBy (comparing fst) -- nub by version. knownGhcs takes precedence. $ nubBy ((==) `on` fst) -- filter out stack provided GHCs (assuming that stack programs path is the default one in linux) From bb61dd1e9e4fef0a304831e0c76ff68afb793ae2 Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 13 Nov 2019 13:48:45 +0100 Subject: [PATCH 05/28] Fix error in splitPaths --- install/src/Stack.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/src/Stack.hs b/install/src/Stack.hs index 210d406e9..b9cf2afd4 100644 --- a/install/src/Stack.hs +++ b/install/src/Stack.hs @@ -135,5 +135,5 @@ withoutStackCachedBinaries action = do splitPaths s = case dropWhile (== searchPathSeparator) s of "" -> [] - s' -> w : words s'' + s' -> w : splitPaths s'' where (w, s'') = break (== searchPathSeparator) s' From 9e70be83460057e53cf9d2f03393cf7ffb7d6aca Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 13 Nov 2019 14:57:37 +0100 Subject: [PATCH 06/28] Fix ghc version used to install hie --- install/src/Cabal.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/install/src/Cabal.hs b/install/src/Cabal.hs index 0c0ca380d..32c9c0f40 100644 --- a/install/src/Cabal.hs +++ b/install/src/Cabal.hs @@ -31,13 +31,17 @@ cabalBuildData = do execCabal_ ["v2-build", "hoogle"] execCabal_ ["v2-exec", "hoogle", "generate"] -cabalBuildHie :: VersionNumber -> Action () -cabalBuildHie versionNumber = do - ghcPath <- getGhcPathOf versionNumber >>= \case +getGhcPathOfOrThrowError :: VersionNumber -> Action GhcPath +getGhcPathOfOrThrowError versionNumber = + getGhcPathOf versionNumber >>= \case Nothing -> do printInStars $ ghcVersionNotFoundFailMsg versionNumber error (ghcVersionNotFoundFailMsg versionNumber) Just p -> return p + +cabalBuildHie :: VersionNumber -> Action () +cabalBuildHie versionNumber = do + ghcPath <- getGhcPathOfOrThrowError versionNumber execCabal_ ["v2-build", "-w", ghcPath, "--write-ghc-environment-files=never", "--max-backjumps=5000", "--disable-tests"] @@ -45,6 +49,7 @@ cabalInstallHie :: VersionNumber -> Action () cabalInstallHie versionNumber = do localBin <- getLocalBin cabalVersion <- getCabalVersion + ghcPath <- getGhcPathOfOrThrowError versionNumber let isCabal3 = checkVersion [3,0,0,0] cabalVersion installDirOpt | isCabal3 = "--installdir" @@ -53,6 +58,7 @@ cabalInstallHie versionNumber = do | otherwise = [] execCabal_ $ [ "v2-install" + , "-w", ghcPath , "--write-ghc-environment-files=never" , installDirOpt ++ "=" ++ localBin , "exe:hie" From 36fa8152946cc91e92afda3d0e4cac7bc0291708 Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 13 Nov 2019 23:03:16 +0100 Subject: [PATCH 07/28] Formatting options list of cabal build --- install/src/Cabal.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install/src/Cabal.hs b/install/src/Cabal.hs index 0c0ca380d..e0553a349 100644 --- a/install/src/Cabal.hs +++ b/install/src/Cabal.hs @@ -39,7 +39,11 @@ cabalBuildHie versionNumber = do error (ghcVersionNotFoundFailMsg versionNumber) Just p -> return p execCabal_ - ["v2-build", "-w", ghcPath, "--write-ghc-environment-files=never", "--max-backjumps=5000", "--disable-tests"] + [ "v2-build" + , "-w", ghcPath + , "--write-ghc-environment-files=never" + , "--max-backjumps=5000" + , "--disable-tests"] cabalInstallHie :: VersionNumber -> Action () cabalInstallHie versionNumber = do From 6e0cf21379cd858af01036c0c9bb8f8d1e33a794 Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 14 Nov 2019 07:35:29 +0100 Subject: [PATCH 08/28] Use cabal options consistently --- install/src/Cabal.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/src/Cabal.hs b/install/src/Cabal.hs index dca7cdfc7..25d1c0203 100644 --- a/install/src/Cabal.hs +++ b/install/src/Cabal.hs @@ -64,7 +64,7 @@ cabalInstallHie versionNumber = do [ "v2-install" , "-w", ghcPath , "--write-ghc-environment-files=never" - , installDirOpt ++ "=" ++ localBin + , installDirOpt, localBin , "exe:hie" , "--overwrite-policy=always" ] From bf7d4b4915656fbb2b2333d823dac572f2c0d636 Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 14 Nov 2019 08:06:18 +0100 Subject: [PATCH 09/28] Update documentation about build system --- README.md | 3 +-- docs/Build.md | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0a1d4aba7..667ef1105 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,7 @@ cabal v2-run ./install.hs --project-file install/shake.project Running the script with cabal on windows requires a cabal version greater or equal to `3.0.0.0`. -Unfortunately, it is still required to have `stack` installed so that the install-script can locate the `local-bin` directory (on Linux `~/.local/bin`) and copy the `hie` binaries to `hie-x.y.z`, which is required for the `hie-wrapper` to function as expected. +Unfortunately, it is still required to have `stack` installed so that the install-script can locate the `local-bin` directory (on Linux `~/.local/bin`) and copy the `hie` binaries to `hie-x.y.z`, which is required for the `hie-wrapper` to function as expected. There are plans to remove this requirement and let users build hie only with one build tool or another. For brevity, only the `stack`-based commands are presented in the following sections. @@ -246,7 +246,6 @@ stack ./install.hs build-data The Haskell IDE Engine can also be built with `cabal new-build` instead of `stack build`. This has the advantage that you can decide how the GHC versions have been installed. -However, this approach does currently not work for windows due to a missing feature upstream. To see what GHC versions are available, the command `stack install.hs cabal-ghcs` can be used. It will list all GHC versions that are on the path and their respective installation directory. If you think, this list is incomplete, you can try to modify the PATH variable, such that the executables can be found. diff --git a/docs/Build.md b/docs/Build.md index 83c6afcbc..27fa4ad36 100644 --- a/docs/Build.md +++ b/docs/Build.md @@ -28,8 +28,10 @@ See the project's `README` for detailed information about installing `hie`. The build script `install.hs` defines several targets using the `shake` build system. The targets are roughly: * `hie-*`: builds and installs the `hie` binaries. Also renames the binaries to contain the correct version-number. -* `build`: builds and installs `hie` binaries for all supported `ghc` versions. +* `build-lastest`: builds ad installs `hie` for the last available and supported `ghc` version. +* `build-all`: builds and installs `hie` binaries for all supported `ghc` versions. This option may take a long time and computer resources so use it with caution. * `build-data`: builds the hoogle-db required by `hie` +* `build`: builds ad installs `hie` for the last supported `ghc` version (like `build-lastest`) and the hoogle-db (like `build-data`) * `cabal-*`: execute the same task as the original target, but with `cabal` instead of `stack` Each `stack-*.yaml` contains references to packages in the submodules. Calling `stack` with one of those causes the build to fail if the submodules have not been initialized already. The file `shake.yaml` solves this issue invoking the `git` binary itself to update the submodules. Moreover, it specifies the correct version of `shake` and is used for installing all run-time dependencies such as `cabal` and `hoogle` if necessary. @@ -38,7 +40,7 @@ Each `stack-*.yaml` contains references to packages in the submodules. Calling ` `hie` depends on a correct environment in order to function properly: -* `cabal-install`: If no `cabal` executable can be found or has an outdated version, `cabal-install` is installed via `stack`. +* `cabal-install`: This dependency is required by `hie` to handle correctly projects that are not `stack` based (without `stack.yaml`). You can install an appropiate version using `stack` with the `stack-install-cabal` target. * The `hoogle` database: `hoogle generate` needs to be called with the most-recent `hoogle` version. ### Steps to build `hie` @@ -47,10 +49,9 @@ Installing `hie` is a multi-step process: 1. `git submodule sync && git submodule update --init` 2. `hoogle generate` (`hoogle>=5.0.17` to be safe) -3. ensure that `cabal-install` is installed in the correct version -4. `stack --stack-yaml=stack-.yaml install` or `cabal new-install -w ghc-` -5. rename `hie` binary to `hie-` in `$HOME/.local/bin`, where `` is the GHC version used -6. repeat step 4 and 5 for all desired GHC versions +3. `stack --stack-yaml=stack-.yaml install` or `cabal new-install -w ghc-` +4. rename `hie` binary to `hie-` in `$HOME/.local/bin`, where `` is the GHC version used +5. repeat step 4 and 5 for all desired GHC versions This ensures that a complete install is always possible after each `git pull` or a `git clone`. @@ -90,19 +91,17 @@ The final step is to configure the `hie` client to use a custom `hie-wrapper` sc The `install.hs` script performs some checks to ensure that a correct installation is possible and provide meaningful error messages for known issues. * `stack` needs to be up-to-date. Version `1.9.3` is required +* `cabal` needs to be up-to-date. Version `3.0.0.0` is required for windows systems and `2.4.1.0` for other ones. * `ghc-8.6.3` is broken on windows. Trying to install `hie-8.6.3` on windows is not possible. -* `cabal new-build` does not work on windows at the moment. All `cabal-*` targets exit with an error message about that. * When the build fails, an error message, that suggests to remove `.stack-work` directory, is displayed. ### Tradeoffs #### `stack` is a build dependency -Currently, it is not possible to build all `hie-*` executables automatically without `stack`, since the `install.hs` script is executed by `stack`. +Currently, `stack` is needed even if you run the script with `cabal` to get the path where install the binaries but there are plans to remove that dependency (see #1380). -We are open to suggestions of other build systems that honor the requirements above, but are executable without `stack`. - -#### `install.hs` installs a GHC before running +#### run `install.hs` with `stack` installs a GHC before running Before the code in `install.hs` can be executed, `stack` installs a `GHC`, depending on the `resolver` field in `shake.yaml`. This is necessary if `install.hs` should be completely functional right after a fresh `git clone` without further configuration. From 8e909e8aa4ee9ef57dc7c2535b8a44ff466e50d6 Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 14 Nov 2019 08:42:45 +0100 Subject: [PATCH 10/28] Mention cabal issue about set custom project file --- install.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/install.hs b/install.hs index b68745bd3..094ee774a 100755 --- a/install.hs +++ b/install.hs @@ -14,6 +14,7 @@ build-depends: -- * `stack install.hs ` -- TODO: set `shake.project` in cabal-config above, when supported +-- (see https://github.com/haskell/cabal/issues/6353) import HieInstall (defaultMain) From 0f72de0c98021299747e59ab17358edd769493ac Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 14 Nov 2019 10:37:54 +0100 Subject: [PATCH 11/28] Use TargetDescription to print targets --- install/src/Help.hs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/install/src/Help.hs b/install/src/Help.hs index 3328cf3e1..5fcae8e1e 100644 --- a/install/src/Help.hs +++ b/install/src/Help.hs @@ -12,13 +12,13 @@ import Version import BuildSystem import Cabal -stackCommand :: String -> String -stackCommand target = "stack install.hs " ++ target +stackCommand :: TargetDescription -> String +stackCommand target = "stack install.hs " ++ fst target -cabalCommand :: String -> String -cabalCommand target = "cabal new-run install.hs --project-file install/shake.project " ++ target +cabalCommand :: TargetDescription -> String +cabalCommand target = "cabal new-run install.hs --project-file install/shake.project " ++ fst target -buildCommand :: String -> String +buildCommand :: TargetDescription -> String buildCommand | isRunFromCabal = cabalCommand | otherwise = stackCommand @@ -26,9 +26,9 @@ printUsage :: Action () printUsage = do printLine "" printLine "Usage:" - printLineIndented (stackCommand "") + printLineIndented (stackCommand templateTarget) printLineIndented "or" - printLineIndented (cabalCommand "") + printLineIndented (cabalCommand templateTarget) -- | short help message is printed by default shortHelpMessage :: Action () @@ -109,6 +109,9 @@ helpMessage versions@BuildableVersions {..} = do emptyTarget :: (String, String) emptyTarget = ("", "") +templateTarget :: (String, String) +templateTarget = ("", "") + targetWithBuildSystem :: String -> TargetDescription -> TargetDescription targetWithBuildSystem system (target, description) = (system ++ "-" ++ target, description ++ "; with " ++ system) @@ -144,9 +147,9 @@ buildAllWarning = "WARNING: This command may take a long time and computer resou buildAllWarningAlt :: String buildAllWarningAlt = "Consider build only the needed ghc versions using:\n" - ++ " " ++ buildCommand "build-${ghcVersion}\n" + ++ " " ++ buildCommand (hieTarget "") ++ "\n" ++ "or the lastest available one with:\n" - ++ " " ++ buildCommand "build-lastest\n" + ++ " " ++ buildCommand (hieTarget "") ++ "\n" -- special targets From 2140a5a9ff3128b20f432088e180a54572036718 Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 14 Nov 2019 10:38:18 +0100 Subject: [PATCH 12/28] Remove unnecessary catch over lookupEnv --- install/src/Stack.hs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/install/src/Stack.hs b/install/src/Stack.hs index b9cf2afd4..96cd18334 100644 --- a/install/src/Stack.hs +++ b/install/src/Stack.hs @@ -105,10 +105,7 @@ stackBuildFailMsg = withoutStackCachedBinaries :: Action a -> Action a withoutStackCachedBinaries action = do - let getEnvErrorHandler e | isDoesNotExistError e = return Nothing - | otherwise = throwIO e - - mbPath <- liftIO (lookupEnv "PATH" `catch` getEnvErrorHandler) + mbPath <- liftIO (lookupEnv "PATH") case (mbPath, isRunFromStack) of From 15cf8ade8de693b25e628377295e35369f758b87 Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 14 Nov 2019 10:44:15 +0100 Subject: [PATCH 13/28] Run stack-install-cabal in azure ci --- .azure/linux-installhs-stack.yml | 6 +++++- .azure/macos-installhs-stack.yml | 6 +++++- .azure/windows-installhs-stack.yml | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.azure/linux-installhs-stack.yml b/.azure/linux-installhs-stack.yml index 40bdc6424..a3c340371 100644 --- a/.azure/linux-installhs-stack.yml +++ b/.azure/linux-installhs-stack.yml @@ -29,4 +29,8 @@ jobs: - bash: | source .azure/linux.bashrc stack install.hs help - displayName: Run help of `instal.hs` + displayName: Run help of `install.hs` + - bash: | + source .azure/linux.bashrc + stack install.hs stack-install-cabal + displayName: Run stack-install-cabal target of `install.hs` diff --git a/.azure/macos-installhs-stack.yml b/.azure/macos-installhs-stack.yml index 971b12a23..1c5cc2c7b 100644 --- a/.azure/macos-installhs-stack.yml +++ b/.azure/macos-installhs-stack.yml @@ -29,4 +29,8 @@ jobs: - bash: | source .azure/macos.bashrc stack install.hs help - displayName: Run help of `instal.hs` + displayName: Run help of `install.hs` + - bash: | + source .azure/macos.bashrc + stack install.hs stack-install-cabal + displayName: Run stack-install-cabal target of `install.hs` diff --git a/.azure/windows-installhs-stack.yml b/.azure/windows-installhs-stack.yml index 3fab9d640..ccd660e3f 100644 --- a/.azure/windows-installhs-stack.yml +++ b/.azure/windows-installhs-stack.yml @@ -27,4 +27,8 @@ jobs: - bash: | source .azure/windows.bashrc stack install.hs help - displayName: Run help of `instal.hs` + displayName: Run help of `install.hs` + - bash: | + source .azure/windows.bashrc + stack install.hs stack-install-cabal + displayName: Run stack-install-cabal target of `install.hs` From 7d993196646243fb5f0ea88209469f5f41c6ed66 Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 14 Nov 2019 11:22:09 +0100 Subject: [PATCH 14/28] Change macos STACK_ROOT to avoid permission issues --- .azure/macos-stack.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure/macos-stack.yml b/.azure/macos-stack.yml index 42b45bb91..82178f0af 100644 --- a/.azure/macos-stack.yml +++ b/.azure/macos-stack.yml @@ -20,7 +20,7 @@ jobs: stack-8.4.2: YAML_FILE: stack-8.4.2.yaml variables: - STACK_ROOT: /Users/vsts/.stack + STACK_ROOT: $(Build.SourcesDirectory)/.stack steps: - task: CacheBeta@0 inputs: From 6f18dcae6ba5e2daf57a3a5eb359586758b1217a Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 14 Nov 2019 12:29:44 +0100 Subject: [PATCH 15/28] Correct suggestion of lastest target --- install/src/Help.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/src/Help.hs b/install/src/Help.hs index 5fcae8e1e..53fbc2c5d 100644 --- a/install/src/Help.hs +++ b/install/src/Help.hs @@ -149,7 +149,7 @@ buildAllWarningAlt :: String buildAllWarningAlt = "Consider build only the needed ghc versions using:\n" ++ " " ++ buildCommand (hieTarget "") ++ "\n" ++ "or the lastest available one with:\n" - ++ " " ++ buildCommand (hieTarget "") ++ "\n" + ++ " " ++ buildCommand buildLastestTarget ++ "\n" -- special targets From 1876ab5ce0f6f0216171620a6542b495a3ca8519 Mon Sep 17 00:00:00 2001 From: jneira Date: Thu, 14 Nov 2019 14:56:40 +0100 Subject: [PATCH 16/28] replace last by lastest --- docs/Build.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Build.md b/docs/Build.md index 27fa4ad36..db02ce6af 100644 --- a/docs/Build.md +++ b/docs/Build.md @@ -28,10 +28,10 @@ See the project's `README` for detailed information about installing `hie`. The build script `install.hs` defines several targets using the `shake` build system. The targets are roughly: * `hie-*`: builds and installs the `hie` binaries. Also renames the binaries to contain the correct version-number. -* `build-lastest`: builds ad installs `hie` for the last available and supported `ghc` version. +* `build-lastest`: builds ad installs `hie` for the lastest available and supported `ghc` version. * `build-all`: builds and installs `hie` binaries for all supported `ghc` versions. This option may take a long time and computer resources so use it with caution. * `build-data`: builds the hoogle-db required by `hie` -* `build`: builds ad installs `hie` for the last supported `ghc` version (like `build-lastest`) and the hoogle-db (like `build-data`) +* `build`: builds ad installs `hie` for the lastest supported `ghc` version (like `build-lastest`) and the hoogle-db (like `build-data`) * `cabal-*`: execute the same task as the original target, but with `cabal` instead of `stack` Each `stack-*.yaml` contains references to packages in the submodules. Calling `stack` with one of those causes the build to fail if the submodules have not been initialized already. The file `shake.yaml` solves this issue invoking the `git` binary itself to update the submodules. Moreover, it specifies the correct version of `shake` and is used for installing all run-time dependencies such as `cabal` and `hoogle` if necessary. From 2c823687797163f0b58a27b8287c98892a3df15a Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 15 Nov 2019 11:45:00 +0100 Subject: [PATCH 17/28] Replace lastest by latest --- docs/Build.md | 4 ++-- install/src/Help.hs | 14 ++++++++------ install/src/HieInstall.hs | 12 ++++++------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/Build.md b/docs/Build.md index db02ce6af..68508d313 100644 --- a/docs/Build.md +++ b/docs/Build.md @@ -28,10 +28,10 @@ See the project's `README` for detailed information about installing `hie`. The build script `install.hs` defines several targets using the `shake` build system. The targets are roughly: * `hie-*`: builds and installs the `hie` binaries. Also renames the binaries to contain the correct version-number. -* `build-lastest`: builds ad installs `hie` for the lastest available and supported `ghc` version. +* `build-latest`: builds ad installs `hie` for the latest available and supported `ghc` version. * `build-all`: builds and installs `hie` binaries for all supported `ghc` versions. This option may take a long time and computer resources so use it with caution. * `build-data`: builds the hoogle-db required by `hie` -* `build`: builds ad installs `hie` for the lastest supported `ghc` version (like `build-lastest`) and the hoogle-db (like `build-data`) +* `build`: builds ad installs `hie` for the latest supported `ghc` version (like `build-latest`) and the hoogle-db (like `build-data`) * `cabal-*`: execute the same task as the original target, but with `cabal` instead of `stack` Each `stack-*.yaml` contains references to packages in the submodules. Calling `stack` with one of those causes the build to fail if the submodules have not been initialized already. The file `shake.yaml` solves this issue invoking the `git` binary itself to update the submodules. Moreover, it specifies the correct version of `shake` and is used for installing all run-time dependencies such as `cabal` and `hoogle` if necessary. diff --git a/install/src/Help.hs b/install/src/Help.hs index 53fbc2c5d..71629a7c4 100644 --- a/install/src/Help.hs +++ b/install/src/Help.hs @@ -86,11 +86,12 @@ helpMessage versions@BuildableVersions {..} = do -- All targets with their respective help message. generalTargets = [helpTarget] - defaultTargets = [buildTarget, buildLastestTarget, buildAllTarget, buildDataTarget] + defaultTargets = [buildTarget, buildLatestTarget, buildAllTarget, buildDataTarget] ++ map hieTarget (getDefaultBuildSystemVersions versions) stackTargets = [ stackTarget buildTarget + , stackTarget buildLatestTarget , stackTarget buildAllTarget , stackTarget buildDataTarget ] @@ -100,6 +101,7 @@ helpMessage versions@BuildableVersions {..} = do cabalTargets = [ cabalGhcsTarget , cabalTarget buildTarget + , cabalTarget buildLatestTarget , cabalTarget buildAllTarget , cabalTarget buildDataTarget ] @@ -127,10 +129,10 @@ hieTarget version = ("hie-" ++ version, "Builds hie for GHC version " ++ version) buildTarget :: TargetDescription -buildTarget = ("build", "Build hie with the lastest available GHC and the data files") +buildTarget = ("build", "Build hie with the latest available GHC and the data files") -buildLastestTarget :: TargetDescription -buildLastestTarget = ("build-lastest", "Build hie with the lastest available GHC") +buildLatestTarget :: TargetDescription +buildLatestTarget = ("build-latest", "Build hie with the latest available GHC") buildDataTarget :: TargetDescription buildDataTarget = @@ -148,8 +150,8 @@ buildAllWarning = "WARNING: This command may take a long time and computer resou buildAllWarningAlt :: String buildAllWarningAlt = "Consider build only the needed ghc versions using:\n" ++ " " ++ buildCommand (hieTarget "") ++ "\n" - ++ "or the lastest available one with:\n" - ++ " " ++ buildCommand buildLastestTarget ++ "\n" + ++ "or the latest available one with:\n" + ++ " " ++ buildCommand buildLatestTarget ++ "\n" -- special targets diff --git a/install/src/HieInstall.hs b/install/src/HieInstall.hs index 0928aa989..479e59cf9 100644 --- a/install/src/HieInstall.hs +++ b/install/src/HieInstall.hs @@ -57,7 +57,7 @@ defaultMain = do , cabalVersions = ghcVersions } - let lastestVersion = last hieVersions + let latestVersion = last hieVersions putStrLn $ "run from: " ++ buildSystem @@ -84,7 +84,7 @@ defaultMain = do -- default-targets phony "build" $ need [buildSystem ++ "-build"] - phony "build-lastest" $ need [buildSystem ++ "-build-lastest"] + phony "build-latest" $ need [buildSystem ++ "-build-latest"] phony "build-all" $ need [buildSystem ++ "-build-all"] phony "build-data" $ need [buildSystem ++ "-build-data"] forM_ @@ -95,8 +95,8 @@ defaultMain = do -- stack specific targets when isRunFromStack (phony "stack-install-cabal" (need ["cabal"])) - phony "stack-build-lastest" (need ["stack-hie-" ++ last hieVersions]) - phony "stack-build" (need ["build-data", "stack-build-lastest"]) + phony "stack-build-latest" (need ["stack-hie-" ++ last hieVersions]) + phony "stack-build" (need ["build-data", "stack-build-latest"]) phony "stack-build-all" $ do printInStars (buildAllWarning ++ ".\n" ++ buildAllWarningAlt) need (["build-data"] ++ (reverse $ map ("stack-hie-" ++) hieVersions)) @@ -115,8 +115,8 @@ defaultMain = do ) -- cabal specific targets - phony "cabal-build-lastest" (need ["cabal-hie-" ++ last ghcVersions]) - phony "cabal-build" (need ["build-data", "cabal-build-lastest"]) + phony "cabal-build-latest" (need ["cabal-hie-" ++ last ghcVersions]) + phony "cabal-build" (need ["build-data", "cabal-build-latest"]) phony "cabal-build-all" $ do printInStars (buildAllWarning ++ ".\n" ++ buildAllWarningAlt) need (["cabal-build-data"] ++ (map ("cabal-hie-" ++) ghcVersions)) From 72de08b86d018e2f63419dafb8e93a7ff06b5fe7 Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 15 Nov 2019 11:48:25 +0100 Subject: [PATCH 18/28] Use v2 prefix intead new --- install/src/Help.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/src/Help.hs b/install/src/Help.hs index 71629a7c4..0796b1ff8 100644 --- a/install/src/Help.hs +++ b/install/src/Help.hs @@ -16,7 +16,7 @@ stackCommand :: TargetDescription -> String stackCommand target = "stack install.hs " ++ fst target cabalCommand :: TargetDescription -> String -cabalCommand target = "cabal new-run install.hs --project-file install/shake.project " ++ fst target +cabalCommand target = "cabal v2-run install.hs --project-file install/shake.project " ++ fst target buildCommand :: TargetDescription -> String buildCommand | isRunFromCabal = cabalCommand From e27003219a78f33532cf11ae1da4e6c395f9c628 Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 15 Nov 2019 12:24:42 +0100 Subject: [PATCH 19/28] Rephrasing alternative to build-all --- install/src/Help.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/src/Help.hs b/install/src/Help.hs index 0796b1ff8..cb335d4db 100644 --- a/install/src/Help.hs +++ b/install/src/Help.hs @@ -148,7 +148,7 @@ 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" +buildAllWarningAlt = "Consider building only the ghc versions you need using:\n" ++ " " ++ buildCommand (hieTarget "") ++ "\n" ++ "or the latest available one with:\n" ++ " " ++ buildCommand buildLatestTarget ++ "\n" From 118525d44d8a2da56318647e97edc02000fb78fd Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 15 Nov 2019 12:30:52 +0100 Subject: [PATCH 20/28] Replace cabal command suffix and fix installing steps --- docs/Build.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/Build.md b/docs/Build.md index 68508d313..222000888 100644 --- a/docs/Build.md +++ b/docs/Build.md @@ -49,15 +49,15 @@ Installing `hie` is a multi-step process: 1. `git submodule sync && git submodule update --init` 2. `hoogle generate` (`hoogle>=5.0.17` to be safe) -3. `stack --stack-yaml=stack-.yaml install` or `cabal new-install -w ghc-` +3. `stack --stack-yaml=stack-.yaml install` or `cabal v2-install -w ghc-` 4. rename `hie` binary to `hie-` in `$HOME/.local/bin`, where `` is the GHC version used -5. repeat step 4 and 5 for all desired GHC versions +5. repeat step 3 and 4 for all desired GHC versions This ensures that a complete install is always possible after each `git pull` or a `git clone`. #### Building `hie` with profiling support -To build `hie` with profiling enabled `cabal new-install` needs to be used instead of `stack`. +To build `hie` with profiling enabled `cabal v2-install` needs to be used instead of `stack`. Configure `cabal` to enable profiling by setting `profiling: True` in `cabal.project.local` for all packages. If that file does not already exist, create it as follows: @@ -72,7 +72,7 @@ Then `hie` can be compiled for a specific GHC version: ```bash export GHCP= -cabal new-install exe:hie -w $GHCP \ +cabal v2-install exe:hie -w $GHCP \ --write-ghc-environment-files=never --symlink-bindir=$HOME/.local/bin \ --overwrite-policy=always --reinstall ``` From db23fa56ce231d267d0a2eefaf57950a55e7ce51 Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 15 Nov 2019 12:35:10 +0100 Subject: [PATCH 21/28] Correct typo --- docs/Build.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Build.md b/docs/Build.md index 222000888..83daebec2 100644 --- a/docs/Build.md +++ b/docs/Build.md @@ -28,10 +28,10 @@ See the project's `README` for detailed information about installing `hie`. The build script `install.hs` defines several targets using the `shake` build system. The targets are roughly: * `hie-*`: builds and installs the `hie` binaries. Also renames the binaries to contain the correct version-number. -* `build-latest`: builds ad installs `hie` for the latest available and supported `ghc` version. +* `build-latest`: builds and installs `hie` for the latest available and supported `ghc` version. * `build-all`: builds and installs `hie` binaries for all supported `ghc` versions. This option may take a long time and computer resources so use it with caution. * `build-data`: builds the hoogle-db required by `hie` -* `build`: builds ad installs `hie` for the latest supported `ghc` version (like `build-latest`) and the hoogle-db (like `build-data`) +* `build`: builds and installs `hie` for the latest supported `ghc` version (like `build-latest`) and the hoogle-db (like `build-data`) * `cabal-*`: execute the same task as the original target, but with `cabal` instead of `stack` Each `stack-*.yaml` contains references to packages in the submodules. Calling `stack` with one of those causes the build to fail if the submodules have not been initialized already. The file `shake.yaml` solves this issue invoking the `git` binary itself to update the submodules. Moreover, it specifies the correct version of `shake` and is used for installing all run-time dependencies such as `cabal` and `hoogle` if necessary. From 27fb514fa03e0398465c04503af874a012b2e7d5 Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 15 Nov 2019 12:40:59 +0100 Subject: [PATCH 22/28] Use existing exe function from Shake --- install/src/Env.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/install/src/Env.hs b/install/src/Env.hs index 45e9ebc01..c521d9923 100644 --- a/install/src/Env.hs +++ b/install/src/Env.hs @@ -8,7 +8,10 @@ import Development.Shake.FilePath import System.Info ( os , arch ) -import Data.Maybe ( isJust ) +import Data.Maybe ( isJust + , isNothing + , mapMaybe + ) import System.Directory ( findExecutable , findExecutables , listDirectory @@ -23,9 +26,7 @@ import Data.List ( sort ) import Data.Ord ( comparing ) import Control.Monad.Extra ( mapMaybeM ) -import Data.Maybe ( isNothing - , mapMaybe - ) + import qualified Data.Text as T import Version @@ -80,8 +81,6 @@ getGhcPathOf ghcVersion = liftIO $ findExecutable ("ghc-" ++ ghcVersion <.> exe) >>= \case Nothing -> lookup ghcVersion <$> getGhcPaths path -> return path - where exe | isWindowsSystem = "exe" - | otherwise = "" -- | Get a list of GHCs that are available in $PATH getGhcPaths :: MonadIO m => m [(VersionNumber, GhcPath)] From c63d0beca9870b63e4ba690eb037de4b97b46112 Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 15 Nov 2019 13:21:24 +0100 Subject: [PATCH 23/28] Test build-latest target --- .azure/linux-installhs-stack.yml | 4 ++++ .azure/macos-installhs-stack.yml | 4 ++++ .azure/windows-installhs-stack.yml | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/.azure/linux-installhs-stack.yml b/.azure/linux-installhs-stack.yml index a3c340371..086354113 100644 --- a/.azure/linux-installhs-stack.yml +++ b/.azure/linux-installhs-stack.yml @@ -34,3 +34,7 @@ jobs: source .azure/linux.bashrc stack install.hs stack-install-cabal displayName: Run stack-install-cabal target of `install.hs` + - bash: | + source .azure/linux.bashrc + stack install.hs build-latest + displayName: Run build-latest target of `install.hs` diff --git a/.azure/macos-installhs-stack.yml b/.azure/macos-installhs-stack.yml index 1c5cc2c7b..e78e8f3dd 100644 --- a/.azure/macos-installhs-stack.yml +++ b/.azure/macos-installhs-stack.yml @@ -34,3 +34,7 @@ jobs: source .azure/macos.bashrc stack install.hs stack-install-cabal displayName: Run stack-install-cabal target of `install.hs` + - bash: | + source .azure/linux.bashrc + stack install.hs build-latest + displayName: Run build-latest target of `install.hs` diff --git a/.azure/windows-installhs-stack.yml b/.azure/windows-installhs-stack.yml index ccd660e3f..cec4fd2e3 100644 --- a/.azure/windows-installhs-stack.yml +++ b/.azure/windows-installhs-stack.yml @@ -32,3 +32,7 @@ jobs: source .azure/windows.bashrc stack install.hs stack-install-cabal displayName: Run stack-install-cabal target of `install.hs` + - bash: | + source .azure/linux.bashrc + stack install.hs build-latest + displayName: Run build-latest target of `install.hs` From ab1dde8135d280c553ba1190bcf582a0c7d13fa6 Mon Sep 17 00:00:00 2001 From: jneira Date: Fri, 15 Nov 2019 23:26:21 +0100 Subject: [PATCH 24/28] Remove build-all target --- README.md | 10 ++-------- docs/Build.md | 2 -- install/src/Help.hs | 23 +++-------------------- install/src/HieInstall.hs | 10 +--------- 4 files changed, 6 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 667ef1105..c5de63bd2 100644 --- a/README.md +++ b/README.md @@ -244,12 +244,12 @@ stack ./install.hs hie-8.4.4 stack ./install.hs build-data ``` -The Haskell IDE Engine can also be built with `cabal new-build` instead of `stack build`. +The Haskell IDE Engine can also be built with `cabal v2-build` instead of `stack build`. This has the advantage that you can decide how the GHC versions have been installed. To see what GHC versions are available, the command `stack install.hs cabal-ghcs` can be used. It will list all GHC versions that are on the path and their respective installation directory. If you think, this list is incomplete, you can try to modify the PATH variable, such that the executables can be found. -Note, that the targets `cabal-build`, `cabal-build-data` and `cabal-build-all` depend on the found GHC versions. +Note, that the targets `cabal-build` and `cabal-build-data` depend on the found GHC versions. They install Haskell IDE Engine only for the found GHC versions. An example output is: @@ -271,12 +271,6 @@ stack install.hs cabal-hie-8.4.4 stack install.hs cabal-build-data ``` -To install HIE for all GHC versions that are present on your system, use: - -```bash -stack ./install.hs cabal-build-all -``` - In general, targets that use `cabal` instead of `stack` are prefixed with `cabal-*` and are identical to their counterpart, except they do not install a GHC if it is missing but fail. ##### Multiple versions of HIE (optional) diff --git a/docs/Build.md b/docs/Build.md index 83daebec2..717f779aa 100644 --- a/docs/Build.md +++ b/docs/Build.md @@ -13,7 +13,6 @@ The design of the build system has the following main goals: - `stack` - `git` * is completely functional right after a simple `git clone` and after every `git pull` -* one-stop-shop for building and naming all executables required for using `hie` in IDEs. * prevents certain build failures by either identifying a failed precondition (such as wrong `stack` version) or by performing the necessary steps so users can't forget them (such as invoking `git` to update submodules) @@ -29,7 +28,6 @@ The build script `install.hs` defines several targets using the `shake` build sy * `hie-*`: builds and installs the `hie` binaries. Also renames the binaries to contain the correct version-number. * `build-latest`: builds and installs `hie` for the latest available and supported `ghc` version. -* `build-all`: builds and installs `hie` binaries for all supported `ghc` versions. This option may take a long time and computer resources so use it with caution. * `build-data`: builds the hoogle-db required by `hie` * `build`: builds and installs `hie` for the latest supported `ghc` version (like `build-latest`) and the hoogle-db (like `build-data`) * `cabal-*`: execute the same task as the original target, but with `cabal` instead of `stack` diff --git a/install/src/Help.hs b/install/src/Help.hs index cb335d4db..02b529c8e 100644 --- a/install/src/Help.hs +++ b/install/src/Help.hs @@ -45,7 +45,7 @@ shortHelpMessage = do [ ("help", "Show help message including all targets") , emptyTarget , buildTarget - , buildAllTarget + , buildLatestTarget , hieTarget $ last hieVersions , buildDataTarget , cabalGhcsTarget @@ -86,13 +86,12 @@ helpMessage versions@BuildableVersions {..} = do -- All targets with their respective help message. generalTargets = [helpTarget] - defaultTargets = [buildTarget, buildLatestTarget, buildAllTarget, buildDataTarget] + defaultTargets = [buildTarget, buildLatestTarget, buildDataTarget] ++ map hieTarget (getDefaultBuildSystemVersions versions) stackTargets = [ stackTarget buildTarget , stackTarget buildLatestTarget - , stackTarget buildAllTarget , stackTarget buildDataTarget ] ++ (if isRunFromStack then [stackTarget installCabalTarget] else []) @@ -102,7 +101,6 @@ helpMessage versions@BuildableVersions {..} = do [ cabalGhcsTarget , cabalTarget buildTarget , cabalTarget buildLatestTarget - , cabalTarget buildAllTarget , cabalTarget buildDataTarget ] ++ map (cabalTarget . hieTarget) cabalVersions @@ -138,21 +136,6 @@ buildDataTarget :: TargetDescription buildDataTarget = ("build-data", "Get the required data-files for `hie` (Hoogle DB)") -buildAllTarget :: TargetDescription -buildAllTarget = - ( "build-all" - , "Builds hie for all installed GHC versions and the data files. " - ++ buildAllWarning) - -buildAllWarning :: String -buildAllWarning = "WARNING: This command may take a long time and computer resources" - -buildAllWarningAlt :: String -buildAllWarningAlt = "Consider building only the ghc versions you need using:\n" - ++ " " ++ buildCommand (hieTarget "") ++ "\n" - ++ "or the latest available one with:\n" - ++ " " ++ buildCommand buildLatestTarget ++ "\n" - -- special targets macosIcuTarget :: TargetDescription @@ -164,7 +147,7 @@ helpTarget = ("help", "Show help message including all targets") cabalGhcsTarget :: TargetDescription cabalGhcsTarget = ( "cabal-ghcs" - , "Show all GHC versions that can be installed via `cabal-build` and `cabal-build-all`." + , "Show all GHC versions that can be installed via `cabal-build`." ) installCabalTarget :: TargetDescription diff --git a/install/src/HieInstall.hs b/install/src/HieInstall.hs index 479e59cf9..f3e12e57b 100644 --- a/install/src/HieInstall.hs +++ b/install/src/HieInstall.hs @@ -85,7 +85,6 @@ defaultMain = do -- default-targets phony "build" $ need [buildSystem ++ "-build"] phony "build-latest" $ need [buildSystem ++ "-build-latest"] - phony "build-all" $ need [buildSystem ++ "-build-all"] phony "build-data" $ need [buildSystem ++ "-build-data"] forM_ (getDefaultBuildSystemVersions versions) @@ -97,10 +96,7 @@ defaultMain = do when isRunFromStack (phony "stack-install-cabal" (need ["cabal"])) phony "stack-build-latest" (need ["stack-hie-" ++ last hieVersions]) phony "stack-build" (need ["build-data", "stack-build-latest"]) - 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"] @@ -117,10 +113,6 @@ defaultMain = do -- cabal specific targets phony "cabal-build-latest" (need ["cabal-hie-" ++ last ghcVersions]) phony "cabal-build" (need ["build-data", "cabal-build-latest"]) - 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"] From 0ae693639716d7209478c904b75ac64751333b24 Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 18 Nov 2019 00:19:21 +0100 Subject: [PATCH 25/28] Use builtin splitSearchPath --- install/src/Stack.hs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/install/src/Stack.hs b/install/src/Stack.hs index 96cd18334..dd054f93e 100644 --- a/install/src/Stack.hs +++ b/install/src/Stack.hs @@ -7,7 +7,7 @@ import Control.Exception import Control.Monad import Data.List import System.Directory ( copyFile ) -import System.FilePath ( searchPathSeparator, () ) +import System.FilePath ( splitSearchPath, searchPathSeparator, () ) import System.Environment ( lookupEnv, setEnv, getEnvironment ) import System.IO.Error ( isDoesNotExistError ) import BuildSystem @@ -124,13 +124,7 @@ withoutStackCachedBinaries action = do otherwise -> action where removePathsContaining strs path = - joinPaths (filter (not . containsAny) (splitPaths path)) + joinPaths (filter (not . containsAny) (splitSearchPath path)) where containsAny p = any (`isInfixOf` p) strs - joinPaths = intercalate [searchPathSeparator] - - splitPaths s = - case dropWhile (== searchPathSeparator) s of - "" -> [] - s' -> w : splitPaths s'' - where (w, s'') = break (== searchPathSeparator) s' + joinPaths = intercalate [searchPathSeparator] \ No newline at end of file From f37b98714e53bb90807951fbb95f91e3f2e6e79b Mon Sep 17 00:00:00 2001 From: jneira Date: Mon, 18 Nov 2019 08:34:55 +0100 Subject: [PATCH 26/28] Make clear requirements for cabal --- docs/Build.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Build.md b/docs/Build.md index 717f779aa..06f7a8190 100644 --- a/docs/Build.md +++ b/docs/Build.md @@ -89,7 +89,7 @@ The final step is to configure the `hie` client to use a custom `hie-wrapper` sc The `install.hs` script performs some checks to ensure that a correct installation is possible and provide meaningful error messages for known issues. * `stack` needs to be up-to-date. Version `1.9.3` is required -* `cabal` needs to be up-to-date. Version `3.0.0.0` is required for windows systems and `2.4.1.0` for other ones. +* `cabal` needs to be up-to-date. Version `2.4.1.0` is required to *use* haskell-ide-engine until the pull request #1126 is merged. Unfortunately cabal version `3.0.0.0` is needed to *install* hie in windows systems but that inconsistence will be fixed by the mentioned pull request. * `ghc-8.6.3` is broken on windows. Trying to install `hie-8.6.3` on windows is not possible. * When the build fails, an error message, that suggests to remove `.stack-work` directory, is displayed. From 756d51df959dceb76bcef5201d88eea237fbad80 Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 19 Nov 2019 12:52:49 +0100 Subject: [PATCH 27/28] Use ghc versions from stack-*.yaml files --- install/src/Env.hs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/install/src/Env.hs b/install/src/Env.hs index c521d9923..cd8a296bd 100644 --- a/install/src/Env.hs +++ b/install/src/Env.hs @@ -43,15 +43,6 @@ existsExecutable executable = liftIO $ isJust <$> findExecutable executable isWindowsSystem :: Bool isWindowsSystem = os `elem` ["mingw32", "win32"] --- | Defines all different hie versions that are supported. --- On windows, `8.6.3` is excluded as this version of ghc does not work there -supportedGhcVersions :: [VersionNumber] -supportedGhcVersions = sort (commonVersions ++ osVersions) - where commonVersions = ["8.4.2", "8.4.3", "8.4.4", "8.6.1", "8.6.2", "8.6.4", "8.6.5"] - -- the following lines exclude `8.6.3` on windows systems - osVersions | isWindowsSystem = [] - | otherwise = ["8.6.3"] - findInstalledGhcs :: IO [(VersionNumber, GhcPath)] findInstalledGhcs = do hieVersions <- getHieVersions :: IO [VersionNumber] @@ -62,7 +53,7 @@ findInstalledGhcs = do ) (reverse hieVersions) -- filter out not supported ghc versions - availableGhcs <- filter ((`elem` supportedGhcVersions) . fst) <$> getGhcPaths + availableGhcs <- filter ((`elem` hieVersions) . fst) <$> getGhcPaths return -- sort by version to make it coherent with getHieVersions $ sortBy (comparing fst) @@ -113,7 +104,8 @@ getHieVersions = do & mapMaybe (T.stripPrefix stackYamlPrefix >=> T.stripSuffix stackYamlSuffix) & map T.unpack - & filter (\p -> p `elem` supportedGhcVersions) + -- the following line excludes `8.6.3` on windows systems + & filter (\p -> not isWindowsSystem || p /= "8.6.3") & sort return hieVersions From cd27b1ebd5c0745a29fd6d31f45e4b57e581e87e Mon Sep 17 00:00:00 2001 From: jneira Date: Tue, 19 Nov 2019 13:21:07 +0100 Subject: [PATCH 28/28] Correct per-os bashrc in win and macos --- .azure/macos-installhs-stack.yml | 2 +- .azure/windows-installhs-stack.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure/macos-installhs-stack.yml b/.azure/macos-installhs-stack.yml index e78e8f3dd..df7296193 100644 --- a/.azure/macos-installhs-stack.yml +++ b/.azure/macos-installhs-stack.yml @@ -35,6 +35,6 @@ jobs: stack install.hs stack-install-cabal displayName: Run stack-install-cabal target of `install.hs` - bash: | - source .azure/linux.bashrc + source .azure/macos.bashrc stack install.hs build-latest displayName: Run build-latest target of `install.hs` diff --git a/.azure/windows-installhs-stack.yml b/.azure/windows-installhs-stack.yml index cec4fd2e3..4dfed9e9d 100644 --- a/.azure/windows-installhs-stack.yml +++ b/.azure/windows-installhs-stack.yml @@ -33,6 +33,6 @@ jobs: stack install.hs stack-install-cabal displayName: Run stack-install-cabal target of `install.hs` - bash: | - source .azure/linux.bashrc + source .azure/windows.bashrc stack install.hs build-latest displayName: Run build-latest target of `install.hs`