gconf 0.12.0 → 0.12.1
raw patch · 8 files changed
+215/−130 lines, 8 filesdep −arraydep −containersdep −haskell98setup-changednew-uploader
Dependencies removed: array, containers, haskell98, mtl
Files
- Gtk2HsSetup.hs +22/−108
- Setup.hs +9/−9
- SetupMain.hs +12/−0
- SetupWrapper.hs +155/−0
- System/Gnome/GConf/GConfValue.chs +4/−2
- demo/GConfDemo.hs +3/−2
- demo/Makefile +1/−1
- gconf.cabal +9/−8
Gtk2HsSetup.hs view
@@ -1,37 +1,7 @@ {-# LANGUAGE CPP #-} -#define CABAL_VERSION_ENCODE(major, minor, micro) ( \- ((major) * 10000) \- + ((minor) * 100) \- + ((micro) * 1))--#define CABAL_VERSION_CHECK(major,minor,micro) \- (CABAL_VERSION >= CABAL_VERSION_ENCODE(major,minor,micro))---- now, this is bad, but Cabal doesn't seem to actually pass any information about--- its version to CPP, so guess the version depending on the version of GHC-#ifdef CABAL_VERSION_MINOR-#ifndef CABAL_VERSION_MAJOR-#define CABAL_VERSION_MAJOR 1-#endif-#ifndef CABAL_VERSION_MICRO-#define CABAL_VERSION_MICRO 0-#endif-#define CABAL_VERSION CABAL_VERSION_ENCODE( \- CABAL_VERSION_MAJOR, \- CABAL_VERSION_MINOR, \- CABAL_VERSION_MICRO)-#else-#warning Setup.hs is guessing the version of Cabal. If compilation of Setup.hs fails use -DCABAL_VERSION_MINOR=x for Cabal version 1.x.0 when building (prefixed by --ghc-option= when using the 'cabal' command)-#if (__GLASGOW_HASKELL__ >= 700)-#define CABAL_VERSION CABAL_VERSION_ENCODE(1,10,0)-#else-#if (__GLASGOW_HASKELL__ >= 612)-#define CABAL_VERSION CABAL_VERSION_ENCODE(1,8,0)-#else-#define CABAL_VERSION CABAL_VERSION_ENCODE(1,6,0)-#endif-#endif+#ifndef CABAL_VERSION_CHECK+#error This module has to be compiled via the Setup.hs program which generates the gtk2hs-macros.h file #endif -- | Build a Gtk2hs package.@@ -49,13 +19,7 @@ libraryDirs, extraLibraries, extraGHCiLibraries )-import Distribution.Simple.PackageIndex (-#if CABAL_VERSION_CHECK(1,8,0)- lookupInstalledPackageId-#else- lookupPackageId-#endif- )+import Distribution.Simple.PackageIndex ( lookupInstalledPackageId ) import Distribution.PackageDescription as PD ( PackageDescription(..), updatePackageDescription, BuildInfo(..),@@ -64,17 +28,13 @@ libModules, hasLibs) import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), InstallDirs(..),-#if CABAL_VERSION_CHECK(1,8,0) componentPackageDeps,-#else- packageDeps,-#endif absoluteInstallDirs) import Distribution.Simple.Compiler ( Compiler(..) ) import Distribution.Simple.Program ( Program(..), ConfiguredProgram(..),- rawSystemProgramConf, rawSystemProgramStdoutConf, programName,- c2hsProgram, pkgConfigProgram, requireProgram, ghcPkgProgram,+ rawSystemProgramConf, rawSystemProgramStdoutConf, programName, programPath,+ c2hsProgram, pkgConfigProgram, gccProgram, requireProgram, ghcPkgProgram, simpleProgram, lookupProgram, rawSystemProgramStdout, ProgArg) import Distribution.ModuleName ( ModuleName, components, toFilePath ) import Distribution.Simple.Utils@@ -84,11 +44,7 @@ fromFlagOrDefault, defaultRegisterFlags) import Distribution.Simple.BuildPaths ( autogenModulesDir ) import Distribution.Simple.Install ( install )-#if CABAL_VERSION_CHECK(1,8,0) import Distribution.Simple.Register ( generateRegistrationInfo, registerPackage )-#else-import qualified Distribution.Simple.Register as Register ( register )-#endif import Distribution.Text ( simpleParse, display ) import System.FilePath import System.Exit (exitFailure)@@ -147,8 +103,6 @@ -- 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. -#if CABAL_VERSION_CHECK(1,8,0)- installHook :: PackageDescription -> LocalBuildInfo -> UserHooks -> InstallFlags -> IO () installHook pkg_descr localbuildinfo _ flags = do@@ -195,19 +149,20 @@ _ | modeGenerateRegFile -> die "Generate Reg File not supported" | modeGenerateRegScript -> die "Generate Reg Script not supported" | otherwise -> registerPackage verbosity+ installedPkgInfo pkg lbi inplace #if CABAL_VERSION_CHECK(1,10,0)- installedPkgInfo pkg lbi inplace [packageDb]+ packageDbs #else- installedPkgInfo pkg lbi inplace packageDb+ packageDb #endif where modeGenerateRegFile = isJust (flagToMaybe (regGenPkgConf regFlags)) modeGenerateRegScript = fromFlag (regGenScript regFlags) inplace = fromFlag (regInPlace regFlags)- packageDb = case flagToMaybe (regPackageDB regFlags) of- Just db -> db- Nothing -> registrationPackageDB (withPackageDB lbi)+ packageDbs = nub $ withPackageDB lbi+ ++ maybeToList (flagToMaybe (regPackageDB regFlags))+ packageDb = registrationPackageDB packageDbs distPref = fromFlag (regDistPref regFlags) verbosity = fromFlag (regVerbosity regFlags) @@ -215,45 +170,7 @@ where verbosity = fromFlag (regVerbosity regFlags) -#else-installHook :: PackageDescription -> LocalBuildInfo- -> UserHooks -> InstallFlags -> IO ()-installHook pkg_descr localbuildinfo _ flags = do- let copyFlags = defaultCopyFlags {- copyDistPref = installDistPref flags,- copyInPlace = installInPlace flags,- copyUseWrapper = installUseWrapper flags,- copyDest = toFlag NoCopyDest,- copyVerbosity = installVerbosity flags- }- install pkg_descr localbuildinfo copyFlags- let registerFlags = defaultRegisterFlags {- regDistPref = installDistPref flags,- regInPlace = installInPlace flags,- regPackageDB = installPackageDB flags,- regVerbosity = installVerbosity flags- }- when (hasLibs pkg_descr) $ register pkg_descr localbuildinfo registerFlags -registerHook :: PackageDescription -> LocalBuildInfo- -> UserHooks -> RegisterFlags -> IO ()-registerHook pkg_descr localbuildinfo _ flags =- if hasLibs pkg_descr- then register pkg_descr localbuildinfo flags- else setupMessage verbosity- "Package contains no library to register:" (packageId pkg_descr)- where verbosity = fromFlag (regVerbosity flags)--register :: PackageDescription -> LocalBuildInfo- -> RegisterFlags -- ^Install in the user's database?; verbose- -> IO ()-register pkg_descr lbi regFlags = do- let verbosity = fromFlag (regVerbosity regFlags)- warn verbosity "Cannot register ghci libraries with Cabal 1.6 (need 1.8)."- Register.register pkg_descr lbi regFlags- -#endif- ------------------------------------------------------------------------------ -- This is a hack for Cabal-1.8, It is not needed in Cabal-1.9.1 or later ------------------------------------------------------------------------------@@ -291,15 +208,12 @@ -- additional .chi files might be needed that other packages have installed; -- we assume that these are installed in the same place as .hi files let chiDirs = [ dir |-#if CABAL_VERSION_CHECK(1,8,0) ipi <- maybe [] (map fst . componentPackageDeps) (libraryConfig lbi), dir <- maybe [] importDirs (lookupInstalledPackageId (installedPkgs lbi) ipi) ]-#else- ipi <- packageDeps lbi,- dir <- maybe [] importDirs (lookupPackageId (installedPkgs lbi) ipi) ]-#endif+ (gccProg, _) <- requireProgram verbosity gccProgram (withPrograms lbi) rawSystemProgramConf verbosity c2hsLocal (withPrograms lbi) $ map ("--include=" ++) (outDir:chiDirs)+ ++ [ "--cpp=" ++ programPath gccProg, "--cppopts=-E" ] ++ ["--cppopts=" ++ opt | opt <- getCppOptions bi lbi] ++ ["--output-dir=" ++ newOutDir, "--output=" ++ newOutFile,@@ -321,18 +235,10 @@ -- cannot use the recommended 'findModuleFiles' since it fails if there exists -- a modules that does not have a .chi file mFiles <- mapM (findFileWithExtension' ["chi"] [buildDir lbi] . toFilePath)-#if CABAL_VERSION_CHECK(1,8,0) (PD.libModules lib)-#else- (PD.libModules pkg)-#endif let files = [ f | Just f <- mFiles ]-#if CABAL_VERSION_CHECK(1,8,0) installOrdinaryFiles verbosity libPref files-#else- copyFiles verbosity libPref files-#endif installCHI _ _ _ _ = return ()@@ -348,7 +254,15 @@ signalGenProgram = simpleProgram "gtk2hsHookGenerator" c2hsLocal :: Program-c2hsLocal = simpleProgram "gtk2hsC2hs"+c2hsLocal = (simpleProgram "gtk2hsC2hs") {+ programFindVersion = findProgramVersion "--version" $ \str ->+ -- Invoking "gtk2hsC2hs --version" gives a string like:+ -- C->Haskell Compiler, version 0.13.4 (gtk2hs branch) "Bin IO", 13 Nov 2004+ case words str of+ (_:_:_:ver:_) -> ver+ _ -> ""+ }+ genSynthezisedFiles :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO () genSynthezisedFiles verb pd lbi = do
Setup.hs view
@@ -1,10 +1,10 @@--- Setup file for a Gtk2Hs module. Contains only adjustments specific to this module,--- all Gtk2Hs-specific boilerplate is stored in Gtk2HsSetup.hs which should be kept--- identical across all modules.-import Gtk2HsSetup ( gtk2hsUserHooks, checkGtk2hsBuildtools )-import Distribution.Simple ( defaultMainWithHooks )+-- Standard setup file for a Gtk2Hs module.+--+-- See also:+-- * SetupMain.hs : the real Setup script for this package+-- * Gtk2HsSetup.hs : Gtk2Hs-specific boilerplate+-- * SetupWrapper.hs : wrapper for compat with various ghc/cabal versions -main = do- checkGtk2hsBuildtools ["gtk2hsC2hs", "gtk2hsTypeGen", "gtk2hsHookGenerator"]- defaultMainWithHooks gtk2hsUserHooks- +import SetupWrapper ( setupWrapper )++main = setupWrapper "SetupMain.hs"
+ SetupMain.hs view
@@ -0,0 +1,12 @@+-- The real Setup file for a Gtk2Hs package (invoked via the SetupWrapper).+-- It contains only adjustments specific to this package,+-- all Gtk2Hs-specific boilerplate is kept in Gtk2HsSetup.hs+-- which should be kept identical across all packages.+--+import Gtk2HsSetup ( gtk2hsUserHooks, checkGtk2hsBuildtools )+import Distribution.Simple ( defaultMainWithHooks )++main = do+ checkGtk2hsBuildtools ["gtk2hsC2hs", "gtk2hsTypeGen", "gtk2hsHookGenerator"]+ defaultMainWithHooks gtk2hsUserHooks+
+ SetupWrapper.hs view
@@ -0,0 +1,155 @@+-- A wrapper script for Cabal Setup.hs scripts. Allows compiling the real Setup+-- conditionally depending on the Cabal version.++module SetupWrapper (setupWrapper) where++import Distribution.Package+import Distribution.Compiler+import Distribution.Simple.Utils+import Distribution.Simple.Program+import Distribution.Simple.Compiler+import Distribution.Simple.BuildPaths (exeExtension)+import Distribution.Simple.Configure (configCompiler)+import Distribution.Simple.GHC (getInstalledPackages)+import qualified Distribution.Simple.PackageIndex as PackageIndex+import Distribution.Version+import Distribution.Verbosity+import Distribution.Text++import System.Environment+import System.Process+import System.Exit+import System.FilePath+import System.Directory+import qualified Control.Exception as Exception+import System.IO.Error (isDoesNotExistError)++import Data.List+import Data.Char+import Control.Monad+++setupWrapper :: FilePath -> IO ()+setupWrapper setupHsFile = do+ args <- getArgs+ createDirectoryIfMissingVerbose verbosity True setupDir+ compileSetupExecutable+ invokeSetupScript args++ where+ setupDir = "dist/setup-wrapper"+ setupVersionFile = setupDir </> "setup" <.> "version"+ setupProgFile = setupDir </> "setup" <.> exeExtension+ setupMacroFile = setupDir </> "wrapper-macros.h"++ useCabalVersion = Version [1,8] []+ usePackageDB = [GlobalPackageDB, UserPackageDB]+ verbosity = normal++ cabalLibVersionToUse comp conf = do+ savedVersion <- savedCabalVersion+ case savedVersion of+ Just version+ -> return version+ _ -> do version <- installedCabalVersion comp conf+ writeFile setupVersionFile (show version ++ "\n")+ return version++ savedCabalVersion = do+ versionString <- readFile setupVersionFile+ `Exception.catch` \e -> if isDoesNotExistError e+ then return ""+ else Exception.throwIO e+ case reads versionString of+ [(version,s)] | all isSpace s -> return (Just version)+ _ -> return Nothing++ installedCabalVersion comp conf = do+ index <- getInstalledPackages verbosity usePackageDB conf++ let cabalDep = Dependency (PackageName "Cabal")+ (orLaterVersion useCabalVersion)+ case PackageIndex.lookupDependency index cabalDep of+ [] -> die $ "The package requires Cabal library version "+ ++ display useCabalVersion+ ++ " but no suitable version is installed."+ pkgs -> return $ bestVersion (map fst pkgs)+ where+ bestVersion = maximumBy (comparing preference)+ preference version = (sameVersion, sameMajorVersion+ ,stableVersion, latestVersion)+ where+ sameVersion = version == cabalVersion+ sameMajorVersion = majorVersion version == majorVersion cabalVersion+ majorVersion = take 2 . versionBranch+ stableVersion = case versionBranch version of+ (_:x:_) -> even x+ _ -> False+ latestVersion = version++ -- | If the Setup.hs is out of date wrt the executable then recompile it.+ -- Currently this is GHC only. It should really be generalised.+ --+ compileSetupExecutable = do+ setupHsNewer <- setupHsFile `moreRecentFile` setupProgFile+ cabalVersionNewer <- setupVersionFile `moreRecentFile` setupProgFile+ let outOfDate = setupHsNewer || cabalVersionNewer+ when outOfDate $ do+ debug verbosity "Setup script is out of date, compiling..."++ (comp, conf) <- configCompiler (Just GHC) Nothing Nothing+ defaultProgramConfiguration verbosity+ cabalLibVersion <- cabalLibVersionToUse comp conf+ let cabalPkgid = PackageIdentifier (PackageName "Cabal") cabalLibVersion+ debug verbosity $ "Using Cabal library version " ++ display cabalLibVersion++ writeFile setupMacroFile (generateVersionMacro cabalLibVersion)++ rawSystemProgramConf verbosity ghcProgram conf $+ ["--make", setupHsFile, "-o", setupProgFile]+ ++ ghcPackageDbOptions usePackageDB+ ++ ["-package", display cabalPkgid+ ,"-cpp", "-optP-include", "-optP" ++ setupMacroFile+ ,"-odir", setupDir, "-hidir", setupDir]+ where++ ghcPackageDbOptions dbstack = case dbstack of+ (GlobalPackageDB:UserPackageDB:dbs) -> concatMap specific dbs+ (GlobalPackageDB:dbs) -> "-no-user-package-conf"+ : concatMap specific dbs+ _ -> ierror+ where+ specific (SpecificPackageDB db) = [ "-package-conf", db ]+ specific _ = ierror+ ierror = error "internal error: unexpected package db stack"++ generateVersionMacro :: Version -> String+ generateVersionMacro version =+ concat+ ["/* DO NOT EDIT: This file is automatically generated by Cabal */\n\n"+ ,"#define CABAL_VERSION_CHECK(major1,major2,minor) (\\\n"+ ," (major1) < ",major1," || \\\n"+ ," (major1) == ",major1," && (major2) < ",major2," || \\\n"+ ," (major1) == ",major1," && (major2) == ",major2," && (minor) <= ",minor,")"+ ,"\n\n"+ ]+ where+ (major1:major2:minor:_) = map show (versionBranch version ++ repeat 0)++ invokeSetupScript :: [String] -> IO ()+ invokeSetupScript args = do+ info verbosity $ unwords (setupProgFile : args)+ process <- runProcess (currentDir </> setupProgFile) args+ Nothing Nothing+ Nothing Nothing Nothing+ exitCode <- waitForProcess process+ unless (exitCode == ExitSuccess) $ exitWith exitCode++moreRecentFile :: FilePath -> FilePath -> IO Bool+moreRecentFile a b = do+ exists <- doesFileExist b+ if not exists+ then return True+ else do tb <- getModificationTime b+ ta <- getModificationTime a+ return (ta > tb)
System/Gnome/GConf/GConfValue.chs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, TypeSynonymInstances, OverlappingInstances, ScopedTypeVariables #-}+{-# LANGUAGE CPP, TypeSynonymInstances, OverlappingInstances, ScopedTypeVariables, FlexibleInstances #-} -- String & [a] overlap -- -*-haskell-*- -- GIMP Toolkit (GTK) GConf API@@ -40,6 +40,8 @@ ) where import Control.Monad (liftM, when)+import Control.Exception (catch, IOException)+import Prelude hiding (catch) import System.Glib.FFI import System.Glib.UTFString@@ -93,7 +95,7 @@ unsafeMarshalFromGConfValue = marshalFromGConfValue marshalFromGConfValue value = catch (liftM Just $ marshalFromGConfValue value)- (\_ -> return Nothing)+ (\(e :: IOException) -> return Nothing) marshalToGConfValue (Just v) = marshalToGConfValue v marshalToGConfValue Nothing = return $ GConfValue nullPtr
demo/GConfDemo.hs view
@@ -1,11 +1,12 @@+{-# LANGUAGE OverlappingInstances, ScopedTypeVariables #-} module Main where import Graphics.UI.Gtk (initGUI, mainGUI) import System.Gnome.GConf -import Monad (when)+import Control.Monad (when) import System.Exit (exitFailure)-import List (intersperse)+import Data.List (intersperse) main = do -- connect to gconf
demo/Makefile view
@@ -3,7 +3,7 @@ SOURCES = GConfDemo.hs $(PROG) : $(SOURCES)- $(HC) --make $< -o $@ -fglasgow-exts -fallow-overlapping-instances $(HCFLAGS)+ $(HC) --make $< -o $@ $(HCFLAGS) clean: rm -f $(SOURCES:.hs=.hi) $(SOURCES:.hs=.o) $(PROG)
gconf.cabal view
@@ -1,14 +1,14 @@ Name: gconf-Version: 0.12.0+Version: 0.12.1 License: LGPL-2.1 License-file: COPYING Copyright: (c) 2001-2010 The Gtk2Hs Team Author: Duncan Coutts-Maintainer: gtk2hs-users@sourceforge.net+Maintainer: gtk2hs-users@lists.sourceforge.net Build-Type: Custom-Cabal-Version: >= 1.6+Cabal-Version: >= 1.8 Stability: stable-homepage: http://www.haskell.org/gtk2hs/+homepage: http://projects.haskell.org/gtk2hs/ bug-reports: http://hackage.haskell.org/trac/gtk2hs/ Synopsis: Binding to the GNOME configuration database system. Description: GConf is a configuration database system for storing application@@ -17,8 +17,8 @@ running applications. It is written for the GNOME desktop but doesn't require it. Category: System-Tested-With: GHC == 6.12.1-Extra-Source-Files: Gtk2HsSetup.hs+Tested-With: GHC == 6.10.4, GHC == 6.12.3, GHC == 7.0.4, GHC == 7.2.1+Extra-Source-Files: SetupWrapper.hs SetupMain.hs Gtk2HsSetup.hs marshal.list hierarchy.list @@ -37,10 +37,11 @@ location: http://code.haskell.org/gconf/ Library- build-depends: base >= 4 && < 5, array, containers, haskell98, mtl,+ build-depends: base >= 4 && < 5, glib >= 0.12 && < 0.13 - build-tools: gtk2hsC2hs, gtk2hsHookGenerator, gtk2hsTypeGen+ build-tools: gtk2hsC2hs >= 0.13.5,+ gtk2hsHookGenerator, gtk2hsTypeGen exposed-modules: System.Gnome.GConf