Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

GC-3: Make COUCH_SRC parsing less fragile

Newer version of rebar support a file called
rebar.config.script to be run before the
actual compiling is done. This way we can
inject the value of COUCH_SRC and the MAKECHECK
environment variable in a less fragile way.

Change-Id: Ifb0082ac1b1272f590897ab6dacdcbf4a87ca6fd
Reviewed-on: http://review.couchbase.org/23397
Reviewed-by: Bin Cui <bin.cui@gmail.com>
Tested-by: Bin Cui <bin.cui@gmail.com>
  • Loading branch information...
commit 8997159c44282cfcd89ea9984dd8c0944a35b2b4 1 parent 59ee7e5
@vmx vmx authored bcui6611 committed
Showing with 23 additions and 5 deletions.
  1. +2 −5 Makefile
  2. BIN  rebar
  3. +21 −0 rebar.config.script
View
7 Makefile
@@ -1,16 +1,13 @@
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}"}, {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}"},{i, "${COUCH_SRC}/.."},{d, makecheck}] ++ Options]), halt(0).')
all: compile
compile:
- ERL_COMPILER_OPTIONS='$(COMPILER_OPTIONS)' ./rebar compile
+ ./rebar compile
compileforcheck:
- ERL_COMPILER_OPTIONS='$(COMPILER_OPTIONS_MAKE_CHECK)' ./rebar compile
+ MAKECHECK=1 ./rebar compile
buildandtest: all test
View
BIN  rebar
Binary file not shown
View
21 rebar.config.script
@@ -0,0 +1,21 @@
+% Add the COUCH_SRC directory to include path
+IncludeDir = case os:getenv("COUCH_SRC") of
+ false -> []; % env var not defined
+ [] -> []; % env var set to empty string
+ Dir -> [{i, Dir}, {i, Dir ++ "/../"}]
+end,
+
+% Add "makecheck" setting for testing
+MakeCheck = case os:getenv("MAKECHECK") of
+ false -> []; % env var not defined
+ [] -> []; % env var set to empty string
+ _ -> [{d, makecheck}]
+end,
+
+% Add all variables to erl_opts
+case lists:keytake(erl_opts, 1, CONFIG) of
+ false ->
+ CONFIG ++ [{erl_opts, IncludeDir ++ MakeCheck}];
+ {value, {erl_opts, ErlOpts}, Config2} ->
+ Config2 ++ [{erl_opts, ErlOpts ++ IncludeDir ++ MakeCheck}]
+end.
Please sign in to comment.
Something went wrong with that request. Please try again.