Skip to content
Snippets Groups Projects
Commit 20a4f251 authored by Ben Gamari's avatar Ben Gamari Committed by Marge Bot
Browse files

hadrian: Factor out --extra-*-dirs=... pattern

We repeated this idiom quite a few times. Give it a name.
parent 083a7583
No related branches found
No related tags found
No related merge requests found
......@@ -210,10 +210,7 @@ ghcBignumArgs = package ghcBignum ? do
-- Ensure that the ghc-bignum package registration includes
-- knowledge of the system gmp's library and include directories.
, notM (flag GmpInTree) ? mconcat
[ if not (null librariesGmp) then arg ("--extra-lib-dirs=" ++ librariesGmp) else mempty
, if not (null includesGmp) then arg ("--extra-include-dirs=" ++ includesGmp) else mempty
]
, notM (flag GmpInTree) ? cabalExtraDirs includesGmp librariesGmp
]
]
_ -> mempty
......@@ -357,11 +354,9 @@ rtsPackageArgs = package rts ? do
, Debug `wayUnit` way `cabalFlag` "find-ptr"
]
, builder (Cabal Setup) ? mconcat
[ if not (null libdwLibraryDir) then arg ("--extra-lib-dirs="++libdwLibraryDir) else mempty
, if not (null libdwIncludeDir) then arg ("--extra-include-dirs="++libdwIncludeDir) else mempty
, if not (null libnumaLibraryDir) then arg ("--extra-lib-dirs="++libnumaLibraryDir) else mempty
, if not (null libnumaIncludeDir) then arg ("--extra-include-dirs="++libnumaIncludeDir) else mempty
]
[ cabalExtraDirs libdwIncludeDir libdwLibraryDir
, cabalExtraDirs libnumaIncludeDir libnumaLibraryDir
]
, builder (Cc (FindCDependencies CDep)) ? cArgs
, builder (Cc (FindCDependencies CxxDep)) ? cArgs
, builder (Ghc CompileCWithGhc) ? map ("-optc" ++) <$> cArgs
......@@ -429,3 +424,18 @@ rtsWarnings = mconcat
, arg "-Wredundant-decls"
, arg "-Wundef"
, arg "-fno-strict-aliasing" ]
-- | Expands to Cabal `--extra-lib-dirs` and `--extra-include-dirs` flags if
-- the respective paths are not null.
cabalExtraDirs :: FilePath -- ^ include path
-> FilePath -- ^ libraries path
-> Args
cabalExtraDirs include lib = mconcat
[ extraDirFlag "--extra-lib-dirs" lib
, extraDirFlag "--extra-include-dirs" include
]
where
extraDirFlag :: String -> FilePath -> Args
extraDirFlag flag dir
| null dir = mempty
| otherwise = arg (flag++"="++dir)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment