Move to rebar3

This commit is contained in:
Paul Oliver 2016-08-06 17:40:55 +12:00
parent 74575bcc72
commit a151d3d2ed
No known key found for this signature in database
GPG Key ID: 9250069E8AF6BF4F
6 changed files with 84 additions and 11 deletions

2
.gitignore vendored
View File

@ -12,3 +12,5 @@ priv
edoc-info edoc-info
stylesheet.css stylesheet.css
_build
/TEST-file_"sha3.app".xml

74
c_src/Makefile Normal file
View File

@ -0,0 +1,74 @@
# Based on c_src.mk from erlang.mk by Loic Hoguin <essen@ninenines.eu>
CURDIR := $(shell pwd)
BASEDIR := $(abspath $(CURDIR)/..)
PROJECT ?= $(notdir $(BASEDIR))
PROJECT := $(strip $(PROJECT))
ERTS_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s/erts-~s/include/\", [code:root_dir(), erlang:system_info(version)]).")
ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, include)]).")
ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~s\", [code:lib_dir(erl_interface, lib)]).")
C_SRC_DIR = $(CURDIR)
C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so
# System type and C compiler/flags.
UNAME_SYS := $(shell uname -s)
ifeq ($(UNAME_SYS), Darwin)
CC ?= cc
CFLAGS ?= -O3 -std=c99 -arch x86_64 -finline-functions -Wall -Wmissing-prototypes
CXXFLAGS ?= -O3 -arch x86_64 -finline-functions -Wall
LDFLAGS ?= -arch x86_64 -flat_namespace -undefined suppress
else ifeq ($(UNAME_SYS), FreeBSD)
CC ?= cc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
CXXFLAGS ?= -O3 -finline-functions -Wall
else ifeq ($(UNAME_SYS), Linux)
CC ?= gcc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
CXXFLAGS ?= -O3 -finline-functions -Wall
endif
CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei
LDFLAGS += -shared
# Verbosity.
c_verbose_0 = @echo " C " $(?F);
c_verbose = $(c_verbose_$(V))
cpp_verbose_0 = @echo " CPP " $(?F);
cpp_verbose = $(cpp_verbose_$(V))
link_verbose_0 = @echo " LD " $(@F);
link_verbose = $(link_verbose_$(V))
SOURCES := $(shell find $(C_SRC_DIR) -type f \( -name "*.c" -o -name "*.C" -o -name "*.cc" -o -name "*.cpp" \))
OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
COMPILE_C = $(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c
COMPILE_CPP = $(cpp_verbose) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
$(C_SRC_OUTPUT): $(OBJECTS)
@mkdir -p $(BASEDIR)/priv/
$(link_verbose) $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT)
%.o: %.c
$(COMPILE_C) $(OUTPUT_OPTION) $<
%.o: %.cc
$(COMPILE_CPP) $(OUTPUT_OPTION) $<
%.o: %.C
$(COMPILE_CPP) $(OUTPUT_OPTION) $<
%.o: %.cpp
$(COMPILE_CPP) $(OUTPUT_OPTION) $<
clean:
@rm -f $(C_SRC_OUTPUT) $(OBJECTS)

BIN
rebar vendored

Binary file not shown.

View File

@ -6,16 +6,12 @@
{clean_files, [".eunit", {clean_files, [".eunit",
"ebin/*.beam"]}. "ebin/*.beam"]}.
{port_env, [{"CFLAGS", "$CFLAGS -O2 -finline-functions -fomit-frame-pointer -fno-strict-aliasing -Wmissing-prototypes -Wall -std=c99"}]}. {pre_hooks,
[{"(linux|darwin|solaris)", compile, "make -C c_src"},
{port_specs, [ {"(freebsd)", compile, "gmake -C c_src"}]}.
% 64 bit only {post_hooks,
{"priv/sha3_nif.so", ["c_src/sha3_nif.c", [{"(linux|darwin|solaris)", clean, "make -C c_src clean"},
"c_src/KeccakNISTInterface.c", {"(freebsd)", clean, "gmake -C c_src clean"}]}.
"c_src/KeccakSponge.c",
"c_src/KeccakF-1600-opt64.c",
"c_src/displayIntermediateValues.c"]}
]}.
{eunit_opts, [{report,{eunit_surefire,[{dir,"."}]}}]}. {eunit_opts, [{report,{eunit_surefire,[{dir,"."}]}}]}.

1
rebar.lock Normal file
View File

@ -0,0 +1 @@
[].

View File

@ -24,7 +24,7 @@ init() ->
Path -> Path ->
Path Path
end, end,
erlang:load_nif(filename:join(PrivDir, sha3_nif), 0). erlang:load_nif(filename:join(PrivDir, "erlang-sha3"), 0).
%% @doc Returns a new context for hash operation. %% @doc Returns a new context for hash operation.
%% Bit length of digest (`BitLen') must be one of 224, 256, 384 and 512. %% Bit length of digest (`BitLen') must be one of 224, 256, 384 and 512.