summaryrefslogtreecommitdiff
path: root/testsuite/mk
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-04-20 12:18:20 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-25 10:18:17 -0400
commit6c7a49139cf120a9bf9370ff472aa2839b4289c6 (patch)
treecac7b8adad18c3ff47b3efa1e3c7808854fcc37b /testsuite/mk
parent18e5103f0f73570e31421e67e54f1693936f5efd (diff)
downloadhaskell-6c7a49139cf120a9bf9370ff472aa2839b4289c6.tar.gz
testsuite: Cabalify ghc-config
To ensure that the build benefits from Hadrian's usual logic for building packages, avoiding #21409. Closes #21409.
Diffstat (limited to 'testsuite/mk')
-rw-r--r--testsuite/mk/boilerplate.mk6
-rw-r--r--testsuite/mk/ghc-config.hs84
2 files changed, 3 insertions, 87 deletions
diff --git a/testsuite/mk/boilerplate.mk b/testsuite/mk/boilerplate.mk
index df1b835b0c..8ce5dafb7b 100644
--- a/testsuite/mk/boilerplate.mk
+++ b/testsuite/mk/boilerplate.mk
@@ -246,7 +246,7 @@ endif
# the results, and emits a little .mk file with make bindings for the values.
# This way we cache the results for different values of $(TEST_HC)
-$(TOP)/mk/ghc-config : $(TOP)/mk/ghc-config.hs
+$(TOP)/ghc-config/ghc-config : $(TOP)/ghc-config/ghc-config.hs
"$(TEST_HC)" --make -o $@ $<
empty=
@@ -254,8 +254,8 @@ space=$(empty) $(empty)
ifeq "$(ghc_config_mk)" ""
ghc_config_mk = $(TOP)/mk/ghcconfig$(subst $(space),_,$(subst :,_,$(subst /,_,$(subst \,_,$(TEST_HC))))).mk
-$(ghc_config_mk) : $(TOP)/mk/ghc-config
- $(TOP)/mk/ghc-config "$(TEST_HC)" >"$@"; if [ "$$?" != "0" ]; then $(RM) "$@"; exit 1; fi
+$(ghc_config_mk) : $(TOP)/ghc-config/ghc-config
+ $(TOP)/ghc-config/ghc-config "$(TEST_HC)" >"$@"; if [ "$$?" != "0" ]; then $(RM) "$@"; exit 1; fi
# If the ghc-config fails, remove $@, and fail
endif
diff --git a/testsuite/mk/ghc-config.hs b/testsuite/mk/ghc-config.hs
deleted file mode 100644
index f12b579e8d..0000000000
--- a/testsuite/mk/ghc-config.hs
+++ /dev/null
@@ -1,84 +0,0 @@
-import System.Environment
-import System.Process
-import Data.Maybe
-
-main = do
- [ghc] <- getArgs
-
- info <- readProcess ghc ["+RTS", "--info"] ""
- let fields = read info :: [(String,String)]
- getGhcFieldOrFail fields "HostOS" "Host OS"
- getGhcFieldOrFail fields "WORDSIZE" "Word size"
- getGhcFieldOrFail fields "TARGETPLATFORM" "Target platform"
- getGhcFieldOrFail fields "TargetOS_CPP" "Target OS"
- getGhcFieldOrFail fields "TargetARCH_CPP" "Target architecture"
-
- info <- readProcess ghc ["--info"] ""
- let fields = read info :: [(String,String)]
-
- getGhcFieldOrFail fields "GhcStage" "Stage"
- getGhcFieldOrFail fields "GhcDebugged" "Debug on"
- getGhcFieldOrFail fields "GhcWithNativeCodeGen" "Have native code generator"
- getGhcFieldOrFail fields "GhcWithInterpreter" "Have interpreter"
- getGhcFieldOrFail fields "GhcWithRtsLinker" "target has RTS linker"
- getGhcFieldOrFail fields "GhcUnregisterised" "Unregisterised"
- getGhcFieldOrFail fields "GhcWithSMP" "Support SMP"
- getGhcFieldOrFail fields "GhcRTSWays" "RTS ways"
- getGhcFieldOrFail fields "GhcLibdir" "LibDir"
- getGhcFieldOrFail fields "GhcGlobalPackageDb" "Global Package DB"
- getGhcFieldOrDefault fields "GhcDynamic" "GHC Dynamic" "NO"
- getGhcFieldOrDefault fields "GhcProfiled" "GHC Profiled" "NO"
- getGhcFieldOrDefault fields "LeadingUnderscore" "Leading underscore" "NO"
- getGhcFieldProgWithDefault fields "AR" "ar command" "ar"
- getGhcFieldProgWithDefault fields "CLANG" "LLVM clang command" "clang"
- getGhcFieldProgWithDefault fields "LLC" "LLVM llc command" "llc"
- getGhcFieldProgWithDefault fields "TEST_CC" "C compiler command" "gcc"
- getGhcFieldProgWithDefault fields "TEST_CC_OPTS" "C compiler flags" ""
-
-getGhcFieldOrFail :: [(String,String)] -> String -> String -> IO ()
-getGhcFieldOrFail fields mkvar key
- = getGhcField fields mkvar key id (fail ("No field: " ++ key))
-
-getGhcFieldOrDefault :: [(String,String)] -> String -> String -> String -> IO ()
-getGhcFieldOrDefault fields mkvar key deflt
- = getGhcField fields mkvar key id on_fail
- where
- on_fail = putStrLn (mkvar ++ '=' : deflt)
-
-getGhcFieldProgWithDefault
- :: [(String,String)]
- -> String -> String -> String
- -> IO ()
-getGhcFieldProgWithDefault fields mkvar key deflt
- = getGhcField fields mkvar key fix on_fail
- where
- fix val = fixSlashes (fixTopdir topdir val)
- topdir = fromMaybe "" (lookup "LibDir" fields)
- on_fail = putStrLn (mkvar ++ '=' : deflt)
-
-getGhcField
- :: [(String,String)] -> String -> String
- -> (String -> String)
- -> IO ()
- -> IO ()
-getGhcField fields mkvar key fix on_fail =
- case lookup key fields of
- Nothing -> on_fail
- Just val -> putStrLn (mkvar ++ '=' : fix val)
-
-fixTopdir :: String -> String -> String
-fixTopdir t "" = ""
-fixTopdir t ('$':'t':'o':'p':'d':'i':'r':s) = t ++ s
-fixTopdir t (c:s) = c : fixTopdir t s
-
-fixSlashes :: FilePath -> FilePath
-fixSlashes = map f
- where f '\\' = '/'
- f c = c
-
-parseVersion :: String -> [Int]
-parseVersion v = case break (== '.') v of
- (n, rest) -> read n : case rest of
- [] -> []
- ('.':v') -> parseVersion v'
- _ -> error "bug in parseVersion"