diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-07-03 17:07:44 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-07-03 17:07:44 -0700 |
commit | 8763ba188c9829e959cd71e1a9e1af44843d74d6 (patch) | |
tree | 99ad9fdde1c8230355f86fc195e2cdb593fb1b60 | |
parent | a27991d398b393586e806da72ad14580005d60b2 (diff) | |
download | pandoc-8763ba188c9829e959cd71e1a9e1af44843d74d6.tar.gz |
Setup.hs: Don't require hsb2hs unless embed_data_files flag specified.
-rw-r--r-- | Setup.hs | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -18,13 +18,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import Distribution.Simple import Distribution.Simple.PreProcess -import Distribution.PackageDescription (PackageDescription(..)) +import Distribution.Simple.Setup (ConfigFlags(..)) +import Distribution.PackageDescription (PackageDescription(..), FlagName(..)) import System.Process ( rawSystem ) import System.FilePath ( (</>) ) import System.Directory ( findExecutable ) import Distribution.Simple.Utils (info, notice, installOrdinaryFiles) import Distribution.Simple.Setup import Distribution.Simple.LocalBuildInfo +import Control.Monad (when) main :: IO () main = defaultMainWithHooks $ simpleUserHooks { @@ -34,16 +36,21 @@ main = defaultMainWithHooks $ simpleUserHooks { } ppBlobSuffixHandler :: PPSuffixHandler -ppBlobSuffixHandler = ("hsb", \_ _ -> +ppBlobSuffixHandler = ("hsb", \_ lbi -> PreProcessor { platformIndependent = True, runPreProcessor = mkSimplePreProcessor $ \infile outfile verbosity -> - do info verbosity $ "Preprocessing " ++ infile ++ " to " ++ outfile - hsb2hsPath <- findExecutable "hsb2hs" - case hsb2hsPath of - Just p -> rawSystem p [infile, infile, outfile] - Nothing -> error "hsb2hs is needed to build this program: cabal install hsb2hs" - return () + do let embedData = case lookup (FlagName "embed_data_files") + (configConfigurationsFlags (configFlags lbi)) of + Just True -> True + _ -> False + when embedData $ + do info verbosity $ "Preprocessing " ++ infile ++ " to " ++ outfile + hsb2hsPath <- findExecutable "hsb2hs" + case hsb2hsPath of + Just p -> rawSystem p [infile, infile, outfile] + Nothing -> error "hsb2hs is needed to build this program: cabal install hsb2hs" + return () }) installManPage :: Args -> CopyFlags |