Skip to content

Commit 5d7db0b

Browse files
authored
Merge pull request #7922 from robx/process-bump
Raise process lower bound to 1.2.1.0
2 parents a943141 + 6d0cb83 commit 5d7db0b

File tree

14 files changed

+14
-199
lines changed

14 files changed

+14
-199
lines changed

Cabal-tests/Cabal-tests.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ test-suite unit-tests
2626
Test.Laws
2727
Test.QuickCheck.Utils
2828
UnitTests.Distribution.CabalSpecVersion
29-
UnitTests.Distribution.Compat.CreatePipe
3029
UnitTests.Distribution.Compat.Graph
3130
UnitTests.Distribution.Compat.Time
3231
UnitTests.Distribution.Described

Cabal-tests/tests/UnitTests.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import Distribution.Simple.Utils
1313
import Distribution.Verbosity
1414
import Distribution.Compat.Time
1515

16-
import qualified UnitTests.Distribution.Compat.CreatePipe
1716
import qualified UnitTests.Distribution.Compat.Time
1817
import qualified UnitTests.Distribution.Compat.Graph
1918
import qualified UnitTests.Distribution.Simple.Command
@@ -44,9 +43,7 @@ tests mtimeChangeCalibrated =
4443
else mtimeChangeCalibrated
4544
in
4645
testGroup "Unit Tests"
47-
[ testGroup "Distribution.Compat.CreatePipe"
48-
UnitTests.Distribution.Compat.CreatePipe.tests
49-
, testGroup "Distribution.Compat.Time"
46+
[ testGroup "Distribution.Compat.Time"
5047
(UnitTests.Distribution.Compat.Time.tests mtimeChange)
5148
, testGroup "Distribution.Compat.Graph"
5249
UnitTests.Distribution.Compat.Graph.tests

Cabal-tests/tests/UnitTests/Distribution/Compat/CreatePipe.hs

Lines changed: 0 additions & 56 deletions
This file was deleted.

Cabal/Cabal.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ library
4343
directory >= 1.2 && < 1.4,
4444
filepath >= 1.3.0.1 && < 1.5,
4545
pretty >= 1.1.1 && < 1.2,
46-
process >= 1.1.0.2 && < 1.7,
46+
process >= 1.2.1.0 && < 1.7,
4747
time >= 1.4.0.1 && < 1.13
4848

4949
if os(windows)
Lines changed: 3 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,5 @@
1-
{-# LANGUAGE CPP #-}
2-
{-# LANGUAGE FlexibleContexts #-}
3-
{-# LANGUAGE RankNTypes #-}
1+
module Distribution.Compat.CreatePipe
2+
{-# DEPRECATED "Use System.Process from package process directly" #-}
3+
(createPipe) where
44

5-
module Distribution.Compat.CreatePipe (createPipe) where
6-
7-
#if MIN_VERSION_process(1,2,1)
85
import System.Process (createPipe)
9-
#else
10-
import System.IO (Handle, hSetBinaryMode)
11-
12-
import Prelude ()
13-
import Distribution.Compat.Prelude
14-
import Distribution.Compat.Stack
15-
16-
-- The mingw32_HOST_OS CPP macro is GHC-specific
17-
#ifdef mingw32_HOST_OS
18-
import qualified Prelude
19-
import Control.Exception (onException)
20-
import Foreign.C.Error (throwErrnoIfMinus1_)
21-
import Foreign.C.Types (CInt(..), CUInt(..))
22-
import Foreign.Ptr (Ptr)
23-
import Foreign.Marshal.Array (allocaArray)
24-
import Foreign.Storable (peek, peekElemOff)
25-
import GHC.IO.FD (mkFD)
26-
import GHC.IO.Device (IODeviceType(Stream))
27-
import GHC.IO.Handle.FD (mkHandleFromFD)
28-
import System.IO (IOMode(ReadMode, WriteMode))
29-
#elif defined ghcjs_HOST_OS
30-
#else
31-
import System.Posix.IO (fdToHandle)
32-
import qualified System.Posix.IO as Posix
33-
#endif
34-
35-
createPipe :: IO (Handle, Handle)
36-
-- The mingw32_HOST_OS CPP macro is GHC-specific
37-
#ifdef mingw32_HOST_OS
38-
createPipe = do
39-
(readfd, writefd) <- allocaArray 2 $ \ pfds -> do
40-
throwErrnoIfMinus1_ "_pipe" $ c__pipe pfds 2 ({- _O_BINARY -} 32768)
41-
readfd <- peek pfds
42-
writefd <- peekElemOff pfds 1
43-
return (readfd, writefd)
44-
(do readh <- fdToHandle readfd ReadMode
45-
writeh <- fdToHandle writefd WriteMode
46-
hSetBinaryMode readh True
47-
hSetBinaryMode writeh True
48-
return (readh, writeh)) `onException` (close readfd >> close writefd)
49-
where
50-
fdToHandle :: CInt -> IOMode -> IO Handle
51-
fdToHandle fd mode = do
52-
(fd', deviceType) <- mkFD fd mode (Just (Stream, 0, 0)) False False
53-
mkHandleFromFD fd' deviceType "" mode False Nothing
54-
55-
close :: CInt -> IO ()
56-
close = throwErrnoIfMinus1_ "_close" . c__close
57-
where _ = callStack -- TODO: attach call stack to exception
58-
59-
_ = callStack -- TODO: attach call stack to exceptions
60-
61-
foreign import ccall "io.h _pipe" c__pipe ::
62-
Ptr CInt -> CUInt -> CInt -> Prelude.IO CInt
63-
64-
foreign import ccall "io.h _close" c__close ::
65-
CInt -> Prelude.IO CInt
66-
#elif defined ghcjs_HOST_OS
67-
createPipe = error "createPipe"
68-
where
69-
_ = callStack
70-
#else
71-
createPipe = do
72-
(readfd, writefd) <- Posix.createPipe
73-
readh <- fdToHandle readfd
74-
writeh <- fdToHandle writefd
75-
hSetBinaryMode readh True
76-
hSetBinaryMode writeh True
77-
return (readh, writeh)
78-
where
79-
_ = callStack
80-
#endif
81-
#endif

Cabal/src/Distribution/Compat/Process.hs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ module Distribution.Compat.Process (
1111
import System.Exit (ExitCode (..))
1212
import System.IO (Handle)
1313

14-
import System.Process (CreateProcess, ProcessHandle)
14+
import System.Process (CreateProcess, ProcessHandle, waitForProcess)
1515
import qualified System.Process as Process
1616

17-
#if MIN_VERSION_process(1,2,0)
18-
import System.Process (waitForProcess)
19-
#endif
20-
2117
#if defined(mingw32_HOST_OS) && MIN_VERSION_process(1,6,9)
2218
import System.IO.Unsafe (unsafePerformIO)
2319
import System.Win32.Info.Version (dwMajorVersion, dwMinorVersion, getVersionEx)
@@ -74,13 +70,8 @@ createProcess = Process.createProcess . enableProcessJobs
7470
-- See 'enableProcessJobs'.
7571
rawSystem :: String -> [String] -> IO ExitCode
7672
rawSystem cmd args = do
77-
#if MIN_VERSION_process(1,2,0)
7873
(_,_,_,p) <- createProcess (Process.proc cmd args) { Process.delegate_ctlc = True }
7974
waitForProcess p
80-
#else
81-
-- With very old 'process', just do its rawSystem
82-
Process.rawSystem cmd args
83-
#endif
8475

8576
-- | 'System.Process.runInteractiveProcess' with process jobs enabled when
8677
-- appropriate. See 'enableProcessJobs'.

Cabal/src/Distribution/Simple/Test/ExeV10.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import Prelude ()
99
import Distribution.Compat.Prelude
1010

1111
import Distribution.Types.UnqualComponentName
12-
import Distribution.Compat.CreatePipe
1312
import Distribution.Compat.Environment
1413
import qualified Distribution.PackageDescription as PD
1514
import Distribution.Simple.Build.PathsModule
@@ -32,6 +31,7 @@ import System.Directory
3231
, getCurrentDirectory, removeDirectoryRecursive )
3332
import System.FilePath ( (</>), (<.>) )
3433
import System.IO ( stdout, stderr )
34+
import System.Process ( createPipe )
3535

3636
import qualified Data.ByteString.Lazy as LBS
3737

Cabal/src/Distribution/Simple/Test/LibV09.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import Prelude ()
1313
import Distribution.Compat.Prelude
1414
import Distribution.Types.UnqualComponentName
1515

16-
import Distribution.Compat.CreatePipe
1716
import Distribution.Compat.Environment
1817
import Distribution.Compat.Internal.TempFile
1918
import Distribution.ModuleName
@@ -42,7 +41,7 @@ import System.Directory
4241
, setCurrentDirectory )
4342
import System.FilePath ( (</>), (<.>) )
4443
import System.IO ( hClose, hPutStr )
45-
import System.Process (StdStream(..), waitForProcess)
44+
import System.Process (StdStream(..), createPipe, waitForProcess)
4645

4746
runTest :: PD.PackageDescription
4847
-> LBI.LocalBuildInfo

Cabal/src/Distribution/Simple/Utils.hs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -779,13 +779,7 @@ rawSystemExitWithEnv verbosity path args env = withFrozenCallStack $ do
779779
hFlush stdout
780780
(_,_,_,ph) <- createProcess $
781781
(Process.proc path args) { Process.env = (Just env)
782-
#ifdef MIN_VERSION_process
783-
#if MIN_VERSION_process(1,2,0)
784-
-- delegate_ctlc has been added in process 1.2, and we still want to be able to
785-
-- bootstrap GHC on systems not having that version
786782
, Process.delegate_ctlc = True
787-
#endif
788-
#endif
789783
}
790784
exitcode <- waitForProcess ph
791785
unless (exitcode == ExitSuccess) $ do
@@ -858,13 +852,7 @@ createProcessWithEnv verbosity path args mcwd menv inp out err = withFrozenCallS
858852
, Process.std_in = inp
859853
, Process.std_out = out
860854
, Process.std_err = err
861-
#ifdef MIN_VERSION_process
862-
#if MIN_VERSION_process(1,2,0)
863-
-- delegate_ctlc has been added in process 1.2, and we still want to be able to
864-
-- bootstrap GHC on systems not having that version
865855
, Process.delegate_ctlc = True
866-
#endif
867-
#endif
868856
}
869857
return (inp', out', err', ph)
870858

cabal-testsuite/cabal-testsuite.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ library
6868
, exceptions ^>= 0.10.0
6969
, filepath ^>= 1.3.0.1 || ^>= 1.4.0.0
7070
, optparse-applicative ^>= 0.14.3.0 || ^>=0.15.1.0 || ^>=0.16.0.0
71-
, process ^>= 1.1.0.2 || ^>= 1.2.0.0 || ^>= 1.4.2.0 || ^>= 1.6.1.0
71+
, process ^>= 1.2.1.0 || ^>= 1.4.2.0 || ^>= 1.6.1.0
7272
, regex-base ^>= 0.94.0.1
7373
, regex-tdfa ^>= 1.2.3.1 || ^>=1.3.1.0
7474
, array ^>= 0.4.0.1 || ^>= 0.5.0.0

cabal-testsuite/main/cabal-tests.hs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@ import qualified System.Clock as Clock
2525
import System.IO
2626
import System.FilePath
2727
import System.Exit
28-
import System.Process (
29-
#if MIN_VERSION_process(1,2,0)
30-
callProcess,
31-
#else
32-
proc, createProcess, waitForProcess, terminateProcess,
33-
#endif
34-
showCommandForUser)
28+
import System.Process (callProcess, showCommandForUser)
3529

3630
#if !MIN_VERSION_base(4,12,0)
3731
import Data.Monoid ((<>))
@@ -288,20 +282,3 @@ getTime = do
288282
t <- Clock.getTime Clock.Monotonic
289283
let ns = realToFrac $ Clock.toNanoSecs t
290284
return $ ns / 10 ^ (9 :: Int)
291-
292-
-------------------------------------------------------------------------------
293-
-- compat
294-
-------------------------------------------------------------------------------
295-
296-
#if !MIN_VERSION_process(1,2,0)
297-
callProcess :: FilePath -> [String] -> IO ()
298-
callProcess cmd args = do
299-
exit_code <- bracket (createProcess (proc cmd args)) cleanupProcess
300-
$ \(_, _, _, ph) -> waitForProcess ph
301-
case exit_code of
302-
ExitSuccess -> return ()
303-
ExitFailure r -> fail $ "processFailedException " ++ show (cmd, args, r)
304-
where
305-
cleanupProcess (_, _, _, ph) = terminateProcess ph
306-
307-
#endif

cabal-testsuite/src/Test/Cabal/Run.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module Test.Cabal.Run (
55
Result(..)
66
) where
77

8-
import qualified Distribution.Compat.CreatePipe as Compat
98
import Distribution.Simple.Program.Run
109
import Distribution.Verbosity
1110

@@ -46,7 +45,7 @@ run _verbosity mb_cwd env_overrides path0 args input = do
4645

4746
mb_env <- getEffectiveEnvironment env_overrides
4847
putStrLn $ "+ " ++ showCommandForUser path args
49-
(readh, writeh) <- Compat.createPipe
48+
(readh, writeh) <- createPipe
5049
hSetBuffering readh LineBuffering
5150
hSetBuffering writeh LineBuffering
5251
let drain = do

cabal-testsuite/src/Test/Cabal/Server.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,9 @@ initServer s0 = do
259259
#else
260260
pid <- withProcessHandle (serverProcessHandle s0) $ \ph ->
261261
case ph of
262-
#if MIN_VERSION_process(1,2,0)
263262
OpenHandle x -> return (show x)
264263
-- TODO: handle OpenExtHandle?
265264
_ -> return (serverProcessId s0)
266-
#else
267-
OpenHandle x -> return (ph, show x)
268-
-- TODO: handle OpenExtHandle?
269-
_ -> return (ph, serverProcessId s0)
270-
#endif
271265
#endif
272266
let s = s0 { serverProcessId = pid }
273267
-- We will read/write a line at a time, including for

changelog.d/pr-7922

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
synopsis: raise lower bound of process and remove compatibility shims
2+
packages: Cabal, Cabal-tests, cabal-testsuite
3+
prs: #7922

0 commit comments

Comments
 (0)