git.iko.soy/typeable/pandoc
on master help sign in
Revert "Revert "Use file-embed instead of hsb2hs to embed data files.""

This reverts commit 1fa15c225b515e1fa1c6566f90f1be363a4d770f.

commitff991d1e2151479ff7dc15aba9c17251ff060408 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 2 Apr 2017, 23:10 (10 years ago) parent913db94
6 files changed+8−38
INSTALL.md−3 Setup.hs+2−26 linux/Dockerfile−1 macos/make_macos_package.sh−3 pandoc.cabal+1−1 src/Text/Pandoc/Data.hsb → src/Text/Pandoc/Data.hs+5−4
INSTALL.md−3
@@ -226,9 +226,6 @@ assume that the pandoc source directory is your working directory.
226226
227227 - `embed_data_files`: embed all data files into the binary (default no).
228228 This is helpful if you want to create a relocatable binary.
229− Note: if this option is selected, you need to install the
230− `hsb2hs` preprocessor: `cabal install hsb2hs` (version 0.3.1 or
231− higher is required).
232229
233230 - `https`: enable support for downloading resources over https
234231 (using the `http-client` and `http-client-tls` libraries).
Setup.hs+2−26
@@ -20,41 +20,17 @@ import Distribution.Simple
2020import Distribution.Simple.PreProcess
2121import Distribution.Simple.Setup (ConfigFlags(..), CopyFlags(..), fromFlag)
2222import Distribution.PackageDescription (PackageDescription(..), FlagName(..))
23−import Distribution.Simple.Utils ( rawSystemExitCode, findProgramVersion )
2423import System.Exit
25−import Distribution.Simple.Utils (info, notice, installOrdinaryFiles)
24+import Distribution.Simple.Utils (notice, installOrdinaryFiles)
2625import Distribution.Simple.Program (simpleProgram, Program(..))
2726import Distribution.Simple.LocalBuildInfo
2827import Control.Monad (when)
2928
3029main :: IO ()
3130main = defaultMainWithHooks $ simpleUserHooks {
32− -- enable hsb2hs preprocessor for .hsb files
33− hookedPreProcessors = [ppBlobSuffixHandler]
34− , hookedPrograms = [(simpleProgram "hsb2hs"){
35− programFindVersion = \verbosity fp ->
36− findProgramVersion "--version" id verbosity fp }]
37− , postCopy = installManPage
31+ postCopy = installManPage
3832 }
3933
40−ppBlobSuffixHandler :: PPSuffixHandler
41−ppBlobSuffixHandler = ("hsb", \_ lbi ->
42− PreProcessor {
43− platformIndependent = True,
44− runPreProcessor = mkSimplePreProcessor $ \infile outfile verbosity ->
45− do let embedData = case lookup (FlagName "embed_data_files")
46− (configConfigurationsFlags (configFlags lbi)) of
47− Just True -> True
48− _ -> False
49− when embedData $
50− do info verbosity $ "Preprocessing " ++ infile ++ " to " ++ outfile
51− ec <- rawSystemExitCode verbosity "hsb2hs"
52− [infile, infile, outfile]
53− case ec of
54− ExitSuccess -> return ()
55− ExitFailure _ -> error "hsb2hs is needed to build this program"
56− })
57−
5834installManPage :: Args -> CopyFlags
5935 -> PackageDescription -> LocalBuildInfo -> IO ()
6036installManPage _ flags pkg lbi = do
linux/Dockerfile−1
@@ -14,7 +14,6 @@ RUN mkdir -p /usr/src/
1414WORKDIR /usr/src/
1515RUN git clone https://github.com/jgm/pandoc
1616WORKDIR /usr/src/pandoc
17−RUN stack install --local-bin-path /usr/bin hsb2hs
1817RUN stack install --stack-yaml stack.pkg.yaml --only-dependencies \
1918 --flag 'pandoc:embed_data_files' \
2019 --test --ghc-options '-O2 -optc-Os -optl-static -fPIC' \
macos/make_macos_package.sh−3
@@ -14,8 +14,6 @@ PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
1414DEVELOPER_ID_APPLICATION=${DEVELOPER_ID_APPLICATION:-Developer ID Application: John Macfarlane}
1515DEVELOPER_ID_INSTALLER=${DEVELOPER_ID_INSTALLER:-Developer ID Installer: John Macfarlane}
1616
17−# We need this for hsb2hs:
18−PATH=$LOCALBIN:$PATH
1917export MACMACOS_DEPLOYMENT_TARGET=10.7
2018
2119# echo Removing old files...
@@ -23,7 +21,6 @@ rm -rf $DIST
2321mkdir -p $DIST
2422mkdir -p $RESOURCES
2523stack setup
26−which hsb2hs || stack install hsb2hs
2724which cpphs || stack install cpphs
2825
2926echo Building pandoc...
pandoc.cabal+1−1
@@ -340,7 +340,7 @@ Library
340340 cpp-options: -DHTTP_CLIENT
341341 if flag(embed_data_files)
342342 cpp-options: -DEMBED_DATA_FILES
343− Build-Tools: hsb2hs >= 0.3.1
343+ build-depends: file-embed >= 0.0 && < 0.1
344344 other-modules: Text.Pandoc.Data
345345 if os(darwin)
346346 Build-Tools: cpphs >= 1.19
src/Text/Pandoc/Data.hsb → src/Text/Pandoc/Data.hsrenamed+5−4
@@ -1,6 +1,8 @@
1−{-# LANGUAGE OverloadedStrings #-}
2−-- to be processed using hsb2hs
1+{-# LANGUAGE TemplateHaskell #-}
2+
33module Text.Pandoc.Data (dataFiles) where
4+
5+import Data.FileEmbed
46import qualified Data.ByteString as B
57import System.FilePath (splitDirectories)
68import qualified System.FilePath.Posix as Posix
@@ -12,5 +14,4 @@ dataFiles = map (\(fp, contents) ->
1214 (Posix.joinPath (splitDirectories fp), contents)) dataFiles'
1315
1416dataFiles' :: [(FilePath, B.ByteString)]
15−dataFiles' = ("MANUAL.txt", %blob "MANUAL.txt") : %blobs "data"
16−
17+dataFiles' = ("MANUAL.txt", $(embedFile "MANUAL.txt")) : $(embedDir "data")