Skip to content

Commit

Permalink
Use rebar for building GeoCouch
Browse files Browse the repository at this point in the history
Instead of using Emake, use rebar to build GeoCouch.
This will make it easier for future dependencies.
The output directory for the beam files changed from "build"
to "ebin".

Change-Id: Idbe9e2ef4197e5886f7ed6627d3689c9f530714f
Reviewed-on: http://review.couchbase.org/9825
Reviewed-by: Filipe David Borba Manana <fdmanana@gmail.com>
Tested-by: Filipe David Borba Manana <fdmanana@gmail.com>
  • Loading branch information
vmx committed Jun 15, 2012
1 parent 65bab64 commit 8acfec9
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@ erl_crash.dump
coverage
*.tar.gz
tmp
ebin
15 changes: 0 additions & 15 deletions Emakefile

This file was deleted.

31 changes: 10 additions & 21 deletions Makefile
@@ -1,38 +1,27 @@
ERL=erl
VERSION=$(shell git describe)
# Output ERL_COMPILER_OPTIONS env variable
COMPILER_OPTIONS=$(shell $(ERL) -noinput +B -eval 'Options = case os:getenv("ERL_COMPILER_OPTIONS") of false -> []; Else -> {ok,Tokens,_} = erl_scan:string(Else ++ "."),{ok,Term} = erl_parse:parse_term(Tokens), Term end, io:format("~p~n", [[{i, "${COUCH_SRC}"}] ++ Options]), halt(0).')
COMPILER_OPTIONS_MAKE_CHECK=$(shell $(ERL) -noinput +B -eval 'Options = case os:getenv("ERL_COMPILER_OPTIONS") of false -> []; Else -> {ok,Tokens,_} = erl_scan:string(Else ++ "."),{ok,Term} = erl_parse:parse_term(Tokens), Term end, io:format("~p~n", [[{i, "${COUCH_SRC}"},{d, makecheck}] ++ Options]), halt(0).')

all: builddir compile
all: compile

compile:
@$(ERL) -boot start_clean -pa build -noinput +B -eval 'case make:all([{i, "'${COUCH_SRC}'"}]) of up_to_date -> halt(0); error -> halt(1) end.'
ERL_COMPILER_OPTIONS='$(COMPILER_OPTIONS)' ./rebar compile

compileforcheck:
@$(ERL) -boot start_clean -pa build -noinput +B -eval 'case make:all([{i, "'${COUCH_SRC}'"}, {d, makecheck}]) of up_to_date -> halt(0); error -> halt(1) end.'

builddir:
@mkdir -p build
ERL_COMPILER_OPTIONS='$(COMPILER_OPTIONS_MAKE_CHECK)' ./rebar compile

buildandtest: all test

runtests:
ERL_FLAGS="-pa ${COUCH_SRC} -pa ${COUCH_SRC}/../etap -pa ${COUCH_SRC}/../snappy" prove ./test/*.t

check: clean builddir compileforcheck runtests
rm -rf build
rm -f test/*.beam

#coverage: compile
# mkdir -p coverage
## erl -noshell -pa build -pa ${COUCH_SRC} -pa /home/vmx/src/erlang/coverize/coverize/ebin -s vtree_bulk run_cover -s init stop
# erl -noshell -pa build -pa test/ebin -pa ${COUCH_SRC} -pa /home/vmx/src/erlang/coverize/coverize/ebin -s run_tests run_cover -s init stop
ERL_FLAGS="-pa ebin -pa ${COUCH_SRC} -pa ${COUCH_SRC}/../etap -pa ${COUCH_SRC}/../snappy" prove ./test/*.t

cover: compile
@mkdir -p coverage
erl -noshell -pa build -pa ${COUCH_SRC} -eval 'cover:compile("src/vtree/vtree_bulk", [{i, "'${COUCH_SRC}'"}]),vtree_bulk:test(),cover:analyse_to_file(vtree_bulk, "coverage/vtree_bulk_coverage.html", [html]).' -s init stop;
check: clean compileforcheck runtests
./rebar clean

clean:
rm -rf build
rm -f test/*.beam
./rebar clean
rm -f *.tar.gz

geocouch-$(VERSION).tar.gz:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -73,12 +73,12 @@ Add the test to `<vanilla-couch>/share/www/script/couch_tests.js`
The compiled beam files from GeoCouch need to be in Erlang's path,
which can be set with the `ERL_FLAGS` environment variable:

export ERL_FLAGS="-pa <geocouch>/build"
export ERL_FLAGS="-pa <geocouch>/ebin"

If you run a dev instance with CouchDB's `./utils/run` you can also
define it on startup:

ERL_FLAGS="-pa <geocouch>/build" <vanilla-couch>/utils/run
ERL_FLAGS="-pa <geocouch>/ebin" <vanilla-couch>/utils/run


Using GeoCouch
Expand Down
Binary file added rebar
Binary file not shown.
4 changes: 4 additions & 0 deletions rebar.config
@@ -0,0 +1,4 @@
{erl_opts, [
% Make sure test/gc_test_util.erl gets compiled
{src_dirs, ["test"]}
]}.
8 changes: 8 additions & 0 deletions src/geocouch.app.src
@@ -0,0 +1,8 @@
{application, geocouch, [
{description, "GeoCouch - A spatial index for CouchDB"},
{vsn, "0.2.0"},
{modules, []},
{registered, []},
{applications, [kernel, stdlib]},
{env, []}
]}.

0 comments on commit 8acfec9

Please sign in to comment.