Commit a3311fc2 authored by Alp Mestanogullari's avatar Alp Mestanogullari Committed by Oleg Grenrus

add new .cabal file field extra-dynamic-library-flavours

It serves an almost identical purpose as extra-library-flavours, except
that the latter is only concerned with static library flavours, while
extra-dynamic-library-flavours lets us, in the case of libHSrts, build
a dynamic, threaded flavour of it.
parent b8b3b414
......@@ -1277,6 +1277,11 @@ checkCabalVersion pkg =
++ " and 'extra-library-flavours' requires the package "
++ " to specify at least 'cabal-version: >= 2.1'."
, checkVersion [2,5] (not . null $ buildInfoField extraDynLibFlavours) $
PackageDistInexcusable $
"The use of 'extra-dynamic-library-flavours' requires the package "
++ " to specify at least 'cabal-version: >= 2.5'."
, checkVersion [2,1] (any (not . null)
(buildInfoField virtualModules)) $
PackageDistInexcusable $
......
......@@ -403,6 +403,7 @@ buildInfoFieldGrammar = BuildInfo
<*> monoidalFieldAla "extra-ghci-libraries" (alaList' VCat Token) L.extraGHCiLibs
<*> monoidalFieldAla "extra-bundled-libraries" (alaList' VCat Token) L.extraBundledLibs
<*> monoidalFieldAla "extra-library-flavours" (alaList' VCat Token) L.extraLibFlavours
<*> monoidalFieldAla "extra-dynamic-library-flavours" (alaList' VCat Token) L.extraDynLibFlavours
<*> monoidalFieldAla "extra-lib-dirs" (alaList' FSep FilePathNT) L.extraLibDirs
<*> monoidalFieldAla "include-dirs" (alaList' FSep FilePathNT) L.includeDirs
<*> monoidalFieldAla "includes" (alaList' FSep FilePathNT) L.includes
......
......@@ -1840,7 +1840,12 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do
whenProf $ do
installOrdinary builtDir targetDir profileLibName
whenGHCi $ installOrdinary builtDir targetDir ghciProfLibName
whenShared $ installShared builtDir dynlibTargetDir sharedLibName
whenShared $
sequence_ [ installShared builtDir dynlibTargetDir
(mkGenericSharedLibName platform compiler_id (l ++ f))
| l <- getHSLibraryName uid : extraBundledLibs (libBuildInfo lib)
, f <- "":extraDynLibFlavours (libBuildInfo lib)
]
where
builtDir = componentBuildDir lbi clbi
......@@ -1856,7 +1861,7 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do
else installOrdinaryFile verbosity src dst
when (stripLibs lbi) $ Strip.stripLib verbosity
(hostPlatform lbi) (withPrograms lbi) dst
platform (withPrograms lbi) dst
installOrdinary = install False
installShared = install True
......@@ -1866,11 +1871,11 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do
>>= installOrdinaryFiles verbosity targetDir
compiler_id = compilerId (compiler lbi)
platform = hostPlatform lbi
uid = componentUnitId clbi
profileLibName = mkProfLibName uid
ghciLibName = Internal.mkGHCiLibName uid
ghciProfLibName = Internal.mkGHCiProfLibName uid
sharedLibName = (mkSharedLibName (hostPlatform lbi) compiler_id) uid
hasLib = not $ null (allLibModules lib clbi)
&& null (cSources (libBuildInfo lib))
......
......@@ -88,6 +88,9 @@ data BuildInfo = BuildInfo {
-- copying. E.g. [libHS<name>_<flavour> | flavour <- extraLibFlavours]. This
-- should only be needed in very specific cases, e.g. the `rts` package, where
-- there are multiple copies of slightly differently built libs.
extraDynLibFlavours :: [String], -- ^ Hidden Flag. This set of strings will be be appended to all /dynamic/
-- libraries when copying. This is particularly useful with the `rts` package,
-- where we want different dynamic flavours of the RTS library to be installed.
extraLibDirs :: [String],
includeDirs :: [FilePath], -- ^directories to find .h files
includes :: [FilePath], -- ^ The .h files to be found in includeDirs
......@@ -140,6 +143,7 @@ instance Monoid BuildInfo where
extraGHCiLibs = [],
extraBundledLibs = [],
extraLibFlavours = [],
extraDynLibFlavours = [],
extraLibDirs = [],
includeDirs = [],
includes = [],
......@@ -186,6 +190,7 @@ instance Semigroup BuildInfo where
extraGHCiLibs = combine extraGHCiLibs,
extraBundledLibs = combine extraBundledLibs,
extraLibFlavours = combine extraLibFlavours,
extraDynLibFlavours = combine extraDynLibFlavours,
extraLibDirs = combineNub extraLibDirs,
includeDirs = combineNub includeDirs,
includes = combineNub includes,
......
......@@ -144,6 +144,10 @@ class HasBuildInfo a where
extraLibFlavours = buildInfo . extraLibFlavours
{-# INLINE extraLibFlavours #-}
extraDynLibFlavours :: Lens' a [String]
extraDynLibFlavours = buildInfo . extraDynLibFlavours
{-# INLINE extraDynLibFlavours #-}
extraLibDirs :: Lens' a [String]
extraLibDirs = buildInfo . extraLibDirs
{-# INLINE extraLibDirs #-}
......@@ -283,6 +287,9 @@ instance HasBuildInfo BuildInfo where
extraLibFlavours f s = fmap (\x -> s { T.extraLibFlavours = x }) (f (T.extraLibFlavours s))
{-# INLINE extraLibFlavours #-}
extraDynLibFlavours f s = fmap (\x -> s { T.extraDynLibFlavours = x}) (f (T.extraDynLibFlavours s))
{-# INLINE extraDynLibFlavours #-}
extraLibDirs f s = fmap (\x -> s { T.extraLibDirs = x }) (f (T.extraLibDirs s))
{-# INLINE extraLibDirs #-}
......
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