Skip to content
  • sof's avatar
    [project @ 2001-10-26 00:53:27 by sof] · 11447047
    sof authored
    Added support for a custom pre-processor pass:
    
      ghc -F -pgmF/path/to/a/pre/processor ...
    
    will now run /path/to/a/pre/processor over Haskell
    input sources. It is positioned in the compilation
    pipeline just before the compiler proper, but after
    unlit'ing and CPP'ing. The pre-processor is passed
    the following command-line when invoked:
    
       /path/to/a/pre/processor orig_input_source_file_path
       			    input_source_file
    			    output_source_file
    			    <other options>
    
    Additionally options can be fed directly to the
    pre-processor via -optF<option> options.
    
    The -F option causes the pre-processor to run _iff_ one
    has been specified via -pgmF (there's some redundancy
    here, but I went for this cmd-line interface as it's
    consistent with the general -pgm<Foo> story).
    
    Motivation:
    
     * hooking in a pre-processor is occasionally useful;
       e.g., cheap&cheerful way to integrate language
       extensions with GHC, compile-time syntax/style
       checking etc.
    
     * Artfully re-using the CPP phase (by specifying your
       own via -pgmP) doesn't really work as the driver
       really assumes that GNU cpp is what's being invoked
       (and path mangling is also performed on Win32 platforms).
    
       Additionally, there are cases when you want to be
       able to run CPP _and_ a pre-processor.
    
     * The alternative of running the pre-processor as a
       separate program in a Makefile (say) doesn't work
       in interpreted mode, and this approach also forces
       you to give up on recompilation checking when in
       batch mode.
    11447047