Hello,
I’m currently building a custom preprocessor I would like to integrate with Cabal build. At the moment I have the following module that I use in my Setup.hs:
module CfgTypedCabal (mainWithCfgTyped) where
import Distribution.Simple
import Distribution.Types.BuildInfo (BuildInfo)
import Distribution.Types.LocalBuildInfo (LocalBuildInfo)
import Distribution.Types.ComponentLocalBuildInfo (ComponentLocalBuildInfo)
import Distribution.Simple.PreProcess (PreProcessor (..), mkSimplePreProcessor)
import System.Process
mainWithCfgTyped :: IO ()
mainWithCfgTyped = defaultMainWithHooks hooks
hooks :: UserHooks
hooks = simpleUserHooks
{ hookedPreProcessors = ("ny", ppCustom) : hookedPreProcessors simpleUserHooks
}
ppCustom :: BuildInfo -> LocalBuildInfo -> ComponentLocalBuildInfo -> PreProcessor
ppCustom _ _ _ =
PreProcessor {
ppOrdering = \_ _ -> pure,
platformIndependent = True,
runPreProcessor = mkSimplePreProcessor $ \inFile outFile _ ->
do
input <- readFile inFile
output <- readProcess "preprocessor" [] input
writeFile outFile output
}
The problem I have right now is that Cabal does not re-run the preprocessor when I change the source (in this case a file with ny
extension) based on which the code is generated. Does anyone know how to fix this issue?