Permalink
Browse files

Portable version of snap-core can be built on Linux/Mac OS

Changed cpp-options to use PORTABLE instead of WIN32
- If the flag portable is set then PORTABLE is used
- If the OS is Windows then PORTABLE is used
  • Loading branch information...
1 parent 99be8d7 commit 1f969fe10cad0ace8fa35ca2734e348971cba72d @jystic jystic committed May 28, 2010
Showing with 20 additions and 10 deletions.
  1. +7 −2 snap-core.cabal
  2. +3 −3 src/Snap/Internal/Http/Types.hs
  3. +3 −3 src/Snap/Iteratee.hs
  4. +7 −2 test/snap-core-testsuite.cabal
View
@@ -100,6 +100,11 @@ Flag testsuite
be evaluated but not printed.
Default: False
+Flag portable
+ Description: Compile in cross-platform mode. No platform-specific code or
+ optimizations such as C routines will be used.
+ Default: False
+
Library
hs-source-dirs: src
@@ -109,8 +114,8 @@ Library
if flag(testsuite)
cpp-options: -DDEBUG_TEST
- if os(windows)
- cpp-options: -DWIN32
+ if flag(portable) || os(windows)
+ cpp-options: -DPORTABLE
else
c-sources: cbits/timefuncs.c
include-dirs: cbits
@@ -43,7 +43,7 @@ import Prelude hiding (take)
import System.Locale (defaultTimeLocale)
-#ifdef WIN32
+#ifdef PORTABLE
import Data.Time.LocalTime
import Data.Time.Clock.POSIX
#else
@@ -55,7 +55,7 @@ import Data.CIByteString
import qualified Snap.Iteratee as I
-#ifndef WIN32
+#ifndef PORTABLE
------------------------------------------------------------------------------
-- foreign imports from cbits
@@ -525,7 +525,7 @@ formatLogTime :: CTime -> IO ByteString
-- | Converts an HTTP timestamp into a 'CTime'.
parseHttpTime :: ByteString -> IO CTime
-#ifdef WIN32
+#ifdef PORTABLE
formatHttpTime = return . format . toUTCTime
where
@@ -49,7 +49,7 @@ import qualified Data.ByteString.Unsafe as S
import qualified Data.ByteString.Lazy as L
import Data.IORef
import Data.Iteratee
-#ifdef WIN32
+#ifdef PORTABLE
import Data.Iteratee.IO (enumHandle)
#endif
import qualified Data.Iteratee.Base.StreamChunk as SC
@@ -59,7 +59,7 @@ import Foreign
import Prelude hiding (catch,drop)
import qualified Data.DList as D
-#ifdef WIN32
+#ifdef PORTABLE
import Control.Monad.Trans (liftIO)
import System.IO
#else
@@ -363,7 +363,7 @@ takeNoMoreThan n' iter =
------------------------------------------------------------------------------
enumFile :: FilePath -> Iteratee IO a -> IO (Iteratee IO a)
-#ifdef WIN32
+#ifdef PORTABLE
enumFile fp iter = do
h <- liftIO $ openBinaryFile fp ReadMode
@@ -12,6 +12,11 @@ Flag testsuite
be evaluated but not printed.
Default: False
+Flag portable
+ Description: Compile in cross-platform mode. No platform-specific code or
+ optimizations such as C routines will be used.
+ Default: False
+
Executable testsuite
hs-source-dirs: ../src suite
main-is: TestSuite.hs
@@ -22,8 +27,8 @@ Executable testsuite
if flag(testsuite)
cpp-options: -DDEBUG_TEST
- if os(windows)
- cpp-options: -DWIN32
+ if flag(portable) || os(windows)
+ cpp-options: -DPORTABLE
else
c-sources: ../cbits/timefuncs.c
include-dirs: ../cbits

0 comments on commit 1f969fe

Please sign in to comment.