Post compile hooks with rebar
Posted by Hyperthunk in builds, erlang, python on July 13, 2010
Sometimes you want your build to do some additional work after compiling. For example, in my Erlang implementation of hamcrest, I dynamically generate the main header file after compiling to ensure that all the functions exported from the hamcrest_matchers module are imported when the header gets included and to ensure that wrapper macros for eunit are also generated for each of them.
Typically you’d just have a makefile deal with this, maybe like so:
compile:
./rebar compile; escript header_gen
But that kind of breaks other people’s builds if they want to use rebar themselves. The problem is that rebar doesn’t yet provide a mechanism for overriding the build/compile command for dependencies (at all, let alone individually) and thus if your build requires a makefile to be run then your consumers build has to incur the same kind of complexity. Fortunately there is a work-around. Rebar provides a compile_post_script hook which you can specify in your rebar.config file. You specify a shell command and rebar will run this hook immediately after compilation. Unfortunately it also runs it when the compile command is applied to all your dependencies (again this is something which isn’t controllable yet) which typically will break because your shell command is not relevant to these apps. I spent a little time trying to do something clever with erl --eval '...' but in the end that didn’t play nicely at all. I then tried to encode the whole thing in a compound shell command like if [ -f hrlgen ]; then escript hrl; fi but then discovered that rebar_utils:sh/1 (which runs the shell command) wraps the supplied command text in an exec system call (which obviously isn’t going to work for a complex if..then expression). In the end, it was a comedic reptile that came to the rescue:
{compile_post_script,
"env ERL_LIBS=deps python -c \"import os; os.path.isfile('hrlgen') and os.system('escript hrlgen') or None\""}.
fixing Microsoft live meeting for Safari on Snow Leopard
Posted by Hyperthunk in java, microsoft live meeting, snow leopard on July 8, 2010
This is surprisingly tricky, but in the end (with a bit of help from the safari java console) I determined that the problem is with DNS resolution and have a work-around. Whether this affects everyone or just those of us lucky to be behind a corporate firewall, I don’t know. The fix for me, was to install Java 1.5 and set my java preferences to always choose the 1.5 JVM for running web apps/applets, after which everything seems to play nicely.
Installing java 1.5 on Snow Leopard is itself quite tricky. The secret is to get hold of the java 1.5 update for Leopard and open it using Pacifist, which allows you to navigate into the /System/Library/Frameworks/JavaVM.framework/Versions directory within the installer package, select the 1.5.0 folder and the symlink to it (1.5) then right click and select “install to default location”. Props to this blogger for revealing the secret to that old chestnut. Please be very careful though – if you don’t delete the existing symlink first (which has 1.5 pointing to the current 1.6 install), then you’ll blow away your existing installation!
Unfortunately this means I no longer have an excuse not to attend boring finance meetings whilst working from home.
Using epm to overcome rebar dependency handling limitations
Posted by Hyperthunk in builds, erlang on July 1, 2010
I love rebar as a build tool, but occasionally it doesn’t do what I want. One example that keeps cropping up is managing dependencies that require complex commands in order to build them. If the dependency you want to manage is built using autotools or requires a series of commands (configure && make for example) then rebar is going to fail when you try and run ./rebar check-deps which is annoying. Read the rest of this entry »
Granularity in Dimensional Modelling
Posted by Hyperthunk in business intelligence on June 16, 2010
It’s been a while since I worked on an interesting Business Intelligence problem, so a recent distraction has proved most stimulating. The reason for this post is a question I’ve had to consider many times in the past: should I design my schema by looking at the reports I’ve been asked for, or is there some other driving force to help me identify “the grain” of a dimensional model? Read the rest of this entry »
Things I always forget about resolving Erlang nodes on localhost
Posted by Hyperthunk in work on May 18, 2010
Switching back and forth between programming languages and development environments gets easier over time. There is one thing that I’m constantly forgetting as switch back and forth between Java and Erlang however. In order to work with distributed Erlang nodes on OSX, you need an entry in your /etc/hosts file resolving 127.0.0.1 to your (short) hostname (because the OS seems incapable of resolving its shortname properly). The problem with doing this is it wreaks all kinds of havoc with java applications, so you need to remember to switch it back again when you’re jumping between developments environments. If you have both kinds of VM running at the same time in your dev environment then it’s a bit of a challenge to keep everything running smoothly. My solution (thus far) has been to use my extra laptop and run the java and erlang apps separately for dev/testing. This works fine as the target environment is generally linux so this OSX nonsense goes away once you’ve actually deployed somewhere.
Still, I forget this point regularly when flitting between my day job and personal projects. Hopefully having written it down will help me to remember.
Getting GHC/Cabal-Install working on Snow Leopard
Posted by Hyperthunk in builds, work on February 9, 2010
Cribbed from http://www.haskell.org/haskellwiki/Mac_OS_X#Mac_OS_X_10.6_.28Snow_Leopard.29:
”
* Open /Library/Frameworks/GHC.framework/Versions/Current/usr/bin/ghc-6.10.4 in a text editor
* Insert -optc-m32 -opta-m32 -optl-m32 just before the last parameter.
The last line in that file is rather long, and should now end like -dynload wrapped -optc-m32 -opta-m32 -optl-m32 ${1+”$@”}
Don’t be tempted to just put an edited local copy of the script in ~/bin/ghc, or edit all the various GHC files in /usr/bin. There is a maze of twisty symlinks that all eventually lead to the above script, and fixing just it is far simpler. Many packages need hsc2hs. To make it work correctly you need similar hackery:
* Open /usr/bin/hsc2hs
* Insert –cflag=”-m32″ –lflag=”-m32″ before $tflag
“
Archived flash players for testing…
Posted by Hyperthunk in work on October 9, 2009
I’ve just had to do it again…
Posted by Hyperthunk in work on September 15, 2009
Install Cabal that is. This time (many thanks once again jan) I’m putting out the details inline.
ghc –make Setup.hs
./Setup configure
./Setup build
sudo ./Setup install
Download HTTP and zlib from HackageDB:
ghc –make Setup.lhs (.lhs in case of HTTP, zlib uses the .hs extension)
./Setup configure
./Setup build
sudo ./Setup install
Change into the cabal-install directory and repeat these steps again. Run cabal update to obtain the latest package list.
Getting the firefox flash plugin working on Ubuntu
Posted by Hyperthunk in work on August 22, 2009
Just ran through the instructions here and my firefox/flash setup is sorted. Nice.
fixing git-svn woes
Posted by Hyperthunk in builds, work on May 27, 2009
At work we mostly use subversion for revision control, although some of the cooler kids are using git. I find subversion a bit of a pain compared to git, so I use the git-svn wrapper to get the best of both worlds whilst at work. Since upgrading to the latest Ubuntu however, I’ve noticed that a clash between gnutls and open-ssl causes git/subversion integration to fail. A fellow git-ite pointed out a quick fix however!
$ sudo rm /usr/lib/libneon-gnutls.so.27
$ sudo ln -s /usr/lib/libneon.so.27 /usr/lib/libneon-gnutls.so.27
Works a treat. 🙂