Skip to content

Bump Cabal versions from 2.5 -> 3.0 #5915

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cabal/Cabal.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cabal-version: >=1.10
name: Cabal
version: 2.5.0.0
version: 3.0.0.0
copyright: 2003-2019, Cabal Development Team (see AUTHORS file)
license: BSD3
license-file: LICENSE
Expand All @@ -16,7 +17,6 @@ description:
The Haskell Cabal is part of a larger infrastructure for distributing,
organizing, and cataloging Haskell libraries and tools.
category: Distribution
cabal-version: >=1.10
build-type: Simple
-- If we use a new Cabal feature, this needs to be changed to Custom so
-- we can bootstrap.
Expand Down
2 changes: 1 addition & 1 deletion Cabal/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 2.6.0.0 (current development version)
# 3.0.0.0 (current development version)
* TODO
* Introduce set notation for `^>=` and `==` operators.
* 'check' reports warnings for various ghc-\*-options fields separately
Expand Down
2 changes: 1 addition & 1 deletion Cabal/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=2.5.0.0
VERSION=3.0.0.0

#KIND=devel
KIND=rc
Expand Down
2 changes: 1 addition & 1 deletion Cabal/doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
sys.path.insert(0, os.path.abspath('.'))
import cabaldomain

version = "2.5.0.0"
version = "3.0.0.0"

extensions = ['sphinx.ext.extlinks', 'sphinx.ext.todo']

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ build_script:
- cabal %CABOPTS% new-test Cabal
- appveyor-retry cabal %CABOPTS% new-build exe:cabal exe:cabal-tests --only-dependencies
- cabal %CABOPTS% new-build exe:cabal
- cabal %CABOPTS% new-run cabal-tests -- -j3 --with-cabal=dist-newstyle\build\x86_64-windows\ghc-8.0.2\cabal-install-2.5.0.0\x\cabal\build\cabal\cabal.exe
- cabal %CABOPTS% new-run cabal-tests -- -j3 --with-cabal=dist-newstyle\build\x86_64-windows\ghc-8.0.2\cabal-install-3.0.0.0\x\cabal\build\cabal\cabal.exe
- appveyor-retry cabal %CABOPTS% new-build cabal-install:tests --only-dependencies
- cd cabal-install
- cabal %CABOPTS% new-run cabal-install:memory-usage-tests
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ NETWORK_URI_VER="2.6.1.0"; NETWORK_URI_VER_REGEXP="2\.6\.(0\.[2-9]|[1-9])"
# >= 2.6.0.2 && < 2.7
NETWORK_VER="2.7.0.0"; NETWORK_VER_REGEXP="2\.[0-7]\."
# >= 2.0 && < 2.7
CABAL_VER="2.5.0.0"; CABAL_VER_REGEXP="2\.5\.[0-9]"
CABAL_VER="3.0.0.0"; CABAL_VER_REGEXP="3\.0\.[0-9]"
# >= 2.5 && < 2.6
TRANS_VER="0.5.5.0"; TRANS_VER_REGEXP="0\.[45]\."
# >= 0.2.* && < 0.6
Expand Down
4 changes: 2 additions & 2 deletions cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Cabal-Version: >= 1.10
-- To update this file, edit 'cabal-install.cabal.pp' and run
-- 'make cabal-install-prod' in the project's root folder.
Name: cabal-install
Version: 2.5.0.0
Version: 3.0.0.0
Synopsis: The command-line interface for Cabal and Hackage.
Description:
The \'cabal\' command-line program simplifies the process of managing
Expand Down Expand Up @@ -311,7 +311,7 @@ executable cabal
base16-bytestring >= 0.1.1 && < 0.2,
binary >= 0.7.3 && < 0.9,
bytestring >= 0.10.6.0 && < 0.11,
Cabal == 2.5.*,
Cabal == 3.0.*,
containers >= 0.5.6.2 && < 0.7,
cryptohash-sha256 >= 0.11 && < 0.12,
deepseq >= 1.4.1.1 && < 1.5,
Expand Down
6 changes: 3 additions & 3 deletions cabal-install/cabal-install.cabal.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
-- To update this file, edit 'cabal-install.cabal.pp' and run
-- 'make cabal-install-prod' in the project's root folder.
Name: cabal-install
Version: 2.5.0.0
Version: 3.0.0.0
#
# NOTE: when updating build-depends, don't forget to update version regexps in bootstrap.sh.
#
Expand All @@ -22,7 +22,7 @@
base16-bytestring >= 0.1.1 && < 0.2,
binary >= 0.7.3 && < 0.9,
bytestring >= 0.10.6.0 && < 0.11,
Cabal == 2.5.*,
Cabal == 3.0.*,
containers >= 0.5.6.2 && < 0.7,
cryptohash-sha256 >= 0.11 && < 0.12,
deepseq >= 1.4.1.1 && < 1.5,
Expand Down Expand Up @@ -472,7 +472,7 @@

cpp-options: -DMONOLITHIC
build-depends:
Cabal == 2.5.*,
Cabal == 3.0.*,
cabal-install-solver-dsl,
QuickCheck >= 2.8.2,
array,
Expand Down
84 changes: 76 additions & 8 deletions cabal-testsuite/Setup.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,78 @@
{-# LANGUAGE Haskell2010 #-}
module Main (main) where

import Distribution.Backpack
import Distribution.Simple
import Distribution.Simple.BuildPaths
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Setup
import Distribution.Simple.Utils
import Distribution.Types.LocalBuildInfo
import Distribution.Types.ModuleRenaming
import Distribution.Types.UnqualComponentName

import System.Directory
import System.FilePath

main :: IO ()
main = defaultMain

-- Although this looks like the Simple build type, it is in fact vital that
-- we use this Setup.hs because we need to compile against the very same
-- version of the Cabal library that the test suite will be compiled
-- against. When this happens, it will mean that we'll be able to
-- read the LocalBuildInfo of our build environment, which we will
-- subsequently use to make decisions about PATHs etc. Important!
main = defaultMainWithHooks simpleUserHooks
{ buildHook = \pkg lbi hooks flags -> do
generateScriptEnvModule lbi flags
buildHook simpleUserHooks pkg lbi hooks flags
}

generateScriptEnvModule :: LocalBuildInfo -> BuildFlags -> IO ()
generateScriptEnvModule lbi flags = do
lbiPackageDbStack <- mapM canonicalizePackageDB (withPackageDB lbi)

createDirectoryIfMissing True moduledir
rewriteFileEx verbosity (moduledir </> "ScriptEnv0.hs") $ unlines
[ "module Test.Cabal.ScriptEnv0 where"
, ""
, "import Distribution.Simple"
, "import Distribution.System (Platform(..), Arch(..), OS(..))"
, "import Distribution.Types.ModuleRenaming"
, "import Distribution.Simple.Program.Db"
, "import Distribution.Backpack (OpenUnitId)"
, "import Data.Map (fromList)"
, ""
, "lbiPackageDbStack :: PackageDBStack"
, "lbiPackageDbStack = " ++ show lbiPackageDbStack
, ""
, "lbiPlatform :: Platform"
, "lbiPlatform = " ++ show (hostPlatform lbi)
, ""
, "lbiCompiler :: Compiler"
, "lbiCompiler = " ++ show (compiler lbi)
, ""
, "lbiPackages :: [(OpenUnitId, ModuleRenaming)]"
, "lbiPackages = read " ++ show (show (cabalTestsPackages lbi))
, ""
, "lbiProgramDb :: ProgramDb"
, "lbiProgramDb = read " ++ show (show (withPrograms lbi))
, ""
, "lbiWithSharedLib :: Bool"
, "lbiWithSharedLib = " ++ show (withSharedLib lbi)
]
where
verbosity = fromFlagOrDefault minBound (buildVerbosity flags)
moduledir = libAutogenDir </> "Test" </> "Cabal"
-- fixme: use component-specific folder
libAutogenDir = autogenPackageModulesDir lbi

-- | Convert package database into absolute path, so that
-- if we change working directories in a subprocess we get the correct database.
canonicalizePackageDB :: PackageDB -> IO PackageDB
canonicalizePackageDB (SpecificPackageDB path)
= SpecificPackageDB `fmap` canonicalizePath path
canonicalizePackageDB x = return x

-- | Compute the set of @-package-id@ flags which would be passed when
-- building the public library. Assumes that the public library is
-- non-Backpack.
cabalTestsPackages :: LocalBuildInfo -> [(OpenUnitId, ModuleRenaming)]
cabalTestsPackages lbi =
case componentNameCLBIs lbi (CExeName (mkUnqualComponentName "cabal-tests")) of
[clbi] -> -- [ (unUnitId $ unDefUnitId duid,rn) | (DefiniteUnitId duid, rn) <- componentIncludes clbi ]
componentIncludes clbi
_ -> error "cabalTestsPackages"
6 changes: 6 additions & 0 deletions cabal-testsuite/Setup.simple.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Main (main) where

import Distribution.Simple

main :: IO ()
main = defaultMain
18 changes: 8 additions & 10 deletions cabal-testsuite/Test/Cabal/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ import Distribution.System
import Distribution.Simple.Program.Db
import Distribution.Simple.Program
import Distribution.Simple.Configure
( getPersistBuildConfig, configCompilerEx )
import Distribution.Types.LocalBuildInfo
( configCompilerEx )
import Distribution.Version
import Distribution.Text
import Distribution.Package
Expand Down Expand Up @@ -240,20 +239,19 @@ runTestM mode m = withSystemTempDirectory "cabal-testsuite" $ \tmp_dir -> do
script_base = dropExtensions script_filename
-- Canonicalize this so that it is stable across working directory changes
script_dir <- canonicalizePath script_dir0
lbi <- getPersistBuildConfig dist_dir
let verbosity = normal -- TODO: configurable
senv <- mkScriptEnv verbosity lbi
senv <- mkScriptEnv verbosity
-- Add test suite specific programs
let program_db0 =
addKnownPrograms
([gitProgram, hackageRepoToolProgram, cabalProgram, diffProgram] ++ builtinPrograms)
(withPrograms lbi)
(runnerProgramDb senv)
-- Reconfigure according to user flags
let cargs = testCommonArgs args

-- Reconfigure GHC
(comp, platform, program_db2) <- case argGhcPath cargs of
Nothing -> return (compiler lbi, hostPlatform lbi, program_db0)
Nothing -> return (runnerCompiler senv, runnerPlatform senv, program_db0)
Just ghc_path -> do
-- All the things that get updated paths from
-- configCompilerEx. The point is to make sure
Expand All @@ -274,7 +272,7 @@ runTestM mode m = withSystemTempDirectory "cabal-testsuite" $ \tmp_dir -> do
-- we don't pay for things we don't need. A bit difficult
-- to do in the current design.
configCompilerEx
(Just (compilerFlavor (compiler lbi)))
(Just (compilerFlavor (runnerCompiler senv)))
(Just ghc_path)
Nothing
program_db1
Expand All @@ -294,7 +292,7 @@ runTestM mode m = withSystemTempDirectory "cabal-testsuite" $ \tmp_dir -> do

let db_stack =
case argGhcPath (testCommonArgs args) of
Nothing -> withPackageDB lbi
Nothing -> runnerPackageDbStack senv -- NB: canonicalized
-- Can't use the build package db stack since they
-- are all for the wrong versions! TODO: Make
-- this configurable
Expand All @@ -311,9 +309,9 @@ runTestM mode m = withSystemTempDirectory "cabal-testsuite" $ \tmp_dir -> do
testVerbosity = verbosity,
testMtimeChangeDelay = Nothing,
testScriptEnv = senv,
testSetupPath = dist_dir </> "setup" </> "setup",
testSetupPath = dist_dir </> "build" </> "setup" </> "setup",
testSkipSetupTests = argSkipSetupTests (testCommonArgs args),
testHaveCabalShared = withSharedLib lbi,
testHaveCabalShared = runnerWithSharedLib senv,
testEnvironment =
-- Try to avoid Unicode output
[ ("LC_ALL", Just "C")
Expand Down
37 changes: 15 additions & 22 deletions cabal-testsuite/Test/Cabal/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ module Test.Cabal.Script (
) where

import Test.Cabal.Run
import Test.Cabal.ScriptEnv0

import Distribution.Backpack
import Distribution.Types.ModuleRenaming
import Distribution.Types.LocalBuildInfo
import Distribution.Types.ComponentLocalBuildInfo
import Distribution.Types.ComponentName
import Distribution.Types.UnqualComponentName
import Distribution.Utils.NubList
import Distribution.Simple.Program.Db
import Distribution.Simple.Program.Builtin
Expand All @@ -26,9 +23,9 @@ import Distribution.Verbosity
import Distribution.System
import Distribution.Simple.Setup (Flag(..))

import System.Directory
import qualified Data.Monoid as M


-- | The runner environment, which contains all of the important
-- parameters for invoking GHC. Mostly subset of 'LocalBuildInfo'.
data ScriptEnv = ScriptEnv
Expand All @@ -38,40 +35,36 @@ data ScriptEnv = ScriptEnv
, runnerPlatform :: Platform
, runnerCompiler :: Compiler
, runnerPackages :: [(OpenUnitId, ModuleRenaming)]
, runnerWithSharedLib :: Bool
}

{-

-- | Convert package database into absolute path, so that
-- if we change working directories in a subprocess we get the correct database.
canonicalizePackageDB :: PackageDB -> IO PackageDB
canonicalizePackageDB (SpecificPackageDB path)
= SpecificPackageDB `fmap` canonicalizePath path
canonicalizePackageDB x = return x

-}

-- | Create a 'ScriptEnv' from a 'LocalBuildInfo' configured with
-- the GHC that we want to use.
mkScriptEnv :: Verbosity -> LocalBuildInfo -> IO ScriptEnv
mkScriptEnv verbosity lbi = do
package_db <- mapM canonicalizePackageDB (withPackageDB lbi)
mkScriptEnv :: Verbosity -> IO ScriptEnv
mkScriptEnv verbosity =
return $ ScriptEnv
{ runnerVerbosity = verbosity
, runnerProgramDb = withPrograms lbi
, runnerPackageDbStack = package_db
, runnerPlatform = hostPlatform lbi
, runnerCompiler = compiler lbi
, runnerProgramDb = lbiProgramDb
, runnerPackageDbStack = lbiPackageDbStack
, runnerPlatform = lbiPlatform
, runnerCompiler = lbiCompiler
-- NB: the set of packages available to test.hs scripts will COINCIDE
-- with the dependencies on the cabal-testsuite library
, runnerPackages = cabalTestsPackages lbi
, runnerPackages = lbiPackages
, runnerWithSharedLib = lbiWithSharedLib
}

-- | Compute the set of @-package-id@ flags which would be passed when
-- building the public library. Assumes that the public library is
-- non-Backpack.
cabalTestsPackages :: LocalBuildInfo -> [(OpenUnitId, ModuleRenaming)]
cabalTestsPackages lbi =
case componentNameCLBIs lbi (CExeName (mkUnqualComponentName "cabal-tests")) of
[clbi] -> componentIncludes clbi
_ -> error "cabalTestsPackages"

-- | Run a script with 'runghc', under the 'ScriptEnv'.
runghc :: ScriptEnv -> Maybe FilePath -> [(String, Maybe String)]
-> FilePath -> [String] -> IO Result
Expand Down
Loading