Commits

John Lenz committed 480ce3c

Add flag to disable icu support, used for released binaries

Comments (0)

Files changed (4)

 
 # Quickstart
 
-To quickly test out the client on linux, make sure you have libgmp, zlib, and libicu installed,
+To quickly test out the client on linux, make sure you have libgmp and zlib installed,
 [download the latest binary](https://bitbucket.org/wuzzeb/notmuch-web/downloads), extract the
 tarball, then run
 
 One nice feature of GHC (the Haskell compiler) is the ability to statically link binaries to not
 require Haskell to be installed.  I have therefore built the latest release; you can find the
 tarballs on the [download page](https://bitbucket.org/wuzzeb/notmuch-web/downloads).  The only
-prerequisites are glibc, libgmp, libicu, and zlib.
+prerequisites are glibc, libgmp, and zlib.  The binaries are missing one feature: use of
+[libicu](http://site.icu-project.org/) to decode text/html message parts that have a charset that is
+not ISO-8859 or UTF-8 (UTF-8 and ISO-8859 are decoded internally without the help of libicu).  The
+reason for this restriction is that libicu is not generally binary compatible between different
+versions, so I could not link against a version of libicu that worked on many distributions.  I am
+working on removing this restriction so future versions should include all features.
 
 #### Source, latest released version
 

notmuch-web.cabal

     Description:   Build for use with "yesod devel"
     Default:       False
 
+Flag no-icu
+    Description:   Do not link against libicu
+    Default:       False
+
 library
     hs-source-dirs:  src
     exposed-modules: Application
     else
         ghc-options:   -Wall -O2
 
+    if flag(no-icu)
+        cpp-options:   -DNO_ICU
+    else
+        cpp-options:   -DUSE_ICU
+
     extensions: TemplateHaskell
                 QuasiQuotes
                 OverloadedStrings
                 EmptyDataDecls
                 NoMonomorphismRestriction
 
-    build-depends: base                          >= 4          && < 5
+    if flag(no-icu)
+        build-depends: base                          >= 4          && < 5
 
-                 , aeson
-                 , attoparsec
-                 , attoparsec-conduit
-                 , blaze-builder
-                 , blaze-html
-                 , blaze-markup
-                 , bytestring
-                 , case-insensitive
-                 , conduit
-                 , containers
-                 , data-default
-                 , directory
-                 , email-validate
-                 , filepath
-                 , hamlet
-                 -- https://github.com/bos/aeson/issues/125 and https://github.com/tibbe/hashable/issues/66
-                 , hashable                      <= 1.2.0.5 || > 1.2.0.7
-                 , hjsmin
-                 , http-conduit
-                 , http-types
-                 , lifted-base
-                 , mime-mail
-                 , monad-control
-                 , network
-                 , old-locale
-                 , pandoc                        >= 1.11   && < 1.12
-                 , process
-                 , process-conduit               >= 0.5
-                 , pwstore-fast
-                 , random
-                 , shakespeare-css
-                 , shakespeare-js
-                 , shakespeare-text
-                 , tagsoup
-                 , template-haskell
-                 , text
-                 , text-icu
-                 , time
-                 , transformers
-                 , unordered-containers
-                 , vector
-                 , wai
-                 , wai-extra
-                 , warp
-                 , xss-sanitize
-                 , yaml
-                 , yesod                         >= 1.2    && < 1.3
-                 , yesod-auth
-                 , yesod-core
-                 , yesod-form
-                 , yesod-static
+                     , aeson
+                     , attoparsec
+                     , attoparsec-conduit
+                     , blaze-builder
+                     , blaze-html
+                     , blaze-markup
+                     , bytestring
+                     , case-insensitive
+                     , conduit
+                     , containers
+                     , data-default
+                     , directory
+                     , email-validate
+                     , filepath
+                     , hamlet
+                     -- https://github.com/bos/aeson/issues/125 and https://github.com/tibbe/hashable/issues/66
+                     , hashable                      <= 1.2.0.5 || > 1.2.0.7
+                     , hjsmin
+                     , http-conduit
+                     , http-types
+                     , lifted-base
+                     , mime-mail
+                     , monad-control
+                     , network
+                     , old-locale
+                     , pandoc                        >= 1.11   && < 1.12
+                     , process
+                     , process-conduit               >= 0.5
+                     , pwstore-fast
+                     , random
+                     , shakespeare-css
+                     , shakespeare-js
+                     , shakespeare-text
+                     , tagsoup
+                     , template-haskell
+                     , text
+                     , time
+                     , transformers
+                     , unordered-containers
+                     , vector
+                     , wai
+                     , wai-extra
+                     , warp
+                     , xss-sanitize
+                     , yaml
+                     , yesod                         >= 1.2    && < 1.3
+                     , yesod-auth
+                     , yesod-core
+                     , yesod-form
+                     , yesod-static
+    else
+        build-depends: base                          >= 4          && < 5
+
+                     , aeson
+                     , attoparsec
+                     , attoparsec-conduit
+                     , blaze-builder
+                     , blaze-html
+                     , blaze-markup
+                     , bytestring
+                     , case-insensitive
+                     , conduit
+                     , containers
+                     , data-default
+                     , directory
+                     , email-validate
+                     , filepath
+                     , hamlet
+                     -- https://github.com/bos/aeson/issues/125 and https://github.com/tibbe/hashable/issues/66
+                     , hashable                      <= 1.2.0.5 || > 1.2.0.7
+                     , hjsmin
+                     , http-conduit
+                     , http-types
+                     , lifted-base
+                     , mime-mail
+                     , monad-control
+                     , network
+                     , old-locale
+                     , pandoc                        >= 1.11   && < 1.12
+                     , process
+                     , process-conduit               >= 0.5
+                     , pwstore-fast
+                     , random
+                     , shakespeare-css
+                     , shakespeare-js
+                     , shakespeare-text
+                     , tagsoup
+                     , template-haskell
+                     , text
+                     , text-icu
+                     , time
+                     , transformers
+                     , unordered-containers
+                     , vector
+                     , wai
+                     , wai-extra
+                     , warp
+                     , xss-sanitize
+                     , yaml
+                     , yesod                         >= 1.2    && < 1.3
+                     , yesod-auth
+                     , yesod-core
+                     , yesod-form
+                     , yesod-static
 
 executable         notmuch-web
     if flag(library-only)
 r="releases/$f"
 
 cabal clean
-cabal configure
+cabal configure -fno-icu
 cabal build
 strip dist/build/notmuch-web/notmuch-web
 mkdir -p $r

src/Handler/View.hs

 import qualified Data.Text as T
 import qualified Data.Text.Encoding as T
 import qualified Data.Text.Lazy as TL
-import qualified Data.Text.ICU.Convert as ICU
 import qualified Data.Map as M
 import qualified Data.Set as S
 import qualified Data.Tree as TR
 import qualified Data.CaseInsensitive as CI
 
+#ifdef USE_ICU
+import qualified Data.Text.ICU.Convert as ICU
+#endif
+
 decodePart :: (MonadLogger m, MonadHandler m) 
            => Maybe T.Text -> C.Source (C.ResourceT IO) B.ByteString -> m TL.Text
 decodePart charset src = case charset of
                             Just "ISO-8859-1" -> decodeConduit C.iso8859_1
                             Just "UTF-8"      -> decodeConduit C.utf8
+#ifdef USE_ICU
                             Just x            -> decodeICU x
-                            Nothing           -> decodeConduit C.utf8
+#endif
+                            _                 -> decodeConduit C.utf8
+
   where decodeConduit c = TL.fromChunks <$> liftResourceT (src $= C.decode c $$ C.consume)
+
+#ifdef USE_ICU
         decodeICU x = do $(logInfo) ("Decoding using ICU: " `T.append` x)
                          raw <- liftResourceT (src $$ C.consume)
                          c <- liftIO $ ICU.open (T.unpack x) (Just True)
                          return $ TL.fromChunks [ICU.toUnicode c $ B.concat raw]
+#endif
 
 messagePart :: MessageID -> Bool -> MessagePart -> Widget