Skip to content

Commit 54c7720

Browse files
committed
Upgrade to rebar3
- Add Travis CI configuration - Add license file
1 parent 3df8a32 commit 54c7720

File tree

12 files changed

+616
-22
lines changed

12 files changed

+616
-22
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
.rebar/
22
c_src/*.d
3+
/_build
4+
*.o
5+
*.so

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
sudo: false
2+
language: erlang
3+
script:
4+
- wget -c https://github.com/erlang/rebar3/releases/download/3.6.2/rebar3
5+
- chmod +x rebar3
6+
- REBAR3=./rebar3 make ci
7+
otp_release:
8+
- 21.1
9+
- 20.3
10+
- 20.2
11+
- 20.1
12+
- 20.0
13+
- 19.3
14+
- 19.2
15+
- 19.1
16+
- 18.3

LICENSE

Lines changed: 373 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.PHONY: all clean clean-all compile xref ci test
2+
3+
REBAR3 ?= rebar3
4+
5+
all: compile xref
6+
7+
ci: compile xref test
8+
9+
compile:
10+
$(REBAR3) compile
11+
12+
clean:
13+
$(REBAR3) clean
14+
15+
clean-all: clean
16+
rm -rf _build
17+
18+
xref:
19+
$(REBAR3) xref
20+
21+
test:
22+
$(REBAR3) ct

c_src/Makefile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Based on c_src.mk from erlang.mk by Loic Hoguin <[email protected]>
2+
3+
CURDIR := $(shell pwd)
4+
BASEDIR := $(abspath $(CURDIR)/..)
5+
6+
PROJECT ?= $(notdir $(BASEDIR))
7+
PROJECT := $(strip $(PROJECT))
8+
9+
ERTS_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s/erts-~s/include/\", [code:root_dir(), erlang:system_info(version)]).")
10+
ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, include)]).")
11+
ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, lib)]).")
12+
13+
C_SRC_DIR = $(CURDIR)
14+
C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so
15+
16+
# System type and C compiler/flags.
17+
18+
UNAME_SYS := $(shell uname -s)
19+
ifeq ($(UNAME_SYS), Darwin)
20+
CC ?= cc
21+
CFLAGS ?= -O3 -std=c99 -arch x86_64 -finline-functions -Wall -Wmissing-prototypes
22+
CXXFLAGS ?= -O3 -arch x86_64 -finline-functions -Wall
23+
LDFLAGS ?= -arch x86_64 -flat_namespace -undefined suppress
24+
else ifeq ($(UNAME_SYS), FreeBSD)
25+
CC ?= cc
26+
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
27+
CXXFLAGS ?= -O3 -finline-functions -Wall
28+
else ifeq ($(UNAME_SYS), Linux)
29+
CC ?= gcc
30+
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
31+
CXXFLAGS ?= -O3 -finline-functions -Wall
32+
endif
33+
34+
CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
35+
CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
36+
37+
LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei
38+
LDFLAGS += -shared
39+
40+
# Verbosity.
41+
42+
c_verbose_0 = @echo " C " $(?F);
43+
c_verbose = $(c_verbose_$(V))
44+
45+
cpp_verbose_0 = @echo " CPP " $(?F);
46+
cpp_verbose = $(cpp_verbose_$(V))
47+
48+
link_verbose_0 = @echo " LD " $(@F);
49+
link_verbose = $(link_verbose_$(V))
50+
51+
SOURCES := $(shell find $(C_SRC_DIR) -type f \( -name "*.c" -o -name "*.C" -o -name "*.cc" -o -name "*.cpp" \))
52+
OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
53+
54+
COMPILE_C = $(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c
55+
COMPILE_CPP = $(cpp_verbose) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
56+
57+
$(C_SRC_OUTPUT): $(OBJECTS)
58+
@mkdir -p $(BASEDIR)/priv/
59+
$(link_verbose) $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT)
60+
61+
%.o: %.c
62+
$(COMPILE_C) $(OUTPUT_OPTION) $<
63+
64+
%.o: %.cc
65+
$(COMPILE_CPP) $(OUTPUT_OPTION) $<
66+
67+
%.o: %.C
68+
$(COMPILE_CPP) $(OUTPUT_OPTION) $<
69+
70+
%.o: %.cpp
71+
$(COMPILE_CPP) $(OUTPUT_OPTION) $<
72+
73+
clean:
74+
@rm -f $(C_SRC_OUTPUT) $(OBJECTS)

ebin/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

rebar.config

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
11
%% -*- erlang -*-
2-
%% Config file for afunix-application
3-
{erl_opts, [debug_info]}.
4-
%% change -DDLOG_DEFAULT=DLOG_DEBUG
5-
{port_env, [{"CFLAGS", "$CFLAGS -Wall -DDLOG_DEFAULT=DLOG_NONE"}]}.
6-
7-
{ct_extra_params, "-suite test/afunix_api_SUITE -erl_args -name ct"}.
8-
%% You can also run ct from the test dir using:
9-
%% ct_run -suite afunix_api_SUITE -erl_args -sname ct
10-
%% ct_run -suite afunix_echo_SUITE -erl_args -sname ct
2+
{erl_opts, [debug_info, fail_on_warning, nowarn_export_all]}.
3+
4+
{pre_hooks,
5+
[
6+
{"(linux|darwin)", compile, "make -C c_src PROJECT=afunix_drv OUTPUT_OPTION=\"-DDLOG_DEFAULT=DLOG_NONE\""}
7+
]}.
8+
9+
{post_hooks,
10+
[
11+
{"(linux|darwin)", clean, "make -C c_src clean"}
12+
]}.
13+
14+
{profiles,
15+
[
16+
{test,
17+
[
18+
{pre_hooks,
19+
[
20+
{"(linux|darwin)", compile, "make -C test/afunix_api_SUITE_data PROJECT=afunix_api_SUITE"}
21+
]},
22+
{post_hooks,
23+
[
24+
{"(linux|darwin)", clean, "make -C test/afunix_api_SUITE_data clean"}
25+
]}
26+
]}
27+
]}.
28+
29+
{xref_checks,
30+
[
31+
undefined_function_calls, undefined_functions, locals_not_used,
32+
deprecated_function_calls, deprecated_functions
33+
]}.
34+
35+
{dist_node,
36+
[
37+
{setcookie, 'afunixnode'},
38+
{sname, 'afunix'}
39+
]}.

rebar.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[].

src/afunix.app.src

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
%% -*- erlang -*-
12
{application, afunix,
23
[{description, "AF_UNIX socket driver"},
3-
{vsn, git},
4-
{modules, [afunix]},
4+
{vsn, "1.0"},
55
{registered, []},
66
{env, []},
7-
{applications,[kernel,stdlib]}
8-
]}.
7+
{applications,[kernel,stdlib]},
8+
{included_applications, []},
9+
{maintainers, ["Tony Rogvall"]},
10+
{licenses, ["MPL-2.0"]},
11+
{links, [{"Github", "https://github.com/tonyrog/afunix"}]}
12+
]}.

test/afunix_api_SUITE.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ all() ->
4646
t_shutdown_async, t_fdopen, t_fdconnect].
4747

4848
groups() ->
49-
[{t_accept, [], [t_accept_timeout]},
50-
{t_connect, [], [t_connect_bad]},
51-
{t_recv, [], [t_recv_timeout, t_recv_eof]}].
49+
[{t_accept, [shuffle], [t_accept_timeout]},
50+
{t_connect, [shuffle], [t_connect_bad]},
51+
{t_recv, [shuffle], [t_recv_timeout, t_recv_eof]}].
5252

5353
init_per_suite(Config) ->
5454
Config.
@@ -205,7 +205,7 @@ t_fdconnect(Config) when is_list(Config) ->
205205
["in ", [], <<"a small town">>, [" in Germany,", <<>>]]],
206206
Question1 = iolist_to_binary(Question2),
207207
Answer = "there was a shoemaker, Schumacher was his name.",
208-
Path = ?config(data_dir, Config),
208+
Path = "../../../../test/priv",
209209
Lib = "afunix_api_SUITE",
210210
ok = erlang:load_nif(filename:join(Path,Lib), []),
211211
SocketName = socket_name(Config,"socket_t_fdopen"),

0 commit comments

Comments
 (0)