git.iko.soy/typeable/pandoc
on master help sign in
Setup.hs: Don't require hsb2hs unless embed_data_files flag specified.
commit8763ba188c9829e959cd71e1a9e1af44843d74d6 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 3 Jul 2015, 17:07 (11 years ago) parenta27991d
1 file changed+15−8
Setup.hs+15−8
Setup.hs+15−8
@@ -18,13 +18,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818
1919import Distribution.Simple
2020import Distribution.Simple.PreProcess
21−import Distribution.PackageDescription (PackageDescription(..))
21+import Distribution.Simple.Setup (ConfigFlags(..))
22+import Distribution.PackageDescription (PackageDescription(..), FlagName(..))
2223import System.Process ( rawSystem )
2324import System.FilePath ( (</>) )
2425import System.Directory ( findExecutable )
2526import Distribution.Simple.Utils (info, notice, installOrdinaryFiles)
2627import Distribution.Simple.Setup
2728import Distribution.Simple.LocalBuildInfo
29+import Control.Monad (when)
2830
2931main :: IO ()
3032main = defaultMainWithHooks $ simpleUserHooks {
@@ -34,16 +36,21 @@ main = defaultMainWithHooks $ simpleUserHooks {
3436 }
3537
3638ppBlobSuffixHandler :: PPSuffixHandler
37−ppBlobSuffixHandler = ("hsb", \_ _ ->
39+ppBlobSuffixHandler = ("hsb", \_ lbi ->
3840 PreProcessor {
3941 platformIndependent = True,
4042 runPreProcessor = mkSimplePreProcessor $ \infile outfile verbosity ->
41− do info verbosity $ "Preprocessing " ++ infile ++ " to " ++ outfile
42− hsb2hsPath <- findExecutable "hsb2hs"
43− case hsb2hsPath of
44− Just p -> rawSystem p [infile, infile, outfile]
45− Nothing -> error "hsb2hs is needed to build this program: cabal install hsb2hs"
46− return ()
43+ do let embedData = case lookup (FlagName "embed_data_files")
44+ (configConfigurationsFlags (configFlags lbi)) of
45+ Just True -> True
46+ _ -> False
47+ when embedData $
48+ do info verbosity $ "Preprocessing " ++ infile ++ " to " ++ outfile
49+ hsb2hsPath <- findExecutable "hsb2hs"
50+ case hsb2hsPath of
51+ Just p -> rawSystem p [infile, infile, outfile]
52+ Nothing -> error "hsb2hs is needed to build this program: cabal install hsb2hs"
53+ return ()
4754 })
4855
4956installManPage :: Args -> CopyFlags