From ff991d1e2151479ff7dc15aba9c17251ff060408 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 2 Apr 2017 23:10:10 +0200 Subject: Revert "Revert "Use file-embed instead of hsb2hs to embed data files."" This reverts commit 1fa15c225b515e1fa1c6566f90f1be363a4d770f. --- INSTALL.md | 3 --- Setup.hs | 28 ++-------------------------- linux/Dockerfile | 1 - macos/make_macos_package.sh | 3 --- pandoc.cabal | 2 +- src/Text/Pandoc/Data.hs | 17 +++++++++++++++++ src/Text/Pandoc/Data.hsb | 16 ---------------- 7 files changed, 20 insertions(+), 50 deletions(-) create mode 100644 src/Text/Pandoc/Data.hs delete mode 100644 src/Text/Pandoc/Data.hsb diff --git a/INSTALL.md b/INSTALL.md index ed34a95c9..902e98a9f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -226,9 +226,6 @@ 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 bc6651942..3f6bb2858 100644 --- a/Setup.hs +++ b/Setup.hs @@ -20,41 +20,17 @@ 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 (info, notice, installOrdinaryFiles) +import Distribution.Simple.Utils (notice, installOrdinaryFiles) import Distribution.Simple.Program (simpleProgram, Program(..)) import Distribution.Simple.LocalBuildInfo import Control.Monad (when) main :: IO () main = defaultMainWithHooks $ simpleUserHooks { - -- enable hsb2hs preprocessor for .hsb files - hookedPreProcessors = [ppBlobSuffixHandler] - , hookedPrograms = [(simpleProgram "hsb2hs"){ - programFindVersion = \verbosity fp -> - findProgramVersion "--version" id verbosity fp }] - , postCopy = installManPage + 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 630abc17e..b725bbaa5 100644 --- a/linux/Dockerfile +++ b/linux/Dockerfile @@ -14,7 +14,6 @@ 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 911219f14..c5d073cdc 100755 --- a/macos/make_macos_package.sh +++ b/macos/make_macos_package.sh @@ -14,8 +14,6 @@ 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... @@ -23,7 +21,6 @@ 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 1588e532f..dfa63cd07 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -340,7 +340,7 @@ Library cpp-options: -DHTTP_CLIENT if flag(embed_data_files) cpp-options: -DEMBED_DATA_FILES - Build-Tools: hsb2hs >= 0.3.1 + build-depends: file-embed >= 0.0 && < 0.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.hs new file mode 100644 index 000000000..df26f5412 --- /dev/null +++ b/src/Text/Pandoc/Data.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE TemplateHaskell #-} + +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 + +-- We ensure that the data files are stored using Posix +-- path separators (/), even on Windows. +dataFiles :: [(FilePath, B.ByteString)] +dataFiles = map (\(fp, contents) -> + (Posix.joinPath (splitDirectories fp), contents)) dataFiles' + +dataFiles' :: [(FilePath, B.ByteString)] +dataFiles' = ("MANUAL.txt", $(embedFile "MANUAL.txt")) : $(embedDir "data") diff --git a/src/Text/Pandoc/Data.hsb b/src/Text/Pandoc/Data.hsb deleted file mode 100644 index 02c109816..000000000 --- a/src/Text/Pandoc/Data.hsb +++ /dev/null @@ -1,16 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} --- to be processed using hsb2hs -module Text.Pandoc.Data (dataFiles) where -import qualified Data.ByteString as B -import System.FilePath (splitDirectories) -import qualified System.FilePath.Posix as Posix - --- We ensure that the data files are stored using Posix --- path separators (/), even on Windows. -dataFiles :: [(FilePath, B.ByteString)] -dataFiles = map (\(fp, contents) -> - (Posix.joinPath (splitDirectories fp), contents)) dataFiles' - -dataFiles' :: [(FilePath, B.ByteString)] -dataFiles' = ("MANUAL.txt", %blob "MANUAL.txt") : %blobs "data" - -- cgit v1.2.3