Commit d91e251d authored by cabal's avatar cabal
Browse files

install Haddock documentation in share/package/doc/html and register that path in the ghc-pkg

parent 3edc9324
......@@ -82,14 +82,13 @@ import Distribution.Simple.Register ( register, unregister,
regScriptLocation, unregScriptLocation
)
import Distribution.Simple.Configure(getPersistBuildConfig, maybeGetPersistBuildConfig,
configure, writePersistBuildConfig,
import Distribution.Simple.Configure(LocalBuildInfo(..), getPersistBuildConfig, maybeGetPersistBuildConfig,
findProgram, configure, writePersistBuildConfig,
localBuildInfoFile)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), distPref, srcPref)
import Distribution.Simple.Install(install)
import Distribution.Simple.Utils (die, currentDir, rawSystemVerbose,
defaultPackageDesc, defaultHookedPackageDesc,
moduleToFilePath, findFile)
moduleToFilePath, findFile, distPref, srcPref)
#if mingw32_HOST_OS || mingw32_TARGET_OS
import Distribution.Simple.Utils (rawSystemPath)
#endif
......@@ -102,13 +101,13 @@ import System.Directory(removeFile, doesFileExist, doesDirectoryExist)
import Distribution.License
import Control.Monad(when, unless)
import Data.List ( intersperse, unionBy )
import Data.Maybe ( isJust, fromJust )
import Data.Maybe ( isNothing, isJust, fromJust )
import System.IO.Error (try)
import Distribution.GetOpt
import Distribution.Compat.Directory(createDirectoryIfMissing,removeDirectoryRecursive, copyFile)
import Distribution.Compat.FilePath(joinFileName, joinPaths, splitFileName, joinFileExt,
splitFileExt, changeFileExt)
import Distribution.Compat.FilePath(joinFileName, joinPaths, joinFileExt,
splitFileName, splitFileExt, changeFileExt)
#ifdef DEBUG
import HUnit (Test)
......@@ -401,10 +400,9 @@ haddock pkg_descr lbi hooks (HaddockFlags verbose) = do
mHaddock <- lookupProgram haddockName programConf
maybe (die "haddock command not found") return mHaddock
let targetDir = joinPaths distPref (joinPaths "doc" "html")
let tmpDir = joinPaths (buildDir lbi) "tmp"
createDirectoryIfMissing True tmpDir
createDirectoryIfMissing True targetDir
createDirectoryIfMissing True haddockPref
preprocessSources pkg_descr lbi verbose pps
setupMessage "Running Haddock for" pkg_descr
......@@ -421,14 +419,14 @@ haddock pkg_descr lbi hooks (HaddockFlags verbose) = do
let prologName = showPkg ++ "-haddock-prolog.txt"
writeFile prologName (description pkg_descr ++ "\n")
let outFiles = replaceLitExts inFiles
let haddockFile = joinFileExt (pkgName (package pkg_descr)) "haddock"
let haddockFile = joinFileName haddockPref (haddockName pkg_descr)
-- FIX: replace w/ rawSystemProgramConf?
rawSystemProgram verbose confHaddock
(["-h",
"-o", targetDir,
"-o", haddockPref,
"-t", showPkg ++ ": " ++ synopsis pkg_descr,
"-k", showPkg,
"-D", joinFileName targetDir haddockFile,
"-D", haddockFile,
"-p", prologName]
++ map ("--use-package=" ++) showDepPkgs
++ programArgs confHaddock
......@@ -439,7 +437,7 @@ haddock pkg_descr lbi hooks (HaddockFlags verbose) = do
removeFile prologName
withExe pkg_descr $ \exe -> do
let bi = buildInfo exe
exeTargetDir = targetDir `joinFileName` exeName exe
exeTargetDir = haddockPref `joinFileName` exeName exe
createDirectoryIfMissing True exeTargetDir
inFiles' <- getModulePaths bi (otherModules bi)
srcMainPath <- findFile (hsSourceDirs bi) (modulePath exe)
......
......@@ -60,7 +60,8 @@ import Distribution.PackageDescription (
setupMessage, hasLibs, withLib, withExe )
import Distribution.Simple.LocalBuildInfo (
LocalBuildInfo(..), mkLibDir, mkBinDir, mkDataDir, mkProgDir)
import Distribution.Simple.Utils(copyFileVerbose, die)
import Distribution.Simple.Utils(smartCopySources, copyFileVerbose, mkLibName,
mkProfLibName, mkGHCiLibName, die, rawSystemVerbose)
import Distribution.Compiler (CompilerFlavor(..), Compiler(..))
import Distribution.Setup (CopyFlags(..), CopyDest(..))
......@@ -73,6 +74,14 @@ import qualified Distribution.Simple.JHC as JHC
import qualified Distribution.Simple.Hugs as Hugs
import Control.Monad(when)
import Data.List(any)
import Data.Maybe(fromMaybe)
import Distribution.Compat.Directory(createDirectoryIfMissing, removeDirectoryRecursive,
findExecutable)
import Distribution.Compat.FilePath(splitFileName,joinFileName, dllExtension, exeExtension,
splitFileExt, joinFileExt)
import System.IO.Error(try)
import System.Directory(Permissions(..), getPermissions, setPermissions)
#ifdef DEBUG
import HUnit (Test)
......@@ -84,27 +93,37 @@ install :: PackageDescription
-> CopyFlags
-> IO ()
install pkg_descr lbi (CopyFlags copydest verbose) = do
when (not (null (dataFiles pkg_descr))) $ do
let dataFilesExist = not (null (dataFiles pkg_descr))
docExists <- doesDirectoryExist haddockPref
when (verbose >= 4)
(putStrLn ("directory " ++ haddockPref ++
" does exist: " ++ show docExists))
when (dataFilesExist || docExists) $ do
let dataPref = mkDataDir pkg_descr lbi copydest
createDirectoryIfMissing True dataPref
flip mapM_ (dataFiles pkg_descr) $ \ file -> do
let (dir, _) = splitFileName file
createDirectoryIfMissing True (dataPref `joinFileName` dir)
copyFileVerbose verbose file (dataPref `joinFileName` file)
when docExists $ do
let targetDir = mkHaddockDir pkg_descr lbi copydest
createDirectoryIfMissing True targetDir
copyDirectoryRecursiveVerbose verbose haddockPref targetDir
-- setPermissionsRecursive [Read] targetDir
let buildPref = buildDir lbi
let libPref = mkLibDir pkg_descr lbi copydest
let binPref = mkBinDir pkg_descr lbi copydest
setupMessage ("Installing: " ++ libPref ++ " & " ++ binPref) pkg_descr
case compilerFlavor (compiler lbi) of
GHC -> do when (hasLibs pkg_descr) (GHC.installLib verbose (withPrograms lbi) (withProfLib lbi) (withGHCiLib lbi) libPref buildPref pkg_descr)
GHC.installExe verbose binPref buildPref pkg_descr
JHC -> do withLib pkg_descr () $ JHC.installLib verbose libPref buildPref pkg_descr
withExe pkg_descr $ JHC.installExe verbose binPref buildPref pkg_descr
GHC -> do when (hasLibs pkg_descr) (installLibGHC verbose (withPrograms lbi) (withProfLib lbi) (withGHCiLib lbi) libPref buildPref pkg_descr)
installExeGHC verbose binPref buildPref pkg_descr
JHC -> do withLib pkg_descr () $ installLibJHC verbose libPref buildPref pkg_descr
withExe pkg_descr $ installExeJHC verbose binPref buildPref pkg_descr
Hugs -> do
let progPref = mkProgDir pkg_descr lbi copydest
let targetProgPref = mkProgDir pkg_descr lbi NoCopyDest
Hugs.install verbose libPref progPref binPref targetProgPref buildPref pkg_descr
_ -> die ("only installing with GHC or Hugs is implemented")
_ -> die ("only installing with GHC, JHC or Hugs is implemented")
return ()
-- register step should be performed by caller.
......
......@@ -50,7 +50,7 @@ module Distribution.Simple.LocalBuildInfo (
default_libexecdir,
default_datadir,
default_datasubdir,
mkLibDir, mkLibDirRel, mkBinDir, mkBinDirRel, mkLibexecDir, mkLibexecDirRel, mkDataDir, mkDataDirRel, mkProgDir,
mkLibDir, mkLibDirRel, mkBinDir, mkBinDirRel, mkLibexecDir, mkLibexecDirRel, mkDataDir, mkDataDirRel, mkHaddockDir, mkProgDir,
absolutePath, prefixRelPath,
substDir,
distPref, srcPref, autogenModulesDir, mkIncludeDir
......@@ -274,6 +274,12 @@ mkDataDirRel :: PackageDescription -> LocalBuildInfo -> CopyDest -> Maybe FilePa
mkDataDirRel pkg_descr lbi copydest =
prefixRelPath pkg_descr lbi copydest (datadir lbi `joinFileName` datasubdir lbi)
mkHaddockDir :: PackageDescription -> LocalBuildInfo -> CopyDest -> FilePath
mkHaddockDir pkg_descr lbi copydest =
foldl1 joinPaths [mkDataDir pkg_descr lbi copydest, "doc", "html"]
-- | Directory for program modules (Hugs only).
mkProgDir :: PackageDescription -> LocalBuildInfo -> CopyDest -> FilePath
mkProgDir pkg_descr lbi copydest =
......
......@@ -62,12 +62,11 @@ module Distribution.Simple.Register (
#endif
#endif
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), mkLibDir,
mkIncludeDir)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), mkLibDir)
import Distribution.Compiler (CompilerFlavor(..), Compiler(..))
import Distribution.Setup (RegisterFlags(..), CopyDest(..), userOverride)
import Distribution.PackageDescription (setupMessage, PackageDescription(..),
BuildInfo(..), Library(..))
BuildInfo(..), Library(..), haddockName)
import Distribution.Package (PackageIdentifier(..), showPackageId)
import Distribution.Version (Version(..))
import Distribution.InstalledPackageInfo
......@@ -83,8 +82,7 @@ import Distribution.Compat.Directory
(createDirectoryIfMissing,removeDirectoryRecursive,
setPermissions, getPermissions, Permissions(executable)
)
import Distribution.Compat.FilePath (joinFileName, splitFileName,
isAbsolutePath)
import Distribution.Compat.FilePath (joinFileName)
import System.Directory(doesFileExist, removeFile, getCurrentDirectory)
import System.IO.Error (try)
......@@ -248,13 +246,8 @@ mkInstalledPackageInfo pkg_descr lbi inplace = do
let
lib = fromJust (library pkg_descr) -- checked for Nothing earlier
bi = libBuildInfo lib
build_dir = pwd `joinFileName` buildDir lbi
libdir = mkLibDir pkg_descr lbi NoCopyDest
incdir = mkIncludeDir libdir
(absinc,relinc) = partition isAbsolutePath (includeDirs bi)
--
return
emptyInstalledPackageInfo{
in
emptyInstalledPackageInfo{
IPI.package = package pkg_descr,
IPI.license = license pkg_descr,
IPI.copyright = copyright pkg_descr,
......@@ -285,8 +278,8 @@ mkInstalledPackageInfo pkg_descr lbi inplace = do
IPI.ldOptions = ldOptions bi,
IPI.frameworkDirs = [],
IPI.frameworks = frameworks bi,
IPI.haddockInterfaces = [],
IPI.haddockHTMLs = []
IPI.haddockInterfaces = [haddockFile],
IPI.haddockHTMLs = [haddockDir]
}
-- -----------------------------------------------------------------------------
......
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