Skip to content

Commit

Permalink
Portable version of snap-server can be built on Linux/Mac OS
Browse files Browse the repository at this point in the history
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
jacobstanley committed May 28, 2010
1 parent 78969b8 commit 3bc11b9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
12 changes: 8 additions & 4 deletions snap-server.cabal
Expand Up @@ -72,6 +72,11 @@ Flag libev
Description: Use libev? Description: Use libev?
Default: False 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 Library
hs-source-dirs: dist/build/autogen, src hs-source-dirs: dist/build/autogen, src
Expand Down Expand Up @@ -111,7 +116,9 @@ Library
unix-compat, unix-compat,
vector >= 0.6 && <0.7 vector >= 0.6 && <0.7


if !os(windows) if flag(portable) || os(windows)
cpp-options: -DPORTABLE
else
build-depends: unix build-depends: unix


if flag(libev) if flag(libev)
Expand All @@ -130,9 +137,6 @@ Library
if os(darwin) if os(darwin)
cpp-options: -DOSX cpp-options: -DOSX


if os(windows)
cpp-options: -DWIN32

ghc-prof-options: -prof -auto-all ghc-prof-options: -prof -auto-all


if impl(ghc >= 6.12.0) if impl(ghc >= 6.12.0)
Expand Down
4 changes: 2 additions & 2 deletions src/Snap/Internal/Http/Server/Date.hs
Expand Up @@ -14,7 +14,7 @@ import Data.IORef
import Foreign.C.Types import Foreign.C.Types
import System.IO.Unsafe import System.IO.Unsafe


#ifndef WIN32 #ifndef PORTABLE
import System.Posix.Time import System.Posix.Time
#else #else
import Data.Time.Clock.POSIX import Data.Time.Clock.POSIX
Expand Down Expand Up @@ -60,7 +60,7 @@ dateState = unsafePerformIO $ do
return d return d




#ifdef WIN32 #ifdef PORTABLE
epochTime :: IO CTime epochTime :: IO CTime
epochTime = do epochTime = do
t <- getPOSIXTime t <- getPOSIXTime
Expand Down
13 changes: 9 additions & 4 deletions test/snap-server-testsuite.cabal
Expand Up @@ -7,6 +7,11 @@ Flag libev
Description: Use libev? Description: Use libev?
Default: False 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 Executable testsuite
hs-source-dirs: ../src suite hs-source-dirs: ../src suite
main-is: TestSuite.hs main-is: TestSuite.hs
Expand Down Expand Up @@ -55,8 +60,8 @@ Executable testsuite


other-modules: Snap.Internal.Http.Server.SimpleBackend other-modules: Snap.Internal.Http.Server.SimpleBackend


if os(windows) if flag(portable) || os(windows)
cpp-options: -DWIN32 cpp-options: -DPORTABLE


ghc-options: -O2 -Wall -fhpc -fwarn-tabs -funbox-strict-fields -threaded ghc-options: -O2 -Wall -fhpc -fwarn-tabs -funbox-strict-fields -threaded
-fno-warn-unused-do-bind -fno-warn-unused-do-bind
Expand Down Expand Up @@ -114,8 +119,8 @@ Executable pongserver
if os(darwin) if os(darwin)
cpp-options: -DOSX cpp-options: -DOSX


if os(windows) if flag(portable) || os(windows)
cpp-options: -DWIN32 cpp-options: -DPORTABLE


ghc-options: -Wall -O2 -fwarn-tabs -funbox-strict-fields -threaded ghc-options: -Wall -O2 -fwarn-tabs -funbox-strict-fields -threaded
-fno-warn-unused-do-bind -fno-warn-unused-do-bind
Expand Down

0 comments on commit 3bc11b9

Please sign in to comment.