Skip to content

Commit

Permalink
Merge pull request #6679 from commercialhaskell/fix6678
Browse files Browse the repository at this point in the history
Fix #6678 Add Cabal boot package to `setup-depends` deps, when needed
  • Loading branch information
mpilgrem authored Jan 20, 2025
2 parents 7dbea09 + 2f66cb6 commit e66f620
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .stan.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@

# Anti-pattern: Data.ByteString.Char8.pack
[[ignore]]
id = "OBS-STAN-0203-erw24B-1031:3"
id = "OBS-STAN-0203-erw24B-1039:3"
# ✦ Description: Usage of 'pack' function that doesn't handle Unicode characters
# ✦ Category: #AntiPattern
# ✦ File: src\Stack\Build\ExecuteEnv.hs
#
# 1030
# 1031 ┃ S8.pack . formatTime defaultTimeLocale "%Y-%m-%dT%H:%M:%S%6Q"
# 1032 ┃ ^^^^^^^
# 1038
# 1039 ┃ S8.pack . formatTime defaultTimeLocale "%Y-%m-%dT%H:%M:%S%6Q"
# 1040 ┃ ^^^^^^^

# Anti-pattern: Data.ByteString.Char8.pack
[[ignore]]
Expand Down
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Behavior changes:
(Latin-1) character in Stack's 'programs' path, as `hsc2hs` does not work if
there is such a character in the path to its default template
`template-hsc.h`.
* Stack customizes setup using `Cabal`, so if a `setup-depends` field does not
mention it as a dependency, Stack warns and adds the GHC boot package as a
dependency. Previously, Stack would not do so but only warn that build errors
were likely.

Other enhancements:

Expand Down
3 changes: 1 addition & 2 deletions doc/commands/build_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ information about how these dependencies get specified.
If a package description specifies a custom build type, it must also specify a
custom setup. That should list the dependencies needed to compile `Setup.hs`.
Stack further customises the setup, using the `Cabal` package. If that package
is not listed, Stack will not add the package as a dependency but warn that
build errors are likely.
is not listed, Stack will warn and add the GHC boot package as a dependency.

In addition to specifying targets, you can also control what gets built, or
retained, with the flags and options listed below. You can also affect what gets
Expand Down
24 changes: 16 additions & 8 deletions src/Stack/Build/ExecuteEnv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -729,13 +729,21 @@ withSingleContext
-- providing an explicit list of dependencies, and we should
-- simply use all of them.
Just customSetupDeps -> do
unless (Map.member (mkPackageName "Cabal") customSetupDeps) $
prettyWarnL
[ fromPackageName package.name
, flow "has a setup-depends field, but it does not mention \
\a Cabal dependency. This is likely to cause build \
\errors."
]
cabalPackageArg' <-
if Map.member (mkPackageName "Cabal") customSetupDeps
then pure []
else do
prettyWarnL
[ style Current (fromPackageName package.name)
, flow "has a"
, style Shell "setup-depends"
, flow "field, but it does not mention a"
, style Current "Cabal"
, flow "dependency. Stack customizes setup using \
\Cabal, so it has added the GHC boot package as \
\a dependency."
]
pure cabalPackageArg
matchedDeps <-
forM (Map.toList customSetupDeps) $ \(name, depValue) -> do
let matches (PackageIdentifier name' version) =
Expand Down Expand Up @@ -772,7 +780,7 @@ withSingleContext
)
)
)
pure (packageDBArgs ++ depsArgs ++ cppArgs)
pure (packageDBArgs ++ depsArgs ++ cabalPackageArg' ++ cppArgs)

-- This branch is usually taken for builds, and is always taken
-- for `stack sdist`.
Expand Down

0 comments on commit e66f620

Please sign in to comment.