Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ConstraintSource back to cabal-install. #9642

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
ghc: ["8.10.7", "9.0.2", "9.2.8", "9.4.8", "9.6.4", "9.8.1"]
ghc: ["9.0.2", "9.2.8", "9.4.8", "9.6.4", "9.8.2"]
include:
- os: macos-latest
ghc: "9.2.8"
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
# If you remove something from here.. then add it to the old-ghcs job.
ghc: ["9.8.1", "9.6.3", "9.4.8", "9.2.8", "9.0.2", "8.10.7", "8.8.4", "8.6.5"]
ghc: ["9.8.2", "9.6.4", "9.4.8", "9.2.8", "9.0.2", "8.10.7", "8.8.4", "8.6.5"]
exclude:
# corrupts GHA cache or the fabric of reality itself, see https://github.com/haskell/cabal/issues/8356
- os: "windows-latest"
Expand Down Expand Up @@ -258,7 +258,9 @@ jobs:
apt-get update
apt-get install -y ghc-${{ matrix.extra-ghc }}-dyn

- uses: haskell-actions/setup@v2
- uses: haskell-actions/[email protected]
# From 2.7 the setup action uses node20,
# which is not supported by the phadej/ghc:8.8.4-xenial container.
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
Expand Down
6 changes: 3 additions & 3 deletions Cabal-QuickCheck/Cabal-QuickCheck.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: Cabal-QuickCheck
version: 3.11.0.0
version: 3.12.0.0
synopsis: QuickCheck instances for types in Cabal
category: Testing
description:
Expand All @@ -13,8 +13,8 @@ library
build-depends:
, base
, bytestring
, Cabal ^>=3.11.0.0
, Cabal-syntax ^>=3.11.0.0
, Cabal ^>=3.12.0.0
, Cabal-syntax ^>=3.12.0.0
, QuickCheck ^>=2.13.2 || ^>=2.14

exposed-modules:
Expand Down
6 changes: 3 additions & 3 deletions Cabal-described/Cabal-described.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: Cabal-described
version: 3.11.0.0
version: 3.12.0.0
synopsis: Described functionality for types in Cabal
category: Testing, Parsec
description: Provides rere bindings
Expand All @@ -11,8 +11,8 @@ library
ghc-options: -Wall
build-depends:
, base
, Cabal ^>=3.11.0.0
, Cabal-syntax ^>=3.11.0.0
, Cabal ^>=3.12.0.0
, Cabal-syntax ^>=3.12.0.0
, containers
, pretty
, QuickCheck
Expand Down
6 changes: 3 additions & 3 deletions Cabal-syntax/Cabal-syntax.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: Cabal-syntax
version: 3.11.0.0
version: 3.12.0.0
copyright: 2003-2024, Cabal Development Team (see AUTHORS file)
license: BSD-3-Clause
license-file: LICENSE
Expand All @@ -15,7 +15,7 @@ description:
category: Distribution
build-type: Simple

extra-source-files:
extra-doc-files:
README.md ChangeLog.md

source-repository head
Expand All @@ -40,7 +40,7 @@ library
parsec >= 3.1.13.0 && < 3.2,
pretty >= 1.1.1 && < 1.2,
text (>= 1.2.3.0 && < 1.3) || (>= 2.0 && < 2.2),
time >= 1.4.0.1 && < 1.13,
time >= 1.4.0.1 && < 1.15,
-- transformers-0.4.0.0 doesn't have record syntax e.g. for Identity
-- See also https://github.com/ekmett/transformers-compat/issues/35
transformers (>= 0.3 && < 0.4) || (>=0.4.1.0 && <0.7)
Expand Down
156 changes: 141 additions & 15 deletions Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs

Large diffs are not rendered by default.

972 changes: 856 additions & 116 deletions Cabal-syntax/src/Distribution/SPDX/LicenseId.hs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cabal-syntax/src/Distribution/SPDX/LicenseListVersion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ data LicenseListVersion
| LicenseListVersion_3_9
| LicenseListVersion_3_10
| LicenseListVersion_3_16
| LicenseListVersion_3_23
deriving (Eq, Ord, Show, Enum, Bounded)

cabalSpecVersionToSPDXListVersion :: CabalSpecVersion -> LicenseListVersion
cabalSpecVersionToSPDXListVersion CabalSpecV3_12 = LicenseListVersion_3_23
cabalSpecVersionToSPDXListVersion CabalSpecV3_8 = LicenseListVersion_3_16
cabalSpecVersionToSPDXListVersion CabalSpecV3_6 = LicenseListVersion_3_10
cabalSpecVersionToSPDXListVersion CabalSpecV3_4 = LicenseListVersion_3_9
Expand Down
24 changes: 16 additions & 8 deletions Cabal-syntax/src/Distribution/Types/CondTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Distribution.Types.CondTree
, traverseCondBranchC
, extractCondition
, simplifyCondTree
, simplifyCondBranch
, ignoreConditions
) where

Expand Down Expand Up @@ -169,21 +170,28 @@ extractCondition p = go
in
((c `cAnd` ct) `cOr` (CNot c `cAnd` ce)) `cAnd` goList cs

-- | Flattens a CondTree using a partial flag assignment. When a condition
-- | Flattens a CondTree using a partial flag assignment. When a condition
-- cannot be evaluated, both branches are ignored.
simplifyCondTree
:: (Semigroup a, Semigroup d)
=> (v -> Either v Bool)
-> CondTree v d a
-> (d, a)
simplifyCondTree env (CondNode a d ifs) =
foldl (<>) (d, a) $ mapMaybe simplifyIf ifs
where
simplifyIf (CondBranch cnd t me) =
case simplifyCondition cnd env of
(Lit True, _) -> Just $ simplifyCondTree env t
(Lit False, _) -> fmap (simplifyCondTree env) me
_ -> Nothing
foldl (<>) (d, a) $ mapMaybe (simplifyCondBranch env) ifs

-- | Realizes a 'CondBranch' using partial flag assignment. When a condition
-- cannot be evaluated, returns 'Nothing'.
simplifyCondBranch
:: (Semigroup a, Semigroup d)
=> (v -> Either v Bool)
-> CondBranch v d a
-> Maybe (d, a)
simplifyCondBranch env (CondBranch cnd t me) =
case simplifyCondition cnd env of
(Lit True, _) -> Just $ simplifyCondTree env t
(Lit False, _) -> fmap (simplifyCondTree env) me
_ -> Nothing

-- | Flatten a CondTree. This will resolve the CondTree by taking all
-- possible paths into account. Note that since branches represent exclusive
Expand Down
6 changes: 3 additions & 3 deletions Cabal-tree-diff/Cabal-tree-diff.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: Cabal-tree-diff
version: 3.11.0.0
version: 3.12.0.0
synopsis: QuickCheck instances for types in Cabal
category: Testing
description: Provides tree-diff ToExpr instances for some types in Cabal
Expand All @@ -11,8 +11,8 @@ library
ghc-options: -Wall
build-depends:
, base
, Cabal-syntax ^>=3.11.0.0
, Cabal ^>=3.11.0.0
, Cabal-syntax ^>=3.12.0.0
, Cabal ^>=3.12.0.0
, tree-diff ^>=0.1 || ^>=0.2 || ^>=0.3

exposed-modules: Data.TreeDiff.Instances.Cabal
Expand Down
8 changes: 4 additions & 4 deletions Cabal/Cabal.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: Cabal
version: 3.11.0.0
version: 3.12.0.0
copyright: 2003-2024, Cabal Development Team (see AUTHORS file)
license: BSD-3-Clause
license-file: LICENSE
Expand All @@ -21,7 +21,7 @@ build-type: Simple
-- If we use a new Cabal feature, this needs to be changed to Custom so
-- we can bootstrap.

extra-source-files:
extra-doc-files:
README.md ChangeLog.md

source-repository head
Expand All @@ -34,7 +34,7 @@ library
hs-source-dirs: src

build-depends:
Cabal-syntax ^>= 3.11,
Cabal-syntax ^>= 3.12,
array >= 0.4.0.1 && < 0.6,
base >= 4.9 && < 5,
bytestring >= 0.10.0.0 && < 0.13,
Expand All @@ -44,7 +44,7 @@ library
filepath >= 1.3.0.1 && < 1.6,
pretty >= 1.1.1 && < 1.2,
process >= 1.2.1.0 && < 1.7,
time >= 1.4.0.1 && < 1.13
time >= 1.4.0.1 && < 1.15

if os(windows)
build-depends: Win32 >= 2.3.0.0 && < 2.15
Expand Down
3 changes: 3 additions & 0 deletions Cabal/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 3.12.0.0 [Francesco Ariis](mailto:[email protected]) March 2024
* See https://github.com/haskell/cabal/blob/master/release-notes/Cabal-3.12.0.0.md

# 3.10.3.0 [Hécate](mailto:[email protected]) January 2024
* See https://github.com/haskell/cabal/blob/master/release-notes/Cabal-3.10.3.0.md

Expand Down
2 changes: 1 addition & 1 deletion Cabal/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=3.11.0.0
VERSION=3.12.0.0

#KIND=devel
KIND=rc
Expand Down
52 changes: 48 additions & 4 deletions Cabal/src/Distribution/PackageDescription/Check/Conditional.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ updateTargetAnnotation t ta = ta{taTarget = taTarget ta <> t}
-- doc for more info).
annotateCondTree
:: forall a
. Monoid a
. (Eq a, Monoid a)
=> [PackageFlag] -- User flags.
-> TargetAnnotation a
-> CondTree ConfVar [Dependency] a
-> CondTree ConfVar [Dependency] (TargetAnnotation a)
annotateCondTree fs ta (CondNode a c bs) =
let ta' = updateTargetAnnotation a ta
bs' = map (annotateBranch ta') bs
in CondNode ta' c bs'
bs'' = crossAnnotateBranches defTrueFlags bs'
in CondNode ta' c bs''
where
annotateBranch
:: TargetAnnotation a
Expand Down Expand Up @@ -107,12 +108,55 @@ annotateCondTree fs ta (CondNode a c bs) =
)
fs

defTrueFlags :: [PackageFlag]
defTrueFlags = filter flagDefault fs

-- Propagate contextual information in CondTree branches. This is
-- needed as CondTree is a rosetree and not a binary tree.
crossAnnotateBranches
:: forall a
. (Eq a, Monoid a)
=> [PackageFlag] -- `default: true` flags.
-> [CondBranch ConfVar [Dependency] (TargetAnnotation a)]
-> [CondBranch ConfVar [Dependency] (TargetAnnotation a)]
crossAnnotateBranches fs bs = map crossAnnBranch bs
where
crossAnnBranch
:: CondBranch ConfVar [Dependency] (TargetAnnotation a)
-> CondBranch ConfVar [Dependency] (TargetAnnotation a)
crossAnnBranch wr =
let
rs = filter (/= wr) bs
ts = mapMaybe realiseBranch rs
in
updateTargetAnnBranch (mconcat ts) wr

realiseBranch :: CondBranch ConfVar [Dependency] (TargetAnnotation a) -> Maybe a
realiseBranch b =
let
-- We are only interested in True by default package flags.
realiseBranchFunction :: ConfVar -> Either ConfVar Bool
realiseBranchFunction (PackageFlag n) | elem n (map flagName fs) = Right True
realiseBranchFunction _ = Right False
ms = simplifyCondBranch realiseBranchFunction (fmap taTarget b)
in
fmap snd ms

updateTargetAnnBranch
:: a
-> CondBranch ConfVar [Dependency] (TargetAnnotation a)
-> CondBranch ConfVar [Dependency] (TargetAnnotation a)
updateTargetAnnBranch a (CondBranch k t mt) =
let updateTargetAnnTree (CondNode ka c wbs) =
(CondNode (updateTargetAnnotation a ka) c wbs)
in CondBranch k (updateTargetAnnTree t) (updateTargetAnnTree <$> mt)

-- | A conditional target is a library, exe, benchmark etc., destructured
-- in a CondTree. Traversing method: we render the branches, pass a
-- relevant context, collect checks.
checkCondTarget
:: forall m a
. (Monad m, Monoid a)
. (Monad m, Eq a, Monoid a)
=> [PackageFlag] -- User flags.
-> (a -> CheckM m ()) -- Check function (a = target).
-> (UnqualComponentName -> a -> a)
Expand All @@ -131,7 +175,7 @@ checkCondTarget fs cf nf (unqualName, ct) =
:: CondTree ConfVar [Dependency] (TargetAnnotation a)
-> CheckM m ()
wTree (CondNode ta _ bs)
-- There are no branches (and [] == True) *or* every branch
-- There are no branches ([] == True) *or* every branch
-- is “simple” (i.e. missing a 'condBranchIfFalse' part).
-- This is convenient but not necessarily correct in all
-- cases; a more precise way would be to check incompatibility
Expand Down
8 changes: 5 additions & 3 deletions Cabal/src/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ import Distribution.Simple.PackageIndex (InstalledPackageIndex, lookupUnitId)
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.PreProcess
import Distribution.Simple.Program
import Distribution.Simple.Program.Db (appendProgramSearchPath, lookupProgramByName)
import Distribution.Simple.Program.Db (lookupProgramByName, modifyProgramSearchPath, prependProgramSearchPath)
import Distribution.Simple.Setup.Common as Setup
import Distribution.Simple.Setup.Config as Setup
import Distribution.Simple.Utils
Expand Down Expand Up @@ -1236,13 +1236,15 @@ mkPromisedDepsSet comps = Map.fromList [((pn, CLibName ln), cid) | GivenComponen
-- arguments.
mkProgramDb :: ConfigFlags -> ProgramDb -> IO ProgramDb
mkProgramDb cfg initialProgramDb = do
programDb <- appendProgramSearchPath (fromFlagOrDefault normal (configVerbosity cfg)) searchpath initialProgramDb
programDb <-
modifyProgramSearchPath (getProgramSearchPath initialProgramDb ++) -- We need to have the paths to programs installed by build-tool-depends before all other paths
<$> prependProgramSearchPath (fromFlagOrDefault normal (configVerbosity cfg)) searchpath initialProgramDb
pure
. userSpecifyArgss (configProgramArgs cfg)
. userSpecifyPaths (configProgramPaths cfg)
$ programDb
where
searchpath = fromNubList $ configProgramPathExtra cfg
searchpath = fromNubList (configProgramPathExtra cfg)

-- Note. We try as much as possible to _prepend_ rather than postpend the extra-prog-path
-- so that we can override the system path. However, in a v2-build, at this point, the "system" path
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/ConfigureScript.hs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ runConfigureScript verbosity flags lbi = do
maybeHostFlag = if hp == buildPlatform then [] else ["--host=" ++ show (pretty hp)]
args' = configureFile' : args ++ ["CC=" ++ ccProgShort] ++ maybeHostFlag
shProg = simpleProgram "sh"
progDb <- appendProgramSearchPath verbosity extraPath emptyProgramDb
progDb <- prependProgramSearchPath verbosity extraPath emptyProgramDb
shConfiguredProg <-
lookupProgram shProg
`fmap` configureProgram verbosity shProg progDb
Expand Down
8 changes: 4 additions & 4 deletions Cabal/src/Distribution/Simple/Program/Db.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module Distribution.Simple.Program.Db
-- ** Query and manipulate the program db
, addKnownProgram
, addKnownPrograms
, appendProgramSearchPath
, prependProgramSearchPath
, lookupKnownProgram
, knownPrograms
, getProgramSearchPath
Expand Down Expand Up @@ -223,14 +223,14 @@ modifyProgramSearchPath f db =
setProgramSearchPath (f $ getProgramSearchPath db) db

-- | Modify the current 'ProgramSearchPath' used by the 'ProgramDb'
-- by appending the provided extra paths. Also logs the added paths
-- by prepending the provided extra paths. Also logs the added paths
-- in info verbosity.
appendProgramSearchPath
prependProgramSearchPath
:: Verbosity
-> [FilePath]
-> ProgramDb
-> IO ProgramDb
appendProgramSearchPath verbosity extraPaths db =
prependProgramSearchPath verbosity extraPaths db =
if not $ null extraPaths
then do
logExtraProgramSearchPath verbosity extraPaths
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/Program/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type ProgArg = String
-- We also use this path to set the environment when running child processes.
--
-- The @ProgramDb@ is created with a @ProgramSearchPath@ to which we
-- @appendProgramSearchPath@ to add the ones that come from cli flags and from
-- @prependProgramSearchPath@ to add the ones that come from cli flags and from
-- configurations. Then each of the programs that are configured in the db
-- inherits the same path as part of @configureProgram@.
type ProgramSearchPath = [ProgramSearchPathEntry]
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SPDX_EXCEPTION_HS:=Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs

spdx : $(SPDX_LICENSE_HS) $(SPDX_EXCEPTION_HS)

SPDX_LICENSE_VERSIONS:=3.0 3.2 3.6 3.9 3.10 3.16
SPDX_LICENSE_VERSIONS:=3.0 3.2 3.6 3.9 3.10 3.16 3.23

$(SPDX_LICENSE_HS) : templates/SPDX.LicenseId.template.hs cabal-dev-scripts/src/GenUtils.hs cabal-dev-scripts/src/GenSPDX.hs license-list-data/licenses-3.0.json license-list-data/licenses-3.2.json
cabal run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-spdx -- templates/SPDX.LicenseId.template.hs $(SPDX_LICENSE_VERSIONS:%=license-list-data/licenses-%.json) $(SPDX_LICENSE_HS)
Expand Down Expand Up @@ -199,13 +199,13 @@ tags :
##############################################################################

bootstrap-json-%: phony
cabal build --project=cabal.project.release --with-compiler=ghc-$* --dry-run cabal-install:exe:cabal
cabal build --project-file=cabal.project.release --with-compiler=ghc-$* --dry-run cabal-install:exe:cabal
cp dist-newstyle/cache/plan.json bootstrap/linux-$*.plan.json
@# -v0 to avoid build output on stdout
cd bootstrap && cabal run -v0 cabal-bootstrap-gen -- linux-$*.plan.json \
| python3 -m json.tool > linux-$*.json

BOOTSTRAP_GHC_VERSIONS := 8.10.7 9.0.2 9.2.7 9.4.4
BOOTSTRAP_GHC_VERSIONS := 9.0.2 9.2.8 9.4.8 9.6.4 9.8.2

bootstrap-jsons: $(BOOTSTRAP_GHC_VERSIONS:%=bootstrap-json-%)

Expand Down
Loading