Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cabal/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* 'check' reports warnings for various ghc-\*-options fields separately
([#5342](https://github.com/haskell/cabal/issues/5432)).
* `KnownExtension`: added new extension `DerivingVia`.
* Add `extra-dynamic-library-flavours`, to specify extra dynamic library
flavours to build and install from a .cabal file.

----

Expand Down
8 changes: 8 additions & 0 deletions Cabal/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,14 @@ checkCabalVersion pkg =
++ " and 'extra-library-flavours' requires the package "
++ " to specify at least 'cabal-version: >= 2.1'."

, checkVersion [2,5] (any (not . null) $ buildInfoField extraDynLibFlavours) $
PackageDistInexcusable $
"The use of 'extra-dynamic-library-flavours' requires the package "
++ " to specify at least 'cabal-version: >= 2.5'. The flavours are: "
++ commaSep [ flav
| flavs <- buildInfoField extraDynLibFlavours
, flav <- flavs ]

, checkVersion [2,1] (any (not . null)
(buildInfoField virtualModules)) $
PackageDistInexcusable $
Expand Down
1 change: 1 addition & 0 deletions Cabal/Distribution/PackageDescription/FieldGrammar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions Cabal/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -1866,12 +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))
&& null (cxxSources (libBuildInfo lib))
Expand Down
5 changes: 5 additions & 0 deletions Cabal/Distribution/Types/BuildInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -140,6 +143,7 @@ instance Monoid BuildInfo where
extraGHCiLibs = [],
extraBundledLibs = [],
extraLibFlavours = [],
extraDynLibFlavours = [],
extraLibDirs = [],
includeDirs = [],
includes = [],
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions Cabal/Distribution/Types/BuildInfo/Lens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 #-}
Expand Down Expand Up @@ -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 #-}

Expand Down
7 changes: 7 additions & 0 deletions Cabal/doc/file-format-changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ relative to the respective preceding *published* version.
versions of the ``Cabal`` library denote unreleased development
branches which have no stability guarantee.

``cabal-version: 2.5``
----------------------

* Added the `extra-dynamic-library-flavours` field to specify non-trivial
variants of dynamic flavours. It is `extra-library-flavours` but for
shared libraries. Mainly useful for GHC's RTS library.

``cabal-version: 2.4``
----------------------

Expand Down
3 changes: 3 additions & 0 deletions Cabal/tests/ParserTests/regressions/Octree-0.5.expr
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -126,6 +127,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -215,6 +217,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down
2 changes: 2 additions & 0 deletions Cabal/tests/ParserTests/regressions/common.expr
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Just Haskell2010,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -89,6 +90,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down
6 changes: 6 additions & 0 deletions Cabal/tests/ParserTests/regressions/common2.expr
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -100,6 +101,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Just Haskell2010,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -179,6 +181,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -241,6 +244,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -299,6 +303,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -361,6 +366,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down
2 changes: 2 additions & 0 deletions Cabal/tests/ParserTests/regressions/elif.expr
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -87,6 +88,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Just Haskell2010,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down
5 changes: 5 additions & 0 deletions Cabal/tests/ParserTests/regressions/elif2.expr
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -89,6 +90,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -142,6 +144,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -197,6 +200,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Nothing,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -250,6 +254,7 @@ GenericPackageDescription
defaultExtensions = [],
defaultLanguage = Just Haskell2010,
extraBundledLibs = [],
extraDynLibFlavours = [],
extraFrameworkDirs = [],
extraGHCiLibs = [],
extraLibDirs = [],
Expand Down
Loading