Commit 1ce2d3df authored by ijones's avatar ijones
Browse files

broke out writing of installedPackageConfig into build step

This will be necessary for creating debian packages.
parent 3e7a3b1a
......@@ -60,7 +60,8 @@ import Distribution.Setup
import Distribution.Simple.Build ( build )
import Distribution.Simple.SrcDist ( sdist )
import Distribution.Simple.Register ( register, unregister, installedPkgConfigFile )
import Distribution.Simple.Register ( register, unregister,
writeInstalledConfig, installedPkgConfigFile )
import Distribution.Simple.Configure(LocalBuildInfo(..), getPersistBuildConfig,
configure, writePersistBuildConfig, localBuildInfoFile)
......@@ -118,7 +119,8 @@ defaultMainNoRead pkg_descr
no_extra_flags args
localbuildinfo <- getPersistBuildConfig
build buildPref pkg_descr localbuildinfo
writeInstalledConfig pkg_descr localbuildinfo
CleanCmd -> do
(_, args) <- parseCleanArgs args []
no_extra_flags args
......
......@@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Simple.Register (
register,
unregister,
writeInstalledConfig,
installedPkgConfigFile,
#ifdef DEBUG
hunitTests
......@@ -60,6 +61,7 @@ import Distribution.Simple.GHCPackageConfig (mkGHCPackageConfig, showGHCPackageC
import qualified Distribution.Simple.GHCPackageConfig as GHC (localPackageConfig)
import System(getEnv)
import System.Directory(doesFileExist)
import Control.Monad (when, unless)
......@@ -70,6 +72,7 @@ import HUnit (Test)
-- -----------------------------------------------------------------------------
-- Registration
-- |Be sure to call writeInstalledConfig first
register :: PackageDescription -> LocalBuildInfo
-> Bool -- ^Install in the user's database?
-> IO ()
......@@ -80,13 +83,22 @@ register pkg_descr lbi userInst = do
GHC -> do let pkg_config = mkGHCPackageConfig pkg_descr lbi
(localConf, pkgConfExists) <- GHC.localPackageConfig
unless pkgConfExists $ writeFile localConf "[]\n"
writeFile installedPkgConfigFile (showGHCPackageConfig pkg_config)
instConfExists <- doesFileExist installedPkgConfigFile
unless instConfExists (writeInstalledConfig pkg_descr lbi)
rawSystemExit (compilerPkgTool (compiler lbi))
(["--auto-ghci-libs", "--add-package",
"--input-file="++installedPkgConfigFile]
++ (if userInst then ["--config-file=" ++ localConf] else []))
_ -> die ("only registering with GHC is implemented")
-- |Register doesn't drop the register info file, it must be done in a separate step.
writeInstalledConfig :: PackageDescription -> LocalBuildInfo -> IO ()
writeInstalledConfig pkg_descr lbi = do
case compilerFlavor (compiler lbi) of
GHC -> do let pkg_config = mkGHCPackageConfig pkg_descr lbi
writeFile installedPkgConfigFile (showGHCPackageConfig pkg_config)
_ -> die ("only registering with GHC is implemented")
installedPkgConfigFile :: String
installedPkgConfigFile = ".installed-pkg-config"
......
Supports Markdown
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