stb-image 0.1.1 → 0.1.2
raw patch · 3 files changed
+55/−16 lines, 3 filessetup-changed
Files
- Codec/Image/STB.hs +4/−4
- Setup.lhs +48/−4
- stb-image.cabal +3/−8
Codec/Image/STB.hs view
@@ -1,7 +1,7 @@ -- -- Module : Codec.Image.STB--- Version : 0.1.1+-- Version : 0.1.2 -- License : Public Domain -- Author : Balazs Komuves -- Maintainer : bkomuves (plus) hackage (at) gmail (dot) com@@ -137,17 +137,17 @@ let imgptr = fromForeignPtr fr 0 (xres*yres*comp) return $ Right $ Image imgptr (xres,yres) comp -#ifdef STBIMAGE_NEW_EXCEPTIONS+#if (BASE_MAJOR_VERSION >= 4) -- base >=4 ioHandler :: IOException -> IO (Either String a)-ioHandler ioerror = return $ Left $ ioeGetErrorString ioerror+ioHandler ioerror = return $ Left $ "IO error: " ++ ioeGetErrorString ioerror #else -- base <=3 ioHandler :: Exception -> IO (Either String a)-ioHandler (IOException ioerror) = return $ Left $ ioeGetErrorString ioerror+ioHandler (IOException ioerror) = return $ Left $ "IO error: " ++ ioeGetErrorString ioerror ioHandler _ = return $ Left "Unknown error" #endif
Setup.lhs view
@@ -1,4 +1,48 @@-#! /usr/bin/env runhaskell - -> import Distribution.Simple -> main = defaultMain+#! /usr/bin/env runhaskell+> +> {-# LANGUAGE FlexibleInstances #-}+>+> import Control.Monad+> import Data.Maybe+> import Data.List+> import Data.Version+> import Distribution.Simple+> import Distribution.Simple.LocalBuildInfo+> import Distribution.Simple.Configure+> import Distribution.Simple.Setup+> import Distribution.Package+> import Distribution.PackageDescription+> import Distribution.Text+> import Text.PrettyPrint.HughesPJ+> +> -- for Cabal 1.4 compatibility+> instance Text [Char] where+> parse = undefined+> disp = text+>+> addToBuildInfo opts binfo = binfo { cppOptions = cppOptions binfo ++ opts }+> addToLibrary opts lib = lib { libBuildInfo = addToBuildInfo opts (libBuildInfo lib) } +> addToExecutable opts exe = exe { buildInfo = addToBuildInfo opts (buildInfo exe) } +> addToPkgDesc opts pkgdesc = pkgdesc +> { library = liftM (addToLibrary opts) (library pkgdesc) +> , executables = map (addToExecutable opts) (executables pkgdesc) +> }+> addToLocalBuildInfo opts lbinfo = lbinfo +> { localPkgDescr = addToPkgDesc opts (localPkgDescr lbinfo) }+>+> -- we detect the base version and add a respective #define +> myPostConf args flags pkgdesc locbuildinfo = do+> let distPref = fromFlag $ configDistPref flags+> deps = packageDeps locbuildinfo+> base = fromJust $ find (\pkg -> display (packageName pkg) == "base") deps+> ver = versionBranch (pkgVersion base)+> major = head ver+> opts = [ "-DBASE_MAJOR_VERSION=" ++ show major ]+> newlocbuildinfo = addToLocalBuildInfo opts locbuildinfo+> putStrLn $ "base version = " ++ concat (intersperse "." $ map show ver)+> writePersistBuildConfig distPref newlocbuildinfo+> +> main = do+> defaultMainWithHooks $ +> simpleUserHooks { postConf = myPostConf }+>
stb-image.cabal view
@@ -1,5 +1,5 @@ Name: stb-image-Version: 0.1.1+Version: 0.1.2 Synopsis: A wrapper around Sean Barrett's JPEG/PNG decoder Description: Partial implementation of JPEG, PNG, TGA, BMP, PSD decoders, with a really simple API.@@ -9,8 +9,8 @@ Maintainer: bkomuves (plus) hackage (at) gmail (dot) com Stability: Experimental Category: Codec-Tested-With: GHC == 6.10.1-Cabal-Version: >= 1.2+Tested-With: GHC == 6.10.1, GHC == 6.8.3 +Cabal-Version: >= 1.4 Build-Type: Simple Extra-Source-Files: example/viewer.hs @@ -22,11 +22,6 @@ Build-Depends: base >= 3, bytestring else Build-Depends: base < 3- - -- should check the base version instead of the- -- compiler version, but i don't know how to do that...- if impl(ghc >= 6.10.1)- cpp-options: -DSTBIMAGE_NEW_EXCEPTIONS Exposed-Modules: Codec.Image.STB Hs-Source-Dirs: .