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

This reverts commit 10d91c147968d2e4d63b99b5b0342624827f416f.

commit1fa15c225b515e1fa1c6566f90f1be363a4d770f authorJohn MacFarlane <jgm@berkeley.edu> dateSun 26 Mar 2017, 20:48 (10 years ago) parentd044715
6 files changed+38−8
INSTALL.md+3 Setup.hs+26−2 linux/Dockerfile+1 macos/make_macos_package.sh+3 pandoc.cabal+1−1 src/Text/Pandoc/Data.hs → src/Text/Pandoc/Data.hsb+4−5
INSTALL.md+3
@@ -226,6 +226,9 @@ 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).
229232
230233 - `https`: enable support for downloading resources over https
231234 (using the `http-client` and `http-client-tls` libraries).
Setup.hs+26−2
@@ -20,17 +20,41 @@ 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 )
2324import System.Exit
24−import Distribution.Simple.Utils (notice, installOrdinaryFiles)
25+import Distribution.Simple.Utils (info, notice, installOrdinaryFiles)
2526import Distribution.Simple.Program (simpleProgram, Program(..))
2627import Distribution.Simple.LocalBuildInfo
2728import Control.Monad (when)
2829
2930main :: IO ()
3031main = defaultMainWithHooks $ simpleUserHooks {
31− postCopy = installManPage
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
3238 }
3339
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+
3458installManPage :: Args -> CopyFlags
3559 -> PackageDescription -> LocalBuildInfo -> IO ()
3660installManPage _ flags pkg lbi = do
linux/Dockerfile+1
@@ -14,6 +14,7 @@ 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
1718RUN stack install --stack-yaml stack.pkg.yaml --only-dependencies \
1819 --flag 'pandoc:embed_data_files' \
1920 --test --ghc-options '-O2 -optc-Os -optl-static -fPIC' \
macos/make_macos_package.sh+3
@@ -14,6 +14,8 @@ 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
1719export MACMACOS_DEPLOYMENT_TARGET=10.7
1820
1921# echo Removing old files...
@@ -21,6 +23,7 @@ rm -rf $DIST
2123mkdir -p $DIST
2224mkdir -p $RESOURCES
2325stack setup
26+which hsb2hs || stack install hsb2hs
2427which cpphs || stack install cpphs
2528
2629echo Building pandoc...
pandoc.cabal+1−1
@@ -332,7 +332,7 @@ Library
332332 cpp-options: -DHTTP_CLIENT
333333 if flag(embed_data_files)
334334 cpp-options: -DEMBED_DATA_FILES
335− build-depends: file-embed >= 0.0 && < 0.1
335+ Build-Tools: hsb2hs >= 0.3.1
336336 other-modules: Text.Pandoc.Data
337337 if os(darwin)
338338 Build-Tools: cpphs >= 1.19
src/Text/Pandoc/Data.hs → src/Text/Pandoc/Data.hsbrenamed+4−5
@@ -1,8 +1,6 @@
1−{-# LANGUAGE TemplateHaskell #-}
2−
1+{-# LANGUAGE OverloadedStrings #-}
2+-- to be processed using hsb2hs
33module Text.Pandoc.Data (dataFiles) where
4−
5−import Data.FileEmbed
64import qualified Data.ByteString as B
75import System.FilePath (splitDirectories)
86import qualified System.FilePath.Posix as Posix
@@ -14,4 +12,5 @@ dataFiles = map (\(fp, contents) ->
1412 (Posix.joinPath (splitDirectories fp), contents)) dataFiles'
1513
1614dataFiles' :: [(FilePath, B.ByteString)]
17−dataFiles' = ("MANUAL.txt", $(embedFile "MANUAL.txt")) : $(embedDir "data")
15+dataFiles' = ("MANUAL.txt", %blob "MANUAL.txt") : %blobs "data"
16+