diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-07-05 13:50:10 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-07-05 13:50:10 -0700 |
commit | f1103f8f69939fd70e358ac06c022306b6678afd (patch) | |
tree | 48043b35e1addec5e2f307bf6e1244f4c59b144f | |
parent | 6e121bfafc24c7036b4993b1e514249842a02165 (diff) |
Make cabal require hsb2hs >= 0.3.1.
This is done by adding `hookedPrograms` in `Setup.hs`,
which allows us to include `hsb2hs` in Build-Tools in cabal.
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | Setup.hs | 17 | ||||
-rw-r--r-- | pandoc.cabal | 2 |
3 files changed, 19 insertions, 2 deletions
@@ -119,7 +119,7 @@ assume that the pandoc source directory is your working directory. - `embed_data_files`: embed all data files into the binary (default no). This is helpful if you want to create a relocatable binary. Note: if this option is selected, you need to install the - `hsb2hs` preprocessor: `cabal install hsb2hs` (version 0.3 or + `hsb2hs` preprocessor: `cabal install hsb2hs` (version 0.3.1 or higher is required). - `https`: enable support for downloading resources over https @@ -23,18 +23,35 @@ import Distribution.PackageDescription (PackageDescription(..), FlagName(..)) import System.Process ( rawSystem ) import System.FilePath ( (</>) ) import System.Directory ( findExecutable ) +import Distribution.Verbosity ( Verbosity ) import Distribution.Simple.Utils (info, notice, installOrdinaryFiles) import Distribution.Simple.Setup +import Distribution.Simple.Program (simpleProgram, Program(..)) import Distribution.Simple.LocalBuildInfo +import Data.Version +import System.Process (readProcess) +import Text.ParserCombinators.ReadP (readP_to_S, skipSpaces, eof) import Control.Monad (when) main :: IO () main = defaultMainWithHooks $ simpleUserHooks { -- enable hsb2hs preprocessor for .hsb files hookedPreProcessors = [ppBlobSuffixHandler] + , hookedPrograms = [(simpleProgram "hsb2hs"){ + programFindVersion = findHsb2hsVersion }] , postCopy = installManPage } +findHsb2hsVersion :: Verbosity -> FilePath -> IO (Maybe Version) +findHsb2hsVersion verb fp = do + outp <- readProcess fp ["--version"] "" + case readP_to_S (do v <- parseVersion + skipSpaces + eof + return v) outp of + ((v,""):_) -> return (Just v) + _ -> return Nothing + ppBlobSuffixHandler :: PPSuffixHandler ppBlobSuffixHandler = ("hsb", \_ lbi -> PreProcessor { diff --git a/pandoc.cabal b/pandoc.cabal index 34d026827..9045647df 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -292,7 +292,7 @@ Library cpp-options: -DHTTP_CLIENT if flag(embed_data_files) cpp-options: -DEMBED_DATA_FILES - -- Build-Tools: hsb2hs -- not yet recognized by cabal + Build-Tools: hsb2hs >= 0.3.1 other-modules: Text.Pandoc.Data if os(windows) Cpp-options: -D_WINDOWS |