diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-23 08:33:45 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-23 19:26:39 -0800 |
commit | fe337b07f7c0a15ac792275ed8fb88d3fa5247a3 (patch) | |
tree | 8c1e4c9f0bcfbfee777f5a36bfd7f9401a72d955 /Setup.hs | |
parent | daeb52d4e0f21b0e1ad8c3ce17ee9f18a6394f63 (diff) |
Use hsb2hs preprocessor instead of TH for embed_data_files.
This should work on Windows, unlike the TH solution with
file-embed.
Diffstat (limited to 'Setup.hs')
-rw-r--r-- | Setup.hs | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -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 () + + }) |