hamish.k.mackenzie at googlemail.com
Sat May 14 19:44:29 CEST 2011
Blackh and I have been trying out some ideas on how to make it easier use GHCJS in your Cabal projects. We took Victor's GHCJS code and added it back into GHC (we could not easily accomplish what we wanted using the current GHC API). We set it up so that GHC outputs a .js file whenever it outputs an object file. We added code to Cabal to install the .js files (in the same place as the .hi files). At link time GHC copies all the .js files from the packages used into a .jsexe directory (with the same name and in the same location as the executable). Finally when the executable is installed we copy the .jsexe directory along with it. Only files with differing modified dates are copied to avoid slowing things down too much.
I have updated my yesod-slides example to show how all this can be used.
The README.mardown there has instructions for building GHC and Cabal with the GHCJS stuff in it. It is a bit painful to build, but the changes to yesod-slides were quite minor...
* Added ghcjs-rts to the build depends
* Published the yesod-slides.jsexe folder (using Yesod's staticFiles)
* Added <script> tags to <head> for rts-common.js and rts-plain.js
* Added Julius script to init the rts
Currently GHC is hard coded to use the GHCJS Trampoline calling convention (in GHC's HscMain.hs).
More information about the Haskell-Cafe