aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL.md3
-rw-r--r--Setup.hs28
-rw-r--r--linux/Dockerfile1
-rwxr-xr-xmacos/make_macos_package.sh3
-rw-r--r--pandoc.cabal2
-rw-r--r--src/Text/Pandoc/Data.hsb (renamed from src/Text/Pandoc/Data.hs)9
6 files changed, 38 insertions, 8 deletions
diff --git a/INSTALL.md b/INSTALL.md
index 902e98a9f..ed34a95c9 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -226,6 +226,9 @@ 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.1 or
+ higher is required).
- `https`: enable support for downloading resources over https
(using the `http-client` and `http-client-tls` libraries).
diff --git a/Setup.hs b/Setup.hs
index 3f6bb2858..bc6651942 100644
--- a/Setup.hs
+++ b/Setup.hs
@@ -20,17 +20,41 @@ import Distribution.Simple
import Distribution.Simple.PreProcess
import Distribution.Simple.Setup (ConfigFlags(..), CopyFlags(..), fromFlag)
import Distribution.PackageDescription (PackageDescription(..), FlagName(..))
+import Distribution.Simple.Utils ( rawSystemExitCode, findProgramVersion )
import System.Exit
-import Distribution.Simple.Utils (notice, installOrdinaryFiles)
+import Distribution.Simple.Utils (info, notice, installOrdinaryFiles)
import Distribution.Simple.Program (simpleProgram, Program(..))
import Distribution.Simple.LocalBuildInfo
import Control.Monad (when)
main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks {
- postCopy = installManPage
+ -- enable hsb2hs preprocessor for .hsb files
+ hookedPreProcessors = [ppBlobSuffixHandler]
+ , hookedPrograms = [(simpleProgram "hsb2hs"){
+ programFindVersion = \verbosity fp ->
+ findProgramVersion "--version" id verbosity fp }]
+ , postCopy = installManPage
}
+ppBlobSuffixHandler :: PPSuffixHandler
+ppBlobSuffixHandler = ("hsb", \_ lbi ->
+ PreProcessor {
+ platformIndependent = True,
+ runPreProcessor = mkSimplePreProcessor $ \infile outfile verbosity ->
+ 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
+ ec <- rawSystemExitCode verbosity "hsb2hs"
+ [infile, infile, outfile]
+ case ec of
+ ExitSuccess -> return ()
+ ExitFailure _ -> error "hsb2hs is needed to build this program"
+ })
+
installManPage :: Args -> CopyFlags
-> PackageDescription -> LocalBuildInfo -> IO ()
installManPage _ flags pkg lbi = do
diff --git a/linux/Dockerfile b/linux/Dockerfile
index b725bbaa5..630abc17e 100644
--- a/linux/Dockerfile
+++ b/linux/Dockerfile
@@ -14,6 +14,7 @@ RUN mkdir -p /usr/src/
WORKDIR /usr/src/
RUN git clone https://github.com/jgm/pandoc
WORKDIR /usr/src/pandoc
+RUN stack install --local-bin-path /usr/bin hsb2hs
RUN stack install --stack-yaml stack.pkg.yaml --only-dependencies \
--flag 'pandoc:embed_data_files' \
--test --ghc-options '-O2 -optc-Os -optl-static -fPIC' \
diff --git a/macos/make_macos_package.sh b/macos/make_macos_package.sh
index c5d073cdc..911219f14 100755
--- a/macos/make_macos_package.sh
+++ b/macos/make_macos_package.sh
@@ -14,6 +14,8 @@ PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
DEVELOPER_ID_APPLICATION=${DEVELOPER_ID_APPLICATION:-Developer ID Application: John Macfarlane}
DEVELOPER_ID_INSTALLER=${DEVELOPER_ID_INSTALLER:-Developer ID Installer: John Macfarlane}
+# We need this for hsb2hs:
+PATH=$LOCALBIN:$PATH
export MACMACOS_DEPLOYMENT_TARGET=10.7
# echo Removing old files...
@@ -21,6 +23,7 @@ rm -rf $DIST
mkdir -p $DIST
mkdir -p $RESOURCES
stack setup
+which hsb2hs || stack install hsb2hs
which cpphs || stack install cpphs
echo Building pandoc...
diff --git a/pandoc.cabal b/pandoc.cabal
index b102ee2d9..4e3edf008 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -332,7 +332,7 @@ Library
cpp-options: -DHTTP_CLIENT
if flag(embed_data_files)
cpp-options: -DEMBED_DATA_FILES
- build-depends: file-embed >= 0.0 && < 0.1
+ Build-Tools: hsb2hs >= 0.3.1
other-modules: Text.Pandoc.Data
if os(darwin)
Build-Tools: cpphs >= 1.19
diff --git a/src/Text/Pandoc/Data.hs b/src/Text/Pandoc/Data.hsb
index df26f5412..02c109816 100644
--- a/src/Text/Pandoc/Data.hs
+++ b/src/Text/Pandoc/Data.hsb
@@ -1,8 +1,6 @@
-{-# LANGUAGE TemplateHaskell #-}
-
+{-# LANGUAGE OverloadedStrings #-}
+-- to be processed using hsb2hs
module Text.Pandoc.Data (dataFiles) where
-
-import Data.FileEmbed
import qualified Data.ByteString as B
import System.FilePath (splitDirectories)
import qualified System.FilePath.Posix as Posix
@@ -14,4 +12,5 @@ dataFiles = map (\(fp, contents) ->
(Posix.joinPath (splitDirectories fp), contents)) dataFiles'
dataFiles' :: [(FilePath, B.ByteString)]
-dataFiles' = ("MANUAL.txt", $(embedFile "MANUAL.txt")) : $(embedDir "data")
+dataFiles' = ("MANUAL.txt", %blob "MANUAL.txt") : %blobs "data"
+