poppler 0.13 → 0.13.1
raw patch · 6 files changed
+93/−78 lines, 6 files
Files
- Graphics/UI/Gtk/Poppler/Structs.hsc +1/−1
- Graphics/UI/Gtk/Poppler/Types.chs +1/−0
- Gtk2HsSetup.hs +79/−30
- SetupMain.hs +4/−39
- SetupWrapper.hs +3/−3
- poppler.cabal +5/−5
Graphics/UI/Gtk/Poppler/Structs.hsc view
@@ -22,7 +22,7 @@ -- #hide #include <glib-2.0/glib.h>-#include <glib/poppler.h>+#include <poppler.h> #include "template-hsc-gtk2hs.h" -- |
Graphics/UI/Gtk/Poppler/Types.chs view
@@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# OPTIONS_HADDOCK hide #-}+{-# OPTIONS_GHC -fno-warn-unused-imports #-} -- -*-haskell-*- -- -------------------- automatically generated file - do not edit ---------- -- Object hierarchy for the GIMP Toolkit (GTK) Binding for Haskell
Gtk2HsSetup.hs view
@@ -6,9 +6,9 @@ -- | Build a Gtk2hs package. ---module Gtk2HsSetup ( - gtk2hsUserHooks, - getPkgConfigPackages, +module Gtk2HsSetup (+ gtk2hsUserHooks,+ getPkgConfigPackages, checkGtk2hsBuildtools, typeGenProgram, signalGenProgram,@@ -55,8 +55,9 @@ import Distribution.Version (Version(..)) import Distribution.Verbosity import Control.Monad (when, unless, filterM, liftM, forM, forM_)-import Data.Maybe ( isJust, isNothing, fromMaybe, maybeToList )-import Data.List (isPrefixOf, isSuffixOf, stripPrefix, nub)+import Data.Maybe ( isJust, isNothing, fromMaybe, maybeToList, catMaybes )+import Data.List (isPrefixOf, isSuffixOf, nub, minimumBy, stripPrefix, tails )+import Data.Ord as Ord (comparing) import Data.Char (isAlpha, isNumber) import qualified Data.Map as M import qualified Data.Set as S@@ -113,15 +114,22 @@ fixLibs :: [FilePath] -> [String] -> [String] fixLibs dlls = concatMap $ \ lib -> case filter (isLib lib) dlls of- dll:_ -> [dropExtension dll]- _ -> if lib == "z" then [] else [lib]+ dlls@(_:_) -> [dropExtension (pickDll dlls)]+ _ -> if lib == "z" then [] else [lib] where+ -- If there are several .dll files matching the one we're after then we+ -- just have to guess. For example for recent Windows cairo builds we get+ -- libcairo-2.dll libcairo-gobject-2.dll libcairo-script-interpreter-2.dll+ -- Our heuristic is to pick the one with the shortest name.+ -- Yes this is a hack but the proper solution is hard: we would need to+ -- parse the .a file and see which .dll file(s) it needed to link to.+ pickDll = minimumBy (Ord.comparing length) isLib lib dll = case stripPrefix ("lib"++lib) dll of Just ('.':_) -> True Just ('-':n:_) | isNumber n -> True _ -> False- + -- The following code is a big copy-and-paste job from the sources of -- Cabal 1.8 just to be able to fix a field in the package file. Yuck. @@ -154,12 +162,16 @@ register :: PackageDescription -> LocalBuildInfo -> RegisterFlags -- ^Install in the user's database?; verbose -> IO ()-register pkg@(library -> Just lib )- lbi@(libraryConfig -> Just clbi) regFlags+register pkg@PackageDescription { library = Just lib } lbi regFlags = do+ let clbi = LBI.getComponentLocalBuildInfo lbi LBI.CLibName installedPkgInfoRaw <- generateRegistrationInfo+#if CABAL_VERSION_CHECK(1,22,0)+ verbosity pkg lib lbi clbi inplace False distPref packageDb+#else verbosity pkg lib lbi clbi inplace distPref+#endif dllsInScope <- getSearchPath >>= (filterM doesDirectoryExist) >>= getDlls let libs = fixLibs dllsInScope (extraLibraries installedPkgInfoRaw)@@ -168,7 +180,7 @@ -- Three different modes: case () of- _ | modeGenerateRegFile -> die "Generate Reg File not supported"+ _ | modeGenerateRegFile -> writeRegistrationFile installedPkgInfo | modeGenerateRegScript -> die "Generate Reg Script not supported" | otherwise -> registerPackage verbosity installedPkgInfo pkg lbi inplace@@ -180,6 +192,8 @@ where modeGenerateRegFile = isJust (flagToMaybe (regGenPkgConf regFlags))+ regFile = fromMaybe (display (packageId pkg) <.> "conf")+ (fromFlag (regGenPkgConf regFlags)) modeGenerateRegScript = fromFlag (regGenScript regFlags) inplace = fromFlag (regInPlace regFlags) packageDbs = nub $ withPackageDB lbi@@ -188,6 +202,10 @@ distPref = fromFlag (regDistPref regFlags) verbosity = fromFlag (regVerbosity regFlags) + writeRegistrationFile installedPkgInfo = do+ notice verbosity ("Creating package registration file: " ++ regFile)+ writeUTF8File regFile (showInstalledPackageInfo installedPkgInfo)+ register _ _ regFlags = notice verbosity "No package to register" where verbosity = fromFlag (regVerbosity regFlags)@@ -247,11 +265,24 @@ = nub $ ["-I" ++ dir | dir <- PD.includeDirs bi] ++ [opt | opt@('-':c:_) <- PD.cppOptions bi ++ PD.ccOptions bi, c `elem` "DIU"]- ++ ["-D__GLASGOW_HASKELL__="++show (ghcDefine . versionBranch . compilerVersion $ LBI.compiler lbi)]+ ++ ["-D__GLASGOW_HASKELL__="++show (ghcDefine . ghcVersion . compilerId $ LBI.compiler lbi)] where ghcDefine (v1:v2:_) = v1 * 100 + v2 ghcDefine _ = __GLASGOW_HASKELL__ + ghcVersion :: CompilerId -> [Int]+-- This version is nicer, but we need to know the Cabal version that includes the new CompilerId+-- #if CABAL_VERSION_CHECK(1,19,2)+-- ghcVersion (CompilerId GHC v _) = versionBranch v+-- ghcVersion (CompilerId _ _ (Just c)) = ghcVersion c+-- #else+-- ghcVersion (CompilerId GHC v) = versionBranch v+-- #endif+-- ghcVersion _ = []+-- This version should work fine for now+ ghcVersion = concat . take 1 . map (read . (++"]") . takeWhile (/=']')) . catMaybes+ . map (stripPrefix "CompilerId GHC (Version {versionBranch = ") . tails . show+ installCHI :: PackageDescription -- ^information from the .cabal file -> LocalBuildInfo -- ^information from the configure step -> Verbosity -> CopyDest -- ^flags sent to copy or install@@ -262,11 +293,11 @@ -- a modules that does not have a .chi file mFiles <- mapM (findFileWithExtension' ["chi"] [buildDir lbi] . toFilePath) (PD.libModules lib)- + let files = [ f | Just f <- mFiles ] installOrdinaryFiles verbosity libPref files - + installCHI _ _ _ _ = return () ------------------------------------------------------------------------------@@ -292,13 +323,12 @@ genSynthezisedFiles :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO () genSynthezisedFiles verb pd lbi = do- cPkgs <- getPkgConfigPackages verb lbi pd let xList = maybe [] (customFieldsBI . libBuildInfo) (library pd) ++customFieldsPD pd typeOpts :: String -> [ProgArg]- typeOpts tag = concat [ map (\val -> '-':'-':drop (length tag) field++'=':val) (words content)+ typeOpts tag = concat [ map (\val -> '-':'-':drop (length tag) field ++ '=':val) (words content) | (field,content) <- xList, tag `isPrefixOf` field, field /= (tag++"file")]@@ -306,8 +336,9 @@ | PackageIdentifier name (Version (major:minor:_) _) <- cPkgs , let name' = filter isAlpha (display name) , tag <- name'- : [ name' ++ "-" ++ show major ++ "." ++ show digit- | digit <- [0,2..minor] ]+ :[ name' ++ "-" ++ show maj ++ "." ++ show d2+ | (maj, d2) <- [(maj, d2) | maj <- [0..(major-1)], d2 <- [0,2..20]]+ ++ [(major, d2) | d2 <- [0,2..minor]] ] ] signalsOpts :: [ProgArg]@@ -333,6 +364,29 @@ info verb ("Ensuring that callback hooks in "++f++" are up-to-date.") genFile signalGenProgram signalsOpts f + writeFile "gtk2hs_macros.h" $ generateMacros cPkgs++-- Based on Cabal/Distribution/Simple/Build/Macros.hs+generateMacros :: [PackageId] -> String+generateMacros cPkgs = concat $+ "/* DO NOT EDIT: This file is automatically generated by Gtk2HsSetup.hs */\n\n" :+ [ concat+ ["/* package ",display pkgid," */\n"+ ,"#define VERSION_",pkgname," ",show (display version),"\n"+ ,"#define MIN_VERSION_",pkgname,"(major1,major2,minor) (\\\n"+ ," (major1) < ",major1," || \\\n"+ ," (major1) == ",major1," && (major2) < ",major2," || \\\n"+ ," (major1) == ",major1," && (major2) == ",major2," && (minor) <= ",minor,")"+ ,"\n\n"+ ]+ | pkgid@(PackageIdentifier name version) <- cPkgs+ , let (major1:major2:minor:_) = map show (versionBranch version ++ repeat 0)+ pkgname = map fixchar (display name)+ ]+ where fixchar '-' = '_'+ fixchar '.' = '_'+ fixchar c = c+ --FIXME: Cabal should tell us the selected pkg-config package versions in the -- LocalBuildInfo or equivalent. -- In the mean time, ask pkg-config again.@@ -375,15 +429,10 @@ let modDeps = zipWith (ModDep True []) expMods mExpFiles++ zipWith (ModDep False []) othMods mOthFiles modDeps <- mapM extractDeps modDeps- let (expMods, othMods) = span mdExposed $ sortTopological modDeps- badOther = map (fromMaybe "<no file>" . mdLocation) $- filter (not . mdExposed) expMods- unless (null badOther) $- die ("internal chs modules "++intercalate "," badOther++- " depend on exposed chs modules; cabal needs to build internal modules first")+ let (othMods, expMods) = span (not . mdExposed) $ reverse $ sortTopological modDeps return pd { PD.library = Just lib {- PD.exposedModules = map mdOriginal expMods,- PD.libBuildInfo = bi { PD.otherModules = map mdOriginal othMods }+ PD.exposedModules = map mdOriginal (reverse expMods),+ PD.libBuildInfo = bi { PD.otherModules = map mdOriginal (reverse othMods) } }} data ModDep = ModDep {@@ -403,14 +452,14 @@ -- Extract the dependencies of this file. This is intentionally rather naive as it -- ignores CPP conditionals. We just require everything which means that the--- existance of a .chs module may not depend on some CPP condition. +-- existance of a .chs module may not depend on some CPP condition. extractDeps :: ModDep -> IO ModDep extractDeps md@ModDep { mdLocation = Nothing } = return md extractDeps md@ModDep { mdLocation = Just f } = withUTF8FileContents f $ \con -> do let findImports acc (('{':'#':xs):xxs) = case (dropWhile (' ' ==) xs) of ('i':'m':'p':'o':'r':'t':' ':ys) -> case simpleParse (takeWhile ('#' /=) ys) of- Just m -> findImports (m:acc) xxs + Just m -> findImports (m:acc) xxs Nothing -> die ("cannot parse chs import in "++f++":\n"++ "offending line is {#"++xs) -- no more imports after the first non-import hook@@ -444,8 +493,8 @@ return (programName prog, location) ) programs let printError name = do- putStrLn $ "Cannot find " ++ name ++ "\n" + putStrLn $ "Cannot find " ++ name ++ "\n" ++ "Please install `gtk2hs-buildtools` first and check that the install directory is in your PATH (e.g. HOME/.cabal/bin)." exitFailure forM_ programInfos $ \ (name, location) ->- when (isNothing location) (printError name) + when (isNothing location) (printError name)
SetupMain.hs view
@@ -3,46 +3,11 @@ -- all Gtk2Hs-specific boilerplate is kept in Gtk2HsSetup.hs -- which should be kept identical across all packages. ---import Distribution.Simple ( defaultMainWithHooks, UserHooks(postConf),- PackageIdentifier(..), PackageName(..) )-import Gtk2HsSetup ( gtk2hsUserHooks, getPkgConfigPackages, checkGtk2hsBuildtools,+import Gtk2HsSetup ( gtk2hsUserHooks, checkGtk2hsBuildtools, typeGenProgram, signalGenProgram, c2hsLocal)-import Distribution.Simple.Setup ( ConfigFlags(configVerbosity), fromFlag)-import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..) )-import Distribution.Simple.BuildPaths ( autogenModulesDir )-import Distribution.Text ( display )-import Distribution.Version ( Version(..) )-import Distribution.Verbosity-import Distribution.Simple.Utils-import System.FilePath+import Distribution.Simple ( defaultMainWithHooks ) main = do- checkGtk2hsBuildtools [c2hsLocal, typeGenProgram]- defaultMainWithHooks gtk2hsUserHooks {-- postConf = \args cf pd lbi -> do- let verb = (fromFlag (configVerbosity cf))- cPkgs <- getPkgConfigPackages verb lbi pd- let [pangoVersion] = [ v | PackageIdentifier (PackageName "pango") v <- cPkgs ]- writePangoVersionHeaderFile verb lbi pangoVersion- postConf gtk2hsUserHooks args cf pd lbi- }----------------------------------------------------------------------------------- Generate CPP defines for version of C libs.---------------------------------------------------------------------------------writePangoVersionHeaderFile :: Verbosity -> LocalBuildInfo -> Version -> IO ()-writePangoVersionHeaderFile verbosity lbi (Version (major:minor:micro:_) []) = do- createDirectoryIfMissingVerbose verbosity True targetDir- rewriteFile targetFile $ unlines- [ "#define PANGO_VERSION_MAJOR " ++ show major- , "#define PANGO_VERSION_MINOR " ++ show minor- , "#define PANGO_VERSION_MICRO " ++ show micro- ]- where- targetDir = autogenModulesDir lbi- targetFile = targetDir </> "hspangoversion.h"+ checkGtk2hsBuildtools [typeGenProgram, signalGenProgram, c2hsLocal]+ defaultMainWithHooks gtk2hsUserHooks -writeVersionHeaderFile _ _ version =- die $ "unexpected pango version number: " ++ display version
SetupWrapper.hs view
@@ -9,7 +9,7 @@ import Distribution.Simple.Program import Distribution.Simple.Compiler import Distribution.Simple.BuildPaths (exeExtension)-import Distribution.Simple.Configure (configCompiler)+import Distribution.Simple.Configure (configCompilerEx) import Distribution.Simple.GHC (getInstalledPackages) import qualified Distribution.Simple.PackageIndex as PackageIndex import Distribution.Version@@ -18,7 +18,7 @@ import System.Environment import System.Process-import System.Exit+import System.Exit (ExitCode(..), exitWith) import System.FilePath import System.Directory import qualified Control.Exception as Exception@@ -115,7 +115,7 @@ when outOfDate $ do debug verbosity "Setup script is out of date, compiling..." - (comp, conf) <- configCompiler (Just GHC) Nothing Nothing+ (comp, _, conf) <- configCompilerEx (Just GHC) Nothing Nothing defaultProgramConfiguration verbosity cabalLibVersion <- cabalLibVersionToUse comp conf let cabalPkgid = PackageIdentifier (PackageName "Cabal") cabalLibVersion
poppler.cabal view
@@ -1,5 +1,5 @@ Name: poppler-Version: 0.13+Version: 0.13.1 License: GPL-2 License-file: COPYING Copyright: (c) 2001-2012, 2014 The Gtk2Hs Team@@ -8,14 +8,14 @@ Build-Type: Custom Cabal-Version: >= 1.8 Stability: stable-homepage: http://www.haskell.org/gtk2hs/-bug-reports: http://hackage.haskell.org/trac/gtk2hs/+homepage: http://projects.haskell.org/gtk2hs+bug-reports: http://github.com/wavewave/poppler/issues Synopsis: Binding to the Poppler. Description: Poppler is a fork of the xpdf PDF viewer, to provide PDF rendering functionality as a shared library, to centralize the maintenance effort. And move to forward in a number of areas that don't fit within the goals of xpdf. Category: Graphics-Tested-With: GHC == 7.4, GHC == 7.6+Tested-With: GHC == 7.10 Extra-Source-Files: SetupWrapper.hs SetupMain.hs Gtk2HsSetup.hs@@ -69,7 +69,7 @@ extensions: ForeignFunctionInterface include-dirs: .- x-c2hs-Header: glib/poppler.h+ x-c2hs-Header: poppler.h if flag(gtk3) pkgconfig-depends: poppler-glib >= 0.12.4, cairo >= 1.2.0, gdk-3.0, pango else