summaryrefslogtreecommitdiff
path: root/testsuite/mk/ghc-config.hs
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2012-01-16 11:48:00 +0000
committerSimon Marlow <marlowsd@gmail.com>2012-01-16 13:31:20 +0000
commit199f38884fd4128979283086fbb77dc0631f0567 (patch)
treea426ab18b5b000c3a98800279dcfe12d85c74e4f /testsuite/mk/ghc-config.hs
parent5ff65d76259203a211a38b043e3e75835fa04fc7 (diff)
downloadhaskell-199f38884fd4128979283086fbb77dc0631f0567.tar.gz
Parse the ghc --info values using a Haskell program, and cache the results
Should improve startup time of make in the testsuite, and it is simpler.
Diffstat (limited to 'testsuite/mk/ghc-config.hs')
-rw-r--r--testsuite/mk/ghc-config.hs29
1 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/mk/ghc-config.hs b/testsuite/mk/ghc-config.hs
new file mode 100644
index 0000000000..d2e9e7fef0
--- /dev/null
+++ b/testsuite/mk/ghc-config.hs
@@ -0,0 +1,29 @@
+import System.Environment
+import System.Process
+
+main = do
+ [ghc] <- getArgs
+
+ info <- readProcess ghc ["+RTS", "--info"] ""
+ let fields = read info :: [(String,String)]
+ getGhcField fields "HostOS" "Host OS"
+ getGhcField fields "WORDSIZE" "Word size"
+ getGhcField fields "TARGETPLATFORM" "Target platform"
+ getGhcField fields "TargetOS_CPP" "Target OS"
+ getGhcField fields "TargetARCH_CPP" "Target architecture"
+
+ info <- readProcess ghc ["--info"] ""
+ let fields = read info :: [(String,String)]
+ getGhcField fields "GhcStage" "Stage"
+ getGhcField fields "GhcWithNativeCodeGen" "Have native code generator"
+ getGhcField fields "GhcWithInterpreter" "Have interpreter"
+ getGhcField fields "GhcUnregisterised" "Unregisterised"
+ getGhcField fields "GhcWithSMP" "Support SMP"
+ getGhcField fields "GhcRTSWays" "RTS ways"
+ getGhcField fields "AR" "ar command"
+
+getGhcField :: [(String,String)] -> String -> String -> IO ()
+getGhcField fields mkvar key = do
+ case lookup key fields of
+ Nothing -> fail ("No field: " ++ key)
+ Just val -> putStrLn (mkvar ++ '=':val)