Skip to content

Commit f59ed78

Browse files
authored
Compat with >=Cabal-2.0
As we need the CPP extension I needed to remove the shebang. Also switched to `getProgramOutput` as these are long deprecated and `getProgramOutput` exists in >=Cabal-1.8.
1 parent f57354e commit f59ed78

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

Setup.hs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
#!/usr/bin/env runhaskell
1+
{-# LANGUAGE CPP #-}
2+
3+
#ifndef MIN_VERSION_Cabal
4+
#define MIN_VERSION_Cabal(x,y,z) 0
5+
#endif
26

37
import Distribution.Simple
48
import Distribution.Simple.Setup
@@ -12,9 +16,28 @@ import Distribution.Verbosity
1216
import Data.Char (isSpace)
1317
import Data.List (dropWhile,reverse)
1418

19+
#if MIN_VERSION_Cabal(2,0,0)
20+
import Distribution.Types.UnqualComponentName
21+
#endif
22+
23+
flag :: String -> FlagName
24+
#if MIN_VERSION_Cabal(2,0,0)
25+
flag = mkFlagName
26+
#else
27+
flag = FlagName
28+
#endif
29+
30+
#if MIN_VERSION_Cabal(2,0,0)
31+
unqualComponentName :: String -> UnqualComponentName
32+
unqualComponentName = mkUnqualComponentName
33+
#else
34+
unqualComponentName :: String -> String
35+
unqualComponentName = id
36+
#endif
37+
1538
main = defaultMainWithHooks simpleUserHooks {
1639
confHook = \pkg flags -> do
17-
if lookup (FlagName "use-pkg-config")
40+
if lookup (flag "use-pkg-config")
1841
(configConfigurationsFlags flags) == Just True
1942
then do
2043
confHook simpleUserHooks pkg flags
@@ -24,15 +47,15 @@ main = defaultMainWithHooks simpleUserHooks {
2447

2548
return lbi {
2649
localPkgDescr = updatePackageDescription
27-
(Just bi, [("runtests", bi)]) (localPkgDescr lbi)
50+
(Just bi, [(unqualComponentName "runtests", bi)]) (localPkgDescr lbi)
2851
}
2952
}
3053

3154
psqlBuildInfo :: LocalBuildInfo -> IO BuildInfo
3255
psqlBuildInfo lbi = do
3356
(pgconfigProg, _) <- requireProgram verbosity
3457
(simpleProgram "pg_config") (withPrograms lbi)
35-
let pgconfig = rawSystemProgramStdout verbosity pgconfigProg
58+
let pgconfig = getProgramOutput verbosity pgconfigProg
3659

3760
incDir <- pgconfig ["--includedir"]
3861
libDir <- pgconfig ["--libdir"]

0 commit comments

Comments
 (0)