Skip to content

Commit 78d6697

Browse files
authored
Merge pull request #5333 from commercialhaskell/stable-into-master
Stable into master
2 parents a1a7688 + 1bdbbfd commit 78d6697

File tree

13 files changed

+82
-8
lines changed

13 files changed

+82
-8
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Other enhancements:
2727
[#5280](https://github.com/commercialhaskell/stack/issues/5280)
2828
* Build failures now show a hint to scroll up to the corresponding section
2929
[#5279](https://github.com/commercialhaskell/stack/issues/5279)
30+
* Add the `stack-developer-mode` flag
3031

3132
Bug fixes:
3233

doc/yaml_configuration.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,16 @@ recommend-stack-upgrade: true
11881188

11891189
Since 2.0
11901190

1191+
### stack-developer-mode
1192+
1193+
Turns on a mode where some messages are printed at WARN level instead of DEBUG level, especially useful for developers of Stack itself. For official distributed binaries, this is set to `false` by default. When you build from source, it is set to `true` by default.
1194+
1195+
```yaml
1196+
stack-developer-mode: false
1197+
```
1198+
1199+
Since 2.3.3
1200+
11911201
### snapshot-location-base
11921202
Sets the base location of LTS Haskell/Stackage Nightly snapshots. Default is https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/ (as set in the `pantry` library).
11931203

@@ -1202,4 +1212,4 @@ has the following effect:
12021212
This field is convenient in setups that restrict access to GitHub, for instance closed corporate setups. In this setting, it is common for the development environment to have general access to the internet, but not for testing/building environments. To avoid the firewall, one can run a local snapshots mirror and then use a custom `snapshot-location-base` in the closed environments only.
12031213

12041214

1205-
Since FIXME:
1215+
Since 2.5.0

etc/scripts/release.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ main =
9191
gUploadLabel = Nothing
9292
gTestHaddocks = True
9393
gProjectRoot = "" -- Set to real value velow.
94-
gBuildArgs = []
94+
gBuildArgs = ["--flag", "stack:-developer-mode"]
9595
gCertificateName = Nothing
9696
gUploadOnly = False
9797
global0 = foldl (flip id) Global{..} flags

package.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ when:
141141
- hsc2hs
142142
dependencies:
143143
- unix
144+
- condition: flag(developer-mode)
145+
then:
146+
cpp-options: -DSTACK_DEVELOPER_MODE_DEFAULT=True
147+
else:
148+
cpp-options: -DSTACK_DEVELOPER_MODE_DEFAULT=False
144149
library:
145150
source-dirs: src/
146151
ghc-options:
@@ -348,3 +353,7 @@ flags:
348353
requests more difficult."
349354
manual: true
350355
default: false
356+
developer-mode:
357+
description: "By default, should extra developer information be output?"
358+
manual: true
359+
default: false

src/Stack/Config.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ configFromConfigMonoid
374374
Nothing -> pure $ configStackRoot </> relDirPantry
375375

376376
let snapLoc =
377-
case getFirst configMonoidSnapshotLocation of
377+
case getFirst configMonoidSnapshotLocation of
378378
Nothing -> defaultSnapshotLocation
379379
Just addr -> customSnapshotLocation
380380
where
@@ -391,6 +391,9 @@ configFromConfigMonoid
391391
<> "/" <> display day <> ".yaml"
392392
mkRSLUrl builder = RSLUrl (utf8BuilderToText builder) Nothing
393393
addr' = display $ T.dropWhileEnd (=='/') addr
394+
395+
let configStackDeveloperMode = fromFirst stackDeveloperModeDefault configMonoidStackDeveloperMode
396+
394397
withPantryConfig
395398
pantryRoot
396399
hsc

src/Stack/Constants.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ module Stack.Constants
120120
,usrLibDirs
121121
,testGhcEnvRelFile
122122
,relFileBuildLock
123+
,stackDeveloperModeDefault
123124
)
124125
where
125126

@@ -555,3 +556,7 @@ testGhcEnvRelFile = $(mkRelFile "test-ghc-env")
555556
-- | File inside a dist directory to use for locking
556557
relFileBuildLock :: Path Rel File
557558
relFileBuildLock = $(mkRelFile "build-lock")
559+
560+
-- | What should the default be for stack-developer-mode
561+
stackDeveloperModeDefault :: Bool
562+
stackDeveloperModeDefault = STACK_DEVELOPER_MODE_DEFAULT

src/Stack/Package.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ parseHI hiPath = do
11001100
result <- liftIO $ Iface.fromFile hiPath
11011101
case result of
11021102
Left msg -> do
1103-
prettyWarnL
1103+
prettyStackDevL
11041104
[ flow "Failed to decode module interface:"
11051105
, style File $ fromString hiPath
11061106
, flow "Decoding failure:"

src/Stack/Types/Config.hs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ module Stack.Types.Config
169169
,envOverrideSettingsL
170170
,shouldForceGhcColorFlag
171171
,appropriateGhcColorFlag
172+
-- * Helper logging functions
173+
,prettyStackDevL
172174
-- * Lens reexport
173175
,view
174176
,to
@@ -214,7 +216,7 @@ import Pantry.Internal (Storage)
214216
import Path
215217
import qualified Paths_stack as Meta
216218
import qualified RIO.List as List
217-
import RIO.PrettyPrint (HasTerm (..))
219+
import RIO.PrettyPrint (HasTerm (..), StyleDoc, prettyWarnL, prettyDebugL)
218220
import RIO.PrettyPrint.StylesUpdate (StylesUpdate,
219221
parseStylesUpdateFromString, HasStylesUpdate (..))
220222
import Stack.Constants
@@ -377,6 +379,8 @@ data Config =
377379
-- ^ Enable GHC hiding source paths?
378380
,configRecommendUpgrade :: !Bool
379381
-- ^ Recommend a Stack upgrade?
382+
,configStackDeveloperMode :: !Bool
383+
-- ^ Turn on Stack developer mode for additional messages?
380384
}
381385

382386
-- | A bit of type safety to ensure we're talking to the right database.
@@ -861,6 +865,8 @@ data ConfigMonoid =
861865
, configMonoidCasaRepoPrefix :: !(First CasaRepoPrefix)
862866
, configMonoidSnapshotLocation :: !(First Text)
863867
-- ^ Custom location of LTS/Nightly snapshots
868+
, configMonoidStackDeveloperMode :: !(First Bool)
869+
-- ^ See 'configStackDeveloperMode'
864870
}
865871
deriving (Show, Generic)
866872

@@ -986,6 +992,8 @@ parseConfigMonoidObject rootDir obj = do
986992
configMonoidCasaRepoPrefix <- First <$> obj ..:? configMonoidCasaRepoPrefixName
987993
configMonoidSnapshotLocation <- First <$> obj ..:? configMonoidSnapshotLocationName
988994

995+
configMonoidStackDeveloperMode <- First <$> obj ..:? configMonoidStackDeveloperModeName
996+
989997
return ConfigMonoid {..}
990998
where
991999
handleExplicitSetupDep :: (Monad m, MonadFail m) => (Text, Bool) -> m (Maybe PackageName, Bool)
@@ -1154,6 +1162,9 @@ configMonoidCasaRepoPrefixName = "casa-repo-prefix"
11541162
configMonoidSnapshotLocationName :: Text
11551163
configMonoidSnapshotLocationName = "snapshot-location-base"
11561164

1165+
configMonoidStackDeveloperModeName :: Text
1166+
configMonoidStackDeveloperModeName = "stack-developer-mode"
1167+
11571168
data ConfigException
11581169
= ParseConfigFileException (Path Abs File) ParseException
11591170
| ParseCustomSnapshotException Text ParseException
@@ -2132,3 +2143,11 @@ terminalL = globalOptsL.lens globalTerminal (\x y -> x { globalTerminal = y })
21322143
-- | See 'globalReExecVersion'
21332144
reExecL :: HasRunner env => SimpleGetter env Bool
21342145
reExecL = globalOptsL.to (isJust . globalReExecVersion)
2146+
2147+
-- | In dev mode, print as a warning, otherwise as debug
2148+
prettyStackDevL :: HasConfig env => [StyleDoc] -> RIO env ()
2149+
prettyStackDevL docs = do
2150+
config <- view configL
2151+
if configStackDeveloperMode config
2152+
then prettyWarnL docs
2153+
else prettyDebugL docs

stack-ghc-84.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ resolver: lts-12.26
33
packages:
44
- .
55

6+
flags:
7+
stack:
8+
developer-mode: true
9+
610
docker:
711
enable: false
812
repo: fpco/stack-build-small:lts-12.26

stack-ghc-88.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ flags:
1616
stack:
1717
hide-dependency-versions: true
1818
supported-build: true
19+
developer-mode: true
1920

2021
ghc-options:
2122
"$locals": -fhide-source-paths

0 commit comments

Comments
 (0)