From 55504f159cb02f4341604ba237662e17b89ddc03 Mon Sep 17 00:00:00 2001 From: waddlaw Date: Sun, 18 Nov 2018 14:27:06 +0900 Subject: [PATCH 1/7] respect --no-install-ghc flag --- src/Stack/Setup.hs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index 04c3caf6f5..1030ea8d07 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -206,6 +206,17 @@ instance Show SetupException where show UnsupportedSetupConfiguration = "I don't know how to install GHC on your system configuration, please install manually" +checkDownloadCompiler :: (HasConfig env, HasGHCVariant env) + => SetupOpts + -> WithDownloadCompiler + -> RIO env (Maybe ExtraDirs, Maybe CompilerBuild, Bool) +checkDownloadCompiler _ SkipDownloadCompiler = return (Nothing, Nothing, False) +checkDownloadCompiler sopts WithDownloadCompiler + | installIfMissing = ensureCompiler sopts + | otherwise = return (Nothing, Nothing, False) + where + installIfMissing = soptsInstallIfMissing sopts + -- | Modify the environment variables (like PATH) appropriately, possibly doing installation too setupEnv :: (HasBuildConfig env, HasGHCVariant env) => Maybe Text -- ^ Message to give user when necessary GHC is not available @@ -234,10 +245,7 @@ setupEnv mResolveMissingGHC = do , soptsGHCJSBootOpts = ["--clean"] } - (mghcBin, mCompilerBuild, _) <- - case bcDownloadCompiler bconfig of - SkipDownloadCompiler -> return (Nothing, Nothing, False) - WithDownloadCompiler -> ensureCompiler sopts + (mghcBin, mCompilerBuild, _) <- checkDownloadCompiler sopts (bcDownloadCompiler bconfig) -- Modify the initial environment to include the GHC path, if a local GHC -- is being used From c0ed27c9c33f7320128e0f2c4ff724ce6d40a729 Mon Sep 17 00:00:00 2001 From: waddlaw Date: Sun, 18 Nov 2018 15:37:45 +0900 Subject: [PATCH 2/7] Add helper lens functions --- src/Stack/Types/Config.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Stack/Types/Config.hs b/src/Stack/Types/Config.hs index fe73732617..519972603c 100644 --- a/src/Stack/Types/Config.hs +++ b/src/Stack/Types/Config.hs @@ -163,6 +163,8 @@ module Stack.Types.Config ,loadedSnapshotL ,shouldForceGhcColorFlag ,appropriateGhcColorFlag + ,configMonoidSkipGHCCheckL + ,configMonoidInstallGHCL -- * Lens reexport ,view ,to @@ -1984,3 +1986,13 @@ appropriateGhcColorFlag :: (HasRunner env, HasEnvConfig env) appropriateGhcColorFlag = f <$> shouldForceGhcColorFlag where f True = Just ghcColorForceFlag f False = Nothing + +configMonoidSkipGHCCheckL :: Lens' ConfigMonoid (Maybe Bool) +configMonoidSkipGHCCheckL = + lens (getFirst . configMonoidSkipGHCCheck) + (\configMonoid t -> configMonoid {configMonoidSkipGHCCheck = First t}) + +configMonoidInstallGHCL :: Lens' ConfigMonoid (Maybe Bool) +configMonoidInstallGHCL = + lens (getFirst . configMonoidInstallGHC) + (\configMonoid t -> configMonoid {configMonoidInstallGHC = First t}) \ No newline at end of file From 3fc58f812c525b78b878b6183a0e553228e029c2 Mon Sep 17 00:00:00 2001 From: waddlaw Date: Sun, 18 Nov 2018 15:43:07 +0900 Subject: [PATCH 3/7] dot and ls ls dependencies work without ghc --- src/Stack/Runners.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Stack/Runners.hs b/src/Stack/Runners.hs index deaa68f714..e770b32cb0 100644 --- a/src/Stack/Runners.hs +++ b/src/Stack/Runners.hs @@ -267,4 +267,8 @@ withBuildConfigDot opts go f = withBuildConfig go' f go' = (if dotTestTargets opts then set (globalOptsBuildOptsMonoidL.buildOptsMonoidTestsL) (Just True) else id) $ (if dotBenchTargets opts then set (globalOptsBuildOptsMonoidL.buildOptsMonoidBenchmarksL) (Just True) else id) + $ + (set (globalOptsL.configMonoidSkipGHCCheckL) (Just True)) + $ + (set (globalOptsL.configMonoidInstallGHCL) (Just False)) go From 8bee990b2f48bdef72321d4e6db5979badcb1f35 Mon Sep 17 00:00:00 2001 From: waddlaw Date: Sun, 18 Nov 2018 19:48:59 +0900 Subject: [PATCH 4/7] fix hlint suggestion, and small refactoring --- src/Stack/Runners.hs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Stack/Runners.hs b/src/Stack/Runners.hs index e770b32cb0..2186c52ea6 100644 --- a/src/Stack/Runners.hs +++ b/src/Stack/Runners.hs @@ -3,6 +3,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE RankNTypes #-} -- | Utilities for running stack commands. module Stack.Runners @@ -261,14 +262,18 @@ munlockFile Nothing = return () munlockFile (Just lk) = liftIO $ unlockFile lk -- Plumbing for --test and --bench flags +-- Force enable --no-install-ghc and --skip-ghc-check flags withBuildConfigDot :: DotOpts -> GlobalOpts -> RIO EnvConfig () -> IO () -withBuildConfigDot opts go f = withBuildConfig go' f +withBuildConfigDot opts go = withBuildConfig (updateGlobalOpts go) where - go' = - (if dotTestTargets opts then set (globalOptsBuildOptsMonoidL.buildOptsMonoidTestsL) (Just True) else id) $ - (if dotBenchTargets opts then set (globalOptsBuildOptsMonoidL.buildOptsMonoidBenchmarksL) (Just True) else id) - $ - (set (globalOptsL.configMonoidSkipGHCCheckL) (Just True)) - $ - (set (globalOptsL.configMonoidInstallGHCL) (Just False)) - go + updateGlobalOpts + = updateOpts (dotTestTargets opts) (globalOptsBuildOptsMonoidL.buildOptsMonoidTestsL) (Just True) + . updateOpts (dotBenchTargets opts) (globalOptsBuildOptsMonoidL.buildOptsMonoidBenchmarksL) (Just True) + . updateOpts True (globalOptsL.configMonoidSkipGHCCheckL) (Just True) + . updateOpts True (globalOptsL.configMonoidInstallGHCL) (Just False) + +-- helper function for update some option +updateOpts :: Bool -> Lens' opts v -> v -> opts -> opts +updateOpts isRequired opt v + | isRequired = set opt v + | otherwise = id From 7412fc06420535ee2a7394bdaff3652f669c462e Mon Sep 17 00:00:00 2001 From: waddlaw Date: Sun, 18 Nov 2018 19:49:06 +0900 Subject: [PATCH 5/7] update Changelog --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index ad58cf70fa..fd0f60f366 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -97,6 +97,7 @@ Bug fixes: [#4314](https://github.com/commercialhaskell/stack/pull/4314) * Add `--cabal-files` flag to `stack ide targets` command. * Don't download ghc when using `stack clean`. +* `dot` and `ls dependencies` commands is no longer require ghc installed. And, fix not respected `--no-install-ghc` flag. (See [#4390](https://github.com/commercialhaskell/stack/issues/4390)) ## v1.9.1 From 0ac8a8baff554597a80333754bb1f038bb3e16b0 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 19 Nov 2018 18:31:21 +0900 Subject: [PATCH 6/7] Update ChangeLog.md Co-Authored-By: waddlaw --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index fd0f60f366..5ffbc958ec 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -97,7 +97,7 @@ Bug fixes: [#4314](https://github.com/commercialhaskell/stack/pull/4314) * Add `--cabal-files` flag to `stack ide targets` command. * Don't download ghc when using `stack clean`. -* `dot` and `ls dependencies` commands is no longer require ghc installed. And, fix not respected `--no-install-ghc` flag. (See [#4390](https://github.com/commercialhaskell/stack/issues/4390)) +* `dot` and `ls dependencies` commands no longer require GHC to be installed. Also, ensures the `--no-install-ghc` flag is respected. See: [#4390](https://github.com/commercialhaskell/stack/issues/4390) ## v1.9.1 From 3167481a0fd9cb2a0069e305dae2ca5fd226a00f Mon Sep 17 00:00:00 2001 From: waddlaw Date: Mon, 19 Nov 2018 18:41:54 +0900 Subject: [PATCH 7/7] simplify --- src/Stack/Runners.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Stack/Runners.hs b/src/Stack/Runners.hs index 2186c52ea6..7bdd5e4962 100644 --- a/src/Stack/Runners.hs +++ b/src/Stack/Runners.hs @@ -269,8 +269,8 @@ withBuildConfigDot opts go = withBuildConfig (updateGlobalOpts go) updateGlobalOpts = updateOpts (dotTestTargets opts) (globalOptsBuildOptsMonoidL.buildOptsMonoidTestsL) (Just True) . updateOpts (dotBenchTargets opts) (globalOptsBuildOptsMonoidL.buildOptsMonoidBenchmarksL) (Just True) - . updateOpts True (globalOptsL.configMonoidSkipGHCCheckL) (Just True) - . updateOpts True (globalOptsL.configMonoidInstallGHCL) (Just False) + . set (globalOptsL.configMonoidSkipGHCCheckL) (Just True) + . set (globalOptsL.configMonoidInstallGHCL) (Just False) -- helper function for update some option updateOpts :: Bool -> Lens' opts v -> v -> opts -> opts