Skip to content

Commit 7577105

Browse files
committed
Adds extra-library-flavours
Not absolutely happy with this solution. I fail to come up with a better one though. The issue is that for some libraries, you might want to have _debug, _p, _l, as well as _thr_debug, _thr_p, _thr_l flavours.
1 parent d0e14f5 commit 7577105

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

Cabal/Distribution/PackageDescription/FieldGrammar.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ buildInfoFieldGrammar = BuildInfo
385385
<*> monoidalFieldAla "extra-libraries" (alaList' VCat Token) L.extraLibs
386386
<*> monoidalFieldAla "extra-ghci-libraries" (alaList' VCat Token) L.extraGHCiLibs
387387
<*> monoidalFieldAla "extra-bundled-libraries" (alaList' VCat Token) L.extraBundledLibs
388+
<*> monoidalFieldAla "extra-library-flavours" (alaList' VCat Token) L.extraLibFlavours
388389
<*> monoidalFieldAla "extra-lib-dirs" (alaList' FSep FilePathNT) L.extraLibDirs
389390
<*> monoidalFieldAla "include-dirs" (alaList' FSep FilePathNT) L.includeDirs
390391
<*> monoidalFieldAla "includes" (alaList' FSep FilePathNT) L.includes

Cabal/Distribution/PackageDescription/Parse.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,9 @@ binfoFieldDescrs =
502502
, listFieldWithSep vcat "extra-bundled-libraries"
503503
showToken parseTokenQ
504504
extraBundledLibs (\xs binfo -> binfo{extraBundledLibs=xs})
505+
, listFieldWithSep vcat "extra-library-flavours"
506+
showToken parseTokenQ
507+
extraLibFlavours (\xs binfo -> binfo{extraLibFlavours=xs})
505508
, listField "extra-lib-dirs"
506509
showFilePath parseFilePathQ
507510
extraLibDirs (\xs binfo -> binfo{extraLibDirs=xs})

Cabal/Distribution/Simple/GHC.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,9 +1707,10 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do
17071707
-- copy the built library files over:
17081708
whenHasCode $ do
17091709
whenVanilla $ do
1710-
installOrdinary builtDir targetDir vanillaLibName
1711-
sequence_ [ installOrdinary builtDir targetDir l
1712-
| l <- mkGenericStaticLibName <$> (extraBundledLibs (libBuildInfo lib))]
1710+
sequence_ [ installOrdinary builtDir targetDir (mkGenericStaticLibName (l ++ f))
1711+
| l <- getHSLibraryName (componentUnitId clbi):(extraBundledLibs (libBuildInfo lib))
1712+
, f <- "":extraLibFlavours (libBuildInfo lib)
1713+
]
17131714
whenProf $ installOrdinary builtDir targetDir profileLibName
17141715
whenGHCi $ installOrdinary builtDir targetDir ghciLibName
17151716
whenShared $ installShared builtDir dynlibTargetDir sharedLibName
@@ -1739,7 +1740,6 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do
17391740

17401741
compiler_id = compilerId (compiler lbi)
17411742
uid = componentUnitId clbi
1742-
vanillaLibName = mkLibName uid
17431743
profileLibName = mkProfLibName uid
17441744
ghciLibName = Internal.mkGHCiLibName uid
17451745
sharedLibName = (mkSharedLibName compiler_id) uid

Cabal/Distribution/Types/BuildInfo.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ data BuildInfo = BuildInfo {
8383
-- logic on how this library is built will have to be encoded in a
8484
-- custom Setup for now. Oherwise cabal would need to lear how to
8585
-- call arbitary lirbary builders.
86+
extraLibFlavours :: [String], -- ^ Hidden Flag. This set of strings, will be appended to all lirbaries when
87+
-- copying. E.g. [libHS<name>_<flavour> | flavour <- extraLibFlavours]. This
88+
-- should only be needed in very specific cases, e.g. the `rts` package, where
89+
-- there are multiple copies of slightly differently built libs.
8690
extraLibDirs :: [String],
8791
includeDirs :: [FilePath], -- ^directories to find .h files
8892
includes :: [FilePath], -- ^ The .h files to be found in includeDirs
@@ -131,6 +135,7 @@ instance Monoid BuildInfo where
131135
extraLibs = [],
132136
extraGHCiLibs = [],
133137
extraBundledLibs = [],
138+
extraLibFlavours = [],
134139
extraLibDirs = [],
135140
includeDirs = [],
136141
includes = [],
@@ -175,6 +180,7 @@ instance Semigroup BuildInfo where
175180
extraLibs = combine extraLibs,
176181
extraGHCiLibs = combine extraGHCiLibs,
177182
extraBundledLibs = combine extraBundledLibs,
183+
extraLibFlavours = combine extraLibFlavours,
178184
extraLibDirs = combineNub extraLibDirs,
179185
includeDirs = combineNub includeDirs,
180186
includes = combineNub includes,

Cabal/Distribution/Types/BuildInfo/Lens.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ class HasBuildInfo a where
135135
extraBundledLibs = buildInfo . extraBundledLibs
136136
{-# INLINE extraBundledLibs #-}
137137

138+
extraLibFlavours :: Lens' a [String]
139+
extraLibFlavours = buildInfo . extraLibFlavours
140+
{-# INLINE extraLibFlavours #-}
141+
138142
extraLibDirs :: Lens' a [String]
139143
extraLibDirs = buildInfo . extraLibDirs
140144
{-# INLINE extraLibDirs #-}
@@ -268,6 +272,9 @@ instance HasBuildInfo BuildInfo where
268272
extraBundledLibs f s = fmap (\x -> s { T.extraBundledLibs = x }) (f (T.extraBundledLibs s))
269273
{-# INLINE extraBundledLibs #-}
270274

275+
extraLibFlavours f s = fmap (\x -> s { T.extraLibFlavours = x }) (f (T.extraLibFlavours s))
276+
{-# INLINE extraLibFlavours #-}
277+
271278
extraLibDirs f s = fmap (\x -> s { T.extraLibDirs = x }) (f (T.extraLibDirs s))
272279
{-# INLINE extraLibDirs #-}
273280

0 commit comments

Comments
 (0)