File: Setup.hs

package info (click to toggle)
haskell-ogma-language-smv 1.7.0-1
  • links: PTS, VCS
  • area: non-free
  • in suites: sid, trixie
  • size: 212 kB
  • sloc: haskell: 90; makefile: 6
file content (27 lines) | stat: -rw-r--r-- 1,139 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-- | Custom Setup that runs bnfc to generate the language sub-libraries
-- for the parsers included in Ogma.
module Main (main) where

import Distribution.Simple         ( defaultMainWithHooks, hookedPrograms,
                                     postConf, preBuild, simpleUserHooks )
import Distribution.Simple.Program ( Program (..), findProgramVersion,
                                     simpleProgram )
import System.Process              ( system )

-- | Run BNFC on the grammar before the actual build step.
--
-- All options for bnfc are hard-coded here. There is an open bug in Cabal's
-- github repo about supporting BNFC.
main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks
  { hookedPrograms = [ bnfcProgram ]
  , postConf       = \args flags packageDesc localBuildInfo -> do
      _ <- system "bnfc --haskell -p Language.SMV -o src/ grammar/SMV.cf"
      postConf simpleUserHooks args flags packageDesc localBuildInfo
  }

-- | TODO: This should be in Cabal.Distribution.Simple.Program.Builtin.
bnfcProgram :: Program
bnfcProgram = (simpleProgram "bnfc")
  { programFindVersion = findProgramVersion "--version" id
  }