Commit 1495a2d6 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Replace option with instance ShowAction Option.

parent 37de3d57
module Oracles.Option (
Option (..),
option, argOption,
ghcWithInterpreter, platformSupportsSharedLibs, windowsHost
) where
......@@ -13,31 +12,26 @@ data Option = TargetOS | TargetArch | TargetPlatformFull
| SrcHcOpts
| HostOsCpp
option :: Option -> Action String
option opt = askConfig $ case opt of
TargetOS -> "target-os"
TargetArch -> "target-arch"
TargetPlatformFull -> "target-platform-full"
ConfCcArgs stage -> "conf-cc-args-stage-" ++ (show . fromEnum) stage
ConfCppArgs stage -> "conf-cpp-args-stage-" ++ (show . fromEnum) stage
ConfGccLinkerArgs stage -> "conf-gcc-linker-args-stage-" ++ (show . fromEnum) stage
ConfLdLinkerArgs stage -> "conf-ld-linker-args-stage-" ++ (show . fromEnum) stage
IconvIncludeDirs -> "iconv-include-dirs"
IconvLibDirs -> "iconv-lib-dirs"
GmpIncludeDirs -> "gmp-include-dirs"
GmpLibDirs -> "gmp-lib-dirs"
SrcHcOpts -> "src-hc-opts"
HostOsCpp -> "host-os-cpp"
argOption :: Option -> Args
argOption opt = do
opt' <- option opt
arg [opt']
instance ShowAction Option where
showAction opt = askConfig $ case opt of
TargetOS -> "target-os"
TargetArch -> "target-arch"
TargetPlatformFull -> "target-platform-full"
ConfCcArgs stage -> "conf-cc-args-stage-" ++ (show . fromEnum) stage
ConfCppArgs stage -> "conf-cpp-args-stage-" ++ (show . fromEnum) stage
ConfGccLinkerArgs stage -> "conf-gcc-linker-args-stage-" ++ (show . fromEnum) stage
ConfLdLinkerArgs stage -> "conf-ld-linker-args-stage-" ++ (show . fromEnum) stage
IconvIncludeDirs -> "iconv-include-dirs"
IconvLibDirs -> "iconv-lib-dirs"
GmpIncludeDirs -> "gmp-include-dirs"
GmpLibDirs -> "gmp-lib-dirs"
SrcHcOpts -> "src-hc-opts"
HostOsCpp -> "host-os-cpp"
ghcWithInterpreter :: Condition
ghcWithInterpreter = do
os <- option TargetOS
arch <- option TargetArch
os <- showAction TargetOS
arch <- showAction TargetArch
return $
os `elem` ["mingw32", "cygwin32", "linux", "solaris2", "freebsd", "dragonfly", "netbsd", "openbsd", "darwin", "kfreebsdgnu"]
&&
......@@ -45,10 +39,10 @@ ghcWithInterpreter = do
platformSupportsSharedLibs :: Condition
platformSupportsSharedLibs = do
platform <- option TargetPlatformFull
platform <- showAction TargetPlatformFull
return $ platform `notElem` [ "powerpc-unknown-linux", "x86_64-unknown-mingw32", "i386-unknown-mingw32" ] -- TODO: i386-unknown-solaris2?
windowsHost :: Condition
windowsHost = do
hostOsCpp <- option HostOsCpp
hostOsCpp <- showAction HostOsCpp
return $ hostOsCpp `elem` ["mingw32", "cygwin32"]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment