Permalink
Browse files

Reverse hash logic and use rebar.config.script

  • Loading branch information...
1 parent 30ceb0a commit ee3a7f4370e127a367942765aa68d4aa13de6b08 @Vagabond Vagabond committed Jul 18, 2013
Showing with 14 additions and 18 deletions.
  1. +0 −15 Makefile
  2. +11 −0 rebar.config.script
  3. +1 −1 src/chash.erl
  4. +1 −1 src/merkerl.erl
  5. +1 −1 src/riak_core_util.erl
View
@@ -3,23 +3,12 @@ APPS = kernel stdlib sasl erts ssl tools os_mon runtime_tools crypto inets \
COMBO_PLT = $(HOME)/.riak_core_combo_dialyzer_plt
PULSE_TESTS = worker_pool_pulse
-# The code below figures out the OTP release and introduces a macro at
-# build and test time to tell later released to use the new hash
-# functions introduced in R15B02. Older versions still use the old
-# hash functions.
-VSN := $(shell erl -eval 'io:format("~s~n", [erlang:system_info(otp_release)]), init:stop().' | grep 'R' | sed -e 's,R\(..\)B.*,\1,')
-NEW_HASH := $(shell expr $(VSN) \>= 16)
-
.PHONY: deps test
all: deps compile
compile:
-ifeq ($(NEW_HASH),1)
- ./rebar compile -Dnew_hash
-else
./rebar compile
-endif
deps:
./rebar get-deps
@@ -31,11 +20,7 @@ distclean: clean
./rebar delete-deps
test: all
-ifeq ($(NEW_HASH),1)
- ./rebar skip_deps=true -Dnew_hash eunit
-else
./rebar skip_deps=true eunit
-endif
# You should 'clean' before your first run of this target
# so that deps get built with PULSE where needed.
View
@@ -0,0 +1,11 @@
+case erlang:system_info(otp_release) =< "R15B01" of
+ true ->
+ HashDefine = [{d,old_hash}],
+ case lists:keysearch(erl_opts, 1, CONFIG) of
+ {value, {erl_opts, Opts}} ->
+ lists:keyreplace(erl_opts,1,CONFIG,{erl_opts,Opts++HashDefine});
+ false ->
+ CONFIG ++ [{erl_opts, HashDefine}]
+ end;
+ false -> CONFIG
+end.
View
@@ -97,7 +97,7 @@ lookup(IndexAsInt, CHash) ->
{IndexAsInt, X} = proplists:lookup(IndexAsInt, Nodes),
X.
--ifdef(new_hash).
+-ifndef(old_hash).
sha(Bin) ->
crypto:hash(sha, Bin).
-else.
View
@@ -323,7 +323,7 @@ contains_node(Tree,Node) ->
getkids(Tree) ->
[V || {_K,V} <- orddict:to_list(Tree#merk.children)].
--ifdef(new_hash).
+-ifndef(old_hash).
sha(X) ->
crypto:hash(sha, term_to_binary(X)).
-else.
View
@@ -176,7 +176,7 @@ integer_to_list(I0, Base, R0) ->
integer_to_list(I1, Base, R1)
end.
--ifdef(new_hash).
+-ifndef(old_hash).
sha(Bin) ->
crypto:hash(sha, Bin).
-else.

0 comments on commit ee3a7f4

Please sign in to comment.