This turned out to be quite involved but save for this huge commit it's
actually quite awesome and squashes quite a few bugs and nasty
problems (hopefully). Most importantly we now have native cabal
component support without the user having to do anything to get it!
To do this we traverse imports starting from each component's
entrypoints (library modules or Main source file for executables) and
use this information to find which component's options each module will
build with. Under the assumption that these modules have to build with
every component they're used in we can now just pick one.
Quite a few internal assumptions have been invalidated by this
change. Most importantly the runGhcModT* family of cuntions now change
the current working directory to `cradleRootDir`.
The idea here is to build cabal-helper with whatever version of Cabal
the user happens to be using (which we find by looking at
dist/setup-config) at runtime.
This way we can support literally any version of Cabal as long as the
actual cabal-helper still compiles.
I tried to only use interfaces in Cabal that have been there since at
least 1.16 so I'm hoping this shouldn't break too much.
X-Install-Target:
Since cabal doesn't have builtin support for installing executables
to locations other than $bindir yet this allows me to install stuff
into $libexec or any other directory.
X-Build-Depends-Like:
Duplicating the dependencies of the main library for every test
suite is getting annoying this allows me to copy the final resolved
external dependencies of a component.
If cabal.sandbox.config contains a "package-db:" declaration with the
wrong path and only the ghc version is wrong, for example:
```
package-db: <DIR>/.cabal-sandbox/x86_64-linux-ghc-7.8.3-packages.conf.d
```
Even though the user is using 7.10.0.20141222 `cabal repl` will correct
this and pass
```
-package-db <DIR>/.cabal-sandbox/x86_64-linux-ghc-7.10.0.20141222-packages.conf.d
```
to ghci, so obviously Cabal/cabal-install is doing some magic.
Conflicts:
Language/Haskell/GhcMod/PathsAndFiles.hs