ddollar/heroku-buildpack-multi — pull request #6 by bernerdschaefer (2012-07-06 15:14:27+00:00)
Title: Config merging; build environment variables

This commit includes two separate but related features:

1. Instead of only taking the last release config, the YAML is parsed and merged after each step. It's quite dumb now, just a "deep merge" on the values emitted by each step, but could be upgraded to even, say, merge "PATH" settings, etc.

2. It adds awareness for a custom key in bin/release's yaml: `build_env`. It's like `config_vars`, except that each stage in a multi-build is run with the combined `build_env` of each previous step.

I'd like some feedback on this, but here's my use case:

I needed libcairo (with development dependencies), which isn't available on heroku. So I put together a buildpack for it, but realized there was no way to pass information from my buildpack into the ruby build pack for installing the "cairo" gem.

So now my cairo buildpack now does this in bin/release:

```
#!/bin/sh
# bin/release

set -e

BUILD_DIR=$1

LIB_PATH="$BUILD_DIR/vendor/cairo/lib:$BUILD_DIR/vendor/pixman-0.26/lib"
INCLUDE_PATH="$BUILD_DIR/vendor/cairo/include/cairo:$BUILD_DIR/vendor/pixman-0.26/include/pixman-1"
PKG_CONFIG_PATH="$BUILD_DIR/vendor/cairo/lib/pkgconfig:$BUILD_DIR/vendor/pixman-0.26/lib/pkgconfig"

cat << EOF
---
build_env:
BUNDLE_BUILD__CAIRO: "--with-opt-lib=${LIB_PATH} --with-opt-include=${INCLUDE_PATH} --with-pkg-config=${PKG_CONFIG_PATH}"
config_vars:
PATH: "bin:/app/vendor/cairo/bin:/usr/local/bin:/usr/bin:/bin"
EOF
```

So that a user can do a multi-build pack with cairo + ruby, do 'gem "cairo"', and everything just works!