Skip to content

Commit

Permalink
Adds suppor for extra-bundled-libraries
Browse files Browse the repository at this point in the history
# Conflicts:
#	Cabal/Distribution/PackageDescription/Parsec/FieldDescr.hs
  • Loading branch information
angerman committed Nov 1, 2017
1 parent 2d5ccc6 commit f6b2394
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Cabal/Distribution/PackageDescription/Parse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,9 @@ binfoFieldDescrs =
, listFieldWithSep vcat "extra-ghci-libraries"
showToken parseTokenQ
extraGHCiLibs (\xs binfo -> binfo{extraGHCiLibs=xs})
, listFieldWithSep vcat "extra-bundled-libraries"
showToken parseTokenQ
extraBundledLibs (\xs binfo -> binfo{extraBundledLibs=xs})
, listField "extra-lib-dirs"
showFilePath parseFilePathQ
extraLibDirs (\xs binfo -> binfo{extraLibDirs=xs})
Expand Down
7 changes: 6 additions & 1 deletion Cabal/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
ifReplLib (runGhcProg replOpts)

-- build any C sources
-- TODO: Add support for S and CMM files.
unless (not has_code || null (cSources libBi)) $ do
info verbosity "Building C Sources..."
sequence_
Expand Down Expand Up @@ -1705,7 +1706,10 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do

-- copy the built library files over:
whenHasCode $ do
whenVanilla $ installOrdinary builtDir targetDir vanillaLibName
whenVanilla $ do
installOrdinary builtDir targetDir vanillaLibName
sequence_ [ installOrdinary builtDir targetDir libName
| libName <- mkGenericStaticLibName <$> (extraBundledLibs (libBuildInfo lib))]
whenProf $ installOrdinary builtDir targetDir profileLibName
whenGHCi $ installOrdinary builtDir targetDir ghciLibName
whenShared $ installShared builtDir dynlibTargetDir sharedLibName
Expand All @@ -1716,6 +1720,7 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do
install isShared srcDir dstDir name = do
let src = srcDir </> name
dst = dstDir </> name

createDirectoryIfMissingVerbose verbosity True dstDir

if isShared
Expand Down
7 changes: 4 additions & 3 deletions Cabal/Distribution/Simple/Register.hs
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,10 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
IPI.libraryDirs = libdirs,
IPI.libraryDynDirs = dynlibdirs,
IPI.dataDir = datadir installDirs,
IPI.hsLibraries = if hasLibrary
then [getHSLibraryName (componentUnitId clbi)]
else [],
IPI.hsLibraries = extraBundledLibs bi
++ if hasLibrary
then [getHSLibraryName (componentUnitId clbi)]
else [],
IPI.extraLibraries = extraLibs bi,
IPI.extraGHCiLibraries = extraGHCiLibs bi,
IPI.includeDirs = absinc ++ adjustRelIncDirs relinc,
Expand Down
9 changes: 9 additions & 0 deletions Cabal/Distribution/Types/BuildInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ data BuildInfo = BuildInfo {

extraLibs :: [String], -- ^ what libraries to link with when compiling a program that uses your package
extraGHCiLibs :: [String], -- ^ if present, overrides extraLibs when package is loaded with GHCi.
extraBundledLibs :: [String], -- ^ if present, adds libs to hs-lirbaries, which become part of the package.
-- Example: the Cffi library shipping with the rts, alognside the HSrts-1.0.a,.o,...
-- Example 2: a library that is being built by a foreing tool (e.g. rust)
-- and copied and registered together with this library. The
-- logic on how this library is built will have to be encoded in a
-- custom Setup for now. Oherwise cabal would need to lear how to
-- call arbitary lirbary builders.
extraLibDirs :: [String],
includeDirs :: [FilePath], -- ^directories to find .h files
includes :: [FilePath], -- ^ The .h files to be found in includeDirs
Expand Down Expand Up @@ -119,6 +126,7 @@ instance Monoid BuildInfo where
oldExtensions = [],
extraLibs = [],
extraGHCiLibs = [],
extraBundledLibs = [],
extraLibDirs = [],
includeDirs = [],
includes = [],
Expand Down Expand Up @@ -160,6 +168,7 @@ instance Semigroup BuildInfo where
oldExtensions = combineNub oldExtensions,
extraLibs = combine extraLibs,
extraGHCiLibs = combine extraGHCiLibs,
extraBundledLibs = combine extraBundledLibs,
extraLibDirs = combineNub extraLibDirs,
includeDirs = combineNub includeDirs,
includes = combineNub includes,
Expand Down

0 comments on commit f6b2394

Please sign in to comment.