Skip to content

Commit ed444c0

Browse files
committed
Make Erlang 16 compatible.
Make Erlang 16, and specifically Lasp, compatible through the use of an older rebar, older lager, namespace_types.
1 parent 52e6bf5 commit ed444c0

File tree

7 files changed

+97
-65
lines changed

7 files changed

+97
-65
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ _tdeps
1919
logs
2020
erln8.config
2121
.local_dialyzer_plt
22+
deps/*

Makefile

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
1+
REBAR = $(shell pwd)/rebar
12
.PHONY: deps compile rel
23

34
DIALYZER_APPS = kernel stdlib erts sasl eunit syntax_tools compiler crypto
4-
REBAR="./rebar3"
55
DEP_DIR="_build/lib"
66

77
all: compile
88

9-
include tools.mk
10-
119
test: common_test
1210

11+
deps:
12+
$(REBAR) get-deps
13+
1314
common_test:
14-
./rebar3 ct
15+
$(REBAR) ct
1516

1617
compile: deps
17-
./rebar3 compile
18+
$(REBAR) compile
1819

1920
rel:
20-
./rebar3 release
21+
$(REBAR) release
2122

2223
stage:
23-
./rebar3 release -d
24+
$(REBAR) release -d
25+
26+
DIALYZER_APPS = kernel stdlib sasl erts ssl tools os_mon runtime_tools crypto inets \
27+
xmerl webtool eunit syntax_tools compiler mnesia public_key snmp
28+
29+
include tools.mk
2430

31+
typer:
32+
typer --annotate -I ../ --plt $(PLT) -r src

rebar

189 KB
Binary file not shown.

rebar.config

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
{erl_opts, [warnings_as_errors, debug_info, {parse_transform, lager_transform}]}.
21
{deps, [
3-
{lager, {git, "git://github.com/basho/lager.git", {tag, "2.1.1"}}},
4-
{riak_dt, {git, "git://github.com/basho/riak_dt.git", {tag, "2.1.0"}}},
5-
{eleveldb, {git, "git://github.com/helium/eleveldb.git", {branch, "adt-helium"}}}
2+
{lager, ".*", {git, "git://github.com/basho/lager.git", {tag, "2.0.3"}}},
3+
{riak_dt, ".*", {git, "git://github.com/basho/riak_dt.git", {tag, "develop"}}},
4+
{eleveldb, ".*", {git, "git://github.com/basho/eleveldb.git", {tag, "2.0.2"}}}
65
]}.
76

87
{dialyzer_base_plt_apps, [kernel, stdlib, erts, sasl, eunit, syntax_tools, compiler, crypto]}.
9-
108
{xref_checks, [undefined_function_calls]}.
11-
12-
{cover_enabled, true}.
9+
{erl_opts, [debug_info,
10+
warnings_as_errors,
11+
{platform_define, "^[0-9]+", namespaced_types},
12+
{parse_transform, lager_transform}]}.
13+
{cover_enabled, false}.
14+
{eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}.
15+
{edoc_opts, [{preprocess, true}]}.

src/hashtree.erl

+13-5
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@
125125
width/1,
126126
mem_levels/1]).
127127

128+
-ifdef(namespaced_types).
129+
-type hashtree_dict() :: dict:dict().
130+
-type hashtree_array() :: array:array().
131+
-else.
132+
-type hashtree_dict() :: dict().
133+
-type hashtree_array() :: array().
134+
-endif.
135+
128136
-ifdef(TEST).
129137
-export([local_compare/2]).
130138
-export([run_local/0,
@@ -174,13 +182,13 @@
174182
segments :: pos_integer(),
175183
width :: pos_integer(),
176184
mem_levels :: integer(),
177-
tree :: dict:dict(),
185+
tree :: hashtree_dict(),
178186
ref :: term(),
179187
path :: string(),
180188
itr :: term(),
181189
write_buffer :: [{put, binary(), binary()} | {delete, binary()}],
182190
write_buffer_count :: integer(),
183-
dirty_segments :: array:array()
191+
dirty_segments :: hashtree_array()
184192
}).
185193

186194
-record(itr_state, {itr :: term(),
@@ -872,17 +880,17 @@ orddict_delta(D1, [], Acc) ->
872880
%%%===================================================================
873881
-define(W, 27).
874882

875-
-spec bitarray_new(integer()) -> array:array().
883+
-spec bitarray_new(integer()) -> hashtree_array().
876884
bitarray_new(N) -> array:new((N-1) div ?W + 1, {default, 0}).
877885

878-
-spec bitarray_set(integer(), array:array()) -> array:array().
886+
-spec bitarray_set(integer(), hashtree_array()) -> hashtree_array().
879887
bitarray_set(I, A) ->
880888
AI = I div ?W,
881889
V = array:get(AI, A),
882890
V1 = V bor (1 bsl (I rem ?W)),
883891
array:set(AI, V1, A).
884892

885-
-spec bitarray_to_list(array:array()) -> [integer()].
893+
-spec bitarray_to_list(hashtree_array()) -> [integer()].
886894
bitarray_to_list(A) ->
887895
lists:reverse(
888896
array:sparse_foldl(fun(I, V, Acc) ->

src/hashtree_tree.erl

+7-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@
119119

120120
-export_type([tree/0, tree_node/0, handler_fun/1, remote_fun/0]).
121121

122+
-ifdef(namespaced_types).
123+
-type hashtree_gb_set() :: gb_sets:set().
124+
-else.
125+
-type hashtree_gb_set() :: gb_set().
126+
-endif.
127+
122128
-record(hashtree_tree, {
123129
%% the identifier for this tree. used as part of the ids
124130
%% passed to hashtree.erl and in keys used to store nodes in
@@ -138,7 +144,7 @@
138144
snapshot :: ets:tab(),
139145

140146
%% set of dirty leaves
141-
dirty :: gb_sets:set()
147+
dirty :: hashtree_gb_set()
142148
}).
143149

144150
-define(ROOT, '$ht_root').

tools.mk

+51-45
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,62 @@
1-
# -------------------------------------------------------------------
2-
#
3-
# Copyright (c) 2014 Basho Technologies, Inc.
4-
#
5-
# This file is provided to you under the Apache License,
6-
# Version 2.0 (the "License"); you may not use this file
7-
# except in compliance with the License. You may obtain
8-
# a copy of the License at
9-
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
11-
#
12-
# Unless required by applicable law or agreed to in writing,
13-
# software distributed under the License is distributed on an
14-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
# KIND, either express or implied. See the License for the
16-
# specific language governing permissions and limitations
17-
# under the License.
18-
#
19-
# -------------------------------------------------------------------
20-
21-
# -------------------------------------------------------------------
22-
# NOTE: This file is is from https://github.com/basho/tools.mk.
23-
# It should not be edited in a project. It should simply be updated
24-
# wholesale when a new version of tools.mk is released.
25-
# -------------------------------------------------------------------
26-
271
REBAR ?= ./rebar
28-
REVISION ?= $(shell git rev-parse --short HEAD)
29-
PROJECT ?= $(shell basename `find src -name "*.app.src"` .app.src)
30-
DEP_DIR ?= "deps"
31-
EBIN_DIR ?= "ebin"
32-
33-
.PHONY: compile-no-deps test docs xref dialyzer-run dialyzer-quick dialyzer \
34-
cleanplt upload-docs
35-
36-
compile-no-deps:
37-
${REBAR} compile skip_deps=true
382

393
test: compile
404
${REBAR} eunit skip_deps=true
415

42-
upload-docs: docs
43-
@if [ -z "${BUCKET}" -o -z "${PROJECT}" -o -z "${REVISION}" ]; then \
44-
echo "Set BUCKET, PROJECT, and REVISION env vars to upload docs"; \
45-
exit 1; fi
46-
@cd doc; s3cmd put -P * "s3://${BUCKET}/${PROJECT}/${REVISION}/" > /dev/null
47-
@echo "Docs built at: http://${BUCKET}.s3-website-us-east-1.amazonaws.com/${PROJECT}/${REVISION}"
48-
496
docs:
507
${REBAR} doc skip_deps=true
518

529
xref: compile
5310
${REBAR} xref skip_deps=true
5411

55-
dialyzer: compile
56-
${REBAR} dialyzer
12+
PLT ?= $(HOME)/.combo_dialyzer_plt
13+
LOCAL_PLT = .local_dialyzer_plt
14+
DIALYZER_FLAGS ?= -Wunmatched_returns -Werror_handling -Wrace_conditions -Wunderspecs
15+
16+
${PLT}: compile
17+
@if [ -f $(PLT) ]; then \
18+
dialyzer --check_plt --plt $(PLT) --apps $(DIALYZER_APPS) && \
19+
dialyzer --add_to_plt --plt $(PLT) --output_plt $(PLT) --apps $(DIALYZER_APPS) ; test $$? -ne 1; \
20+
else \
21+
dialyzer --build_plt --output_plt $(PLT) --apps $(DIALYZER_APPS); test $$? -ne 1; \
22+
fi
23+
24+
${LOCAL_PLT}: compile
25+
@if [ -d deps ]; then \
26+
if [ -f $(LOCAL_PLT) ]; then \
27+
dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin && \
28+
dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1; \
29+
else \
30+
dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1; \
31+
fi \
32+
fi
33+
34+
dialyzer: ${PLT} ${LOCAL_PLT}
35+
@echo "==> $(shell basename $(shell pwd)) (dialyzer)"
36+
@if [ -f $(LOCAL_PLT) ]; then \
37+
PLTS="$(PLT) $(LOCAL_PLT)"; \
38+
else \
39+
PLTS=$(PLT); \
40+
fi; \
41+
if [ -f dialyzer.ignore-warnings ]; then \
42+
if [ $$(grep -cvE '[^[:space:]]' dialyzer.ignore-warnings) -ne 0 ]; then \
43+
echo "ERROR: dialyzer.ignore-warnings contains a blank/empty line, this will match all messages!"; \
44+
exit 1; \
45+
fi; \
46+
dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -c ebin > dialyzer_warnings ; \
47+
egrep -v "^[[:space:]]*(done|Checking|Proceeding|Compiling)" dialyzer_warnings | grep -F -f dialyzer.ignore-warnings -v > dialyzer_unhandled_warnings ; \
48+
cat dialyzer_unhandled_warnings ; \
49+
[ $$(cat dialyzer_unhandled_warnings | wc -l) -eq 0 ] ; \
50+
else \
51+
dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -c ebin; \
52+
fi
53+
54+
cleanplt:
55+
@echo
56+
@echo "Are you sure? It takes several minutes to re-build."
57+
@echo Deleting $(PLT) and $(LOCAL_PLT) in 5 seconds.
58+
@echo
59+
sleep 5
60+
rm $(PLT)
61+
rm $(LOCAL_PLT)
62+

0 commit comments

Comments
 (0)