This commit changes many aspect of our cmake build system
- shared libraries are compiled by default:
* this modifies RPATH of unix executables;
* this will prevent a lot of linking issues, esp. from pascal world;
* the old behaviour (static libs) is still available with -DBUILD_SHARED_LIBS=off;
* of course in this case you have to provide the full list of dependencies with FPFLAGS and CMAKE_C_FLAGS;
- pascal is now fully integrated with cmake, meaning you can just do add_sources and use CMAKE_Pascal_FLAGS:
* some of the language features are only partially implemented, for example .inc files will not get rebuilt if you modify them;
* target_link_libraries for pascal targets is just dummy as linking is determined within pascal files;
* universal builds for osx are not available any more;
- bundled libraries and system libraries are addressed using the target name:
* this avoids depedency tracking;
* this allows to name output as we wish.
{-# LANGUAGE CPP #-}
module Main where
import System.IO
import System.IO.Error
import Control.Concurrent
import Network
import Control.OldException
import Control.Monad
import System.Random
import Control.Monad.State
import Data.List
#if !defined(mingw32_HOST_OS)
import System.Posix
#endif
type SState = Handle
io = liftIO
readPacket :: StateT SState IO [String]
readPacket = do
h <- get
io $ hGetPacket h []
where
hGetPacket h buf = do
l <- hGetLine h
if not $ null l then hGetPacket h (buf ++ [l]) else return buf
waitPacket :: String -> StateT SState IO Bool
waitPacket s = do
p <- readPacket
return $ head p == s
sendPacket :: [String] -> StateT SState IO ()
sendPacket s = do
h <- get
io $ do
mapM_ (hPutStrLn h) s
hPutStrLn h ""
hFlush h
emulateSession :: StateT SState IO ()
emulateSession = do
n <- io $ randomRIO (100000::Int, 100100)
waitPacket "CONNECTED"
sendPacket ["NICK", "test" ++ show n]
waitPacket "NICK"
sendPacket ["PROTO", "41"]
waitPacket "PROTO"
b <- waitPacket "LOBBY:JOINED"
--io $ print b
sendPacket ["QUIT", "BYE"]
return ()
testing = Control.OldException.handle print $ do
putStr "+"
sock <- connectTo "127.0.0.1" (PortNumber 46631)
evalStateT emulateSession sock
--hClose sock
putStr "-"
hFlush stdout
forks = forever $ do
delay <- randomRIO (0::Int, 80000)
threadDelay delay
forkIO testing
main = withSocketsDo $ do
#if !defined(mingw32_HOST_OS)
installHandler sigPIPE Ignore Nothing;
#endif
forks