Skip to content

Commit

Permalink
update cabal file to the ver 1.2 syntax
Browse files Browse the repository at this point in the history
Use cabal configuration flags to detect building on windows
and set a custom CPP flag.  This seems like a better solution than
looking for the mingwin_32 flag (or whatever its called).

darcs-hash:20071127181454-f399b-73c1440937ac0daf437376bb68dd577e8e75b186
  • Loading branch information
robdockins committed Nov 27, 2007
1 parent 9f3cbb9 commit 4556d01
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 38 deletions.
63 changes: 38 additions & 25 deletions Shellac.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Name: Shellac
Version: 0.9
Cabal-Version: >= 1.2
Build-Type: Simple
Version: 0.9.1
License: BSD3
License-File: LICENSE
Author: Robert Dockins
Expand All @@ -17,27 +19,38 @@ Description:
This library attempts to allow users to write shells at a high level
and still enjoy the advanced features that may be available from a
powerful line editing package like readline.
Hs-Source-Dirs:
src
Build-Depends:
base >= 1.0,
haskell98 >= 1.0,
mtl >= 1.0
Extensions:
MultiParamTypeClasses
FunctionalDependencies
ExistentialQuantification
CPP
UndecidableInstances
Exposed-modules:
System.Console.Shell
System.Console.Shell.Backend
System.Console.Shell.Backend.Basic
System.Console.Shell.ShellMonad
Other-modules:
System.Console.Shell.Regex
System.Console.Shell.PPrint
System.Console.Shell.Types
System.Console.Shell.RunShell
System.Console.Shell.Commands
System.Console.Shell.ConsoleHandler

Library
Hs-Source-Dirs:
src
Build-Depends:
base >= 3.0,
haskell98 >= 1.0,
mtl >= 1.0,
directory >= 1.0
Extensions:
MultiParamTypeClasses
FunctionalDependencies
ExistentialQuantification
CPP
UndecidableInstances
GeneralizedNewtypeDeriving
FlexibleInstances
ScopedTypeVariables
GHC-Options: -XPatternSignatures
if os(windows)
GHC-Options: -DBUILD_WINDOWS
else
Build-Depends: unix >= 2.2
Exposed-modules:
System.Console.Shell
System.Console.Shell.Backend
System.Console.Shell.Backend.Basic
System.Console.Shell.ShellMonad
Other-modules:
System.Console.Shell.Regex
System.Console.Shell.PPrint
System.Console.Shell.Types
System.Console.Shell.RunShell
System.Console.Shell.Commands
System.Console.Shell.ConsoleHandler
27 changes: 14 additions & 13 deletions src/System/Console/Shell/ConsoleHandler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,12 @@ module System.Console.Shell.ConsoleHandler

import qualified Control.Exception as Ex

#ifndef mingw32_HOST_OS

import qualified System.Posix.Signals as PS

withControlCHandler :: IO () -> IO a -> IO a
withControlCHandler hdl m =
Ex.bracket
(PS.installHandler PS.keyboardSignal (PS.Catch hdl) Nothing)
(\oldh -> PS.installHandler PS.keyboardSignal oldh Nothing)
(\_ -> m)

#else
#ifdef BUILD_WINDOWS

-- Windows build, use the GHC console
-- handler module
import qualified GHC.ConsoleHandler as CH


handleCtrlC :: IO () -> CH.Handler
handleCtrlC hdl = CH.Catch $ \ev ->
case ev of
Expand All @@ -40,5 +30,16 @@ withControlCHandler hdl m =
(\oldh -> CH.installHandler oldh)
(\_ -> m)

#else

-- not Windows, assume POSIX
import qualified System.Posix.Signals as PS

withControlCHandler :: IO () -> IO a -> IO a
withControlCHandler hdl m =
Ex.bracket
(PS.installHandler PS.keyboardSignal (PS.Catch hdl) Nothing)
(\oldh -> PS.installHandler PS.keyboardSignal oldh Nothing)
(\_ -> m)

#endif

0 comments on commit 4556d01

Please sign in to comment.