Skip to content

Commit 5d1c9e3

Browse files
committed
Re #6379 Introduce notify-if-arch-unknown configuration option
1 parent 5b30901 commit 5d1c9e3

File tree

6 files changed

+40
-12
lines changed

6 files changed

+40
-12
lines changed

ChangeLog.md

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ Other enhancements:
6565
`stack> build (lib + exe + test) with ghc-9.6.3`).
6666
* Add flag `--candidate` to Stack's `unpack` command, to allow package
6767
candidates to be unpacked locally.
68+
* Stack will notify the user if a specified architecture value is unknown to
69+
Cabal (the library). In YAML configuration files, the `notify-if-arch-unknown`
70+
key is introduced, to allow the notification to be muted if unwanted.
6871

6972
Bug fixes:
7073

doc/yaml_configuration.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,9 @@ See [`setup-info`](#setup-info).
474474
`aarch64` / `arm64`), or other values (which are case-sensitive and treated as
475475
an unknown 'other' architecture of the specified name).
476476

477-
Stack will warn the user if the specified machine architecture is an unknown
478-
'other' architecture.
477+
By default, Stack will warn the user if the specified machine architecture is an
478+
unknown 'other' architecture. The warning can be muted; see
479+
[`notify-if-arch-unknown`](#notify-if-arch-unknown)
479480

480481
!!! note
481482

@@ -1237,6 +1238,15 @@ for details).
12371238
For further information, see the
12381239
[Nix integration](nix_integration.md#configuration) documentation.
12391240

1241+
### notify-if-arch-unknown
1242+
1243+
:octicons-tag-24: UNRELEASED
1244+
1245+
Default: `true`
1246+
1247+
If the specified machine architecture value is unknown to Cabal (the library),
1248+
should Stack notify the user of that?
1249+
12401250
### notify-if-cabal-untested
12411251

12421252
:octicons-tag-24: UNRELEASED

src/Stack/Config.hs

+14-9
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import Data.Monoid.Map ( MonoidMap (..) )
4848
import qualified Data.Text as T
4949
import qualified Data.Yaml as Yaml
5050
import Distribution.System
51-
( Arch (OtherArch), OS (..), Platform (..), buildPlatform )
51+
( Arch (..), OS (..), Platform (..), buildPlatform )
5252
import qualified Distribution.Text ( simpleParse )
5353
import Distribution.Version ( simplifyVersionRange )
5454
import GHC.Conc ( getNumProcessors )
@@ -322,14 +322,6 @@ configFromConfigMonoid
322322
configRequireStackVersion = simplifyVersionRange
323323
(getIntersectingVersionRange configMonoidRequireStackVersion)
324324
configCompilerCheck = fromFirst MatchMinor configMonoidCompilerCheck
325-
case arch of
326-
OtherArch "aarch64" -> pure ()
327-
OtherArch unk ->
328-
prettyWarnL
329-
[ flow "Unknown value for architecture setting:"
330-
, style Shell (fromString unk) <> "."
331-
]
332-
_ -> pure ()
333325
configPlatformVariant <- liftIO $
334326
maybe PlatformVariantNone PlatformVariant <$> lookupEnv platformVariantEnvVar
335327
let configBuild = buildOptsFromMonoid configMonoidBuildOpts
@@ -427,6 +419,7 @@ configFromConfigMonoid
427419
configNotifyIfNixOnPath = fromFirstTrue configMonoidNotifyIfNixOnPath
428420
configNotifyIfGhcUntested = fromFirstTrue configMonoidNotifyIfGhcUntested
429421
configNotifyIfCabalUntested = fromFirstTrue configMonoidNotifyIfCabalUntested
422+
configNotifyIfArchUnknown = fromFirstTrue configMonoidNotifyIfArchUnknown
430423
configNoRunCompile = fromFirstFalse configMonoidNoRunCompile
431424
configAllowDifferentUser <-
432425
case getFirst configMonoidAllowDifferentUser of
@@ -618,6 +611,18 @@ loadConfig inner = do
618611
(mconcat $ configArgs : addConfigMonoid extraConfigs)
619612

620613
withConfig $ \config -> do
614+
let Platform arch _ = configPlatform config
615+
case arch of
616+
OtherArch unknownArch
617+
| configNotifyIfArchUnknown config ->
618+
prettyWarnL
619+
[ flow "Unknown value for architecture setting:"
620+
, style Shell (fromString unknownArch) <> "."
621+
, flow "To mute this message in future, set"
622+
, style Shell (flow "notify-if-arch-unknown: false")
623+
, flow "in Stack's configuration."
624+
]
625+
_ -> pure ()
621626
unless (stackVersion `withinRange` configRequireStackVersion config)
622627
(throwM (BadStackVersionException (configRequireStackVersion config)))
623628
unless (configAllowDifferentUser config) $ do

src/Stack/Options/ConfigParser.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ configOptsParser currentDir hide0 =
100100
<*> optionalFirst (strOption
101101
( long "arch"
102102
<> metavar "ARCH"
103-
<> help "System architecture, e.g. i386, x86_64."
103+
<> help "System architecture, e.g. i386, x86_64, aarch64."
104104
<> hide
105105
))
106106
<*> optionalFirst (ghcVariantParser (hide0 /= OuterGlobalOpts))

src/Stack/Types/Config.hs

+3
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ data Config = Config
186186
-- ^ Notify if Stack has not been tested with the GHC version?
187187
, configNotifyIfCabalUntested :: !Bool
188188
-- ^ Notify if Stack has not been tested with the Cabal version?
189+
, configNotifyIfArchUnknown :: !Bool
190+
-- ^ Notify if the specified machine architecture is unknown to Cabal (the
191+
-- library)?
189192
, configNoRunCompile :: !Bool
190193
-- ^ Use --no-run and --compile options when using `stack script`
191194
, configStackDeveloperMode :: !Bool

src/Stack/Types/ConfigMonoid.hs

+7
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ data ConfigMonoid = ConfigMonoid
174174
-- ^ See 'configNotifyIfGhcUntested'
175175
, configMonoidNotifyIfCabalUntested :: !FirstTrue
176176
-- ^ See 'configNotifyIfCabalUntested'
177+
, configMonoidNotifyIfArchUnknown :: !FirstTrue
178+
-- ^ See 'configNotifyIfArchUnknown'
177179
, configMonoidCasaOpts :: !CasaOptsMonoid
178180
-- ^ Casa configuration options.
179181
, configMonoidCasaRepoPrefix :: !(First CasaRepoPrefix)
@@ -350,6 +352,8 @@ parseConfigMonoidObject rootDir obj = do
350352
FirstTrue <$> obj ..:? configMonoidNotifyIfGhcUntestedName
351353
configMonoidNotifyIfCabalUntested <-
352354
FirstTrue <$> obj ..:? configMonoidNotifyIfCabalUntestedName
355+
configMonoidNotifyIfArchUnknown <-
356+
FirstTrue <$> obj ..:? configMonoidNotifyIfArchUnknownName
353357
configMonoidCasaOpts <-
354358
jsonSubWarnings (obj ..:? configMonoidCasaOptsName ..!= mempty)
355359
configMonoidCasaRepoPrefix <-
@@ -536,6 +540,9 @@ configMonoidNotifyIfGhcUntestedName = "notify-if-ghc-untested"
536540
configMonoidNotifyIfCabalUntestedName :: Text
537541
configMonoidNotifyIfCabalUntestedName = "notify-if-cabal-untested"
538542

543+
configMonoidNotifyIfArchUnknownName :: Text
544+
configMonoidNotifyIfArchUnknownName = "notify-if-arch-unknown"
545+
539546
configMonoidCasaOptsName :: Text
540547
configMonoidCasaOptsName = "casa"
541548

0 commit comments

Comments
 (0)