cabal: question on compiling build prerequisites
Peter Selinger
selinger at mathstat.dal.ca
Sat Dec 14 06:06:54 UTC 2013
Hi Dag,
this was a good suggestion, but it doesn't work. When invoking this
preprocessor, GHC will run the command
runghc <source> <input> <output> PreProc.
In other words, any options specified with -optF are appended at the
*end* of the preprocessor arguments, not the beginning. So one can
never use runghc to run a proprocessor.
Thanks, -- Peter
Dag Odenhall wrote:
>
> How about -pgmF runghc -optF PreProc?
>
>
> On Mon, Dec 9, 2013 at 12:48 AM, Peter Selinger <selinger at mathstat.dal.ca>wrote:
>
> > Thanks for the suggestion! However, it is not portable: it doesn't
> > work on Windows.
> >
> > Similarly, giving "runhaskell ./PreProc.hs" as the preprocessor
> > command to GHC doesn't work either, because GHC will try to run a
> > program with that exact name (including the space), rather than
> > interpreting it as a command with an argument.
> >
> > In addition, even on Posix systems, where the above method does work,
> > it is nevertheless extremely slow: runhaskell will have to interpret
> > or compile ./PreProc.hs separately for each source file, of which
> > there could be many.
> >
> > Another solution I thought of is to include
> >
> > import Preproc
> >
> > at the beginning of Setup.hs. This way compiling Setup.hs would have
> > the side effect of compiling Preproc.hs. It would not work with the
> > "runhaskell Setup.hs" method, though.
> >
> > -- Peter
> >
> > Erik Hesselink wrote:
> > >
> > > On Sun, Dec 8, 2013 at 7:50 PM, Peter Selinger <selinger at mathstat.dal.ca>
> > wrote:
> > > > thanks for your reply! So say my package directory contains two files:
> > > >
> > > > Test.hs
> > > > PreProc.hs
> > > >
> > > > What you are suggesting is:
> > > >
> > > > ghc Test.hs -F -pgmF ./PreProc
> > > >
> > > > However, this gives the error message:
> > > >
> > > > ghc: could not execute: ./PreProc
> > > >
> > > > And indeed, while GHC is smart enough to automatically run a
> > > > preprocessor, it is not smart enough to automatically *compile* the
> > > > preprocessor. So it needs to be compiled beforehand, which would be
> > > > Cabal's job.
> > >
> > > Not per se. You could try making it executable, and prepending a line
> > like:
> > >
> > > #!/usr/bin/env runhaskell
> > >
> > > That way you can run your preprocessor like a script, without compiling
> > it.
> > >
> > > Erik
> > >
> >
> > _______________________________________________
> > cabal-devel mailing list
> > cabal-devel at haskell.org
> > http://www.haskell.org/mailman/listinfo/cabal-devel
> >
>
More information about the cabal-devel
mailing list