Quantcast

How to force recompilation of preprocessed files (-F -pgmF ..)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to force recompilation of preprocessed files (-F -pgmF ..)

Simon Hengel
Hi,
I'm experimenting with a preprocessor to automatically generate test
drivers[1].  The result depends on the existence of other files on the
disk.  When files are added or removed, the test driver has to be
regenerated.

Ideally ghc would just always recompile that single file (akin to make's
.PHONY), and it should work with ghci's :reload and with cabal.

I tried to touch the file within the preprocessor, but this does not
work.  It seems, that GHC checks the modification time only after
preprocessing.

Any ideas how to tackle this?

Cheers,
Simon

[1] https://github.com/sol/hspec-discover

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to force recompilation of preprocessed files (-F -pgmF ..)

Etienne Laurin
Hello Simon,

You can use Template Haskell's addDependentFile to register a
dependency on external files.

http://hackage.haskell.org/packages/archive/template-haskell/2.7.0.0/doc/html/Language-Haskell-TH-Syntax.html#v:addDependentFile

You can also put -fforce-recomp in an OPTIONS_GHC pragma to ask GHC to
always recompile the file.

{-# OPTIONS_GHC -fforce-recomp #-}

Etienne Laurin

2012/5/17 Simon Hengel <[hidden email]>:

> Hi,
> I'm experimenting with a preprocessor to automatically generate test
> drivers[1].  The result depends on the existence of other files on the
> disk.  When files are added or removed, the test driver has to be
> regenerated.
>
> Ideally ghc would just always recompile that single file (akin to make's
> .PHONY), and it should work with ghci's :reload and with cabal.
>
> I tried to touch the file within the preprocessor, but this does not
> work.  It seems, that GHC checks the modification time only after
> preprocessing.
>
> Any ideas how to tackle this?
>
> Cheers,
> Simon
>
> [1] https://github.com/sol/hspec-discover

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to force recompilation of preprocessed files (-F -pgmF ..)

Simon Hengel
Hi Etienne,
thanks for your reply.

> You can use Template Haskell's addDependentFile to register a
> dependency on external files.
>
> http://hackage.haskell.org/packages/archive/template-haskell/2.7.0.0/doc/html/Language-Haskell-TH-Syntax.html#v:addDependentFile

That's interesting.  But from what I've tried, it seems that it does not
work with GHCi.

> You can also put -fforce-recomp in an OPTIONS_GHC pragma to ask GHC to
> always recompile the file.
>
> {-# OPTIONS_GHC -fforce-recomp #-}

I think it's amazing, that this works with ghc --make.  But it does not
work with GHCi, I created a ticket for that [1].

Cheers,
Simon

[1] http://hackage.haskell.org/trac/ghc/ticket/6105

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Loading...