From fe337b07f7c0a15ac792275ed8fb88d3fa5247a3 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 23 Jan 2013 08:33:45 -0800 Subject: Use hsb2hs preprocessor instead of TH for embed_data_files. This should work on Windows, unlike the TH solution with file-embed. --- Setup.hs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Setup.hs') diff --git a/Setup.hs b/Setup.hs index ba89b51cf..4245df203 100644 --- a/Setup.hs +++ b/Setup.hs @@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} import Distribution.Simple +import Distribution.Simple.PreProcess import Distribution.Simple.Setup (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..)) import Distribution.PackageDescription (PackageDescription(..), Executable(..)) @@ -8,10 +9,11 @@ import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), absoluteInstallDirs) import Distribution.Verbosity ( Verbosity, silent ) import Distribution.Simple.InstallDirs (mandir, CopyDest (NoCopyDest)) -import Distribution.Simple.Utils (installOrdinaryFiles) +import Distribution.Simple.Utils (installOrdinaryFiles, info) import Prelude hiding (catch) import System.Process ( rawSystem ) import System.FilePath ( () ) +import System.Directory ( findExecutable ) import System.Exit main :: IO () @@ -29,6 +31,7 @@ main = do , instHook = \pkgdescr -> (instHook simpleUserHooks) pkgdescr{ executables = [x | x <- executables pkgdescr, exeName x /= "make-pandoc-man-pages"] } + , hookedPreProcessors = [ppBlobSuffixHandler] } exitWith ExitSuccess @@ -53,3 +56,16 @@ installManpages pkg lbi verbosity copy = installOrdinaryFiles verbosity (mandir (absoluteInstallDirs pkg lbi copy)) (zip (repeat manDir) manpages) +ppBlobSuffixHandler :: PPSuffixHandler +ppBlobSuffixHandler = ("hsb", \_ _ -> + 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 () + + }) -- cgit v1.2.3