From 991b5d13cc84716eff9a789662f026bb8ce40faa Mon Sep 17 00:00:00 2001 From: Simon Hengel Date: Sun, 30 Mar 2025 20:36:33 +0700 Subject: [PATCH] Depend on `Cabal-3.14.*` --- .gitattributes | 1 + Setup.hs | 3 ++- package.yaml | 4 ++-- src/Stack/Component.hs | 13 +++++++------ src/Stack/ComponentFile.hs | 9 +++++---- src/Stack/Package.hs | 6 +++--- src/Stack/PackageFile.hs | 11 ++++++----- src/Stack/SDist.hs | 13 +------------ src/Stack/Types/Component.hs | 5 +++-- stack.cabal | 10 +++++----- stack.yaml | 2 ++ stack.yaml.lock | 14 ++++++++++++++ 12 files changed, 51 insertions(+), 40 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..0b9805e450 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +/stack.cabal linguist-generated=true diff --git a/Setup.hs b/Setup.hs index 3812223d2d..9e63859e88 100644 --- a/Setup.hs +++ b/Setup.hs @@ -25,6 +25,7 @@ import Distribution.Simple.Utils import Distribution.Types.PackageName ( unPackageName ) import Distribution.Types.UnqualComponentName ( unUnqualComponentName ) +import Distribution.Utils.Path ( interpretSymbolicPathCWD ) import Distribution.Verbosity ( Verbosity, normal ) import System.FilePath ( () ) @@ -47,7 +48,7 @@ generateBuildModule :: -> LocalBuildInfo -> IO () generateBuildModule verbosity pkg lbi = do - let dir = autogenPackageModulesDir lbi + let dir = interpretSymbolicPathCWD (autogenPackageModulesDir lbi) createDirectoryIfMissingVerbose verbosity True dir withLibLBI pkg lbi $ \_ libcfg -> do withExeLBI pkg lbi $ \exe clbi -> diff --git a/package.yaml b/package.yaml index 4b580ccca4..045be6edca 100644 --- a/package.yaml +++ b/package.yaml @@ -26,7 +26,7 @@ homepage: http://haskellstack.org custom-setup: dependencies: - base >= 4.14.3.0 && < 5 - - Cabal < 3.12 + - Cabal >= 3.14 && < 3.16 - filepath extra-source-files: # note: leaving out 'package.yaml' because it causes confusion with hackage metadata revisions @@ -58,7 +58,7 @@ ghc-options: - -optP-Wno-nonportable-include-path dependencies: - base >= 4.16.0.0 && < 5 -- Cabal >= 3.8.1.0 && < 3.12 +- Cabal >= 3.14 && < 3.16 - aeson >= 2.0.3.0 - aeson-warning-parser >= 0.1.1 - ansi-terminal >= 1.0.2 diff --git a/src/Stack/Component.hs b/src/Stack/Component.hs index 58903446a5..c5f2c6ec3c 100644 --- a/src/Stack/Component.hs +++ b/src/Stack/Component.hs @@ -36,6 +36,7 @@ import Distribution.PackageDescription import Distribution.Types.BuildInfo ( BuildInfo ) import Distribution.Package ( mkPackageName ) import qualified Distribution.PackageDescription as Cabal +import Distribution.Utils.Path (interpretSymbolicPathCWD) import GHC.Records ( HasField ) import Stack.Prelude import Stack.Types.Component @@ -74,7 +75,7 @@ stackExecutableFromCabal :: Executable -> StackExecutable stackExecutableFromCabal cabalExecutable = StackExecutable { name = fromCabalName cabalExecutable.exeName , buildInfo = stackBuildInfoFromCabal cabalExecutable.buildInfo - , modulePath = cabalExecutable.modulePath + , modulePath = interpretSymbolicPathCWD cabalExecutable.modulePath } stackForeignLibraryFromCabal :: ForeignLib -> StackForeignLibrary @@ -108,9 +109,9 @@ stackBuildInfoFromCabal buildInfoV = gatherComponentToolsAndDepsFromCabal StackBuildInfo { buildable = buildInfoV.buildable , otherModules = buildInfoV.otherModules - , jsSources = buildInfoV.jsSources + , jsSources = map interpretSymbolicPathCWD buildInfoV.jsSources , hsSourceDirs = buildInfoV.hsSourceDirs - , cSources = buildInfoV.cSources + , cSources = map interpretSymbolicPathCWD buildInfoV.cSources , dependency = mempty , unknownTools = mempty , cppOptions = buildInfoV.cppOptions @@ -118,10 +119,10 @@ stackBuildInfoFromCabal buildInfoV = gatherComponentToolsAndDepsFromCabal , options = buildInfoV.options , allLanguages = Cabal.allLanguages buildInfoV , usedExtensions = Cabal.usedExtensions buildInfoV - , includeDirs = buildInfoV.includeDirs + , includeDirs = map interpretSymbolicPathCWD buildInfoV.includeDirs , extraLibs = buildInfoV.extraLibs - , extraLibDirs = buildInfoV.extraLibDirs - , frameworks = buildInfoV.frameworks + , extraLibDirs = map interpretSymbolicPathCWD buildInfoV.extraLibDirs + , frameworks = map interpretSymbolicPathCWD buildInfoV.frameworks } -- | Iterate on all three dependency list given, and transform and sort them diff --git a/src/Stack/ComponentFile.hs b/src/Stack/ComponentFile.hs index 554017b477..f9c1c40890 100644 --- a/src/Stack/ComponentFile.hs +++ b/src/Stack/ComponentFile.hs @@ -32,7 +32,8 @@ import Distribution.PackageDescription ( BenchmarkInterface (..), TestSuiteInterface (..) ) import Distribution.Text ( display ) import Distribution.Utils.Path - ( PackageDir, SourceDir, SymbolicPath, getSymbolicPath ) + ( Pkg, Source, SymbolicPath, getSymbolicPath ) +import qualified Distribution.Utils.Path as Cabal import GHC.Records ( HasField ) import qualified HiFileParser as Iface import Path @@ -87,7 +88,7 @@ stackBenchmarkFiles bench = exposed :: [DotCabalDescriptor] exposed = case bench.interface of - BenchmarkExeV10 _ fp -> [DotCabalMain fp] + BenchmarkExeV10 _ fp -> [DotCabalMain $ getSymbolicPath fp] BenchmarkUnsupported _ -> [] bnames :: [DotCabalDescriptor] @@ -109,7 +110,7 @@ stackTestSuiteFiles test = exposed :: [DotCabalDescriptor] exposed = case test.interface of - TestSuiteExeV10 _ fp -> [DotCabalMain fp] + TestSuiteExeV10 _ fp -> [DotCabalMain $ getSymbolicPath fp] TestSuiteLibV09 _ mn -> [DotCabalModule mn] TestSuiteUnsupported _ -> [] @@ -164,7 +165,7 @@ stackLibraryFiles lib = -- | Get all files referenced by the component. resolveComponentFiles :: ( CAndJsSources rec - , HasField "hsSourceDirs" rec [SymbolicPath PackageDir SourceDir] + , HasField "hsSourceDirs" rec [SymbolicPath Pkg (Cabal.Dir Source)] ) => NamedComponent -> rec diff --git a/src/Stack/Package.hs b/src/Stack/Package.hs index 6f62011a16..e43c9b908e 100644 --- a/src/Stack/Package.hs +++ b/src/Stack/Package.hs @@ -57,7 +57,7 @@ import Distribution.Simple.PackageDescription ( readHookedBuildInfo ) import Distribution.System ( OS (..), Arch, Platform (..) ) import Distribution.Text ( display ) import qualified Distribution.Types.CondTree as Cabal -import Distribution.Utils.Path ( getSymbolicPath ) +import Distribution.Utils.Path ( makeSymbolicPath, getSymbolicPath ) import Distribution.Verbosity ( silent ) import Distribution.Version ( anyVersion, mkVersion, orLaterVersion ) @@ -125,8 +125,8 @@ import RIO.Seq ((|>)) -- -- NOTE: not to be confused with BuildInfo, an Stack-internal datatype. readDotBuildinfo :: MonadIO m => Path Abs File -> m HookedBuildInfo -readDotBuildinfo buildinfofp = - liftIO $ readHookedBuildInfo silent (toFilePath buildinfofp) +readDotBuildinfo = + liftIO . readHookedBuildInfo silent Nothing . makeSymbolicPath . toFilePath -- | Resolve a parsed Cabal file into a 'Package', which contains all of the -- info needed for Stack to build the 'Package' given the current configuration. diff --git a/src/Stack/PackageFile.hs b/src/Stack/PackageFile.hs index bc3c63f8d5..b3b19a7cf3 100644 --- a/src/Stack/PackageFile.hs +++ b/src/Stack/PackageFile.hs @@ -13,6 +13,7 @@ import qualified Data.Set as S import Distribution.CabalSpecVersion ( CabalSpecVersion ) import qualified Distribution.PackageDescription as Cabal import Distribution.Simple.Glob ( matchDirFileGlob ) +import Distribution.Utils.Path ( makeSymbolicPath, getSymbolicPath ) import Path ( parent, () ) import Path.Extra ( forgivingResolveFile, rejectMissingFile ) import Path.IO ( doesFileExist ) @@ -102,9 +103,9 @@ resolveGlobFiles cabalFileVersion = FilePath -> FilePath -> RIO GetPackageFileContext [FilePath] - matchDirFileGlob' dir glob = + matchDirFileGlob' dir glob = map getSymbolicPath <$> do catch - (liftIO (matchDirFileGlob minBound cabalFileVersion dir glob)) + (liftIO $ matchDirFileGlob minBound cabalFileVersion (Just $ makeSymbolicPath dir) (makeSymbolicPath glob)) ( \(e :: IOException) -> if isUserError e then do @@ -162,9 +163,9 @@ getPackageFile pkg cabalFP = stackPackageFileFromCabal :: Cabal.PackageDescription -> StackPackageFile stackPackageFileFromCabal cabalPkg = StackPackageFile - (Cabal.extraSrcFiles cabalPkg) - (Cabal.dataDir cabalPkg) - (Cabal.dataFiles cabalPkg) + (map getSymbolicPath $ Cabal.extraSrcFiles cabalPkg) + (getSymbolicPath $ Cabal.dataDir cabalPkg) + (map getSymbolicPath $ Cabal.dataFiles cabalPkg) insertComponentFile :: PackageComponentFile diff --git a/src/Stack/SDist.hs b/src/Stack/SDist.hs index f43f18f623..d94170f2cb 100644 --- a/src/Stack/SDist.hs +++ b/src/Stack/SDist.hs @@ -578,18 +578,7 @@ checkPackageInExtractedTarball pkgDir = do , flow "for common mistakes using Cabal version" , fromString $ versionString cabalVersion <> "." ] - let pkgChecks = - -- MSS 2017-12-12: Try out a few different variants of pkgDesc to try - -- and provoke an error or warning. I don't know why, but when using - -- `Just pkgDesc`, it appears that Cabal does not detect that `^>=` is - -- used with `cabal-version: 1.24` or earlier. It seems like pkgDesc - -- (the one we create) does not populate the `buildDepends` field, - -- whereas flattenPackageDescription from Cabal does. In any event, - -- using `Nothing` seems more logical for this check anyway, and the - -- fallback to `Just pkgDesc` is just a crazy sanity check. - case Check.checkPackage gpd Nothing of - [] -> Check.checkPackage gpd (Just pkgDesc) - x -> x + let pkgChecks = Check.checkPackage gpd fileChecks <- liftIO $ Check.checkPackageFiles minBound pkgDesc (toFilePath pkgDir) let checks = pkgChecks ++ fileChecks diff --git a/src/Stack/Types/Component.hs b/src/Stack/Types/Component.hs index dee4979e4f..ab73ebfd60 100644 --- a/src/Stack/Types/Component.hs +++ b/src/Stack/Types/Component.hs @@ -31,7 +31,8 @@ import Distribution.ModuleName ( ModuleName ) import Distribution.PackageDescription ( BenchmarkInterface, Dependency, TestSuiteInterface ) import Distribution.Simple ( Extension, Language ) -import Distribution.Utils.Path ( PackageDir, SourceDir, SymbolicPath ) +import Distribution.Utils.Path ( Pkg, Source, SymbolicPath ) +import qualified Distribution.Utils.Path as Cabal import GHC.Records ( HasField (..) ) import Stack.Prelude import Stack.Types.ComponentUtils @@ -133,7 +134,7 @@ data StackBuildInfo = StackBuildInfo -- ^ Only used in file gathering. See usage in "Stack.ComponentFile" module. , jsSources :: [FilePath] -- ^ Only used in file gathering. See usage in "Stack.ComponentFile" module. - , hsSourceDirs :: [SymbolicPath PackageDir SourceDir] + , hsSourceDirs :: [SymbolicPath Pkg (Cabal.Dir Source)] -- ^ Only used in file & opts gathering. See usage in "Stack.ComponentFile" -- module for fle gathering. , cSources :: [FilePath] diff --git a/stack.cabal b/stack.cabal index 680eb19a20..f190ba7eca 100644 --- a/stack.cabal +++ b/stack.cabal @@ -153,7 +153,7 @@ source-repository head custom-setup setup-depends: - Cabal <3.12 + Cabal >=3.14 && <3.16 , base >=4.14.3.0 && <5 , filepath @@ -397,7 +397,7 @@ library src ghc-options: -fwrite-ide-info -hiedir=.hie -Wall -Wmissing-export-lists -optP-Wno-nonportable-include-path -Widentities build-depends: - Cabal >=3.8.1.0 && <3.12 + Cabal >=3.14 && <3.16 , aeson >=2.0.3.0 , aeson-warning-parser >=0.1.1 , ansi-terminal >=1.0.2 @@ -520,7 +520,7 @@ executable stack app ghc-options: -fwrite-ide-info -hiedir=.hie -Wall -Wmissing-export-lists -optP-Wno-nonportable-include-path -threaded -rtsopts build-depends: - Cabal >=3.8.1.0 && <3.12 + Cabal >=3.14 && <3.16 , aeson >=2.0.3.0 , aeson-warning-parser >=0.1.1 , ansi-terminal >=1.0.2 @@ -622,7 +622,7 @@ executable stack-integration-test tests/integration/lib ghc-options: -fwrite-ide-info -hiedir=.hie -Wall -Wmissing-export-lists -optP-Wno-nonportable-include-path -threaded -rtsopts -with-rtsopts=-N build-depends: - Cabal >=3.8.1.0 && <3.12 + Cabal >=3.14 && <3.16 , aeson >=2.0.3.0 , aeson-warning-parser >=0.1.1 , ansi-terminal >=1.0.2 @@ -739,7 +739,7 @@ test-suite stack-unit-test tests/unit ghc-options: -fwrite-ide-info -hiedir=.hie -Wall -Wmissing-export-lists -optP-Wno-nonportable-include-path -threaded build-depends: - Cabal >=3.8.1.0 && <3.12 + Cabal >=3.14 && <3.16 , QuickCheck , aeson >=2.0.3.0 , aeson-warning-parser >=0.1.1 diff --git a/stack.yaml b/stack.yaml index 6c31e777c7..ade5da4466 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,6 +3,8 @@ snapshot: lts-23.14 # GHC 9.8.4 extra-deps: # lts-23.14 provides hpack-0.37.0 - hpack-0.38.1 +- Cabal-syntax-3.14.1.0 +- Cabal-3.14.1.1 docker: enable: false diff --git a/stack.yaml.lock b/stack.yaml.lock index 94db03b6d7..d3ea444e5d 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -11,6 +11,20 @@ packages: size: 3798 original: hackage: hpack-0.38.1 +- completed: + hackage: Cabal-syntax-3.14.1.0@sha256:557a2b20dc85f052c86c5a06dcbd7c6995f2d0391bbff8e62c90b4b5975211da,7380 + pantry-tree: + sha256: b515a5cfb9da09c0aae57ca223281d06dad9d11dfc466fc47d2e83720a078fea + size: 10977 + original: + hackage: Cabal-syntax-3.14.1.0 +- completed: + hackage: Cabal-3.14.1.1@sha256:424e9f5053a17d4598f1d2b9ae657e6f039233a127b7adb148ded7a8d0cb8103,13720 + pantry-tree: + sha256: 10fef40e6b2a9f061b9da5fa5daccdbf8ef16f919ed58a9f3604bacb0ba75b80 + size: 12219 + original: + hackage: Cabal-3.14.1.1 snapshots: - completed: sha256: 1964d439d2a152be4238053f3f997a09fb348391984daab86d724975ef9a423f