------------------------------------------------------------------------------- |-- Module : Distribution.Simple.Configure-- Copyright : Isaac Jones 2003-2005---- Maintainer : cabal-devel@haskell.org-- Portability : portable---- This deals with the /configure/ phase. It provides the 'configure' action-- which is given the package description and configure flags. It then tries-- to: configure the compiler; resolves any conditionals in the package-- description; resolve the package dependencies; check if all the extensions-- used by this package are supported by the compiler; check that all the build-- tools are available (including version checks if appropriate); checks for-- any required @pkg-config@ packages (updating the 'BuildInfo' with the-- results)-- -- Then based on all this it saves the info in the 'LocalBuildInfo' and writes-- it out to the @dist\/setup-config@ file. It also displays various details to-- the user, the amount of information displayed depending on the verbosity-- level.{- All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Isaac Jones nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}moduleDistribution.Simple.Configure(configure,writePersistBuildConfig,getPersistBuildConfig,checkPersistBuildConfig,maybeGetPersistBuildConfig,-- getConfiguredPkgDescr,localBuildInfoFile,getInstalledPackages,configDependency,configCompiler,configCompilerAux,ccLdOptionsBuildInfo,tryGetConfigStateFile,)whereimportDistribution.Simple.Compiler(CompilerFlavor(..),Compiler(compilerId),compilerFlavor,compilerVersion,showCompilerId,unsupportedExtensions,PackageDB(..))importDistribution.Package(PackageName(PackageName),PackageIdentifier(PackageIdentifier),packageVersion,Package(..),Dependency(Dependency))importDistribution.InstalledPackageInfo(InstalledPackageInfo,emptyInstalledPackageInfo)importqualifiedDistribution.InstalledPackageInfoasInstalledPackageInfo(InstalledPackageInfo_(package,depends))importqualifiedDistribution.Simple.PackageIndexasPackageIndeximportDistribution.Simple.PackageIndex(PackageIndex)importDistribution.PackageDescriptionasPD(PackageDescription(..),GenericPackageDescription(..),Library(..),hasLibs,Executable(..),BuildInfo(..),HookedBuildInfo,updatePackageDescription,allBuildInfo,FlagName(..))importDistribution.PackageDescription.Configuration(finalizePackageDescription)importDistribution.PackageDescription.Check(PackageCheck(..),checkPackage,checkConfiguredPackage,checkPackageFiles)importDistribution.Simple.Program(Program(..),ProgramLocation(..),ConfiguredProgram(..),ProgramConfiguration,defaultProgramConfiguration,configureAllKnownPrograms,knownPrograms,userSpecifyArgss,userSpecifyPaths,lookupKnownProgram,requireProgram,pkgConfigProgram,rawSystemProgramStdoutConf)importDistribution.Simple.Setup(ConfigFlags(..),CopyDest(..),fromFlag,fromFlagOrDefault,flagToMaybe)importDistribution.Simple.InstallDirs(InstallDirs(..),defaultInstallDirs,combineInstallDirs)importDistribution.Simple.LocalBuildInfo(LocalBuildInfo(..),absoluteInstallDirs,prefixRelativeInstallDirs)importDistribution.Simple.Utils(die,warn,info,setupMessage,createDirectoryIfMissingVerbose,intercalate,comparing,cabalVersion,cabalBootstrapping,withFileContents,writeFileAtomic)importDistribution.Simple.Register(removeInstalledConfig)importDistribution.System(OS(..),buildOS,buildArch)importDistribution.Version(Version(..),VersionRange(..),orLaterVersion,withinRange)importDistribution.Verbosity(Verbosity,lessVerbose)importqualifiedDistribution.Simple.GHCasGHCimportqualifiedDistribution.Simple.JHCasJHCimportqualifiedDistribution.Simple.NHCasNHCimportqualifiedDistribution.Simple.HugsasHugsimportControl.Monad(when,unless,foldM)importData.List(nub,partition,isPrefixOf,maximumBy)importData.Maybe(fromMaybe,isNothing)importData.Monoid(Monoid(..))importSystem.Directory(doesFileExist,getModificationTime,createDirectoryIfMissing)importSystem.Exit(ExitCode(..),exitWith)importSystem.FilePath((</>),isAbsolute)importqualifiedSystem.Info(compilerName,compilerVersion)importSystem.IO(hPutStrLn,stderr)importDistribution.Text(Text(disp),display,simpleParse)importText.PrettyPrint.HughesPJ(comma,punctuate,render,nest,sep)importDistribution.Compat.Exception(catchExit,catchIO)importPreludehiding(catch)tryGetConfigStateFile::(Reada)=>FilePath->IO(EitherStringa)tryGetConfigStateFilefilename=doexists<-doesFileExistfilenameifnotexiststhenreturn(Leftmissing)elsewithFileContentsfilename$\str->caselinesstrof[headder,rest]->casecheckHeaderheadderofJustmsg->return(Leftmsg)Nothing->casereadsrestof[(bi,_)]->return(Rightbi)_->return(LeftcantParse)_->return(LeftcantParse)wherecheckHeader::String->MaybeStringcheckHeaderheader=caseparseHeaderheaderofJust(cabalId,compId)|cabalId==currentCabalId->Nothing|otherwise->Just(badVersioncabalIdcompId)Nothing->JustcantParsemissing="Run the 'configure' command first."cantParse="Saved package config file seems to be corrupt. "++"Try re-running the 'configure' command."badVersioncabalIdcompId="You need to re-run the 'configure' command. "++"The version of Cabal being used has changed (was "++displaycabalId++", now "++displaycurrentCabalId++")."++badcompilercompIdbadcompilercompId|compId==currentCompilerId=""|otherwise=" Additionally the compiler is different (was "++displaycompId++", now "++displaycurrentCompilerId++") which is probably the cause of the problem."-- internal functiontryGetPersistBuildConfig::FilePath->IO(EitherStringLocalBuildInfo)tryGetPersistBuildConfigdistPref=tryGetConfigStateFile(localBuildInfoFiledistPref)-- |Read the 'localBuildInfoFile'. Error if it doesn't exist. Also-- fail if the file containing LocalBuildInfo is older than the .cabal-- file, indicating that a re-configure is required.getPersistBuildConfig::FilePath->IOLocalBuildInfogetPersistBuildConfigdistPref=dolbi<-tryGetPersistBuildConfigdistPrefeitherdiereturnlbi-- |Try to read the 'localBuildInfoFile'.maybeGetPersistBuildConfig::FilePath->IO(MaybeLocalBuildInfo)maybeGetPersistBuildConfigdistPref=dolbi<-tryGetPersistBuildConfigdistPrefreturn$either(constNothing)Justlbi-- |After running configure, output the 'LocalBuildInfo' to the-- 'localBuildInfoFile'.writePersistBuildConfig::FilePath->LocalBuildInfo->IO()writePersistBuildConfigdistPreflbi=docreateDirectoryIfMissingFalsedistPrefwriteFileAtomic(localBuildInfoFiledistPref)(showHeaderpkgid++'\n':showlbi)wherepkgid=packageId(localPkgDescrlbi)showHeader::PackageIdentifier->StringshowHeaderpkgid="Saved package config for "++displaypkgid++" written by "++displaycurrentCabalId++" using "++displaycurrentCompilerIdwherecurrentCabalId::PackageIdentifiercurrentCabalId=PackageIdentifier(PackageName"Cabal")currentVersionwherecurrentVersion|cabalBootstrapping=Version[0][]|otherwise=cabalVersioncurrentCompilerId::PackageIdentifiercurrentCompilerId=PackageIdentifier(PackageNameSystem.Info.compilerName)System.Info.compilerVersionparseHeader::String->Maybe(PackageIdentifier,PackageIdentifier)parseHeaderheader=casewordsheaderof["Saved","package","config","for",pkgid,"written","by",cabalid,"using",compilerid]->case(simpleParsepkgid::MaybePackageIdentifier,simpleParsecabalid,simpleParsecompilerid)of(Just_,Justcabalid',Justcompilerid')->Just(cabalid',compilerid')_->Nothing_->Nothing-- |Check that localBuildInfoFile is up-to-date with respect to the-- .cabal file.checkPersistBuildConfig::FilePath->FilePath->IO()checkPersistBuildConfigdistPrefpkg_descr_file=dot0<-getModificationTimepkg_descr_filet1<-getModificationTime$localBuildInfoFiledistPrefwhen(t0>t1)$die(pkg_descr_file++" has been changed, please re-configure.")-- |@dist\/setup-config@localBuildInfoFile::FilePath->FilePathlocalBuildInfoFiledistPref=distPref</>"setup-config"-- ------------------------------------------------------------------------------- * Configuration-- ------------------------------------------------------------------------------- |Perform the \"@.\/setup configure@\" action.-- Returns the @.setup-config@ file.configure::(EitherGenericPackageDescriptionPackageDescription,HookedBuildInfo)->ConfigFlags->IOLocalBuildInfoconfigure(pkg_descr0,pbi)cfg=doletdistPref=fromFlag(configDistPrefcfg)verbosity=fromFlag(configVerbositycfg)setupMessageverbosity"Configuring"(packageId(eitherpackageDescriptionidpkg_descr0))createDirectoryIfMissingVerbose(lessVerboseverbosity)TruedistPrefletprogramsConfig=userSpecifyArgss(configProgramArgscfg).userSpecifyPaths(configProgramPathscfg)$configProgramscfguserInstall=fromFlag(configUserInstallcfg)defaultPackageDB|userInstall=UserPackageDB|otherwise=GlobalPackageDBpackageDb=fromFlagOrDefaultdefaultPackageDB(configPackageDBcfg)-- detect compiler(comp,programsConfig')<-configCompiler(flagToMaybe$configHcFlavorcfg)(flagToMaybe$configHcPathcfg)(flagToMaybe$configHcPkgcfg)programsConfig(lessVerboseverbosity)letversion=compilerVersioncompflavor=compilerFlavorcomp-- FIXME: currently only GHC has hc-pkgmaybePackageSet<-getInstalledPackages(lessVerboseverbosity)comppackageDbprogramsConfig'(pkg_descr0',flags)<-casepkg_descr0ofLeftppd->casefinalizePackageDescription(configConfigurationsFlagscfg)maybePackageSetDistribution.System.buildOSDistribution.System.buildArch(compilerIdcomp)(configConstraintscfg)ppdofRightr->returnrLeftmissing->die$"At least the following dependencies are missing:\n"++(render.nest4.sep.punctuatecomma$mapdispmissing)Rightpd->return(pd,[])-- add extra include/lib dirs as specified in cfg-- we do it here so that those get checked tooletpkg_descr=addExtraIncludeLibDirspkg_descr0'when(not(nullflags))$infoverbosity$"Flags chosen: "++intercalate", "[name++"="++displayvalue|(FlagNamename,value)<-flags]checkPackageProblemsverbosity(eitherJust(\_->Nothing)pkg_descr0)--TODO: make the Either go away(updatePackageDescriptionpbipkg_descr)letpackageSet=fromMaybebogusPackageSetmaybePackageSet-- FIXME: For Hugs, nhc98 and other compilers we do not know what-- packages are already installed, so we just make some up, pretend-- that they do exist and just hope for the best. We make them up-- based on what other package the package we're currently building-- happens to depend on. See 'inventBogusPackageId' below.-- Let's hope they really are installed... :-)bogusDependencies=mapinventBogusPackageId(buildDependspkg_descr)bogusPackageSet=PackageIndex.fromList[emptyInstalledPackageInfo{InstalledPackageInfo.package=bogusPackageId-- note that these bogus packages have no other dependencies}|bogusPackageId<-bogusDependencies]dep_pkgs<-caseflavorofGHC->mapM(configDependencyverbositypackageSet)(buildDependspkg_descr)JHC->mapM(configDependencyverbositypackageSet)(buildDependspkg_descr)_->returnbogusDependenciespackageDependsIndex<-casePackageIndex.dependencyClosurepackageSetdep_pkgsofLeftpackageDependsIndex->returnpackageDependsIndexRightbroken->die$"The following installed packages are broken because other"++" packages they depend on are missing. These broken "++"packages must be rebuilt before they can be used.\n"++unlines["package "++display(packageIdpkg)++" is broken due to missing package "++intercalate", "(mapdisplaydeps)|(pkg,deps)<-broken]letpseudoTopPkg=emptyInstalledPackageInfo{InstalledPackageInfo.package=packageIdpkg_descr,InstalledPackageInfo.depends=dep_pkgs}casePackageIndex.dependencyInconsistencies.PackageIndex.insertpseudoTopPkg$packageDependsIndexof[]->return()inconsistencies->warnverbosity$"This package indirectly depends on multiple versions of the same "++"package. This is highly likely to cause a compile failure.\n"++unlines["package "++displaypkg++" requires "++display(PackageIdentifiernamever)|(name,uses)<-inconsistencies,(pkg,ver)<-uses]removeInstalledConfigdistPref-- installation directoriesdefaultDirs<-defaultInstallDirsflavoruserInstall(hasLibspkg_descr)letinstallDirs=combineInstallDirsfromFlagOrDefaultdefaultDirs(configInstallDirscfg)-- check extensionsletextlist=nub$concatMapextensions(allBuildInfopkg_descr)letexts=unsupportedExtensionscompextlistunless(nullexts)$warnverbosity$-- Just warn, FIXME: Should this be an error?displayflavor++" does not support the following extensions: "++intercalate", "(mapdisplayexts)letrequiredBuildTools=concatMapbuildTools(allBuildInfopkg_descr)programsConfig''<-configureAllKnownPrograms(lessVerboseverbosity)programsConfig'>>=configureRequiredProgramsverbosityrequiredBuildTools(pkg_descr',programsConfig''')<-configurePkgconfigPackagesverbositypkg_descrprogramsConfig''split_objs<-ifnot(fromFlag$configSplitObjscfg)thenreturnFalseelsecaseflavorofGHC|version>=Version[6,5][]->returnTrue_->dowarnverbosity("this compiler does not support "++"--enable-split-objs; ignoring")returnFalseletlbi=LocalBuildInfo{installDirTemplates=installDirs,compiler=comp,buildDir=distPref</>"build",scratchDir=fromFlagOrDefault(distPref</>"scratch")(configScratchDircfg),packageDeps=dep_pkgs,installedPkgs=packageDependsIndex,pkgDescrFile=Nothing,localPkgDescr=pkg_descr',withPrograms=programsConfig''',withVanillaLib=fromFlag$configVanillaLibcfg,withProfLib=fromFlag$configProfLibcfg,withSharedLib=fromFlag$configSharedLibcfg,withProfExe=fromFlag$configProfExecfg,withOptimization=fromFlag$configOptimizationcfg,withGHCiLib=fromFlag$configGHCiLibcfg,splitObjs=split_objs,stripExes=fromFlag$configStripExescfg,withPackageDB=packageDb,progPrefix=fromFlag$configProgPrefixcfg,progSuffix=fromFlag$configProgSuffixcfg}letdirs=absoluteInstallDirspkg_descrlbiNoCopyDestrelative=prefixRelativeInstallDirspkg_descrlbiunless(isAbsolute(prefixdirs))$die$"expected an absolute directory name for --prefix: "++prefixdirsinfoverbosity$"Using "++displaycurrentCabalId++" compiled by "++displaycurrentCompilerIdinfoverbosity$"Using compiler: "++showCompilerIdcompinfoverbosity$"Using install prefix: "++prefixdirsletdirinfonamedirisPrefixRelative=infoverbosity$name++" installed in: "++dir++relNotewhererelNote=casebuildOSofWindows|not(hasLibspkg_descr)&&isNothingisPrefixRelative->" (fixed location)"_->""dirinfo"Binaries"(bindirdirs)(bindirrelative)dirinfo"Libraries"(libdirdirs)(libdirrelative)dirinfo"Private binaries"(libexecdirdirs)(libexecdirrelative)dirinfo"Data files"(datadirdirs)(datadirrelative)dirinfo"Documentation"(docdirdirs)(docdirrelative)sequence_[reportProgramverbosityprogconfiguredProg|(prog,configuredProg)<-knownProgramsprogramsConfig''']returnlbiwhereaddExtraIncludeLibDirspkg_descr=letextraBi=mempty{extraLibDirs=configExtraLibDirscfg,PD.includeDirs=configExtraIncludeDirscfg}modifyLibl=l{libBuildInfo=libBuildInfol`mappend`extraBi}modifyExecutablee=e{buildInfo=buildInfoe`mappend`extraBi}inpkg_descr{library=modifyLib`fmap`librarypkg_descr,executables=modifyExecutable`map`executablespkg_descr}-- ------------------------------------------------------------------------------- Configuring package dependencies-- |Converts build dependencies to a versioned dependency. only sets-- version information for exact versioned dependencies.inventBogusPackageId::Dependency->PackageIdentifier-- if they specify the exact version, use that:inventBogusPackageId(Dependencys(ThisVersionv))=PackageIdentifiersv-- otherwise, just set it to emptyinventBogusPackageId(Dependencys_)=PackageIdentifiers(Version[][])reportProgram::Verbosity->Program->MaybeConfiguredProgram->IO()reportProgramverbosityprogNothing=infoverbosity$"No "++programNameprog++" found"reportProgramverbosityprog(JustconfiguredProg)=infoverbosity$"Using "++programNameprog++version++locationwherelocation=caseprogramLocationconfiguredProgofFoundOnSystemp->" found on system at: "++pUserSpecifiedp->" given by user at: "++pversion=caseprogramVersionconfiguredProgofNothing->""Justv->" version "++displayvhackageUrl::StringhackageUrl="http://hackage.haskell.org/cgi-bin/hackage-scripts/package/"-- | Test for a package dependency and record the version we have installed.configDependency::Verbosity->PackageIndexInstalledPackageInfo->Dependency->IOPackageIdentifierconfigDependencyverbosityindexdep@(Dependencypkgname_)=casePackageIndex.lookupDependencyindexdepof[]->die$"cannot satisfy dependency "++displaydep++"\n"++"Perhaps you need to download and install it from\n"++hackageUrl++displaypkgname++"?"pkgs->doletpkgid=maximumBy(comparingpackageVersion)(mappackageIdpkgs)infoverbosity$"Dependency "++displaydep++": using "++displaypkgidreturnpkgidgetInstalledPackages::Verbosity->Compiler->PackageDB->ProgramConfiguration->IO(Maybe(PackageIndexInstalledPackageInfo))getInstalledPackagesverbositycomppackageDbprogconf=doinfoverbosity"Reading installed packages..."casecompilerFlavorcompofGHC->Just`fmap`GHC.getInstalledPackagesverbositypackageDbprogconfJHC->Just`fmap`JHC.getInstalledPackagesverbositypackageDbprogconf_->returnNothing-- ------------------------------------------------------------------------------- Configuring program dependenciesconfigureRequiredPrograms::Verbosity->[Dependency]->ProgramConfiguration->IOProgramConfigurationconfigureRequiredProgramsverbositydepsconf=foldM(configureRequiredProgramverbosity)confdepsconfigureRequiredProgram::Verbosity->ProgramConfiguration->Dependency->IOProgramConfigurationconfigureRequiredProgramverbosityconf(Dependency(PackageNameprogName)verRange)=caselookupKnownProgramprogNameconfofNothing->die("Unknown build tool "++progName)Justprog->snd`fmap`requireProgramverbosityprogverRangeconf-- ------------------------------------------------------------------------------- Configuring pkg-config package dependenciesconfigurePkgconfigPackages::Verbosity->PackageDescription->ProgramConfiguration->IO(PackageDescription,ProgramConfiguration)configurePkgconfigPackagesverbositypkg_descrconf|nullallpkgs=return(pkg_descr,conf)|otherwise=do(_,conf')<-requireProgram(lessVerboseverbosity)pkgConfigProgram(orLaterVersion$Version[0,9,0][])confmapM_requirePkgallpkgslib'<-updateLibrary(librarypkg_descr)exes'<-mapMupdateExecutable(executablespkg_descr)letpkg_descr'=pkg_descr{library=lib',executables=exes'}return(pkg_descr',conf')whereallpkgs=concatMappkgconfigDepends(allBuildInfopkg_descr)pkgconfig=rawSystemProgramStdoutConf(lessVerboseverbosity)pkgConfigProgramconfrequirePkgdep@(Dependency(PackageNamepkg)range)=doversion<-pkgconfig["--modversion",pkg]`catchIO`(\_->dienotFound)`catchExit`(\_->dienotFound)casesimpleParseversionofNothing->die"parsing output of pkg-config --modversion failed"Justv|not(withinRangevrange)->die(badVersionv)|otherwise->infoverbosity(depSatisfiedv)wherenotFound="The pkg-config package "++pkg++versionRequirement++" is required but it could not be found."badVersionv="The pkg-config package "++pkg++versionRequirement++" is required but the version installed on the"++" system is version "++displayvdepSatisfiedv="Dependency "++displaydep++": using version "++displayvversionRequirement|range==AnyVersion=""|otherwise=" version "++displayrangeupdateLibraryNothing=returnNothingupdateLibrary(Justlib)=dobi<-pkgconfigBuildInfo(pkgconfigDepends(libBuildInfolib))return$Justlib{libBuildInfo=libBuildInfolib`mappend`bi}updateExecutableexe=dobi<-pkgconfigBuildInfo(pkgconfigDepends(buildInfoexe))returnexe{buildInfo=buildInfoexe`mappend`bi}pkgconfigBuildInfo::[Dependency]->IOBuildInfopkgconfigBuildInfopkgdeps=doletpkgs=nub[displaypkg|Dependencypkg_<-pkgdeps]ccflags<-pkgconfig("--cflags":pkgs)ldflags<-pkgconfig("--libs":pkgs)return(ccLdOptionsBuildInfo(wordsccflags)(wordsldflags))-- | Makes a 'BuildInfo' from C compiler and linker flags.---- This can be used with the output from configuration programs like pkg-config-- and similar package-specific programs like mysql-config, freealut-config etc.-- For example:---- > ccflags <- rawSystemProgramStdoutConf verbosity prog conf ["--cflags"]-- > ldflags <- rawSystemProgramStdoutConf verbosity prog conf ["--libs"]-- > return (ccldOptionsBuildInfo (words ccflags) (words ldflags))--ccLdOptionsBuildInfo::[String]->[String]->BuildInfoccLdOptionsBuildInfocflagsldflags=let(includeDirs',cflags')=partition("-I"`isPrefixOf`)cflags(extraLibs',ldflags')=partition("-l"`isPrefixOf`)ldflags(extraLibDirs',ldflags'')=partition("-L"`isPrefixOf`)ldflags'inmempty{PD.includeDirs=map(drop2)includeDirs',PD.extraLibs=map(drop2)extraLibs',PD.extraLibDirs=map(drop2)extraLibDirs',PD.ccOptions=cflags',PD.ldOptions=ldflags''}-- ------------------------------------------------------------------------------- Determining the compiler detailsconfigCompilerAux::ConfigFlags->IO(Compiler,ProgramConfiguration)configCompilerAuxcfg=configCompiler(flagToMaybe$configHcFlavorcfg)(flagToMaybe$configHcPathcfg)(flagToMaybe$configHcPkgcfg)defaultProgramConfiguration(fromFlag(configVerbositycfg))configCompiler::MaybeCompilerFlavor->MaybeFilePath->MaybeFilePath->ProgramConfiguration->Verbosity->IO(Compiler,ProgramConfiguration)configCompilerNothing____=die"Unknown compiler"configCompiler(JusthcFlavor)hcPathhcPkgconfverbosity=docasehcFlavorofGHC->GHC.configureverbosityhcPathhcPkgconfJHC->JHC.configureverbosityhcPathhcPkgconfHugs->Hugs.configureverbosityhcPathhcPkgconfNHC->NHC.configureverbosityhcPathhcPkgconf_->die"Unknown compiler"-- | Output package check warnings and errors. Exit if any errors.checkPackageProblems::Verbosity->MaybeGenericPackageDescription->PackageDescription->IO()checkPackageProblemsverbositymgpkgpkg=doioChecks<-checkPackageFilespkg"."letpureChecks=casemgpkgofJustgpkg->checkPackagegpkg(Justpkg)Nothing->checkConfiguredPackagepkgerrors=[e|PackageBuildImpossiblee<-pureChecks++ioChecks]warnings=[w|PackageBuildWarningw<-pureChecks++ioChecks]ifnullerrorsthenmapM_(warnverbosity)warningselsedomapM_(hPutStrLnstderr.("Error: "++))errorsexitWith(ExitFailure1)-- ------------------------------------------------------------------------------- Tests{- Too specific:
hunitTests :: [Test]
hunitTests = []
packageID = PackageIdentifier "Foo" (Version [1] [])
= [TestCase $
do let simonMarGHCLoc = "/usr/bin/ghc"
simonMarGHC <- configure emptyPackageDescription {package=packageID}
(Just GHC,
Just simonMarGHCLoc,
Nothing, Nothing)
assertEqual "finding ghc, etc on simonMar's machine failed"
(LocalBuildInfo "/usr" (Compiler GHC
(Version [6,2,2] []) simonMarGHCLoc
(simonMarGHCLoc ++ "-pkg")) [] [])
simonMarGHC
]
-}