diff --git a/Cabal/Cabal.cabal b/Cabal/Cabal.cabal index 5a100e75223..25f3ec023ee 100644 --- a/Cabal/Cabal.cabal +++ b/Cabal/Cabal.cabal @@ -447,6 +447,7 @@ library Distribution.Types.TargetInfo Distribution.Types.Version Distribution.Types.VersionRange + Distribution.Types.VersionRange.Internal Distribution.Types.VersionInterval Distribution.Types.GivenComponent Distribution.Types.PackageVersionConstraint diff --git a/Cabal/Distribution/InstalledPackageInfo.hs b/Cabal/Distribution/InstalledPackageInfo.hs index 5d0da46d074..ae510907466 100644 --- a/Cabal/Distribution/InstalledPackageInfo.hs +++ b/Cabal/Distribution/InstalledPackageInfo.hs @@ -26,7 +26,6 @@ module Distribution.InstalledPackageInfo ( InstalledPackageInfo(..), - installedPackageId, installedComponentId, installedOpenUnitId, sourceComponentName, @@ -50,7 +49,7 @@ import Distribution.CabalSpecVersion (cabalSpecLatest) import Distribution.FieldGrammar import Distribution.FieldGrammar.FieldDescrs import Distribution.ModuleName -import Distribution.Package hiding (installedPackageId, installedUnitId) +import Distribution.Package hiding (installedUnitId) import Distribution.Types.ComponentName import Distribution.Utils.Generic (toUTF8BS) @@ -83,15 +82,6 @@ installedOpenUnitId ipi requiredSignatures :: InstalledPackageInfo -> Set ModuleName requiredSignatures ipi = openModuleSubstFreeHoles (Map.fromList (instantiatedWith ipi)) -{-# DEPRECATED installedPackageId "Use installedUnitId instead" #-} --- | Backwards compatibility with Cabal pre-1.24. --- --- This type synonym is slightly awful because in cabal-install --- we define an 'InstalledPackageId' but it's a ComponentId, --- not a UnitId! -installedPackageId :: InstalledPackageInfo -> UnitId -installedPackageId = installedUnitId - -- ----------------------------------------------------------------------------- -- Munging diff --git a/Cabal/Distribution/Make.hs b/Cabal/Distribution/Make.hs index bda5d059a6b..cde201eb9c2 100644 --- a/Cabal/Distribution/Make.hs +++ b/Cabal/Distribution/Make.hs @@ -60,7 +60,7 @@ module Distribution.Make ( module Distribution.Package, License(..), Version, - defaultMain, defaultMainArgs, defaultMainNoRead + defaultMain, defaultMainArgs ) where import Prelude () @@ -70,7 +70,6 @@ import Distribution.Compat.Prelude import Distribution.Compat.Exception import Distribution.Package import Distribution.Simple.Program -import Distribution.PackageDescription import Distribution.Simple.Setup import Distribution.Simple.Command @@ -89,10 +88,6 @@ defaultMain = getArgs >>= defaultMainArgs defaultMainArgs :: [String] -> IO () defaultMainArgs = defaultMainHelper -{-# DEPRECATED defaultMainNoRead "it ignores its PackageDescription arg" #-} -defaultMainNoRead :: PackageDescription -> IO () -defaultMainNoRead = const defaultMain - defaultMainHelper :: [String] -> IO () defaultMainHelper args = case commandsRun (globalCommand commands) commands args of diff --git a/Cabal/Distribution/ModuleName.hs b/Cabal/Distribution/ModuleName.hs index bf3729cd499..e004fd1c44c 100644 --- a/Cabal/Distribution/ModuleName.hs +++ b/Cabal/Distribution/ModuleName.hs @@ -19,7 +19,6 @@ module Distribution.ModuleName ( components, toFilePath, main, - simple, -- * Internal validModuleComponent, ) where @@ -66,10 +65,6 @@ validModuleComponent [] = False validModuleComponent (c:cs) = isUpper c && all validModuleChar cs -{-# DEPRECATED simple "use ModuleName.fromString instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -simple :: String -> ModuleName -simple str = ModuleName (stlFromStrings [str]) - -- | Construct a 'ModuleName' from a valid module name 'String'. -- -- This is just a convenience function intended for valid module strings. It is diff --git a/Cabal/Distribution/Package.hs b/Cabal/Distribution/Package.hs index 0b467d11de4..6c2950b26f0 100644 --- a/Cabal/Distribution/Package.hs +++ b/Cabal/Distribution/Package.hs @@ -28,7 +28,6 @@ module Distribution.Package , Package(..), packageName, packageVersion , HasMungedPackageId(..), mungedName', mungedVersion' , HasUnitId(..) - , installedPackageId , PackageInstalled(..) ) where @@ -87,11 +86,6 @@ instance HasMungedPackageId MungedPackageId where class Package pkg => HasUnitId pkg where installedUnitId :: pkg -> UnitId -{-# DEPRECATED installedPackageId "Use installedUnitId instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} --- | Compatibility wrapper for Cabal pre-1.24. -installedPackageId :: HasUnitId pkg => pkg -> UnitId -installedPackageId = installedUnitId - -- | Class of installed packages. -- -- The primary data type which is an instance of this package is diff --git a/Cabal/Distribution/PackageDescription.hs b/Cabal/Distribution/PackageDescription.hs index 072989f27e0..e50ed77a62f 100644 --- a/Cabal/Distribution/PackageDescription.hs +++ b/Cabal/Distribution/PackageDescription.hs @@ -17,7 +17,6 @@ module Distribution.PackageDescription ( specVersion, buildType, license, - descCabalVersion, BuildType(..), knownBuildTypes, allLibraries, @@ -35,7 +34,6 @@ module Distribution.PackageDescription ( hasLibs, explicitLibModules, libModulesAutogen, - libModules, -- ** Executables Executable(..), diff --git a/Cabal/Distribution/PackageDescription/Configuration.hs b/Cabal/Distribution/PackageDescription/Configuration.hs index 264c1d4b896..2b00ec2224b 100644 --- a/Cabal/Distribution/PackageDescription/Configuration.hs +++ b/Cabal/Distribution/PackageDescription/Configuration.hs @@ -17,7 +17,6 @@ module Distribution.PackageDescription.Configuration ( finalizePD, - finalizePackageDescription, flattenPackageDescription, -- Utils @@ -492,20 +491,6 @@ finalizePD userflags enabled satisfyDep then DepOk else MissingDeps missingDeps -{-# DEPRECATED finalizePackageDescription "This function now always assumes tests and benchmarks are disabled; use finalizePD with ComponentRequestedSpec to specify something more specific. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -finalizePackageDescription :: - FlagAssignment -- ^ Explicitly specified flag assignments - -> (Dependency -> Bool) -- ^ Is a given dependency satisfiable from the set of - -- available packages? If this is unknown then use - -- True. - -> Platform -- ^ The 'Arch' and 'OS' - -> CompilerInfo -- ^ Compiler information - -> [Dependency] -- ^ Additional constraints - -> GenericPackageDescription - -> Either [Dependency] - (PackageDescription, FlagAssignment) -finalizePackageDescription flags = finalizePD flags defaultComponentRequestedSpec - {- let tst_p = (CondNode [1::Int] [Distribution.Package.Dependency "a" AnyVersion] []) let tst_p2 = (CondNode [1::Int] [Distribution.Package.Dependency "a" (EarlierVersion (Version [1,0] [])), Distribution.Package.Dependency "a" (LaterVersion (Version [2,0] []))] []) diff --git a/Cabal/Distribution/Simple.hs b/Cabal/Distribution/Simple.hs index 6399f769626..65d81d459e9 100644 --- a/Cabal/Distribution/Simple.hs +++ b/Cabal/Distribution/Simple.hs @@ -52,9 +52,7 @@ module Distribution.Simple ( -- ** Standard sets of hooks simpleUserHooks, autoconfUserHooks, - defaultUserHooks, emptyUserHooks, - -- ** Utils - defaultHookedPackageDesc + emptyUserHooks, ) where import Prelude () @@ -259,7 +257,7 @@ buildAction hooks flags args = do (buildProgramArgs flags') (withPrograms lbi) - hookedAction preBuild buildHook postBuild + hookedAction verbosity preBuild buildHook postBuild (return lbi { withPrograms = progs }) hooks flags' { buildArgs = args } args @@ -280,7 +278,7 @@ replAction hooks flags args = do -- takes the args explicitly. UGH. -- ezyang pbi <- preRepl hooks args flags' let pkg_descr0 = localPkgDescr lbi - sanityCheckHookedBuildInfo pkg_descr0 pbi + sanityCheckHookedBuildInfo verbosity pkg_descr0 pbi let pkg_descr = updatePackageDescription pbi pkg_descr0 lbi' = lbi { withPrograms = progs , localPkgDescr = pkg_descr } @@ -295,7 +293,7 @@ hscolourAction hooks flags args = do let flags' = flags { hscolourDistPref = toFlag distPref , hscolourCabalFilePath = maybeToFlag (cabalFilePath lbi)} - hookedAction preHscolour hscolourHook postHscolour + hookedAction verbosity preHscolour hscolourHook postHscolour (getBuildConfig hooks verbosity distPref) hooks flags' args @@ -311,7 +309,7 @@ doctestAction hooks flags args = do (doctestProgramArgs flags') (withPrograms lbi) - hookedAction preDoctest doctestHook postDoctest + hookedAction verbosity preDoctest doctestHook postDoctest (return lbi { withPrograms = progs }) hooks flags' args @@ -328,7 +326,7 @@ haddockAction hooks flags args = do (haddockProgramArgs flags') (withPrograms lbi) - hookedAction preHaddock haddockHook postHaddock + hookedAction verbosity preHaddock haddockHook postHaddock (return lbi { withPrograms = progs }) hooks flags' { haddockArgs = args } args @@ -354,7 +352,7 @@ cleanAction hooks flags args = do let pkg_descr0 = flattenPackageDescription ppd -- We don't sanity check for clean as an error -- here would prevent cleaning: - --sanityCheckHookedBuildInfo pkg_descr0 pbi + --sanityCheckHookedBuildInfo verbosity pkg_descr0 pbi let pkg_descr = updatePackageDescription pbi pkg_descr0 cleanHook hooks pkg_descr () hooks flags' @@ -369,7 +367,7 @@ copyAction hooks flags args = do lbi <- getBuildConfig hooks verbosity distPref let flags' = flags { copyDistPref = toFlag distPref , copyCabalFilePath = maybeToFlag (cabalFilePath lbi)} - hookedAction preCopy copyHook postCopy + hookedAction verbosity preCopy copyHook postCopy (getBuildConfig hooks verbosity distPref) hooks flags' { copyArgs = args } args @@ -380,15 +378,14 @@ installAction hooks flags args = do lbi <- getBuildConfig hooks verbosity distPref let flags' = flags { installDistPref = toFlag distPref , installCabalFilePath = maybeToFlag (cabalFilePath lbi)} - hookedAction preInst instHook postInst + hookedAction verbosity preInst instHook postInst (getBuildConfig hooks verbosity distPref) hooks flags' args sdistAction :: UserHooks -> SDistFlags -> Args -> IO () -sdistAction hooks flags args = do +sdistAction hooks flags _args = do distPref <- findDistPrefOrDefault (sDistDistPref flags) - let flags' = flags { sDistDistPref = toFlag distPref } - pbi <- preSDist hooks args flags' + let pbi = emptyHookedBuildInfo mlbi <- maybeGetPersistBuildConfig distPref @@ -405,12 +402,11 @@ sdistAction hooks flags args = do (_, ppd) <- confPkgDescr hooks verbosity Nothing let pkg_descr0 = flattenPackageDescription ppd - sanityCheckHookedBuildInfo pkg_descr0 pbi + sanityCheckHookedBuildInfo verbosity pkg_descr0 pbi let pkg_descr = updatePackageDescription pbi pkg_descr0 mlbi' = fmap (\lbi -> lbi { localPkgDescr = pkg_descr }) mlbi - sDistHook hooks pkg_descr mlbi' hooks flags' - postSDist hooks args flags' pkg_descr mlbi' + sdist pkg_descr mlbi' flags srcPref (allSuffixHandlers hooks) where verbosity = fromFlag (sDistVerbosity flags) @@ -420,13 +416,7 @@ testAction hooks flags args = do let verbosity = fromFlag $ testVerbosity flags flags' = flags { testDistPref = toFlag distPref } - localBuildInfo <- getBuildConfig hooks verbosity distPref - let pkg_descr = localPkgDescr localBuildInfo - -- It is safe to do 'runTests' before the new test handler because the - -- default action is a no-op and if the package uses the old test interface - -- the new handler will find no tests. - runTests hooks args False pkg_descr localBuildInfo - hookedActionWithArgs preTest testHook postTest + hookedActionWithArgs verbosity preTest testHook postTest (getBuildConfig hooks verbosity distPref) hooks flags' args @@ -435,7 +425,7 @@ benchAction hooks flags args = do distPref <- findDistPrefOrDefault (benchmarkDistPref flags) let verbosity = fromFlag $ benchmarkVerbosity flags flags' = flags { benchmarkDistPref = toFlag distPref } - hookedActionWithArgs preBench benchHook postBench + hookedActionWithArgs verbosity preBench benchHook postBench (getBuildConfig hooks verbosity distPref) hooks flags' args @@ -446,7 +436,7 @@ registerAction hooks flags args = do lbi <- getBuildConfig hooks verbosity distPref let flags' = flags { regDistPref = toFlag distPref , regCabalFilePath = maybeToFlag (cabalFilePath lbi)} - hookedAction preReg regHook postReg + hookedAction verbosity preReg regHook postReg (getBuildConfig hooks verbosity distPref) hooks flags' { regArgs = args } args @@ -457,55 +447,62 @@ unregisterAction hooks flags args = do lbi <- getBuildConfig hooks verbosity distPref let flags' = flags { regDistPref = toFlag distPref , regCabalFilePath = maybeToFlag (cabalFilePath lbi)} - hookedAction preUnreg unregHook postUnreg + hookedAction verbosity preUnreg unregHook postUnreg (getBuildConfig hooks verbosity distPref) hooks flags' args -hookedAction :: (UserHooks -> Args -> flags -> IO HookedBuildInfo) - -> (UserHooks -> PackageDescription -> LocalBuildInfo - -> UserHooks -> flags -> IO ()) - -> (UserHooks -> Args -> flags -> PackageDescription - -> LocalBuildInfo -> IO ()) - -> IO LocalBuildInfo - -> UserHooks -> flags -> Args -> IO () -hookedAction pre_hook cmd_hook = - hookedActionWithArgs pre_hook (\h _ pd lbi uh flags -> - cmd_hook h pd lbi uh flags) - -hookedActionWithArgs :: (UserHooks -> Args -> flags -> IO HookedBuildInfo) - -> (UserHooks -> Args -> PackageDescription -> LocalBuildInfo - -> UserHooks -> flags -> IO ()) - -> (UserHooks -> Args -> flags -> PackageDescription - -> LocalBuildInfo -> IO ()) - -> IO LocalBuildInfo - -> UserHooks -> flags -> Args -> IO () -hookedActionWithArgs pre_hook cmd_hook post_hook +hookedAction + :: Verbosity + -> (UserHooks -> Args -> flags -> IO HookedBuildInfo) + -> (UserHooks -> PackageDescription -> LocalBuildInfo + -> UserHooks -> flags -> IO ()) + -> (UserHooks -> Args -> flags -> PackageDescription + -> LocalBuildInfo -> IO ()) + -> IO LocalBuildInfo + -> UserHooks -> flags -> Args -> IO () +hookedAction verbosity pre_hook cmd_hook = + hookedActionWithArgs verbosity pre_hook + (\h _ pd lbi uh flags -> + cmd_hook h pd lbi uh flags) + +hookedActionWithArgs + :: Verbosity + -> (UserHooks -> Args -> flags -> IO HookedBuildInfo) + -> (UserHooks -> Args -> PackageDescription -> LocalBuildInfo + -> UserHooks -> flags -> IO ()) + -> (UserHooks -> Args -> flags -> PackageDescription + -> LocalBuildInfo -> IO ()) + -> IO LocalBuildInfo + -> UserHooks -> flags -> Args -> IO () +hookedActionWithArgs verbosity pre_hook cmd_hook post_hook get_build_config hooks flags args = do pbi <- pre_hook hooks args flags lbi0 <- get_build_config let pkg_descr0 = localPkgDescr lbi0 - sanityCheckHookedBuildInfo pkg_descr0 pbi + sanityCheckHookedBuildInfo verbosity pkg_descr0 pbi let pkg_descr = updatePackageDescription pbi pkg_descr0 lbi = lbi0 { localPkgDescr = pkg_descr } cmd_hook hooks args pkg_descr lbi hooks flags post_hook hooks args flags pkg_descr lbi -sanityCheckHookedBuildInfo :: PackageDescription -> HookedBuildInfo -> IO () -sanityCheckHookedBuildInfo PackageDescription { library = Nothing } (Just _,_) - = die $ "The buildinfo contains info for a library, " - ++ "but the package does not have a library." +sanityCheckHookedBuildInfo + :: Verbosity -> PackageDescription -> HookedBuildInfo -> IO () +sanityCheckHookedBuildInfo verbosity + (PackageDescription { library = Nothing }) (Just _,_) + = die' verbosity $ "The buildinfo contains info for a library, " + ++ "but the package does not have a library." -sanityCheckHookedBuildInfo pkg_descr (_, hookExes) +sanityCheckHookedBuildInfo verbosity pkg_descr (_, hookExes) | not (null nonExistant) - = die $ "The buildinfo contains info for an executable called '" - ++ prettyShow (head nonExistant) ++ "' but the package does not have a " - ++ "executable with that name." + = die' verbosity $ "The buildinfo contains info for an executable called '" + ++ prettyShow (head nonExistant) ++ "' but the package does not have a " + ++ "executable with that name." where pkgExeNames = nub (map exeName (executables pkg_descr)) hookExeNames = nub (map fst hookExes) nonExistant = hookExeNames \\ pkgExeNames -sanityCheckHookedBuildInfo _ _ = return () +sanityCheckHookedBuildInfo _ _ _ = return () -- | Try to read the 'localBuildInfoFile' tryGetBuildConfig :: UserHooks -> Verbosity -> FilePath @@ -603,7 +600,6 @@ simpleUserHooks = testHook = defaultTestHook, benchHook = defaultBenchHook, instHook = defaultInstallHook, - sDistHook = \p l h f -> sdist p l f srcPref (allSuffixHandlers h), cleanHook = \p _ _ f -> clean p f, hscolourHook = \p l h f -> hscolour p l (allSuffixHandlers h) f, haddockHook = \p l h f -> haddock p l (allSuffixHandlers h) f, @@ -628,37 +624,6 @@ simpleUserHooks = -- Thus @configure@ can use local system information to generate -- /package/@.buildinfo@ and possibly other files. -{-# DEPRECATED defaultUserHooks - "Use simpleUserHooks or autoconfUserHooks, unless you need Cabal-1.2\n compatibility in which case you must stick with defaultUserHooks" #-} -defaultUserHooks :: UserHooks -defaultUserHooks = autoconfUserHooks { - confHook = \pkg flags -> do - let verbosity = fromFlag (configVerbosity flags) - warn verbosity - "defaultUserHooks in Setup script is deprecated." - confHook autoconfUserHooks pkg flags, - postConf = oldCompatPostConf - } - -- This is the annoying old version that only runs configure if it exists. - -- It's here for compatibility with existing Setup.hs scripts. See: - -- https://github.com/haskell/cabal/issues/158 - where oldCompatPostConf args flags pkg_descr lbi - = do let verbosity = fromFlag (configVerbosity flags) - baseDir lbi' = fromMaybe "" (takeDirectory <$> cabalFilePath lbi') - - confExists <- doesFileExist $ (baseDir lbi) "configure" - when confExists $ - runConfigureScript verbosity - backwardsCompatHack flags lbi - - pbi <- getHookedBuildInfo (buildDir lbi) verbosity - sanityCheckHookedBuildInfo pkg_descr pbi - let pkg_descr' = updatePackageDescription pbi pkg_descr - lbi' = lbi { localPkgDescr = pkg_descr' } - postConf simpleUserHooks args flags pkg_descr' lbi' - - backwardsCompatHack = True - autoconfUserHooks :: UserHooks autoconfUserHooks = simpleUserHooks @@ -677,15 +642,16 @@ autoconfUserHooks -> LocalBuildInfo -> IO () defaultPostConf args flags pkg_descr lbi = do let verbosity = fromFlag (configVerbosity flags) - baseDir lbi' = fromMaybe "" (takeDirectory <$> cabalFilePath lbi') + baseDir lbi' = fromMaybe "" + (takeDirectory <$> cabalFilePath lbi') confExists <- doesFileExist $ (baseDir lbi) "configure" if confExists then runConfigureScript verbosity backwardsCompatHack flags lbi - else die "configure script not found." + else die' verbosity "configure script not found." - pbi <- getHookedBuildInfo (buildDir lbi) verbosity - sanityCheckHookedBuildInfo pkg_descr pbi + pbi <- getHookedBuildInfo verbosity (buildDir lbi) + sanityCheckHookedBuildInfo verbosity pkg_descr pbi let pkg_descr' = updatePackageDescription pbi pkg_descr lbi' = lbi { localPkgDescr = pkg_descr' } postConf simpleUserHooks args flags pkg_descr' lbi' @@ -698,7 +664,7 @@ autoconfUserHooks -> IO HookedBuildInfo readHookWithArgs get_verbosity get_dist_pref _ flags = do dist_dir <- findDistPrefOrDefault (get_dist_pref flags) - getHookedBuildInfo (dist_dir "build") verbosity + getHookedBuildInfo verbosity (dist_dir "build") where verbosity = fromFlag (get_verbosity flags) @@ -708,7 +674,7 @@ autoconfUserHooks readHook get_verbosity get_dist_pref a flags = do noExtraFlags a dist_dir <- findDistPrefOrDefault (get_dist_pref flags) - getHookedBuildInfo (dist_dir "build") verbosity + getHookedBuildInfo verbosity (dist_dir "build") where verbosity = fromFlag (get_verbosity flags) @@ -768,7 +734,7 @@ runConfigureScript verbosity backwardsCompatHack flags lbi = do Just sh -> runProgramInvocation verbosity $ (programInvocation (sh {programOverrideEnv = overEnv}) args') { progInvokeCwd = Just (buildDir lbi) } - Nothing -> die notFoundMsg + Nothing -> die' verbosity notFoundMsg where args = configureArgs backwardsCompatHack flags @@ -803,9 +769,9 @@ runConfigureScript verbosity backwardsCompatHack flags lbi = do ++ "If you are not on Windows, ensure that an 'sh' command " ++ "is discoverable in your path." -getHookedBuildInfo :: FilePath -> Verbosity -> IO HookedBuildInfo -getHookedBuildInfo build_dir verbosity = do - maybe_infoFile <- findHookedPackageDesc build_dir +getHookedBuildInfo :: Verbosity -> FilePath -> IO HookedBuildInfo +getHookedBuildInfo verbosity build_dir = do + maybe_infoFile <- findHookedPackageDesc verbosity build_dir case maybe_infoFile of Nothing -> return emptyHookedBuildInfo Just infoFile -> do diff --git a/Cabal/Distribution/Simple/BuildPaths.hs b/Cabal/Distribution/Simple/BuildPaths.hs index f43b29a7cc3..c8557c9999a 100644 --- a/Cabal/Distribution/Simple/BuildPaths.hs +++ b/Cabal/Distribution/Simple/BuildPaths.hs @@ -16,11 +16,9 @@ module Distribution.Simple.BuildPaths ( defaultDistPref, srcPref, haddockDirName, hscolourPref, haddockPref, - autogenModulesDir, autogenPackageModulesDir, autogenComponentModulesDir, - autogenModuleName, autogenPathsModuleName, cppHeaderName, haddockName, @@ -81,12 +79,6 @@ haddockPref :: HaddockTarget -> FilePath -> PackageDescription -> FilePath haddockPref haddockTarget distPref pkg_descr = distPref "doc" "html" haddockDirName haddockTarget pkg_descr --- | The directory in which we put auto-generated modules for EVERY --- component in the package. See deprecation notice. -{-# DEPRECATED autogenModulesDir "If you can, use 'autogenComponentModulesDir' instead, but if you really wanted package-global generated modules, use 'autogenPackageModulesDir'. In Cabal 2.0, we avoid using autogenerated files which apply to all components, because the information you often want in these files, e.g., dependency information, is best specified per component, so that reconfiguring a different component (e.g., enabling tests) doesn't force the entire to be rebuilt. 'autogenPackageModulesDir' still provides a place to put files you want to apply to the entire package, but most users of 'autogenModulesDir' should seriously consider 'autogenComponentModulesDir' if you really wanted the module to apply to one component." #-} -autogenModulesDir :: LocalBuildInfo -> String -autogenModulesDir = autogenPackageModulesDir - -- | The directory in which we put auto-generated modules for EVERY -- component in the package. autogenPackageModulesDir :: LocalBuildInfo -> String @@ -102,11 +94,6 @@ autogenComponentModulesDir lbi clbi = componentBuildDir lbi clbi "autogen" cppHeaderName :: String cppHeaderName = "cabal_macros.h" -{-# DEPRECATED autogenModuleName "Use autogenPathsModuleName instead" #-} --- |The name of the auto-generated module associated with a package -autogenModuleName :: PackageDescription -> ModuleName -autogenModuleName = autogenPathsModuleName - -- | The name of the auto-generated Paths_* module associated with a package autogenPathsModuleName :: PackageDescription -> ModuleName autogenPathsModuleName pkg_descr = @@ -141,7 +128,7 @@ getExeSourceFiles :: Verbosity -> IO [(ModuleName.ModuleName, FilePath)] getExeSourceFiles verbosity lbi exe clbi = do moduleFiles <- getSourceFiles verbosity searchpaths modules - srcMainPath <- findFile (hsSourceDirs bi) (modulePath exe) + srcMainPath <- findFileEx verbosity (hsSourceDirs bi) (modulePath exe) return ((ModuleName.main, srcMainPath) : moduleFiles) where bi = buildInfo exe diff --git a/Cabal/Distribution/Simple/Configure.hs b/Cabal/Distribution/Simple/Configure.hs index cb8e7297dd1..ed7c45ee78d 100644 --- a/Cabal/Distribution/Simple/Configure.hs +++ b/Cabal/Distribution/Simple/Configure.hs @@ -44,7 +44,6 @@ module Distribution.Simple.Configure , getInstalledPackages , getInstalledPackagesMonitorFiles , getPackageDBContents - , configCompiler, configCompilerAux , configCompilerEx, configCompilerAuxEx , computeEffectiveProfiling , ccLdOptionsBuildInfo @@ -1677,25 +1676,6 @@ configCompilerEx (Just hcFlavor) hcPath hcPkg progdb verbosity = do _ -> die' verbosity "Unknown compiler" return (comp, fromMaybe buildPlatform maybePlatform, programDb) --- Ideally we would like to not have separate configCompiler* and --- configCompiler*Ex sets of functions, but there are many custom setup scripts --- in the wild that are using them, so the versions with old types are kept for --- backwards compatibility. Platform was added to the return triple in 1.18. - -{-# DEPRECATED configCompiler - "'configCompiler' is deprecated. Use 'configCompilerEx' instead." #-} -configCompiler :: Maybe CompilerFlavor -> Maybe FilePath -> Maybe FilePath - -> ProgramDb -> Verbosity - -> IO (Compiler, ProgramDb) -configCompiler mFlavor hcPath hcPkg progdb verbosity = - fmap (\(a,_,b) -> (a,b)) $ configCompilerEx mFlavor hcPath hcPkg progdb verbosity - -{-# DEPRECATED configCompilerAux - "configCompilerAux is deprecated. Use 'configCompilerAuxEx' instead." #-} -configCompilerAux :: ConfigFlags - -> IO (Compiler, ProgramDb) -configCompilerAux = fmap (\(a,_,b) -> (a,b)) . configCompilerAuxEx - -- ----------------------------------------------------------------------------- -- Testing C lib and header dependencies diff --git a/Cabal/Distribution/Simple/GHC.hs b/Cabal/Distribution/Simple/GHC.hs index 2bceac7fbe0..67a5c2d4d5c 100644 --- a/Cabal/Distribution/Simple/GHC.hs +++ b/Cabal/Distribution/Simple/GHC.hs @@ -1117,7 +1117,7 @@ gbuildSources verbosity specVer tmpDir bm = where exeSources :: Executable -> IO BuildSources exeSources exe@Executable{buildInfo = bnfo, modulePath = modPath} = do - main <- findFile (tmpDir : hsSourceDirs bnfo) modPath + main <- findFileEx verbosity (tmpDir : hsSourceDirs bnfo) modPath let mainModName = fromMaybe ModuleName.main $ exeMainModuleName exe otherModNames = exeModules exe @@ -1919,7 +1919,7 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir pkg lib clbi = do installShared = install True copyModuleFiles ext = - findModuleFiles [builtDir] [ext] (allLibModules lib clbi) + findModuleFilesEx verbosity [builtDir] [ext] (allLibModules lib clbi) >>= installOrdinaryFiles verbosity targetDir compiler_id = compilerId (compiler lbi) diff --git a/Cabal/Distribution/Simple/GHCJS.hs b/Cabal/Distribution/Simple/GHCJS.hs index 5624ddcb31e..9e0c67cab80 100644 --- a/Cabal/Distribution/Simple/GHCJS.hs +++ b/Cabal/Distribution/Simple/GHCJS.hs @@ -559,7 +559,7 @@ buildOrReplExe mReplFlags verbosity numJobs _pkg_descr lbi -- build executables - srcMainFile <- findFile (exeDir : hsSourceDirs exeBi) modPath + srcMainFile <- findFileEx verbosity (exeDir : hsSourceDirs exeBi) modPath let isGhcjsDynamic = isDynamic comp dynamicTooSupported = supportsDynamicToo comp buildRunner = case clbi of @@ -746,7 +746,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do installSharedNative = install True False copyModuleFiles ext = - findModuleFiles [builtDir] [ext] (allLibModules lib clbi) + findModuleFilesEx verbosity [builtDir] [ext] (allLibModules lib clbi) >>= installOrdinaryFiles verbosity targetDir compiler_id = compilerId (compiler lbi) diff --git a/Cabal/Distribution/Simple/LocalBuildInfo.hs b/Cabal/Distribution/Simple/LocalBuildInfo.hs index 52251d5ab92..b625febb095 100644 --- a/Cabal/Distribution/Simple/LocalBuildInfo.hs +++ b/Cabal/Distribution/Simple/LocalBuildInfo.hs @@ -21,7 +21,6 @@ module Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..), - externalPackageDeps, localComponentId, localUnitId, localCompatPackageKey, @@ -43,15 +42,11 @@ module Distribution.Simple.LocalBuildInfo ( pkgBuildableComponents, lookupComponent, getComponent, - getComponentLocalBuildInfo, allComponentsInBuildOrder, - componentsInBuildOrder, depLibraryPaths, allLibModules, withAllComponentsInBuildOrder, - withComponentsInBuildOrder, - withComponentsLBI, withLibLBI, withExeLBI, withBenchLBI, @@ -95,7 +90,6 @@ import qualified Distribution.Compat.Graph as Graph import Data.List (stripPrefix) import System.FilePath -import qualified Data.Map as Map import System.Directory (doesDirectoryExist, canonicalizePath) @@ -122,19 +116,6 @@ componentBuildDir lbi clbi CTestName s -> unUnqualComponentName s CBenchName s -> unUnqualComponentName s -{-# DEPRECATED getComponentLocalBuildInfo "This function is not well-defined, because a 'ComponentName' does not uniquely identify a 'ComponentLocalBuildInfo'. If you have a 'TargetInfo', you should use 'targetCLBI' to get the 'ComponentLocalBuildInfo'. Otherwise, use 'componentNameTargets' to get all possible 'ComponentLocalBuildInfo's. This will be removed in Cabal 2.2." #-} -getComponentLocalBuildInfo :: LocalBuildInfo -> ComponentName -> ComponentLocalBuildInfo -getComponentLocalBuildInfo lbi cname = - case componentNameCLBIs lbi cname of - [clbi] -> clbi - [] -> - error $ "internal error: there is no configuration data " - ++ "for component " ++ show cname - clbis -> - error $ "internal error: the component name " ++ show cname - ++ "is ambiguous. Refers to: " - ++ intercalate ", " (map (prettyShow . componentUnitId) clbis) - -- | Perform the action on each enabled 'library' in the package -- description with the 'ComponentLocalBuildInfo'. withLibLBI :: PackageDescription -> LocalBuildInfo @@ -182,12 +163,6 @@ enabledBenchLBIs pkg lbi = | target <- allTargetsInBuildOrder' pkg lbi , CBench bench <- [targetComponent target] ] -{-# DEPRECATED withComponentsLBI "Use withAllComponentsInBuildOrder" #-} -withComponentsLBI :: PackageDescription -> LocalBuildInfo - -> (Component -> ComponentLocalBuildInfo -> IO ()) - -> IO () -withComponentsLBI = withAllComponentsInBuildOrder - -- | Perform the action on each buildable 'Library' or 'Executable' (Component) -- in the PackageDescription, subject to the build order specified by the -- 'compBuildOrder' field of the given 'LocalBuildInfo' @@ -198,37 +173,11 @@ withAllComponentsInBuildOrder pkg lbi f = withAllTargetsInBuildOrder' pkg lbi $ \target -> f (targetComponent target) (targetCLBI target) -{-# DEPRECATED withComponentsInBuildOrder "You have got a 'TargetInfo' right? Use 'withNeededTargetsInBuildOrder' on the 'UnitId's you can 'nodeKey' out." #-} -withComponentsInBuildOrder :: PackageDescription -> LocalBuildInfo - -> [ComponentName] - -> (Component -> ComponentLocalBuildInfo -> IO ()) - -> IO () -withComponentsInBuildOrder pkg lbi cnames f = - withNeededTargetsInBuildOrder' pkg lbi uids $ \target -> - f (targetComponent target) (targetCLBI target) - where uids = concatMap (componentNameToUnitIds lbi) cnames - allComponentsInBuildOrder :: LocalBuildInfo -> [ComponentLocalBuildInfo] allComponentsInBuildOrder lbi = Graph.topSort (componentGraph lbi) --- | Private helper function for some of the deprecated implementations. -componentNameToUnitIds :: LocalBuildInfo -> ComponentName -> [UnitId] -componentNameToUnitIds lbi cname = - case Map.lookup cname (componentNameMap lbi) of - Just clbis -> map componentUnitId clbis - Nothing -> error $ "componentNameToUnitIds " ++ prettyShow cname - -{-# DEPRECATED componentsInBuildOrder "You've got 'TargetInfo' right? Use 'neededTargetsInBuildOrder' on the 'UnitId's you can 'nodeKey' out." #-} -componentsInBuildOrder :: LocalBuildInfo -> [ComponentName] - -> [ComponentLocalBuildInfo] -componentsInBuildOrder lbi cnames - -- NB: use of localPkgDescr here is safe because we throw out the - -- result immediately afterwards - = map targetCLBI (neededTargetsInBuildOrder' (localPkgDescr lbi) lbi uids) - where uids = concatMap (componentNameToUnitIds lbi) cnames - -- ----------------------------------------------------------------------------- -- A random function that has no business in this module diff --git a/Cabal/Distribution/Simple/PackageIndex.hs b/Cabal/Distribution/Simple/PackageIndex.hs index 4357d12928b..caa6350be14 100644 --- a/Cabal/Distribution/Simple/PackageIndex.hs +++ b/Cabal/Distribution/Simple/PackageIndex.hs @@ -92,11 +92,7 @@ module Distribution.Simple.PackageIndex ( dependencyInconsistencies, dependencyCycles, dependencyGraph, - moduleNameIndex, - - -- * Backwards compatibility - deleteInstalledPackageId, - lookupInstalledPackageId, + moduleNameIndex ) where import Prelude () @@ -302,12 +298,6 @@ deleteUnitId ipkgid original@(PackageIndex pids pnames) = (\xs -> if null xs then Nothing else Just xs) . List.deleteBy (\_ pkg -> installedUnitId pkg == ipkgid) undefined --- | Backwards compatibility wrapper for Cabal pre-1.24. -{-# DEPRECATED deleteInstalledPackageId "Use deleteUnitId instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -deleteInstalledPackageId :: UnitId -> InstalledPackageIndex - -> InstalledPackageIndex -deleteInstalledPackageId = deleteUnitId - -- | Removes all packages with this source 'PackageId' from the index. -- deleteSourcePackageId :: PackageId -> InstalledPackageIndex @@ -418,13 +408,6 @@ lookupComponentId :: PackageIndex a -> ComponentId lookupComponentId index cid = Map.lookup (newSimpleUnitId cid) (unitIdIndex index) --- | Backwards compatibility for Cabal pre-1.24. -{-# DEPRECATED lookupInstalledPackageId "Use lookupUnitId instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -lookupInstalledPackageId :: PackageIndex a -> UnitId - -> Maybe a -lookupInstalledPackageId = lookupUnitId - - -- | Does a lookup by source package id (name & version). -- -- There can be multiple installed packages with the same source 'PackageId' diff --git a/Cabal/Distribution/Simple/Program.hs b/Cabal/Distribution/Simple/Program.hs index 1b1cfdbebf4..f1428831cde 100644 --- a/Cabal/Distribution/Simple/Program.hs +++ b/Cabal/Distribution/Simple/Program.hs @@ -118,19 +118,6 @@ module Distribution.Simple.Program ( , cppProgram , pkgConfigProgram , hpcProgram - - -- * deprecated - , ProgramConfiguration - , emptyProgramConfiguration - , defaultProgramConfiguration - , restoreProgramConfiguration - , rawSystemProgram - , rawSystemProgramStdout - , rawSystemProgramConf - , rawSystemProgramStdoutConf - , findProgramOnPath - , findProgramLocation - ) where import Prelude () @@ -192,48 +179,3 @@ getDbProgramOutput verbosity prog programDb args = where notFound = "The program '" ++ programName prog ++ "' is required but it could not be found" - - ---------------------- --- Deprecated aliases --- - -{-# DEPRECATED rawSystemProgram "use runProgram instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -rawSystemProgram :: Verbosity -> ConfiguredProgram - -> [ProgArg] -> IO () -rawSystemProgram = runProgram - -{-# DEPRECATED rawSystemProgramStdout "use getProgramOutput instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -rawSystemProgramStdout :: Verbosity -> ConfiguredProgram - -> [ProgArg] -> IO String -rawSystemProgramStdout = getProgramOutput - -{-# DEPRECATED rawSystemProgramConf "use runDbProgram instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -rawSystemProgramConf :: Verbosity -> Program -> ProgramConfiguration - -> [ProgArg] -> IO () -rawSystemProgramConf = runDbProgram - -{-# DEPRECATED rawSystemProgramStdoutConf "use getDbProgramOutput instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -rawSystemProgramStdoutConf :: Verbosity -> Program -> ProgramConfiguration - -> [ProgArg] -> IO String -rawSystemProgramStdoutConf = getDbProgramOutput - -{-# DEPRECATED ProgramConfiguration "use ProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -type ProgramConfiguration = ProgramDb - -{-# DEPRECATED emptyProgramConfiguration "use emptyProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -{-# DEPRECATED defaultProgramConfiguration "use defaultProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -emptyProgramConfiguration, defaultProgramConfiguration :: ProgramConfiguration -emptyProgramConfiguration = emptyProgramDb -defaultProgramConfiguration = defaultProgramDb - -{-# DEPRECATED restoreProgramConfiguration "use restoreProgramDb instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -restoreProgramConfiguration :: [Program] -> ProgramConfiguration - -> ProgramConfiguration -restoreProgramConfiguration = restoreProgramDb - -{-# DEPRECATED findProgramOnPath "use findProgramOnSearchPath instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -findProgramOnPath :: String -> Verbosity -> IO (Maybe FilePath) -findProgramOnPath name verbosity = - fmap (fmap fst) $ - findProgramOnSearchPath verbosity defaultProgramSearchPath name diff --git a/Cabal/Distribution/Simple/Setup.hs b/Cabal/Distribution/Simple/Setup.hs index 8937109565d..82ad40389d0 100644 --- a/Cabal/Distribution/Simple/Setup.hs +++ b/Cabal/Distribution/Simple/Setup.hs @@ -45,7 +45,6 @@ module Distribution.Simple.Setup ( HaddockFlags(..), emptyHaddockFlags, defaultHaddockFlags, haddockCommand, HscolourFlags(..), emptyHscolourFlags, defaultHscolourFlags, hscolourCommand, BuildFlags(..), emptyBuildFlags, defaultBuildFlags, buildCommand, - buildVerbose, ReplFlags(..), defaultReplFlags, replCommand, CleanFlags(..), emptyCleanFlags, defaultCleanFlags, cleanCommand, RegisterFlags(..), emptyRegisterFlags, defaultRegisterFlags, registerCommand, @@ -59,7 +58,6 @@ module Distribution.Simple.Setup ( configureArgs, configureOptions, configureCCompiler, configureLinker, buildOptions, haddockOptions, installDirsOptions, testOptions', programDbOptions, programDbPaths', - programConfigurationOptions, programConfigurationPaths', programFlagsDescription, replOptions, splitArgs, @@ -506,11 +504,6 @@ configureOptions showOrParseArgs = configProf (\v flags -> flags { configProf = v }) (boolOpt [] []) - ,option "" ["executable-profiling"] - "Executable profiling (DEPRECATED)" - configProfExe (\v flags -> flags { configProfExe = v }) - (boolOpt [] []) - ,option "" ["profiling-detail"] ("Profiling detail level for executable and library (default, " ++ "none, exported-functions, toplevel-functions, all-functions).") @@ -678,11 +671,6 @@ configureOptions showOrParseArgs = configCoverage (\v flags -> flags { configCoverage = v }) (boolOpt [] []) - ,option "" ["library-coverage"] - "build package with Haskell Program Coverage. (GHC only) (DEPRECATED)" - configLibCoverage (\v flags -> flags { configLibCoverage = v }) - (boolOpt [] []) - ,option "" ["exact-configuration"] "All direct dependencies and flags are provided on the command line." configExactConfiguration @@ -1639,10 +1627,6 @@ data BuildFlags = BuildFlags { } deriving (Read, Show, Generic) -{-# DEPRECATED buildVerbose "Use buildVerbosity instead" #-} -buildVerbose :: BuildFlags -> Verbosity -buildVerbose = fromFlagOrDefault normal . buildVerbosity - defaultBuildFlags :: BuildFlags defaultBuildFlags = BuildFlags { buildProgramPaths = mempty, @@ -2076,19 +2060,14 @@ programDbPaths programDbPaths progDb showOrParseArgs get set = programDbPaths' ("with-" ++) progDb showOrParseArgs get set -{-# DEPRECATED programConfigurationPaths' "Use programDbPaths' instead" #-} - -- | Like 'programDbPaths', but allows to customise the option name. -programDbPaths', programConfigurationPaths' +programDbPaths' :: (String -> String) -> ProgramDb -> ShowOrParseArgs -> (flags -> [(String, FilePath)]) -> ([(String, FilePath)] -> (flags -> flags)) -> [OptionField flags] - -programConfigurationPaths' = programDbPaths' - programDbPaths' mkName progDb showOrParseArgs get set = case showOrParseArgs of -- we don't want a verbose help text list so we just show a generic one: @@ -2127,19 +2106,15 @@ programDbOption progDb showOrParseArgs get set = (\progArgs -> concat [ args | (prog', args) <- progArgs, prog==prog' ])) -{-# DEPRECATED programConfigurationOptions "Use programDbOptions instead" #-} -- | For each known program @PROG@ in 'progDb', produce a @PROG-options@ -- 'OptionField'. -programDbOptions, programConfigurationOptions +programDbOptions :: ProgramDb -> ShowOrParseArgs -> (flags -> [(String, [String])]) -> ([(String, [String])] -> (flags -> flags)) -> [OptionField flags] - -programConfigurationOptions = programDbOptions - programDbOptions progDb showOrParseArgs get set = case showOrParseArgs of -- we don't want a verbose help text list so we just show a generic one: diff --git a/Cabal/Distribution/Simple/SrcDist.hs b/Cabal/Distribution/Simple/SrcDist.hs index 0331dcd24fc..0f1cce99d70 100644 --- a/Cabal/Distribution/Simple/SrcDist.hs +++ b/Cabal/Distribution/Simple/SrcDist.hs @@ -171,14 +171,15 @@ listPackageSourcesOrdinary verbosity pkg_descr pps = , fmap concat . withAllExe $ \Executable { modulePath = mainPath, buildInfo = exeBi } -> do biSrcs <- allSourcesBuildInfo verbosity exeBi pps [] - mainSrc <- findMainExeFile exeBi pps mainPath + mainSrc <- findMainExeFile verbosity exeBi pps mainPath return (mainSrc:biSrcs) -- Foreign library sources , fmap concat . withAllFLib $ \flib@(ForeignLib { foreignLibBuildInfo = flibBi }) -> do biSrcs <- allSourcesBuildInfo verbosity flibBi pps [] - defFiles <- mapM (findModDefFile flibBi pps) (foreignLibModDefFile flib) + defFiles <- mapM (findModDefFile verbosity flibBi pps) + (foreignLibModDefFile flib) return (defFiles ++ biSrcs) -- Test suites sources. @@ -188,12 +189,12 @@ listPackageSourcesOrdinary verbosity pkg_descr pps = case testInterface t of TestSuiteExeV10 _ mainPath -> do biSrcs <- allSourcesBuildInfo verbosity bi pps [] - srcMainFile <- findMainExeFile bi pps mainPath + srcMainFile <- findMainExeFile verbosity bi pps mainPath return (srcMainFile:biSrcs) TestSuiteLibV09 _ m -> allSourcesBuildInfo verbosity bi pps [m] - TestSuiteUnsupported tp -> die' verbosity $ "Unsupported test suite type: " - ++ show tp + TestSuiteUnsupported tp -> + die' verbosity $ "Unsupported test suite type: " ++ show tp -- Benchmarks sources. , fmap concat @@ -202,7 +203,7 @@ listPackageSourcesOrdinary verbosity pkg_descr pps = case benchmarkInterface bm of BenchmarkExeV10 _ mainPath -> do biSrcs <- allSourcesBuildInfo verbosity bi pps [] - srcMainFile <- findMainExeFile bi pps mainPath + srcMainFile <- findMainExeFile verbosity bi pps mainPath return (srcMainFile:biSrcs) BenchmarkUnsupported tp -> die' verbosity $ "Unsupported benchmark type: " ++ show tp @@ -300,20 +301,22 @@ maybeCreateDefaultSetupScript targetDir = do "main = defaultMain"] -- | Find the main executable file. -findMainExeFile :: BuildInfo -> [PPSuffixHandler] -> FilePath -> IO FilePath -findMainExeFile exeBi pps mainPath = do +findMainExeFile + :: Verbosity -> BuildInfo -> [PPSuffixHandler] -> FilePath -> IO FilePath +findMainExeFile verbosity exeBi pps mainPath = do ppFile <- findFileWithExtension (ppSuffixes pps) (hsSourceDirs exeBi) (dropExtension mainPath) case ppFile of - Nothing -> findFile (hsSourceDirs exeBi) mainPath + Nothing -> findFileEx verbosity (hsSourceDirs exeBi) mainPath Just pp -> return pp -- | Find a module definition file -- -- TODO: I don't know if this is right -findModDefFile :: BuildInfo -> [PPSuffixHandler] -> FilePath -> IO FilePath -findModDefFile flibBi _pps modDefPath = - findFile (".":hsSourceDirs flibBi) modDefPath +findModDefFile + :: Verbosity -> BuildInfo -> [PPSuffixHandler] -> FilePath -> IO FilePath +findModDefFile verbosity flibBi _pps modDefPath = + findFileEx verbosity (".":hsSourceDirs flibBi) modDefPath -- | Given a list of include paths, try to find the include file named -- @f@. Return the name of the file and the full path, or exit with error if diff --git a/Cabal/Distribution/Simple/UserHooks.hs b/Cabal/Distribution/Simple/UserHooks.hs index 4eb239987ad..306092186d1 100644 --- a/Cabal/Distribution/Simple/UserHooks.hs +++ b/Cabal/Distribution/Simple/UserHooks.hs @@ -51,8 +51,6 @@ type Args = [String] -- break in future releases. data UserHooks = UserHooks { - -- | Used for @.\/setup test@ - runTests :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO (), -- | Read the description file readDesc :: IO (Maybe GenericPackageDescription), -- | Custom preprocessors in addition to and overriding 'knownSuffixHandlers'. @@ -107,13 +105,6 @@ data UserHooks = UserHooks { -- on the target, not on the build machine. postInst :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO (), - -- |Hook to run before sdist command. Second arg indicates verbosity level. - preSDist :: Args -> SDistFlags -> IO HookedBuildInfo, - -- |Over-ride this hook to get different behavior during sdist. - sDistHook :: PackageDescription -> Maybe LocalBuildInfo -> UserHooks -> SDistFlags -> IO (), - -- |Hook to run after sdist command. Second arg indicates verbosity level. - postSDist :: Args -> SDistFlags -> PackageDescription -> Maybe LocalBuildInfo -> IO (), - -- |Hook to run before register command preReg :: Args -> RegisterFlags -> IO HookedBuildInfo, -- |Over-ride this hook to get different behavior during registration. @@ -164,16 +155,10 @@ data UserHooks = UserHooks { postBench :: Args -> BenchmarkFlags -> PackageDescription -> LocalBuildInfo -> IO () } -{-# DEPRECATED runTests "Please use the new testing interface instead!" #-} -{-# DEPRECATED preSDist "SDist hooks violate the invariants of new-sdist. Use 'autogen-modules' and 'build-tool-depends' instead." #-} -{-# DEPRECATED sDistHook "SDist hooks violate the invariants of new-sdist. Use 'autogen-modules' and 'build-tool-depends' instead." #-} -{-# DEPRECATED postSDist "SDist hooks violate the invariants of new-sdist. Use 'autogen-modules' and 'build-tool-depends' instead." #-} - -- |Empty 'UserHooks' which do nothing. emptyUserHooks :: UserHooks emptyUserHooks = UserHooks { - runTests = ru, readDesc = return Nothing, hookedPreProcessors = [], hookedPrograms = [], @@ -195,9 +180,6 @@ emptyUserHooks preInst = rn, instHook = ru, postInst = ru, - preSDist = rn, - sDistHook = ru, - postSDist = ru, preReg = rn', regHook = ru, postReg = ru, diff --git a/Cabal/Distribution/Simple/Utils.hs b/Cabal/Distribution/Simple/Utils.hs index 17ed16e83fb..8dbcf07a908 100644 --- a/Cabal/Distribution/Simple/Utils.hs +++ b/Cabal/Distribution/Simple/Utils.hs @@ -25,9 +25,6 @@ module Distribution.Simple.Utils ( cabalVersion, -- * logging and errors - -- Old style - die, dieWithLocation, - -- New style dieNoVerbosity, die', dieWithLocation', dieNoWrap, @@ -55,7 +52,6 @@ module Distribution.Simple.Utils ( createProcessWithEnv, maybeExit, xargs, - findProgramLocation, findProgramVersion, -- ** 'IOData' re-export @@ -67,10 +63,8 @@ module Distribution.Simple.Utils ( IODataMode(..), -- * copying files - smartCopySources, createDirectoryIfMissingVerbose, copyFileVerbose, - copyDirectoryRecursiveVerbose, copyFiles, copyFileTo, @@ -96,13 +90,13 @@ module Distribution.Simple.Utils ( exeExtensions, -- * finding files - findFile, + findFileEx, findFirstFile, findFileWithExtension, findFileWithExtension', findAllFilesWithExtension, - findModuleFile, - findModuleFiles, + findModuleFileEx, + findModuleFilesEx, getDirectoryContentsRecursive, -- * environment variables @@ -123,13 +117,11 @@ module Distribution.Simple.Utils ( defaultPackageDesc, findPackageDesc, tryFindPackageDesc, - defaultHookedPackageDesc, findHookedPackageDesc, -- * reading and writing files safely withFileContents, writeFileAtomic, - rewriteFile, rewriteFileEx, -- * Unicode @@ -166,6 +158,11 @@ module Distribution.Simple.Utils ( -- * FilePath stuff isAbsoluteOnAnyPlatform, isRelativeOnAnyPlatform, + + -- * Deprecated functions + findFile, + findModuleFile, + findModuleFiles, ) where import Prelude () @@ -209,7 +206,7 @@ import qualified Data.ByteString.Lazy as BS import System.Directory ( Permissions(executable), getDirectoryContents, getPermissions - , doesDirectoryExist, doesFileExist, removeFile, findExecutable + , doesDirectoryExist, doesFileExist, removeFile , getModificationTime, createDirectory, removeDirectoryRecursive ) import System.Environment ( getProgName ) @@ -302,21 +299,6 @@ cabalVersion = mkVersion [1,9999] --used when bootstrapping -- 'ioeSetVerbatim' and 'ioeGetVerbatim'. -- -{-# DEPRECATED dieWithLocation "Messages thrown with dieWithLocation can't be controlled with Verbosity; use dieWithLocation' instead" #-} -dieWithLocation :: FilePath -> Maybe Int -> String -> IO a -dieWithLocation filename lineno msg = - ioError . setLocation lineno - . flip ioeSetFileName (normalise filename) - $ userError msg - where - setLocation Nothing err = err - setLocation (Just n) err = ioeSetLocation err (show n) - _ = callStack -- TODO: Attach CallStack to exception - -{-# DEPRECATED die "Messages thrown with die can't be controlled with Verbosity; use die' instead, or dieNoVerbosity if Verbosity truly is not available" #-} -die :: String -> IO a -die = dieNoVerbosity - dieNoVerbosity :: String -> IO a dieNoVerbosity msg = ioError (userError msg) @@ -815,7 +797,7 @@ rawSystemStdout verbosity path args = withFrozenCallStack $ do Nothing Nothing Nothing IODataModeText when (exitCode /= ExitSuccess) $ - die errors + die' verbosity errors return output -- | Run a command and return its output, errors and exit status. Optionally @@ -893,20 +875,6 @@ rawSystemStdInOut verbosity path args mcwd menv input outputMode = withFrozenCal either (\e -> throwIO (ioeSetFileName e ("output of " ++ path))) return - -{-# DEPRECATED findProgramLocation - "No longer used within Cabal, try findProgramOnSearchPath" #-} --- | Look for a program on the path. -findProgramLocation :: Verbosity -> FilePath -> IO (Maybe FilePath) -findProgramLocation verbosity prog = withFrozenCallStack $ do - debug verbosity $ "searching for " ++ prog ++ " in path." - res <- findExecutable prog - case res of - Nothing -> debug verbosity ("Cannot find " ++ prog ++ " on the path") - Just path -> debug verbosity ("found " ++ prog ++ " at "++ path) - return res - - -- | Look for a program and try to find it's version number. It can accept -- either an absolute path or the name of a program binary, in which case we -- will look for the program on the path. @@ -962,16 +930,24 @@ xargs maxSize rawSystemFun fixedArgs bigArgs = ---------------- -- Finding files --- | Find a file by looking in a search path. The file path must match exactly. --- + +{-# DEPRECATED findFile "Use findFileEx instead. This symbol will be removed in Cabal 3.2 (est. December 2019)" #-} findFile :: [FilePath] -- ^search locations -> FilePath -- ^File Name -> IO FilePath -findFile searchPath fileName = +findFile = findFileEx normal + +-- | Find a file by looking in a search path. The file path must match exactly. +-- +findFileEx :: Verbosity + -> [FilePath] -- ^search locations + -> FilePath -- ^File Name + -> IO FilePath +findFileEx verbosity searchPath fileName = findFirstFile id [ path fileName | path <- nub searchPath] - >>= maybe (die $ fileName ++ " doesn't exist") return + >>= maybe (die' verbosity $ fileName ++ " doesn't exist") return -- | Find a file by looking in a search path with one of a list of possible -- file extensions. The file base name should be given and it will be tried @@ -1021,34 +997,52 @@ findFirstFile file = findFirst findAllFiles :: (a -> FilePath) -> [a] -> NoCallStackIO [a] findAllFiles file = filterM (doesFileExist . file) --- | Finds the files corresponding to a list of Haskell module names. --- --- As 'findModuleFile' but for a list of module names. --- + +{-# DEPRECATED findModuleFiles "Use findModuleFilesEx instead. This symbol will be removed in Cabal 3.2 (est. December 2019)" #-} findModuleFiles :: [FilePath] -- ^ build prefix (location of objects) -> [String] -- ^ search suffixes -> [ModuleName] -- ^ modules -> IO [(FilePath, FilePath)] -findModuleFiles searchPath extensions moduleNames = - traverse (findModuleFile searchPath extensions) moduleNames +findModuleFiles = findModuleFilesEx normal --- | Find the file corresponding to a Haskell module name. +-- | Finds the files corresponding to a list of Haskell module names. -- --- This is similar to 'findFileWithExtension'' but specialised to a module --- name. The function fails if the file corresponding to the module is missing. +-- As 'findModuleFile' but for a list of module names. -- +findModuleFilesEx :: Verbosity + -> [FilePath] -- ^ build prefix (location of objects) + -> [String] -- ^ search suffixes + -> [ModuleName] -- ^ modules + -> IO [(FilePath, FilePath)] +findModuleFilesEx verbosity searchPath extensions moduleNames = + traverse (findModuleFileEx verbosity searchPath extensions) moduleNames + +{-# DEPRECATED findModuleFile "Use findModuleFileEx instead. This symbol will be removed in Cabal 3.2 (est. December 2019)" #-} findModuleFile :: [FilePath] -- ^ build prefix (location of objects) -> [String] -- ^ search suffixes -> ModuleName -- ^ module -> IO (FilePath, FilePath) -findModuleFile searchPath extensions mod_name = +findModuleFile = findModuleFileEx normal + +-- | Find the file corresponding to a Haskell module name. +-- +-- This is similar to 'findFileWithExtension'' but specialised to a module +-- name. The function fails if the file corresponding to the module is missing. +-- +findModuleFileEx :: Verbosity + -> [FilePath] -- ^ build prefix (location of objects) + -> [String] -- ^ search suffixes + -> ModuleName -- ^ module + -> IO (FilePath, FilePath) +findModuleFileEx verbosity searchPath extensions mod_name = maybe notFound return =<< findFileWithExtension' extensions searchPath (ModuleName.toFilePath mod_name) where - notFound = die $ "Error: Could not find module: " ++ prettyShow mod_name - ++ " with any suffix: " ++ show extensions - ++ " in the search path: " ++ show searchPath + notFound = die' verbosity $ + "Error: Could not find module: " ++ prettyShow mod_name + ++ " with any suffix: " ++ show extensions + ++ " in the search path: " ++ show searchPath -- | List all the files in a directory and all subdirectories. -- @@ -1312,25 +1306,6 @@ doesExecutableExist f = do return (executable perms) else return False ---------------------------------- --- Deprecated file copy functions - -{-# DEPRECATED smartCopySources - "Use findModuleFiles and copyFiles or installOrdinaryFiles" #-} -smartCopySources :: Verbosity -> [FilePath] -> FilePath - -> [ModuleName] -> [String] -> IO () -smartCopySources verbosity searchPath targetDir moduleNames extensions = withFrozenCallStack $ - findModuleFiles searchPath extensions moduleNames - >>= copyFiles verbosity targetDir - -{-# DEPRECATED copyDirectoryRecursiveVerbose - "You probably want installDirectoryContents instead" #-} -copyDirectoryRecursiveVerbose :: Verbosity -> FilePath -> FilePath -> IO () -copyDirectoryRecursiveVerbose verbosity srcDir destDir = withFrozenCallStack $ do - info verbosity ("copy directory '" ++ srcDir ++ "' to '" ++ destDir ++ "'.") - srcFiles <- getDirectoryContentsRecursive srcDir - copyFiles verbosity destDir [ (srcDir, f) | f <- srcFiles ] - --------------------------- -- Temporary files and dirs @@ -1393,10 +1368,6 @@ withTempDirectoryEx _verbosity opts targetDir template f = withFrozenCallStack $ ----------------------------------- -- Safely reading and writing files -{-# DEPRECATED rewriteFile "Use rewriteFileEx so that Verbosity is respected" #-} -rewriteFile :: FilePath -> String -> IO () -rewriteFile = rewriteFileEx normal - -- | Write a file but only if it would have new content. If we would be writing -- the same as the existing content then leave the file as is so that we do not -- update the file's modification time. @@ -1458,9 +1429,9 @@ exeExtensions = case buildOS of -- * Finding the description file -- ------------------------------------------------------------ --- |Package description file (/pkgname/@.cabal@) +-- | Package description file (/pkgname/@.cabal@) defaultPackageDesc :: Verbosity -> IO FilePath -defaultPackageDesc _verbosity = tryFindPackageDesc currentDir +defaultPackageDesc verbosity = tryFindPackageDesc verbosity currentDir -- |Find a package description file in the given directory. Looks for -- @.cabal@ files. @@ -1491,20 +1462,17 @@ findPackageDesc dir ++ intercalate ", " l -- |Like 'findPackageDesc', but calls 'die' in case of error. -tryFindPackageDesc :: FilePath -> IO FilePath -tryFindPackageDesc dir = either die return =<< findPackageDesc dir - -{-# DEPRECATED defaultHookedPackageDesc "Use findHookedPackageDesc with the proper base directory instead" #-} --- |Optional auxiliary package information file (/pkgname/@.buildinfo@) -defaultHookedPackageDesc :: IO (Maybe FilePath) -defaultHookedPackageDesc = findHookedPackageDesc currentDir +tryFindPackageDesc :: Verbosity -> FilePath -> IO FilePath +tryFindPackageDesc verbosity dir = + either (die' verbosity) return =<< findPackageDesc dir -- |Find auxiliary package information in the given directory. -- Looks for @.buildinfo@ files. findHookedPackageDesc - :: FilePath -- ^Directory to search + :: Verbosity + -> FilePath -- ^Directory to search -> IO (Maybe FilePath) -- ^/dir/@\/@/pkgname/@.buildinfo@, if present -findHookedPackageDesc dir = do +findHookedPackageDesc verbosity dir = do files <- getDirectoryContents dir buildInfoFiles <- filterM doesFileExist [ dir file @@ -1512,9 +1480,9 @@ findHookedPackageDesc dir = do , let (name, ext) = splitExtension file , not (null name) && ext == buildInfoExt ] case buildInfoFiles of - [] -> return Nothing + [] -> return Nothing [f] -> return (Just f) - _ -> die ("Multiple files with extension " ++ buildInfoExt) + _ -> die' verbosity ("Multiple files with extension " ++ buildInfoExt) buildInfoExt :: String buildInfoExt = ".buildinfo" diff --git a/Cabal/Distribution/Text.hs b/Cabal/Distribution/Text.hs index 41ce60b1d76..258b4dc835f 100644 --- a/Cabal/Distribution/Text.hs +++ b/Cabal/Distribution/Text.hs @@ -1,5 +1,5 @@ -- Since @3.0@ this is a compat module. -module Distribution.Text where +module Distribution.Text (display, simpleParse) where {- {-# DEPRECATED "Use Distribution.Parsec or Distribution.Pretty" #-} -} import Distribution.Pretty diff --git a/Cabal/Distribution/Types/Library.hs b/Cabal/Distribution/Types/Library.hs index b7ff72456f4..26e9bfb324a 100644 --- a/Cabal/Distribution/Types/Library.hs +++ b/Cabal/Distribution/Types/Library.hs @@ -6,7 +6,6 @@ module Distribution.Types.Library ( emptyLibrary, explicitLibModules, libModulesAutogen, - libModules, ) where import Distribution.Compat.Prelude @@ -88,16 +87,6 @@ explicitLibModules lib = exposedModules lib libModulesAutogen :: Library -> [ModuleName] libModulesAutogen lib = autogenModules (libBuildInfo lib) --- | Backwards-compatibility shim for 'explicitLibModules'. In most cases, --- you actually want 'allLibModules', which returns all modules that will --- actually be compiled, as opposed to those which are explicitly listed --- in the package description ('explicitLibModules'); unfortunately, the --- type signature for 'allLibModules' is incompatible since we need a --- 'ComponentLocalBuildInfo'. -{-# DEPRECATED libModules "If you want all modules that are built with a library, use 'allLibModules'. Otherwise, use 'explicitLibModules' for ONLY the modules explicitly mentioned in the package description. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -libModules :: Library -> [ModuleName] -libModules = explicitLibModules - -- | Combine 'LibraryName'. in parsing we prefer value coming -- from munged @name@ field over the @lib-name@. -- diff --git a/Cabal/Distribution/Types/LocalBuildInfo.hs b/Cabal/Distribution/Types/LocalBuildInfo.hs index 90bbf6dfef6..31ad96ef89a 100644 --- a/Cabal/Distribution/Types/LocalBuildInfo.hs +++ b/Cabal/Distribution/Types/LocalBuildInfo.hs @@ -46,11 +46,6 @@ module Distribution.Types.LocalBuildInfo ( withAllTargetsInBuildOrder, neededTargetsInBuildOrder, withNeededTargetsInBuildOrder, - - -- * Backwards compatibility. - - componentsConfigs, - externalPackageDeps, ) where import Prelude () @@ -60,7 +55,6 @@ import Distribution.Types.PackageDescription import Distribution.Types.ComponentLocalBuildInfo import Distribution.Types.ComponentRequestedSpec import Distribution.Types.ComponentId -import Distribution.Types.MungedPackageId import Distribution.Types.PackageId import Distribution.Types.UnitId import Distribution.Types.TargetInfo @@ -306,32 +300,3 @@ neededTargetsInBuildOrder lbi = neededTargetsInBuildOrder' (localPkgDescr lbi) l withNeededTargetsInBuildOrder :: LocalBuildInfo -> [UnitId] -> (TargetInfo -> IO ()) -> IO () withNeededTargetsInBuildOrder lbi = withNeededTargetsInBuildOrder' (localPkgDescr lbi) lbi - -------------------------------------------------------------------------------- --- Backwards compatibility - -{-# DEPRECATED componentsConfigs "Use 'componentGraph' instead; you can get a list of 'ComponentLocalBuildInfo' with 'Distribution.Compat.Graph.toList'. There's not a good way to get the list of 'ComponentName's the 'ComponentLocalBuildInfo' depends on because this query doesn't make sense; the graph is indexed by 'UnitId' not 'ComponentName'. Given a 'UnitId' you can lookup the 'ComponentLocalBuildInfo' ('getCLBI') and then get the 'ComponentName' ('componentLocalName]). To be removed in Cabal 3.0" #-} -componentsConfigs :: LocalBuildInfo -> [(ComponentName, ComponentLocalBuildInfo, [ComponentName])] -componentsConfigs lbi = - [ (componentLocalName clbi, - clbi, - mapMaybe (fmap componentLocalName . flip Graph.lookup g) - (componentInternalDeps clbi)) - | clbi <- Graph.toList g ] - where - g = componentGraph lbi - --- | External package dependencies for the package as a whole. This is the --- union of the individual 'componentPackageDeps', less any internal deps. -{-# DEPRECATED externalPackageDeps "You almost certainly don't want this function, which agglomerates the dependencies of ALL enabled components. If you're using this to write out information on your dependencies, read off the dependencies directly from the actual component in question. To be removed in Cabal 3.0" #-} -externalPackageDeps :: LocalBuildInfo -> [(UnitId, MungedPackageId)] -externalPackageDeps lbi = - -- TODO: what about non-buildable components? - nub [ (ipkgid, pkgid) - | clbi <- Graph.toList (componentGraph lbi) - , (ipkgid, pkgid) <- componentPackageDeps clbi - , not (internal ipkgid) ] - where - -- True if this dependency is an internal one (depends on the library - -- defined in the same package). - internal ipkgid = any ((==ipkgid) . componentUnitId) (Graph.toList (componentGraph lbi)) diff --git a/Cabal/Distribution/Types/PackageDescription.hs b/Cabal/Distribution/Types/PackageDescription.hs index ea648a57a11..10110fa6667 100644 --- a/Cabal/Distribution/Types/PackageDescription.hs +++ b/Cabal/Distribution/Types/PackageDescription.hs @@ -32,7 +32,6 @@ module Distribution.Types.PackageDescription ( specVersion', license, license', - descCabalVersion, buildType, emptyPackageDescription, hasPublicLib, @@ -190,18 +189,6 @@ license = license' . licenseRaw license' :: Either SPDX.License License -> SPDX.License license' = either id licenseToSPDX --- | The range of versions of the Cabal tools that this package is intended to --- work with. --- --- This function is deprecated and should not be used for new purposes, only to --- support old packages that rely on the old interpretation. --- -descCabalVersion :: PackageDescription -> VersionRange -descCabalVersion pkg = case specVersionRaw pkg of - Left version -> orLaterVersion version - Right versionRange -> versionRange -{-# DEPRECATED descCabalVersion "Use specVersion instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} - -- | The effective @build-type@ after applying defaulting rules. -- -- The original @build-type@ value parsed is stored in the diff --git a/Cabal/Distribution/Types/UnitId.hs b/Cabal/Distribution/Types/UnitId.hs index c040c15599d..464089d7b3c 100644 --- a/Cabal/Distribution/Types/UnitId.hs +++ b/Cabal/Distribution/Types/UnitId.hs @@ -11,7 +11,6 @@ module Distribution.Types.UnitId , newSimpleUnitId , mkLegacyUnitId , getHSLibraryName - , InstalledPackageId -- backwards compat ) where import Prelude () @@ -66,9 +65,6 @@ import Text.PrettyPrint (text) newtype UnitId = UnitId ShortText deriving (Generic, Read, Show, Eq, Ord, Typeable, Data, NFData) -{-# DEPRECATED InstalledPackageId "Use UnitId instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -type InstalledPackageId = UnitId - instance Binary UnitId -- | The textual format for 'UnitId' coincides with the format diff --git a/Cabal/Distribution/Types/Version.hs b/Cabal/Distribution/Types/Version.hs index 03da7f18f1d..0a0cd3effd4 100644 --- a/Cabal/Distribution/Types/Version.hs +++ b/Cabal/Distribution/Types/Version.hs @@ -10,9 +10,6 @@ module Distribution.Types.Version ( alterVersion, version0, - -- ** Backwards compatibility - showVersion, - -- * Internal validVersion, versionDigitParser, @@ -236,7 +233,3 @@ alterVersion f = mkVersion . f . versionNumbers -- internal helper validVersion :: Version -> Bool validVersion v = v /= nullVersion && all (>=0) (versionNumbers v) - -showVersion :: Version -> String -showVersion = prettyShow -{-# DEPRECATED showVersion "Use prettyShow. This function will be removed in Cabal-3.0 (estimated Mar 2019)" #-} diff --git a/Cabal/Distribution/Types/VersionRange.hs b/Cabal/Distribution/Types/VersionRange.hs index 23e1a7bdcbd..c95bc5b2566 100644 --- a/Cabal/Distribution/Types/VersionRange.hs +++ b/Cabal/Distribution/Types/VersionRange.hs @@ -1,13 +1,6 @@ -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE DeriveFoldable #-} -{-# LANGUAGE DeriveFunctor #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE DeriveTraversable #-} -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE ScopedTypeVariables #-} module Distribution.Types.VersionRange ( -- * Version ranges - VersionRange(..), + VersionRange, -- ** Constructing anyVersion, noVersion, @@ -45,208 +38,9 @@ module Distribution.Types.VersionRange ( import Distribution.Compat.Prelude import Distribution.Types.Version +import Distribution.Types.VersionRange.Internal import Prelude () -import Distribution.CabalSpecVersion -import Distribution.Parsec -import Distribution.Pretty -import Text.PrettyPrint ((<+>)) - -import qualified Distribution.Compat.CharParsing as P -import qualified Distribution.Compat.DList as DList -import qualified Text.PrettyPrint as Disp - -data VersionRange - = AnyVersion - | ThisVersion Version -- = version - | LaterVersion Version -- > version (NB. not >=) - | OrLaterVersion Version -- >= version - | EarlierVersion Version -- < version - | OrEarlierVersion Version -- <= version - | WildcardVersion Version -- == ver.* (same as >= ver && < ver+1) - | MajorBoundVersion Version -- @^>= ver@ (same as >= ver && < MAJ(ver)+1) - | UnionVersionRanges VersionRange VersionRange - | IntersectVersionRanges VersionRange VersionRange - | VersionRangeParens VersionRange -- just '(exp)' parentheses syntax - deriving (Data, Eq, Generic, Read, Show, Typeable) - -instance Binary VersionRange - -instance NFData VersionRange where rnf = genericRnf - -{-# DeprecateD AnyVersion - "Use 'anyVersion', 'foldVersionRange' or 'asVersionIntervals'" #-} -{-# DEPRECATED ThisVersion - "Use 'thisVersion', 'foldVersionRange' or 'asVersionIntervals'" #-} -{-# DEPRECATED LaterVersion - "Use 'laterVersion', 'foldVersionRange' or 'asVersionIntervals'" #-} -{-# DEPRECATED EarlierVersion - "Use 'earlierVersion', 'foldVersionRange' or 'asVersionIntervals'" #-} -{-# DEPRECATED WildcardVersion - "Use 'anyVersion', 'foldVersionRange' or 'asVersionIntervals'" #-} -{-# DEPRECATED UnionVersionRanges - "Use 'unionVersionRanges', 'foldVersionRange' or 'asVersionIntervals'" #-} -{-# DEPRECATED IntersectVersionRanges - "Use 'intersectVersionRanges', 'foldVersionRange' or 'asVersionIntervals'"#-} - --- | The version range @-any@. That is, a version range containing all --- versions. --- --- > withinRange v anyVersion = True --- -anyVersion :: VersionRange -anyVersion = AnyVersion - --- | The empty version range, that is a version range containing no versions. --- --- This can be constructed using any unsatisfiable version range expression, --- for example @> 1 && < 1@. --- --- > withinRange v noVersion = False --- -noVersion :: VersionRange -noVersion = IntersectVersionRanges (LaterVersion v) (EarlierVersion v) - where v = mkVersion [1] - --- | The version range @== v@ --- --- > withinRange v' (thisVersion v) = v' == v --- -thisVersion :: Version -> VersionRange -thisVersion = ThisVersion - --- | The version range @< v || > v@ --- --- > withinRange v' (notThisVersion v) = v' /= v --- -notThisVersion :: Version -> VersionRange -notThisVersion v = UnionVersionRanges (EarlierVersion v) (LaterVersion v) - --- | The version range @> v@ --- --- > withinRange v' (laterVersion v) = v' > v --- -laterVersion :: Version -> VersionRange -laterVersion = LaterVersion - --- | The version range @>= v@ --- --- > withinRange v' (orLaterVersion v) = v' >= v --- -orLaterVersion :: Version -> VersionRange -orLaterVersion = OrLaterVersion - --- | The version range @< v@ --- --- > withinRange v' (earlierVersion v) = v' < v --- -earlierVersion :: Version -> VersionRange -earlierVersion = EarlierVersion - --- | The version range @<= v@ --- --- > withinRange v' (orEarlierVersion v) = v' <= v --- -orEarlierVersion :: Version -> VersionRange -orEarlierVersion = OrEarlierVersion - --- | The version range @vr1 || vr2@ --- --- > withinRange v' (unionVersionRanges vr1 vr2) --- > = withinRange v' vr1 || withinRange v' vr2 --- -unionVersionRanges :: VersionRange -> VersionRange -> VersionRange -unionVersionRanges = UnionVersionRanges - --- | The version range @vr1 && vr2@ --- --- > withinRange v' (intersectVersionRanges vr1 vr2) --- > = withinRange v' vr1 && withinRange v' vr2 --- -intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange -intersectVersionRanges = IntersectVersionRanges - --- | The version range @== v.*@. --- --- For example, for version @1.2@, the version range @== 1.2.*@ is the same as --- @>= 1.2 && < 1.3@ --- --- > withinRange v' (laterVersion v) = v' >= v && v' < upper v --- > where --- > upper (Version lower t) = Version (init lower ++ [last lower + 1]) t --- -withinVersion :: Version -> VersionRange -withinVersion = WildcardVersion - --- | The version range @^>= v@. --- --- For example, for version @1.2.3.4@, the version range @^>= 1.2.3.4@ is the same as --- @>= 1.2.3.4 && < 1.3@. --- --- Note that @^>= 1@ is equivalent to @>= 1 && < 1.1@. --- --- @since 2.0.0.2 -majorBoundVersion :: Version -> VersionRange -majorBoundVersion = MajorBoundVersion - --- | F-Algebra of 'VersionRange'. See 'cataVersionRange'. --- --- @since 2.2 -data VersionRangeF a - = AnyVersionF - | ThisVersionF Version -- = version - | LaterVersionF Version -- > version (NB. not >=) - | OrLaterVersionF Version -- >= version - | EarlierVersionF Version -- < version - | OrEarlierVersionF Version -- <= version - | WildcardVersionF Version -- == ver.* (same as >= ver && < ver+1) - | MajorBoundVersionF Version -- @^>= ver@ (same as >= ver && < MAJ(ver)+1) - | UnionVersionRangesF a a - | IntersectVersionRangesF a a - | VersionRangeParensF a - deriving (Data, Eq, Generic, Read, Show, Typeable, Functor, Foldable, Traversable) - --- | @since 2.2 -projectVersionRange :: VersionRange -> VersionRangeF VersionRange -projectVersionRange AnyVersion = AnyVersionF -projectVersionRange (ThisVersion v) = ThisVersionF v -projectVersionRange (LaterVersion v) = LaterVersionF v -projectVersionRange (OrLaterVersion v) = OrLaterVersionF v -projectVersionRange (EarlierVersion v) = EarlierVersionF v -projectVersionRange (OrEarlierVersion v) = OrEarlierVersionF v -projectVersionRange (WildcardVersion v) = WildcardVersionF v -projectVersionRange (MajorBoundVersion v) = MajorBoundVersionF v -projectVersionRange (UnionVersionRanges a b) = UnionVersionRangesF a b -projectVersionRange (IntersectVersionRanges a b) = IntersectVersionRangesF a b -projectVersionRange (VersionRangeParens a) = VersionRangeParensF a - --- | Fold 'VersionRange'. --- --- @since 2.2 -cataVersionRange :: (VersionRangeF a -> a) -> VersionRange -> a -cataVersionRange f = c where c = f . fmap c . projectVersionRange - --- | @since 2.2 -embedVersionRange :: VersionRangeF VersionRange -> VersionRange -embedVersionRange AnyVersionF = AnyVersion -embedVersionRange (ThisVersionF v) = ThisVersion v -embedVersionRange (LaterVersionF v) = LaterVersion v -embedVersionRange (OrLaterVersionF v) = OrLaterVersion v -embedVersionRange (EarlierVersionF v) = EarlierVersion v -embedVersionRange (OrEarlierVersionF v) = OrEarlierVersion v -embedVersionRange (WildcardVersionF v) = WildcardVersion v -embedVersionRange (MajorBoundVersionF v) = MajorBoundVersion v -embedVersionRange (UnionVersionRangesF a b) = UnionVersionRanges a b -embedVersionRange (IntersectVersionRangesF a b) = IntersectVersionRanges a b -embedVersionRange (VersionRangeParensF a) = VersionRangeParens a - --- | Unfold 'VersionRange'. --- --- @since 2.2 -anaVersionRange :: (a -> VersionRangeF a) -> a -> VersionRange -anaVersionRange g = a where a = embedVersionRange . fmap a . g - - -- | Fold over the basic syntactic structure of a 'VersionRange'. -- -- This provides a syntactic view of the expression defining the version range. @@ -286,14 +80,6 @@ foldVersionRange anyv this later earlier union intersect = fold (orLaterVersion v) (earlierVersion (majorUpperBound v)) --- | Refold 'VersionRange' --- --- @since 2.2 -hyloVersionRange :: (VersionRangeF VersionRange -> VersionRange) - -> (VersionRange -> VersionRangeF VersionRange) - -> VersionRange -> VersionRange -hyloVersionRange f g = h where h = f . fmap h . g - -- | Normalise 'VersionRange'. -- -- In particular collapse @(== v || > v)@ into @>= v@, and so on. @@ -352,200 +138,6 @@ isWildcardRange ver1 ver2 = check (versionNumbers ver1) (versionNumbers ver2) check (n:ns) (m:ms) | n == m = check ns ms check _ _ = False --- | Compute next greater major version to be used as upper bound --- --- Example: @0.4.1@ produces the version @0.5@ which then can be used --- to construct a range @>= 0.4.1 && < 0.5@ --- --- @since 2.2 -majorUpperBound :: Version -> Version -majorUpperBound = alterVersion $ \numbers -> case numbers of - [] -> [0,1] -- should not happen - [m1] -> [m1,1] -- e.g. version '1' - (m1:m2:_) -> [m1,m2+1] - -------------------------------------------------------------------------------- --- Parsec & Pretty -------------------------------------------------------------------------------- - -instance Pretty VersionRange where - pretty = fst . cataVersionRange alg - where - alg AnyVersionF = (Disp.text "-any", 0 :: Int) - alg (ThisVersionF v) = (Disp.text "==" <<>> pretty v, 0) - alg (LaterVersionF v) = (Disp.char '>' <<>> pretty v, 0) - alg (OrLaterVersionF v) = (Disp.text ">=" <<>> pretty v, 0) - alg (EarlierVersionF v) = (Disp.char '<' <<>> pretty v, 0) - alg (OrEarlierVersionF v) = (Disp.text "<=" <<>> pretty v, 0) - alg (WildcardVersionF v) = (Disp.text "==" <<>> dispWild v, 0) - alg (MajorBoundVersionF v) = (Disp.text "^>=" <<>> pretty v, 0) - alg (UnionVersionRangesF (r1, p1) (r2, p2)) = - (punct 1 p1 r1 <+> Disp.text "||" <+> punct 2 p2 r2 , 2) - alg (IntersectVersionRangesF (r1, p1) (r2, p2)) = - (punct 0 p1 r1 <+> Disp.text "&&" <+> punct 1 p2 r2 , 1) - alg (VersionRangeParensF (r, _)) = - (Disp.parens r, 0) - - dispWild ver = - Disp.hcat (Disp.punctuate (Disp.char '.') (map Disp.int $ versionNumbers ver)) - <<>> Disp.text ".*" - - punct p p' | p < p' = Disp.parens - | otherwise = id - -instance Parsec VersionRange where - parsec = versionRangeParser versionDigitParser - --- | 'VersionRange' parser parametrised by version digit parser --- --- - 'versionDigitParser' is used for all 'VersionRange' --- - 'P.integral' is used for backward-compat @pkgconfig-depends@ versions, 'PkgConfigVersionRange'. --- --- @since 3.0 -versionRangeParser :: forall m. CabalParsing m => m Int -> m VersionRange -versionRangeParser digitParser = expr - where - expr = do P.spaces - t <- term - P.spaces - (do _ <- P.string "||" - P.spaces - e <- expr - return (unionVersionRanges t e) - <|> - return t) - term = do f <- factor - P.spaces - (do _ <- P.string "&&" - P.spaces - t <- term - return (intersectVersionRanges f t) - <|> - return f) - factor = parens expr <|> prim - - prim = do - op <- P.munch1 (`elem` "<>=^-") P. "operator" - case op of - "-" -> anyVersion <$ P.string "any" <|> P.string "none" *> noVersion' - - "==" -> do - P.spaces - (do (wild, v) <- verOrWild - pure $ (if wild then withinVersion else thisVersion) v - <|> - (verSet' thisVersion =<< verSet)) - - "^>=" -> do - P.spaces - (do (wild, v) <- verOrWild - when wild $ P.unexpected $ - "wild-card version after ^>= operator" - majorBoundVersion' v - <|> - (verSet' majorBoundVersion =<< verSet)) - - _ -> do - P.spaces - (wild, v) <- verOrWild - when wild $ P.unexpected $ - "wild-card version after non-== operator: " ++ show op - case op of - ">=" -> pure $ orLaterVersion v - "<" -> pure $ earlierVersion v - "<=" -> pure $ orEarlierVersion v - ">" -> pure $ laterVersion v - _ -> fail $ "Unknown version operator " ++ show op - - -- Note: There are other features: - -- && and || since 1.8 - -- x.y.* (wildcard) since 1.6 - - -- -none version range is available since 1.22 - noVersion' = do - csv <- askCabalSpecVersion - if csv >= CabalSpecV1_22 - then pure noVersion - else fail $ unwords - [ "-none version range used." - , "To use this syntax the package needs to specify at least 'cabal-version: 1.22'." - , "Alternatively, if broader compatibility is important then use" - , "<0 or other empty range." - ] - - -- ^>= is available since 2.0 - majorBoundVersion' v = do - csv <- askCabalSpecVersion - if csv >= CabalSpecV2_0 - then pure $ majorBoundVersion v - else fail $ unwords - [ "major bounded version syntax (caret, ^>=) used." - , "To use this syntax the package need to specify at least 'cabal-version: 2.0'." - , "Alternatively, if broader compatibility is important then use:" - , prettyShow $ eliminateMajorBoundSyntax $ majorBoundVersion v - ] - where - eliminateMajorBoundSyntax = hyloVersionRange embed projectVersionRange - embed (MajorBoundVersionF u) = intersectVersionRanges - (orLaterVersion u) (earlierVersion (majorUpperBound u)) - embed vr = embedVersionRange vr - - -- version set notation (e.g. "== { 0.0.1.0, 0.0.2.0, 0.1.0.0 }") - verSet' op vs = do - csv <- askCabalSpecVersion - if csv >= CabalSpecV3_0 - then pure $ foldr1 unionVersionRanges (map op vs) - else fail $ unwords - [ "version set syntax used." - , "To use this syntax the package needs to specify at least 'cabal-version: 3.0'." - , "Alternatively, if broader compatibility is important then use" - , "a series of single version constraints joined with the || operator:" - , prettyShow (foldr1 unionVersionRanges (map op vs)) - ] - - verSet :: CabalParsing m => m [Version] - verSet = do - _ <- P.char '{' - P.spaces - vs <- P.sepBy1 (verPlain <* P.spaces) (P.char ',' *> P.spaces) - _ <- P.char '}' - pure vs - - -- a plain version without tags or wildcards - verPlain :: CabalParsing m => m Version - verPlain = mkVersion <$> P.sepBy1 digitParser (P.char '.') - - -- either wildcard or normal version - verOrWild :: CabalParsing m => m (Bool, Version) - verOrWild = do - x <- digitParser - verLoop (DList.singleton x) - - -- trailing: wildcard (.y.*) or normal version (optional tags) (.y.z-tag) - verLoop :: CabalParsing m => DList.DList Int -> m (Bool, Version) - verLoop acc = verLoop' acc <|> (tags *> pure (False, mkVersion (DList.toList acc))) - - verLoop' :: CabalParsing m => DList.DList Int -> m (Bool, Version) - verLoop' acc = do - _ <- P.char '.' - let digit = digitParser >>= verLoop . DList.snoc acc - let wild = (True, mkVersion (DList.toList acc)) <$ P.char '*' - digit <|> wild - - parens p = P.between - ((P.char '(' P. "opening paren") >> P.spaces) - (P.char ')' >> P.spaces) - (do a <- p - P.spaces - return (VersionRangeParens a)) - - tags :: CabalParsing m => m () - tags = do - ts <- many $ P.char '-' *> some (P.satisfy isAlphaNum) - case ts of - [] -> pure () - (_ : _) -> parsecWarning PWTVersionTag "version with tags" - -- | Does the version range have an upper bound? -- -- @since 1.24.0.0 diff --git a/Cabal/Distribution/Types/VersionRange/Internal.hs b/Cabal/Distribution/Types/VersionRange/Internal.hs new file mode 100644 index 00000000000..93828a4d4d9 --- /dev/null +++ b/Cabal/Distribution/Types/VersionRange/Internal.hs @@ -0,0 +1,433 @@ +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveFoldable #-} +{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE ScopedTypeVariables #-} + +-- | The only purpose of this module is to prevent the export of +-- 'VersionRange' constructors from +-- 'Distribution.Types.VersionRange'. To avoid creating orphan +-- instances, a lot of related code had to be moved here too. + +module Distribution.Types.VersionRange.Internal + ( VersionRange(..) + , anyVersion, noVersion + , thisVersion, notThisVersion + , laterVersion, earlierVersion + , orLaterVersion, orEarlierVersion + , unionVersionRanges, intersectVersionRanges + , withinVersion + , majorBoundVersion + + , VersionRangeF(..) + , projectVersionRange + , embedVersionRange + , cataVersionRange + , anaVersionRange + , hyloVersionRange + , versionRangeParser + + , majorUpperBound + ) where + +import Distribution.Compat.Prelude +import Distribution.Types.Version +import Prelude () + +import Distribution.CabalSpecVersion +import Distribution.Parsec +import Distribution.Pretty +import Text.PrettyPrint ((<+>)) + +import qualified Distribution.Compat.CharParsing as P +import qualified Distribution.Compat.DList as DList +import qualified Text.PrettyPrint as Disp + +data VersionRange + = AnyVersion + | ThisVersion Version -- = version + | LaterVersion Version -- > version (NB. not >=) + | OrLaterVersion Version -- >= version + | EarlierVersion Version -- < version + | OrEarlierVersion Version -- <= version + | WildcardVersion Version -- == ver.* (same as >= ver && < ver+1) + | MajorBoundVersion Version -- @^>= ver@ (same as >= ver && < MAJ(ver)+1) + | UnionVersionRanges VersionRange VersionRange + | IntersectVersionRanges VersionRange VersionRange + | VersionRangeParens VersionRange -- just '(exp)' parentheses syntax + deriving ( Data, Eq, Generic, Read, Show, Typeable ) + +instance Binary VersionRange + +instance NFData VersionRange where rnf = genericRnf + +-- | The version range @-any@. That is, a version range containing all +-- versions. +-- +-- > withinRange v anyVersion = True +-- +anyVersion :: VersionRange +anyVersion = AnyVersion + +-- | The empty version range, that is a version range containing no versions. +-- +-- This can be constructed using any unsatisfiable version range expression, +-- for example @> 1 && < 1@. +-- +-- > withinRange v noVersion = False +-- +noVersion :: VersionRange +noVersion = IntersectVersionRanges (LaterVersion v) (EarlierVersion v) + where v = mkVersion [1] + +-- | The version range @== v@ +-- +-- > withinRange v' (thisVersion v) = v' == v +-- +thisVersion :: Version -> VersionRange +thisVersion = ThisVersion + +-- | The version range @< v || > v@ +-- +-- > withinRange v' (notThisVersion v) = v' /= v +-- +notThisVersion :: Version -> VersionRange +notThisVersion v = UnionVersionRanges (EarlierVersion v) (LaterVersion v) + +-- | The version range @> v@ +-- +-- > withinRange v' (laterVersion v) = v' > v +-- +laterVersion :: Version -> VersionRange +laterVersion = LaterVersion + +-- | The version range @>= v@ +-- +-- > withinRange v' (orLaterVersion v) = v' >= v +-- +orLaterVersion :: Version -> VersionRange +orLaterVersion = OrLaterVersion + +-- | The version range @< v@ +-- +-- > withinRange v' (earlierVersion v) = v' < v +-- +earlierVersion :: Version -> VersionRange +earlierVersion = EarlierVersion + +-- | The version range @<= v@ +-- +-- > withinRange v' (orEarlierVersion v) = v' <= v +-- +orEarlierVersion :: Version -> VersionRange +orEarlierVersion = OrEarlierVersion + +-- | The version range @vr1 || vr2@ +-- +-- > withinRange v' (unionVersionRanges vr1 vr2) +-- > = withinRange v' vr1 || withinRange v' vr2 +-- +unionVersionRanges :: VersionRange -> VersionRange -> VersionRange +unionVersionRanges = UnionVersionRanges + +-- | The version range @vr1 && vr2@ +-- +-- > withinRange v' (intersectVersionRanges vr1 vr2) +-- > = withinRange v' vr1 && withinRange v' vr2 +-- +intersectVersionRanges :: VersionRange -> VersionRange -> VersionRange +intersectVersionRanges = IntersectVersionRanges + +-- | The version range @== v.*@. +-- +-- For example, for version @1.2@, the version range @== 1.2.*@ is the same as +-- @>= 1.2 && < 1.3@ +-- +-- > withinRange v' (laterVersion v) = v' >= v && v' < upper v +-- > where +-- > upper (Version lower t) = Version (init lower ++ [last lower + 1]) t +-- +withinVersion :: Version -> VersionRange +withinVersion = WildcardVersion + +-- | The version range @^>= v@. +-- +-- For example, for version @1.2.3.4@, the version range @^>= 1.2.3.4@ +-- is the same as @>= 1.2.3.4 && < 1.3@. +-- +-- Note that @^>= 1@ is equivalent to @>= 1 && < 1.1@. +-- +-- @since 2.0.0.2 +majorBoundVersion :: Version -> VersionRange +majorBoundVersion = MajorBoundVersion + + +-- | F-Algebra of 'VersionRange'. See 'cataVersionRange'. +-- +-- @since 2.2 +data VersionRangeF a + = AnyVersionF + | ThisVersionF Version -- = version + | LaterVersionF Version -- > version (NB. not >=) + | OrLaterVersionF Version -- >= version + | EarlierVersionF Version -- < version + | OrEarlierVersionF Version -- <= version + | WildcardVersionF Version -- == ver.* (same as >= ver && < ver+1) + | MajorBoundVersionF Version -- @^>= ver@ (same as >= ver && < MAJ(ver)+1) + | UnionVersionRangesF a a + | IntersectVersionRangesF a a + | VersionRangeParensF a + deriving ( Data, Eq, Generic, Read, Show, Typeable + , Functor, Foldable, Traversable ) + +-- | @since 2.2 +projectVersionRange :: VersionRange -> VersionRangeF VersionRange +projectVersionRange AnyVersion = AnyVersionF +projectVersionRange (ThisVersion v) = ThisVersionF v +projectVersionRange (LaterVersion v) = LaterVersionF v +projectVersionRange (OrLaterVersion v) = OrLaterVersionF v +projectVersionRange (EarlierVersion v) = EarlierVersionF v +projectVersionRange (OrEarlierVersion v) = OrEarlierVersionF v +projectVersionRange (WildcardVersion v) = WildcardVersionF v +projectVersionRange (MajorBoundVersion v) = MajorBoundVersionF v +projectVersionRange (UnionVersionRanges a b) = UnionVersionRangesF a b +projectVersionRange (IntersectVersionRanges a b) = IntersectVersionRangesF a b +projectVersionRange (VersionRangeParens a) = VersionRangeParensF a + +-- | Fold 'VersionRange'. +-- +-- @since 2.2 +cataVersionRange :: (VersionRangeF a -> a) -> VersionRange -> a +cataVersionRange f = c where c = f . fmap c . projectVersionRange + +-- | @since 2.2 +embedVersionRange :: VersionRangeF VersionRange -> VersionRange +embedVersionRange AnyVersionF = AnyVersion +embedVersionRange (ThisVersionF v) = ThisVersion v +embedVersionRange (LaterVersionF v) = LaterVersion v +embedVersionRange (OrLaterVersionF v) = OrLaterVersion v +embedVersionRange (EarlierVersionF v) = EarlierVersion v +embedVersionRange (OrEarlierVersionF v) = OrEarlierVersion v +embedVersionRange (WildcardVersionF v) = WildcardVersion v +embedVersionRange (MajorBoundVersionF v) = MajorBoundVersion v +embedVersionRange (UnionVersionRangesF a b) = UnionVersionRanges a b +embedVersionRange (IntersectVersionRangesF a b) = IntersectVersionRanges a b +embedVersionRange (VersionRangeParensF a) = VersionRangeParens a + +-- | Unfold 'VersionRange'. +-- +-- @since 2.2 +anaVersionRange :: (a -> VersionRangeF a) -> a -> VersionRange +anaVersionRange g = a where a = embedVersionRange . fmap a . g + +-- | Refold 'VersionRange' +-- +-- @since 2.2 +hyloVersionRange :: (VersionRangeF VersionRange -> VersionRange) + -> (VersionRange -> VersionRangeF VersionRange) + -> VersionRange -> VersionRange +hyloVersionRange f g = h where h = f . fmap h . g + +------------------------------------------------------------------------------- +-- Parsec & Pretty +------------------------------------------------------------------------------- + +instance Pretty VersionRange where + pretty = fst . cataVersionRange alg + where + alg AnyVersionF = (Disp.text "-any", 0 :: Int) + alg (ThisVersionF v) = (Disp.text "==" <<>> pretty v, 0) + alg (LaterVersionF v) = (Disp.char '>' <<>> pretty v, 0) + alg (OrLaterVersionF v) = (Disp.text ">=" <<>> pretty v, 0) + alg (EarlierVersionF v) = (Disp.char '<' <<>> pretty v, 0) + alg (OrEarlierVersionF v) = (Disp.text "<=" <<>> pretty v, 0) + alg (WildcardVersionF v) = (Disp.text "==" <<>> dispWild v, 0) + alg (MajorBoundVersionF v) = (Disp.text "^>=" <<>> pretty v, 0) + alg (UnionVersionRangesF (r1, p1) (r2, p2)) = + (punct 1 p1 r1 <+> Disp.text "||" <+> punct 2 p2 r2 , 2) + alg (IntersectVersionRangesF (r1, p1) (r2, p2)) = + (punct 0 p1 r1 <+> Disp.text "&&" <+> punct 1 p2 r2 , 1) + alg (VersionRangeParensF (r, _)) = + (Disp.parens r, 0) + + dispWild ver = + Disp.hcat (Disp.punctuate (Disp.char '.') + (map Disp.int $ versionNumbers ver)) + <<>> Disp.text ".*" + + punct p p' | p < p' = Disp.parens + | otherwise = id + +instance Parsec VersionRange where + parsec = versionRangeParser versionDigitParser + +-- | 'VersionRange' parser parametrised by version digit parser +-- +-- - 'versionDigitParser' is used for all 'VersionRange'. +-- - 'P.integral' is used for backward-compat @pkgconfig-depends@ +-- versions, 'PkgConfigVersionRange'. +-- +-- @since 3.0 +versionRangeParser :: forall m. CabalParsing m => m Int -> m VersionRange +versionRangeParser digitParser = expr + where + expr = do P.spaces + t <- term + P.spaces + (do _ <- P.string "||" + P.spaces + e <- expr + return (unionVersionRanges t e) + <|> + return t) + term = do f <- factor + P.spaces + (do _ <- P.string "&&" + P.spaces + t <- term + return (intersectVersionRanges f t) + <|> + return f) + factor = parens expr <|> prim + + prim = do + op <- P.munch1 (`elem` "<>=^-") P. "operator" + case op of + "-" -> anyVersion <$ P.string "any" <|> P.string "none" *> noVersion' + + "==" -> do + P.spaces + (do (wild, v) <- verOrWild + pure $ (if wild then withinVersion else thisVersion) v + <|> + (verSet' thisVersion =<< verSet)) + + "^>=" -> do + P.spaces + (do (wild, v) <- verOrWild + when wild $ P.unexpected $ + "wild-card version after ^>= operator" + majorBoundVersion' v + <|> + (verSet' majorBoundVersion =<< verSet)) + + _ -> do + P.spaces + (wild, v) <- verOrWild + when wild $ P.unexpected $ + "wild-card version after non-== operator: " ++ show op + case op of + ">=" -> pure $ orLaterVersion v + "<" -> pure $ earlierVersion v + "<=" -> pure $ orEarlierVersion v + ">" -> pure $ laterVersion v + _ -> fail $ "Unknown version operator " ++ show op + + -- Note: There are other features: + -- && and || since 1.8 + -- x.y.* (wildcard) since 1.6 + + -- -none version range is available since 1.22 + noVersion' = do + csv <- askCabalSpecVersion + if csv >= CabalSpecV1_22 + then pure noVersion + else fail $ unwords + [ "-none version range used." + , "To use this syntax the package needs to specify at least 'cabal-version: 1.22'." + , "Alternatively, if broader compatibility is important then use" + , "<0 or other empty range." + ] + + -- ^>= is available since 2.0 + majorBoundVersion' v = do + csv <- askCabalSpecVersion + if csv >= CabalSpecV2_0 + then pure $ majorBoundVersion v + else fail $ unwords + [ "major bounded version syntax (caret, ^>=) used." + , "To use this syntax the package need to specify at least 'cabal-version: 2.0'." + , "Alternatively, if broader compatibility is important then use:" + , prettyShow $ eliminateMajorBoundSyntax $ majorBoundVersion v + ] + where + eliminateMajorBoundSyntax = hyloVersionRange embed projectVersionRange + embed (MajorBoundVersionF u) = intersectVersionRanges + (orLaterVersion u) (earlierVersion (majorUpperBound u)) + embed vr = embedVersionRange vr + + -- version set notation (e.g. "== { 0.0.1.0, 0.0.2.0, 0.1.0.0 }") + verSet' op vs = do + csv <- askCabalSpecVersion + if csv >= CabalSpecV3_0 + then pure $ foldr1 unionVersionRanges (map op vs) + else fail $ unwords + [ "version set syntax used." + , "To use this syntax the package needs to specify at least 'cabal-version: 3.0'." + , "Alternatively, if broader compatibility is important then use" + , "a series of single version constraints joined with the || operator:" + , prettyShow (foldr1 unionVersionRanges (map op vs)) + ] + + verSet :: CabalParsing m => m [Version] + verSet = do + _ <- P.char '{' + P.spaces + vs <- P.sepBy1 (verPlain <* P.spaces) (P.char ',' *> P.spaces) + _ <- P.char '}' + pure vs + + -- a plain version without tags or wildcards + verPlain :: CabalParsing m => m Version + verPlain = mkVersion <$> P.sepBy1 digitParser (P.char '.') + + -- either wildcard or normal version + verOrWild :: CabalParsing m => m (Bool, Version) + verOrWild = do + x <- digitParser + verLoop (DList.singleton x) + + -- trailing: wildcard (.y.*) or normal version (optional tags) (.y.z-tag) + verLoop :: CabalParsing m => DList.DList Int -> m (Bool, Version) + verLoop acc = verLoop' acc + <|> (tags *> pure (False, mkVersion (DList.toList acc))) + + verLoop' :: CabalParsing m => DList.DList Int -> m (Bool, Version) + verLoop' acc = do + _ <- P.char '.' + let digit = digitParser >>= verLoop . DList.snoc acc + let wild = (True, mkVersion (DList.toList acc)) <$ P.char '*' + digit <|> wild + + parens p = P.between + ((P.char '(' P. "opening paren") >> P.spaces) + (P.char ')' >> P.spaces) + (do a <- p + P.spaces + return (VersionRangeParens a)) + + tags :: CabalParsing m => m () + tags = do + ts <- many $ P.char '-' *> some (P.satisfy isAlphaNum) + case ts of + [] -> pure () + (_ : _) -> parsecWarning PWTVersionTag "version with tags" + + +---------------------------- +-- Wildcard range utilities +-- + +-- | Compute next greater major version to be used as upper bound +-- +-- Example: @0.4.1@ produces the version @0.5@ which then can be used +-- to construct a range @>= 0.4.1 && < 0.5@ +-- +-- @since 2.2 +majorUpperBound :: Version -> Version +majorUpperBound = alterVersion $ \numbers -> case numbers of + [] -> [0,1] -- should not happen + [m1] -> [m1,1] -- e.g. version '1' + (m1:m2:_) -> [m1,m2+1] diff --git a/Cabal/Distribution/Version.hs b/Cabal/Distribution/Version.hs index 9beb9385861..06571b7fd0a 100644 --- a/Cabal/Distribution/Version.hs +++ b/Cabal/Distribution/Version.hs @@ -22,11 +22,8 @@ module Distribution.Version ( nullVersion, alterVersion, - -- ** Backwards compatibility - showVersion, - -- * Version ranges - VersionRange(..), + VersionRange, -- ** Constructing anyVersion, noVersion, @@ -38,7 +35,6 @@ module Distribution.Version ( invertVersionRange, withinVersion, majorBoundVersion, - betweenVersionsInclusive, -- ** Inspection withinRange, @@ -47,7 +43,6 @@ module Distribution.Version ( isSpecificVersion, simplifyVersionRange, foldVersionRange, - foldVersionRange', normaliseVersionRange, stripParensVersionRange, hasUpperBound, @@ -198,65 +193,3 @@ removeUpperBound = fromVersionIntervals . relaxLastInterval . toVersionIntervals -- @(>= 0 && < 3) || (>= 4 && < 5)@. removeLowerBound :: VersionRange -> VersionRange removeLowerBound = fromVersionIntervals . relaxHeadInterval . toVersionIntervals - -------------------------------------------------------------------------------- --- Deprecated -------------------------------------------------------------------------------- - --- In practice this is not very useful because we normally use inclusive lower --- bounds and exclusive upper bounds. --- --- > withinRange v' (laterVersion v) = v' > v --- -betweenVersionsInclusive :: Version -> Version -> VersionRange -betweenVersionsInclusive v1 v2 = - intersectVersionRanges (orLaterVersion v1) (orEarlierVersion v2) - -{-# DEPRECATED betweenVersionsInclusive - "In practice this is not very useful because we normally use inclusive lower bounds and exclusive upper bounds" #-} - - - - --- | An extended variant of 'foldVersionRange' that also provides a view of the --- expression in which the syntactic sugar @\">= v\"@, @\"<= v\"@ and @\"== --- v.*\"@ is presented explicitly rather than in terms of the other basic --- syntax. --- -foldVersionRange' :: a -- ^ @\"-any\"@ version - -> (Version -> a) -- ^ @\"== v\"@ - -> (Version -> a) -- ^ @\"> v\"@ - -> (Version -> a) -- ^ @\"< v\"@ - -> (Version -> a) -- ^ @\">= v\"@ - -> (Version -> a) -- ^ @\"<= v\"@ - -> (Version -> Version -> a) -- ^ @\"== v.*\"@ wildcard. The - -- function is passed the - -- inclusive lower bound and the - -- exclusive upper bounds of the - -- range defined by the wildcard. - -> (Version -> Version -> a) -- ^ @\"^>= v\"@ major upper bound - -- The function is passed the - -- inclusive lower bound and the - -- exclusive major upper bounds - -- of the range defined by this - -- operator. - -> (a -> a -> a) -- ^ @\"_ || _\"@ union - -> (a -> a -> a) -- ^ @\"_ && _\"@ intersection - -> (a -> a) -- ^ @\"(_)\"@ parentheses - -> VersionRange -> a -foldVersionRange' anyv this later earlier orLater orEarlier - wildcard major union intersect parens = - cataVersionRange alg . normaliseVersionRange - where - alg AnyVersionF = anyv - alg (ThisVersionF v) = this v - alg (LaterVersionF v) = later v - alg (EarlierVersionF v) = earlier v - alg (OrLaterVersionF v) = orLater v - alg (OrEarlierVersionF v) = orEarlier v - alg (WildcardVersionF v) = wildcard v (wildcardUpperBound v) - alg (MajorBoundVersionF v) = major v (majorUpperBound v) - alg (UnionVersionRangesF v1 v2) = union v1 v2 - alg (IntersectVersionRangesF v1 v2) = intersect v1 v2 - alg (VersionRangeParensF v) = parens v -{-# DEPRECATED foldVersionRange' "Use cataVersionRange & normaliseVersionRange for more principled folding" #-} diff --git a/Cabal/Language/Haskell/Extension.hs b/Cabal/Language/Haskell/Extension.hs index 4eccbf29eae..0372b21ec75 100644 --- a/Cabal/Language/Haskell/Extension.hs +++ b/Cabal/Language/Haskell/Extension.hs @@ -19,7 +19,6 @@ module Language.Haskell.Extension ( Extension(..), KnownExtension(..), - knownExtensions, deprecatedExtensions, classifyExtension, ) where @@ -829,11 +828,6 @@ instance Binary KnownExtension instance NFData KnownExtension where rnf = genericRnf -{-# DEPRECATED knownExtensions - "KnownExtension is an instance of Enum and Bounded, use those instead. This symbol will be removed in Cabal-3.0 (est. Mar 2019)." #-} -knownExtensions :: [KnownExtension] -knownExtensions = [minBound..maxBound] - -- | Extensions that have been deprecated, possibly paired with another -- extension that replaces it. -- diff --git a/Cabal/tests/UnitTests/Distribution/Version.hs b/Cabal/tests/UnitTests/Distribution/Version.hs index 5b382008adf..f090997eba9 100644 --- a/Cabal/tests/UnitTests/Distribution/Version.hs +++ b/Cabal/tests/UnitTests/Distribution/Version.hs @@ -9,6 +9,7 @@ import Distribution.Compat.Prelude.Internal import Prelude () import Distribution.Version +import Distribution.Types.VersionRange.Internal import Distribution.Parsec (simpleParsec) import Distribution.Pretty @@ -69,7 +70,6 @@ versionTests = , typProperty prop_invertVersionRange , typProperty prop_withinVersion , typProperty prop_foldVersionRange - , typProperty prop_foldVersionRange' -- the semantic query functions --, typProperty prop_isAnyVersion1 --FIXME: runs out of test cases @@ -344,19 +344,6 @@ prop_foldVersionRange range = upper = alterVersion $ \numbers -> init numbers ++ [last numbers + 1] -prop_foldVersionRange' :: VersionRange -> Property -prop_foldVersionRange' range = - normaliseVersionRange srange - === foldVersionRange' anyVersion thisVersion - laterVersion earlierVersion - orLaterVersion orEarlierVersion - (\v _ -> withinVersion v) - (\v _ -> majorBoundVersion v) - unionVersionRanges intersectVersionRanges id - srange - where - srange = stripParensVersionRange range - prop_isAnyVersion1 :: VersionRange -> Version -> Property prop_isAnyVersion1 range version = isAnyVersion range ==> withinRange version range @@ -750,21 +737,24 @@ prop_parse_disp5 vr = displayRaw :: VersionRange -> String displayRaw = Disp.render - . foldVersionRange' -- precedence: - -- All the same as the usual pretty printer, except for the parens - ( Disp.text "-any") - (\v -> Disp.text "==" <<>> pretty v) - (\v -> Disp.char '>' <<>> pretty v) - (\v -> Disp.char '<' <<>> pretty v) - (\v -> Disp.text ">=" <<>> pretty v) - (\v -> Disp.text "<=" <<>> pretty v) - (\v _ -> Disp.text "==" <<>> dispWild v) - (\v _ -> Disp.text "^>=" <<>> pretty v) - (\r1 r2 -> r1 <+> Disp.text "||" <+> r2) - (\r1 r2 -> r1 <+> Disp.text "&&" <+> r2) - (\r -> Disp.parens r) -- parens - + . cataVersionRange alg . normaliseVersionRange where + + -- precedence: + -- All the same as the usual pretty printer, except for the parens + alg AnyVersionF = Disp.text "-any" + alg (ThisVersionF v) = Disp.text "==" <<>> pretty v + alg (LaterVersionF v) = Disp.char '>' <<>> pretty v + alg (EarlierVersionF v) = Disp.char '<' <<>> pretty v + alg (OrLaterVersionF v) = Disp.text ">=" <<>> pretty v + alg (OrEarlierVersionF v) = Disp.text "<=" <<>> pretty v + alg (WildcardVersionF v) = Disp.text "==" <<>> dispWild v + alg (MajorBoundVersionF v) = Disp.text "^>=" <<>> pretty v + alg (UnionVersionRangesF r1 r2) = r1 <+> Disp.text "||" <+> r2 + alg (IntersectVersionRangesF r1 r2) = r1 <+> Disp.text "&&" <+> r2 + alg (VersionRangeParensF r) = Disp.parens r -- parens + + dispWild v = Disp.hcat (Disp.punctuate (Disp.char '.') (map Disp.int (versionNumbers v))) diff --git a/Cabal/tests/custom-setup/CabalDoctestSetup.hs b/Cabal/tests/custom-setup/CabalDoctestSetup.hs index 7e064ab2ed0..1e20f264c37 100644 --- a/Cabal/tests/custom-setup/CabalDoctestSetup.hs +++ b/Cabal/tests/custom-setup/CabalDoctestSetup.hs @@ -94,10 +94,6 @@ import qualified Data.Foldable as F (for_) import qualified Data.Traversable as T (traverse) -import qualified Distribution.ModuleName as ModuleName - (fromString) -import Distribution.ModuleName - (ModuleName) import Distribution.Package (InstalledPackageId) import Distribution.Package @@ -107,8 +103,10 @@ import Distribution.PackageDescription PackageDescription (), TestSuite (..)) import Distribution.Simple (UserHooks (..), autoconfUserHooks, defaultMainWithHooks, simpleUserHooks) +#if !MIN_VERSION_Cabal(1,25,0) import Distribution.Simple.BuildPaths (autogenModulesDir) +#endif import Distribution.Simple.Compiler (PackageDB (..), showCompilerId) import Distribution.Simple.LocalBuildInfo @@ -117,11 +115,11 @@ import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Setup (BuildFlags (buildDistPref, buildVerbosity), fromFlag) import Distribution.Simple.Utils - (createDirectoryIfMissingVerbose, findFile, rewriteFile) + (createDirectoryIfMissingVerbose) import Distribution.Text (display, simpleParse) import System.FilePath - ((), (<.>), dropExtension) + (()) import Data.IORef (newIORef, modifyIORef, readIORef) @@ -136,6 +134,14 @@ import Distribution.Types.UnqualComponentName (unUnqualComponentName) #endif +#if MIN_VERSION_Cabal(3,0,0) +import Distribution.Simple.Utils + (findFileEx) +#else +import Distribution.Simple.Utils + (findFile) +#endif + #if MIN_VERSION_Cabal(2,5,0) import Distribution.Types.LibraryName (libraryNameString) @@ -157,6 +163,15 @@ makeAbsolute p | isAbsolute p = return p return $ cwd p #endif +#if !MIN_VERSION_Cabal(3,0,0) +findFileEx :: Verbosity + -> [FilePath] -- ^search locations + -> FilePath -- ^File Name + -> IO FilePath +findFileEx _verbosity = findFile +#endif + + -- | A default main with doctests: -- -- @ @@ -328,7 +343,7 @@ generateBuildModule testSuiteName flags pkg lbi = do -- even though the main-is module is named Main, its filepath might -- actually be Something.hs. To account for this possibility, we simply -- pass the full path to the main-is module instead. - mainIsPath <- T.traverse (findFile iArgsNoPrefix) (compMainIs comp) + mainIsPath <- T.traverse (findFileEx verbosity iArgsNoPrefix) (compMainIs comp) let all_sources = map display module_sources ++ additionalModules @@ -356,7 +371,7 @@ generateBuildModule testSuiteName flags pkg lbi = do getBuildDoctests withExeLBI (NameExe . executableName) (const []) (Just . modulePath) buildInfo components <- readIORef componentsRef - F.for_ components $ \(Component name pkgs flags sources) -> do + F.for_ components $ \(Component name pkgs flags' sources) -> do let compSuffix = nameToString name pkgs_comp = "pkgs" ++ compSuffix flags_comp = "flags" ++ compSuffix @@ -369,7 +384,7 @@ generateBuildModule testSuiteName flags pkg lbi = do , pkgs_comp ++ " = " ++ show pkgs , "" , flags_comp ++ " :: [String]" - , flags_comp ++ " = " ++ show flags + , flags_comp ++ " = " ++ show flags' , "" , module_sources_comp ++ " :: [String]" , module_sources_comp ++ " = " ++ show sources diff --git a/Cabal/tests/custom-setup/IdrisSetup.hs b/Cabal/tests/custom-setup/IdrisSetup.hs index b26b0038c7d..0c3ce2d3854 100644 --- a/Cabal/tests/custom-setup/IdrisSetup.hs +++ b/Cabal/tests/custom-setup/IdrisSetup.hs @@ -60,7 +60,8 @@ import Distribution.Simple.InstallDirs as I import Distribution.Simple.LocalBuildInfo as L import qualified Distribution.Simple.Setup as S import qualified Distribution.Simple.Program as P -import Distribution.Simple.Utils (createDirectoryIfMissingVerbose, rewriteFile, notice, installOrdinaryFiles) +import Distribution.Simple.Utils (createDirectoryIfMissingVerbose, notice, installOrdinaryFiles) +import Distribution.Simple.Utils (rewriteFileEx) import Distribution.Compiler import Distribution.PackageDescription import Distribution.Text @@ -177,7 +178,7 @@ generateVersionModule verbosity dir release = do putStrLn $ "Generating " ++ versionModulePath ++ if release then " for release" else " for prerelease " ++ hash createDirectoryIfMissingVerbose verbosity True dir - rewriteFile versionModulePath (versionModuleContents hash) + rewriteFileEx verbosity versionModulePath (versionModuleContents hash) where versionModuleContents h = "module Version_idris where\n\n" ++ "gitHash :: String\n" ++ @@ -191,7 +192,7 @@ generateTargetModule verbosity dir targetDir = do let targetModulePath = dir "Target_idris" Px.<.> "hs" putStrLn $ "Generating " ++ targetModulePath createDirectoryIfMissingVerbose verbosity True dir - rewriteFile targetModulePath (versionModuleContents absPath targetDir) + rewriteFileEx verbosity targetModulePath (versionModuleContents absPath targetDir) where versionModuleContents absolute td = "module Target_idris where\n\n" ++ "import System.FilePath\n" ++ "import System.Environment\n" ++ @@ -217,7 +218,7 @@ generateToolchainModule verbosity srcDir toolDir = do "getToolchainDir = \"\"" let toolPath = srcDir "Tools_idris" Px.<.> "hs" createDirectoryIfMissingVerbose verbosity True srcDir - rewriteFile toolPath (commonContent ++ toolContent) + rewriteFileEx verbosity toolPath (commonContent ++ toolContent) idrisConfigure _ flags pkgdesc local = do configureRTS @@ -249,6 +250,7 @@ idrisConfigure _ flags pkgdesc local = do autogenComponentModulesDir lbi _ = autogenModulesDir lbi #endif +#if !MIN_VERSION_Cabal(3,0,0) idrisPreSDist args flags = do let dir = S.fromFlag (S.sDistDirectory flags) let verb = S.fromFlag (S.sDistVerbosity flags) @@ -277,6 +279,7 @@ idrisPostSDist args flags desc lbi = do removeFile targetFile) (\e -> let e' = (e :: SomeException) in return ()) postSDist simpleUserHooks args flags desc lbi +#endif -- ----------------------------------------------------------------------------- -- Build @@ -376,8 +379,10 @@ main = defaultMainWithHooks $ simpleUserHooks , postInst = \_ flags pkg local -> idrisInstall (S.fromFlag $ S.installVerbosity flags) NoCopyDest pkg local +#if !MIN_VERSION_Cabal(3,0,0) , preSDist = idrisPreSDist , sDistHook = idrisSDist (sDistHook simpleUserHooks) , postSDist = idrisPostSDist +#endif , testHook = idrisTestHook } diff --git a/cabal-install/Distribution/Client/GenBounds.hs b/cabal-install/Distribution/Client/GenBounds.hs index 3acff34c322..553ee0827d7 100644 --- a/cabal-install/Distribution/Client/GenBounds.hs +++ b/cabal-install/Distribution/Client/GenBounds.hs @@ -51,7 +51,7 @@ import Distribution.Verbosity ( Verbosity ) import Distribution.Version ( Version, alterVersion - , LowerBound(..), UpperBound(..), VersionRange(..), asVersionIntervals + , LowerBound(..), UpperBound(..), VersionRange, asVersionIntervals , orLaterVersion, earlierVersion, intersectVersionRanges ) import System.Directory ( getCurrentDirectory ) @@ -112,7 +112,7 @@ genBounds verbosity packageDBs repoCtxt comp platform progdb mSandboxPkgInfo let cinfo = compilerInfo comp cwd <- getCurrentDirectory - path <- tryFindPackageDesc cwd + path <- tryFindPackageDesc verbosity cwd gpd <- readGenericPackageDescription verbosity path -- NB: We don't enable tests or benchmarks, since often they -- don't really have useful bounds. diff --git a/cabal-install/Distribution/Client/Outdated.hs b/cabal-install/Distribution/Client/Outdated.hs index 925779cadbd..9095c70c205 100644 --- a/cabal-install/Distribution/Client/Outdated.hs +++ b/cabal-install/Distribution/Client/Outdated.hs @@ -149,7 +149,7 @@ depsFromNewFreezeFile verbosity mprojectFile = do depsFromPkgDesc :: Verbosity -> Compiler -> Platform -> IO [Dependency] depsFromPkgDesc verbosity comp platform = do cwd <- getCurrentDirectory - path <- tryFindPackageDesc cwd + path <- tryFindPackageDesc verbosity cwd gpd <- readGenericPackageDescription verbosity path let cinfo = compilerInfo comp epd = finalizePD mempty (ComponentRequestedSpec True True) diff --git a/cabal-install/Distribution/Client/ProjectBuilding.hs b/cabal-install/Distribution/Client/ProjectBuilding.hs index 420f2f2aad8..cce62595bd6 100644 --- a/cabal-install/Distribution/Client/ProjectBuilding.hs +++ b/cabal-install/Distribution/Client/ProjectBuilding.hs @@ -72,8 +72,7 @@ import Distribution.Client.Utils ( ProgressPhase(..), progressMessage, removeExistingFile ) import Distribution.Compat.Lens -import Distribution.Package hiding - (InstalledPackageId, installedPackageId) +import Distribution.Package import qualified Distribution.PackageDescription as PD import Distribution.InstalledPackageInfo (InstalledPackageInfo) import qualified Distribution.InstalledPackageInfo as Installed diff --git a/cabal-install/Distribution/Client/ProjectOrchestration.hs b/cabal-install/Distribution/Client/ProjectOrchestration.hs index 86d38baf887..923cc5aff75 100644 --- a/cabal-install/Distribution/Client/ProjectOrchestration.hs +++ b/cabal-install/Distribution/Client/ProjectOrchestration.hs @@ -135,7 +135,6 @@ import Distribution.Types.UnqualComponentName import Distribution.Solver.Types.OptionalStanza import Distribution.Package - hiding (InstalledPackageId, installedPackageId) import Distribution.PackageDescription ( FlagAssignment, unFlagAssignment, showFlagValue , diffFlagAssignment ) diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index 74add74d692..054da23a129 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -110,8 +110,7 @@ import Distribution.Solver.Types.SourcePackage import Distribution.Solver.Types.Settings import Distribution.ModuleName -import Distribution.Package hiding - (InstalledPackageId, installedPackageId) +import Distribution.Package import Distribution.Types.AnnotatedId import Distribution.Types.ComponentName import Distribution.Types.LibraryName diff --git a/cabal-install/Distribution/Client/ProjectPlanning/Types.hs b/cabal-install/Distribution/Client/ProjectPlanning/Types.hs index 9d93eeafc93..af2ed744db1 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning/Types.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning/Types.hs @@ -81,7 +81,6 @@ import Distribution.Types.ComponentRequestedSpec import Distribution.Types.PkgconfigVersion import Distribution.Types.PackageDescription (PackageDescription(..)) import Distribution.Package - hiding (InstalledPackageId, installedPackageId) import Distribution.System import qualified Distribution.PackageDescription as Cabal import Distribution.InstalledPackageInfo (InstalledPackageInfo) diff --git a/cabal-install/Distribution/Client/SetupWrapper.hs b/cabal-install/Distribution/Client/SetupWrapper.hs index df4c4e37bfb..d422a2fddfb 100644 --- a/cabal-install/Distribution/Client/SetupWrapper.hs +++ b/cabal-install/Distribution/Client/SetupWrapper.hs @@ -311,7 +311,7 @@ getSetup verbosity options mpkg = do , setupPackage = pkg } where - getPkg = tryFindPackageDesc (fromMaybe "." (useWorkingDir options)) + getPkg = tryFindPackageDesc verbosity (fromMaybe "." (useWorkingDir options)) >>= readGenericPackageDescription verbosity >>= return . packageDescription diff --git a/cabal-install/Distribution/Deprecated/Text.hs b/cabal-install/Distribution/Deprecated/Text.hs index b685f8128c7..44f2d899637 100644 --- a/cabal-install/Distribution/Deprecated/Text.hs +++ b/cabal-install/Distribution/Deprecated/Text.hs @@ -48,6 +48,7 @@ import qualified Distribution.Types.PackageVersionConstraint as D import qualified Distribution.Types.SourceRepo as D import qualified Distribution.Types.UnqualComponentName as D import qualified Distribution.Version as D +import qualified Distribution.Types.VersionRange.Internal as D import qualified Language.Haskell.Extension as E -- | /Note:/ this class will soon be deprecated. diff --git a/cabal-install/main/Main.hs b/cabal-install/main/Main.hs index 3b634472aee..33bbd86eb45 100644 --- a/cabal-install/main/Main.hs +++ b/cabal-install/main/Main.hs @@ -1046,7 +1046,7 @@ formatAction verbosityFlag extraArgs _globalFlags = do let verbosity = fromFlag verbosityFlag path <- case extraArgs of [] -> do cwd <- getCurrentDirectory - tryFindPackageDesc cwd + tryFindPackageDesc verbosity cwd (p:_) -> return p pkgDesc <- readGenericPackageDescription verbosity path -- Uses 'writeFileAtomic' under the hood. diff --git a/cabal-install/tests/UnitTests/Distribution/Client/ArbitraryInstances.hs b/cabal-install/tests/UnitTests/Distribution/Client/ArbitraryInstances.hs index b82f0f5ad82..412cec347a3 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/ArbitraryInstances.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/ArbitraryInstances.hs @@ -21,6 +21,7 @@ import Control.Applicative import Control.Monad import Distribution.Version +import Distribution.Types.VersionRange.Internal import Distribution.Types.Dependency import Distribution.Types.PackageVersionConstraint import Distribution.Types.UnqualComponentName diff --git a/cabal-testsuite/Test/Cabal/Prelude.hs b/cabal-testsuite/Test/Cabal/Prelude.hs index 821c5a7f027..f5fe6191922 100644 --- a/cabal-testsuite/Test/Cabal/Prelude.hs +++ b/cabal-testsuite/Test/Cabal/Prelude.hs @@ -188,7 +188,8 @@ setup'' prefix cmd args = do full_args' = if a `elem` legacyCmds then ("v1-" ++ a) : as else a:as in runProgramM cabalProgram full_args' else do - pdfile <- liftIO $ tryFindPackageDesc (testCurrentDir env prefix) + pdfile <- liftIO $ tryFindPackageDesc (testVerbosity env) + (testCurrentDir env prefix) pdesc <- liftIO $ readGenericPackageDescription (testVerbosity env) pdfile if buildType (packageDescription pdesc) == Simple then runM (testSetupPath env) full_args