commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.95k stars 842 forks source link

Fix #6570 Apply `--flag *:[-]<flag_name` only to relevant packages #6571

Closed mpilgrem closed 1 month ago

mpilgrem commented 1 month ago

Previously, the Cabal flags specified at the command line were added and then an action checked the validity of the flags specified for specific packages (only) (in checkFlagsUsedThrowing). Now, the flags are 'checked' as they are added and applyOptsFlag yields a value of type RIO env (Either UnusedFlags CommonPackage).

Moves logic of getLocalFiles from module Stack.Build.Source to Stack.Ghci.loadGhciPkgDescs, as that is the only place where it is now used in the original form.

Moves logic of checkFlagsUsedThrowing from module Stack.SourceMap to Stack.Config.fillProjectWanted, as that is the only place where it is now used in the original form.

To avoid Set.toList . Set.fromList, changes error data constructor to be InvalidFlagSpecification [UnusedFlags].

Note: Fixes for the online documentation of the current Stack release (https://docs.haskellstack.org/en/stable/) should target the 'stable' branch, not the 'master' branch.

Please include the following checklist in your pull request:

Please also shortly describe how you tested your change. Bonus points for added tests! Tested locally on Windows 11.