Reputation: 6366
I'm working on a custom ghc plugin. In order to test it out, I want to run it on every package on hackage. I'm running into two difficulties with this.
First, I need to pass the -fplugin=MyPlugin
option to ghc when installing packages. The only way I've found to do this is to create the file myghc.sh
that contains:
#!/bin/sh
ghc -fplugin=MyPlugin $@
And then run cabal install --with-compiler=./myghc.sh
. But then when I run that command, I get the error
Could not find module 'MyPlugin'
it is a member of the hidden package...
So is there a special flag I can pass to cabal install
to use my plugin without having to modify every packages' cabal file?
Second, I want my plugin to record information about the package it is compiling, so I need a way for my package to know this information.
It seems like there might be a number of ways to do this, but here's what I've come up with so far. I want a list of hackage packages ordered so that all the dependencies of a package are guaranteed to come before it in the list? Then, when I run cabal install
, I can pass the name of the package it is installing to the plugin. Since the dependencies are already installed, I wouldn't have to worry about them getting installed under the wrong name.
Upvotes: 1
Views: 226
Reputation: 153172
I'm not sure about the second part, but the first part should be possible with a command-line flag to cabal:
cabal install --ghc-option=-fplugin=MyPlugin
Upvotes: 1