Commit f6b2394c authored by Moritz Angermann's avatar Moritz Angermann

Adds suppor for `extra-bundled-libraries`

# Conflicts:
#	Cabal/Distribution/PackageDescription/Parsec/FieldDescr.hs
parent 2d5ccc6a
......@@ -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})
......
......@@ -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_
......@@ -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
......@@ -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
......
......@@ -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,
......
......@@ -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
......@@ -119,6 +126,7 @@ instance Monoid BuildInfo where
oldExtensions = [],
extraLibs = [],
extraGHCiLibs = [],
extraBundledLibs = [],
extraLibDirs = [],
includeDirs = [],
includes = [],
......@@ -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,
......
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