Update runplugs to latest version from lambdabot
This commit is contained in:
parent
07a2f5e150
commit
3c44c98dc1
@ -1,6 +1,5 @@
|
|||||||
{-# OPTIONS -cpp #-}
|
|
||||||
--
|
--
|
||||||
-- Copyright (c) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons
|
-- Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons
|
||||||
-- GPL version 2 or later (see http://www.gnu.org/copyleft/gpl.html)
|
-- GPL version 2 or later (see http://www.gnu.org/copyleft/gpl.html)
|
||||||
--
|
--
|
||||||
|
|
||||||
@ -8,61 +7,39 @@
|
|||||||
-- | Runplugs: use hs-plugins to run a Haskell expression under
|
-- | Runplugs: use hs-plugins to run a Haskell expression under
|
||||||
-- controlled conditions.
|
-- controlled conditions.
|
||||||
--
|
--
|
||||||
import System.Eval.Haskell (unsafeEval_)
|
import System.Eval.Haskell (unsafeEval)
|
||||||
|
|
||||||
import Data.Maybe (isJust, fromJust)
|
import Data.Maybe (isJust, fromJust)
|
||||||
import Control.Monad (when)
|
import Control.Monad (when)
|
||||||
import Control.Exception (evaluate)
|
|
||||||
|
|
||||||
|
|
||||||
import System.Exit (exitWith, ExitCode(ExitSuccess))
|
import System.Exit (exitWith, ExitCode(ExitSuccess))
|
||||||
import System.IO (hGetContents, hPutStrLn, putStrLn, hClose, stdin, stdout, stderr)
|
import System.IO (getContents, putStrLn)
|
||||||
#if !defined(CYGWIN) && !defined(__MINGW32__)
|
|
||||||
import System.Posix.Resource (setResourceLimit,
|
import System.Posix.Resource (setResourceLimit,
|
||||||
Resource(ResourceCPUTime),
|
Resource(ResourceCPUTime),
|
||||||
ResourceLimits(ResourceLimits),
|
ResourceLimits(ResourceLimits),
|
||||||
ResourceLimit(ResourceLimit))
|
ResourceLimit(ResourceLimit))
|
||||||
import Control.Concurrent ( forkIO )
|
|
||||||
import qualified Control.Exception ( evaluate )
|
|
||||||
|
|
||||||
rlimit = ResourceLimit 3
|
rlimit = ResourceLimit 3
|
||||||
#endif
|
|
||||||
|
|
||||||
context = prehier ++ datas ++ controls
|
context = prehier ++ datas ++ qualifieds ++ controls
|
||||||
|
|
||||||
prehier = ["Char", "List", "Maybe", "Numeric", "Random" ]
|
prehier = ["Char", "List", "Maybe", "Numeric", "Random" ]
|
||||||
|
|
||||||
|
qualifieds = ["qualified Data.Map as M", "qualified Data.Set as S"]
|
||||||
|
|
||||||
datas = map ("Data." ++) [
|
datas = map ("Data." ++) [
|
||||||
"Bits", "Bool", "Char", "Dynamic", "Either",
|
"Bits", "Bool", "Char", "Dynamic", "Either",
|
||||||
"Graph", "Int", "Ix", "List", "Maybe",
|
"Graph", "Int", "Ix", "List",
|
||||||
#if __GLASGOW_HASKELL__ >= 604
|
"Maybe", "Ratio", "Tree", "Tuple", "Typeable", "Word"
|
||||||
"Map",
|
|
||||||
#else
|
|
||||||
"FiniteMap",
|
|
||||||
#endif
|
|
||||||
"Ratio", "Set", "Tree", "Tuple", "Typeable", "Word"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
controls = map ("Control." ++) ["Monad", "Arrow"]
|
controls = map ("Control." ++) ["Monad", "Monad.Reader", "Monad.Fix", "Arrow"]
|
||||||
|
|
||||||
--
|
|
||||||
-- with ghc 6.4, ghc doesn't seem to be able to call gcc, setNoFDBlocking fails.
|
|
||||||
--
|
|
||||||
-- *** Assembler
|
|
||||||
-- gcc -I/tmp -c /tmp/ghc11596.s -o /tmp/MySzQ14137.o
|
|
||||||
--
|
|
||||||
-- Failed: gcc -I/tmp -c /tmp/ghc11596.s -o /tmp/MySzQ14137.o
|
|
||||||
-- gcc: setNonBlockingFD: invalid argument (Bad file descriptor)
|
|
||||||
--
|
|
||||||
main = do
|
main = do
|
||||||
#if !defined(CYGWIN) && defined(__MINGW32__)
|
|
||||||
setResourceLimit ResourceCPUTime (ResourceLimits rlimit rlimit)
|
setResourceLimit ResourceCPUTime (ResourceLimits rlimit rlimit)
|
||||||
#endif
|
s <- getContents
|
||||||
s <- hGetContents stdin
|
|
||||||
when (not . null $ s) $ do
|
when (not . null $ s) $ do
|
||||||
s <- unsafeEval_ ("(take 2048 (show ("++s++")))") context ["-v"] [] []
|
s <- unsafeEval ("(take 2048 (show ("++s++")))") context
|
||||||
case s of
|
when (isJust s) (putStrLn (fromJust s))
|
||||||
Left errs -> mapM_ putStrLn errs
|
|
||||||
Right s -> putStrLn s
|
|
||||||
exitWith ExitSuccess
|
exitWith ExitSuccess
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
GHCFLAGS= -Onot $(GHC_EXTRA_OPTS)
|
GHCFLAGS= -Onot $(GHC_EXTRA_OPTS)
|
||||||
PKGFLAGS= -package posix -package-conf $(TOP)/plugins.conf.inplace
|
PKGFLAGS= -package posix
|
||||||
PKGFLAGS+= -package plugins
|
PKGFLAGS+= -package plugins
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
Loading…
x
Reference in New Issue
Block a user