Skip to content

Commit

Permalink
Rewrite build system for new versions and Heroku stacks
Browse files Browse the repository at this point in the history
This allows new versions to be built for uploading by running
`make VERSION=5.0.1` rather than updating the hard coded version in
multiple places. I've also added support for building against either the
legacy cedar-14 architecture or heroku-16. While versions built on
cedar-14 appear to run on heroku-16, the newer stack should also mean a
newer and better tool chain.

I've removed the Dockerfile and switched to using Heroku's docker images
directly as this removes the need for cleaning them up afterwards. It
possibly makes debugging harder but having build.sh available should
avoid some of that.

Fixes #2
Fixes #7
Fixes #13
  • Loading branch information
gaffneyc committed Dec 5, 2017
1 parent 48a8c80 commit 71ac02c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 26 deletions.
11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

38 changes: 25 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
default: dist/jemalloc-5.0.0-1.tar.gz
default: heroku-16 cedar

dist/jemalloc-5.0.0-1.tar.gz: jemalloc-cedar
docker cp $<:/tmp/jemalloc-cedar.tar.gz .
mkdir -p $$(dirname $@)
mv jemalloc-cedar.tar.gz $@
VERSION := 5.0.1
ROOT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

clean:
rm -rf src/ dist/
-docker rm jemalloc-cedar

src/jemalloc.tar.bz2:
# Download missing source archives to ./src/
src/jemalloc-%.tar.bz2:
mkdir -p $$(dirname $@)
curl -sL https://github.com/jemalloc/jemalloc/releases/download/5.0.0/jemalloc-5.0.0.tar.bz2 -o $@
curl -fsL https://github.com/jemalloc/jemalloc/releases/download/$*/jemalloc-$*.tar.bz2 -o $@

.PHONY: cedar-14 heroku-16

# Build for cedar stack (deprecated)
cedar-14: src/jemalloc-$(VERSION).tar.bz2
docker run -it --volume="$(ROOT_DIR):/wrk" \
heroku/cedar:14 /wrk/build.sh $(VERSION) cedar-14

.PHONY: jemalloc-cedar
# Build for heroku-16 stack
heroku-16: src/jemalloc-$(VERSION).tar.bz2
docker run -it --volume="$(ROOT_DIR):/wrk" \
heroku/heroku:16-build /wrk/build.sh $(VERSION) heroku-16

jemalloc-cedar: src/jemalloc.tar.bz2
docker build --rm -t mojodna/$@ .
-docker rm $@
docker run --name $@ mojodna/$@ /bin/echo $@
# Build recent releases for heroku-16 and cedar
all:
$(MAKE) cedar-14 VERSION=3.6.0
$(MAKE) cedar-14 VERSION=4.5.0
$(MAKE) cedar-14 VERSION=5.0.1
$(MAKE) heroku-16 VERSION=3.6.0
$(MAKE) heroku-16 VERSION=4.5.0
$(MAKE) heroku-16 VERSION=5.0.1
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ This uses Docker to build against Heroku
[stack-image](https://github.com/heroku/stack-images)-like images.

```bash
make
make VERSION=5.0.1
```

Artifacts will be dropped in `dist/`. See `Dockerfile`s for build options.
Artifacts will be dropped in `dist/` based on Heroku stack and jemalloc version.
17 changes: 17 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# usage: build [version] [stack]
set -e

version=$1
stack=$2
build=`mktemp -d`

tar -C $build --strip-components=1 -xj -f /wrk/src/jemalloc-$version.tar.bz2

cd $build
./configure --prefix=/app/vendor/jemalloc
make install_bin install_include install_lib_shared install_lib_static

# Bundle and compress the compiled library
mkdir -p /wrk/dist/$stack
tar -C /app/vendor/jemalloc -zc -f /wrk/dist/$stack/jemalloc-$version.tar.gz .

0 comments on commit 71ac02c

Please sign in to comment.