nixpkgs/pkgs/development/haskell-modules/patches/darcs-setup.patch
2020-04-24 22:00:38 +02:00

121 lines
4.8 KiB
Diff

--- darcs-2.14.2/Setup.hs 2019-01-27 03:14:51.000000000 +1300
+++ darcs.net/Setup.hs 2019-10-18 02:41:57.000000000 +1300
@@ -11,7 +11,9 @@
, TestSuite(testBuildInfo)
, updatePackageDescription
, cppOptions, ccOptions
- , library, libBuildInfo, otherModules )
+ , library, libBuildInfo, otherModules
+ , ComponentName(CExeName)
+ )
import Distribution.Package
( packageVersion )
import Distribution.Version( Version )
@@ -21,24 +23,27 @@
import Distribution.Simple.Setup
(buildVerbosity, copyDest, copyVerbosity, fromFlag,
haddockVerbosity, installVerbosity, sDistVerbosity, replVerbosity )
-import Distribution.Simple.BuildPaths ( autogenModulesDir )
+import Distribution.Simple.BuildPaths ( autogenPackageModulesDir )
import Distribution.System
( OS(Windows), buildOS )
import Distribution.Simple.Utils
(copyFiles, createDirectoryIfMissingVerbose, rawSystemStdout,
- rewriteFile )
+ rewriteFileEx)
+import Distribution.Types.UnqualComponentName
import Distribution.Verbosity
- ( Verbosity )
+ ( Verbosity, silent )
import Distribution.Text
( display )
-import Control.Monad ( unless, void )
+import Control.Monad ( unless, when, void )
import System.Directory
( doesDirectoryExist, doesFileExist )
import System.IO
( openFile, IOMode(..) )
import System.Process (runProcess)
import Data.List( isInfixOf, lines )
+import qualified Data.Map as M
+import Data.Maybe ( isJust )
import System.FilePath ( (</>) )
import Foreign.Marshal.Utils ( with )
import Foreign.Storable ( peek )
@@ -75,8 +80,8 @@
verb = fromFlag $ sDistVerbosity flags
x <- versionPatches verb pkgVer
y <- context verb
- rewriteFile "release/distributed-version" $ show x
- rewriteFile "release/distributed-context" $ show y
+ rewriteFileEx silent "release/distributed-version" $ show x
+ rewriteFileEx silent "release/distributed-context" $ show y
putStrLn "about to hand over"
let pkg' = pkg { library = sanity (library pkg) }
sanity (Just lib) = Just $ lib { libBuildInfo = sanity' $ libBuildInfo lib }
@@ -105,8 +110,7 @@
littleEndian <- testEndianness
let args = ("-DPACKAGE_VERSION=" ++ show' version) :
[arg | (arg, True) <- -- include fst iff snd.
- [-- We have MAPI iff building on/for Windows.
- ("-DHAVE_MAPI", buildOS == Windows),
+ [
("-DLITTLEENDIAN", littleEndian),
("-DBIGENDIAN", not littleEndian)]]
bi = emptyBuildInfo { cppOptions = args, ccOptions = args }
@@ -133,20 +137,26 @@
-- man page
-- ---------------------------------------------------------------------
+hasDarcsExe :: LocalBuildInfo -> Bool
+hasDarcsExe = isJust . M.lookup darcsExe . componentNameMap where
+ darcsExe = CExeName (mkUnqualComponentName "darcs")
+
buildManpage :: LocalBuildInfo -> IO ()
-buildManpage lbi = do
- let darcs = buildDir lbi </> "darcs/darcs"
- manpage = buildDir lbi </> "darcs/darcs.1"
- manpageHandle <- openFile manpage WriteMode
- void $ runProcess darcs ["help","manpage"]
- Nothing Nothing Nothing (Just manpageHandle) Nothing
+buildManpage lbi =
+ when (hasDarcsExe lbi) $ do
+ let darcs = buildDir lbi </> "darcs/darcs"
+ manpage = buildDir lbi </> "darcs/darcs.1"
+ manpageHandle <- openFile manpage WriteMode
+ void $ runProcess darcs ["help","manpage"]
+ Nothing Nothing Nothing (Just manpageHandle) Nothing
-installManpage :: PackageDescription -> LocalBuildInfo
- -> Verbosity -> CopyDest -> IO ()
+installManpage :: PackageDescription -> LocalBuildInfo -> Verbosity -> CopyDest -> IO ()
installManpage pkg lbi verbosity copy =
- copyFiles verbosity
- (mandir (absoluteInstallDirs pkg lbi copy) </> "man1")
- [(buildDir lbi </> "darcs", "darcs.1")]
+ when (hasDarcsExe lbi) $
+ copyFiles
+ verbosity
+ (mandir (absoluteInstallDirs pkg lbi copy) </> "man1")
+ [(buildDir lbi </> "darcs", "darcs.1")]
-- ---------------------------------------------------------------------
-- version module
@@ -187,12 +197,13 @@
generateVersionModule :: Verbosity -> LocalBuildInfo
-> String -> String -> IO ()
generateVersionModule verbosity lbi version state = do
- let dir = autogenModulesDir lbi
+ let dir = autogenPackageModulesDir lbi
createDirectoryIfMissingVerbose verbosity True dir
ctx <- context verbosity
hash <- weakhash verbosity
- rewriteFile (dir </> "Version.hs") $ unlines
+ rewriteFileEx silent (dir </> "Version.hs") $ unlines
["module Version where"
+ ,"import Darcs.Prelude"
,"version, weakhash, context :: String"
,"version = \"" ++ version ++ " (" ++ state ++ ")\""
,"weakhash = " ++ case hash of