haskell/cabal — pull request #2269 by luite (2014-12-12 23:28:53+00:00)
Title: Add GHCJS support to the Simple build infrastructure

This is the whole GHCJS build system, I've tested this with GHCJS based on GHC HEAD and on 7.8.3, `cabal install`, `cabal test`, `cabal run`, Haddock, sandboxes etc all work. Apologies for the rather large amount of code in a single commit. Fortunately most of the changes are relatively straightforward:

- some of the code in `Distribution.Simple.GHC` is moved to `Distribution.Simple.GHC.Internal`, from where it can be shared between multiple similar (GHC-derived) compilers.
- In order to make the shared code work reasonably well, many of the feature / quirk dependent code paths now use `GhcImplProps` from `Distribution.Simple.GHC.Props` rather than checking version numbers (which are different between the compilers). This mostly affects the Haddock and HcPkg modules and GHC command line rendering.
- The `GHCJS` flavor is handled throughout the code and in some places the hardcoded assumption that GHC is used has been removed (Building `Setup.hs` scripts and initializing package databases for example)
- The `Distribution.Simple.GHCJS` module contains most of the GHCJS-specific build code. It's very similar to `Distribution.Simple.GHC` and pretty big. More code can be shared with the GHC flavour, but that would have required more invasive restructuring of the code, which i didn't want to do in the first version.

Note that the reported architecture of the GHCJS compiler is that of the build machine. This is done to support `native-too` mode, where all code is built for the build machine too.

The `Cabal` library is compiled to JavaScript as part of the GHCJS installation procedure (`ghcjs-boot`). Some functionality (`createPipe`) is not yet supported, so I'm just throwing an exception there on the `ghcjs_HOST_OS` platform. The limitation should be removed at some later point.