diff --git a/.eqc-info b/.eqc-info deleted file mode 100644 index ba0e2501..00000000 Binary files a/.eqc-info and /dev/null differ diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index 2f3ac686..ccc4593c 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -19,8 +19,6 @@ jobs: steps: - uses: actions/checkout@v2 - name: Compile - run: ./rebar3 compile - - name: Run xref and dialyzer - run: ./rebar3 do xref, dialyzer - - name: Run eunit - run: ./rebar3 do eunit + run: apt-get update && apt-get install -y cmake && make + - name: Run tests + run: apt-get update && apt-get install -y cmake libc6-dev && make check diff --git a/.gitignore b/.gitignore index b2a8c592..6537695f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ c_src/system _build .DS_Store rebar.lock +snappy-*.tar.gz diff --git a/Makefile b/Makefile index 60edb911..b0d00683 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,12 @@ -.PHONY: compile rel cover test dialyzer +.PHONY: compile rel cover test dialyzer get-deps REBAR=./rebar3 -compile: +all: compile + +get-deps: + $(REBAR) get-deps + +compile: get-deps $(REBAR) compile clean: @@ -11,6 +16,7 @@ cover: test $(REBAR) cover test: compile + $(MAKE) -C c_src test $(REBAR) as test do eunit dialyzer: diff --git a/c_src/Makefile b/c_src/Makefile new file mode 100644 index 00000000..8de7e330 --- /dev/null +++ b/c_src/Makefile @@ -0,0 +1,50 @@ +LEVELDB_VSN ?= "2.0.38" +SNAPPY_VSN ?= "1.1.9" +BASEDIR = $(shell pwd) + +LDFLAGS := $(LDFLAGS) -L$(BASEDIR)/system/lib +LD_LIBRARY_PATH := $(BASEDIR)/system/lib:$(LD_LIBRARY_PATH) +CFLAGS := $(CFLAGS) -I $(BASEDIR)/system/include -I. -I $(BASEDIR)/leveldb/include -fPIC +CXXFLAGS := $(CXXFLAGS) -I $(BASEDIR)/system/include -I. -I $(BASEDIR)/leveldb/include -fPIC + +get-deps: + if [ ! -r snappy-$(SNAPPY_VSN).tar.gz ]; then \ + wget -O snappy-$(SNAPPY_VSN).tar.gz https://github.com/google/snappy/archive/refs/tags/$(SNAPPY_VSN).tar.gz; \ + fi + if [ ! -d leveldb ]; then \ + git clone https://github.com/basho/leveldb && \ + (cd leveldb && git checkout $(LEVELDB_VSN)) && \ + (cd leveldb && git submodule update --init); \ + fi + +compile: get-deps snappy ldb + cp leveldb/perf_dump leveldb/sst_rewrite leveldb/sst_scan leveldb/leveldb_repair ../priv + +ldb: + $(MAKE) LDFLAGS="$(LDFLAGS) -lsnappy" LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)" -C leveldb all + $(MAKE) LDFLAGS="$(LDFLAGS) -lsnappy" LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)" -C leveldb tools + +snappy: system/lib/libsnappy.a + +system/lib/libsnappy.a: + tar -xzf snappy-$(SNAPPY_VSN).tar.gz && \ + (cd snappy-$(SNAPPY_VSN) && \ + git submodule update --init && \ + if [ -r autogen.sh ]; then \ + ./autogen.sh && ./configure --prefix=$(BASEDIR)/system && make && make install; \ + else \ + mkdir build && cd build && \ + mkdir -p $(BASEDIR)/system && \ + cmake -D SNAPPY_BUILD_TESTS=0 -D SNAPPY_BUILD_BENCHMARKS=0 \ + -D CMAKE_INSTALL_PREFIX=$(BASEDIR)/system \ + ..; \ + fi && \ + make && make install) + mv system/lib64 system/lib || true + +clean: + $(MAKE) -C leveldb clean + rm -rf system snappy-$(SNAPPY_VSN)/build + +test: compile + $(MAKE) CXXFLAGS="$(CXXFLAGS) -Wno-narrowing" LDFLAGS="$(LDFLAGS) -lsnappy -lpthread" LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)" -C leveldb test diff --git a/c_src/build_deps.sh b/c_src/build_deps.sh deleted file mode 100755 index cfb1120c..00000000 --- a/c_src/build_deps.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh - -# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/ksh is. -if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then - POSIX_SHELL="true" - export POSIX_SHELL - exec /usr/bin/ksh $0 $@ -fi -unset POSIX_SHELL # clear it so if we invoke other scripts, they run as ksh as well - -LEVELDB_VSN="2.0.36" - -SNAPPY_VSN="1.0.4" - -set -e - -if [ `basename $PWD` != "c_src" ]; then - # originally "pushd c_src" of bash - # but no need to use directory stack push here - cd c_src -fi - -BASEDIR="$PWD" - -# detecting gmake and if exists use it -# if not use make -# (code from github.com/tuncer/re2/c_src/build_deps.sh -which gmake 1>/dev/null 2>/dev/null && MAKE=gmake -MAKE=${MAKE:-make} - -# Changed "make" to $MAKE - -case "$1" in - rm-deps) - rm -rf leveldb system snappy-$SNAPPY_VSN - ;; - - clean) - rm -rf system snappy-$SNAPPY_VSN - if [ -d leveldb ]; then - (cd leveldb && $MAKE clean) - fi - rm -f ../priv/leveldb_repair ../priv/sst_scan ../priv/sst_rewrite ../priv/perf_dump - ;; - - test) - export CFLAGS="$CFLAGS -I $BASEDIR/system/include" - export CXXFLAGS="$CXXFLAGS -I $BASEDIR/system/include" - export LDFLAGS="$LDFLAGS -L$BASEDIR/system/lib" - export LD_LIBRARY_PATH="$BASEDIR/system/lib:$LD_LIBRARY_PATH" - export LEVELDB_VSN="$LEVELDB_VSN" - - (cd leveldb && $MAKE check) - - ;; - - get-deps) - if [ ! -d leveldb ]; then - git clone https://github.com/basho/leveldb - (cd leveldb && git checkout $LEVELDB_VSN) - (cd leveldb && git submodule update --init) - fi - ;; - - *) - TARGET_OS=`uname -s` - - export CFLAGS="$CFLAGS -I $BASEDIR/system/include" - export CXXFLAGS="$CXXFLAGS -I $BASEDIR/system/include" - # On GCC, we pick libc's memcmp over GCC's memcmp via -fno-builtin-memcmp - if [ "$TARGET_OS" = "Darwin" ]; then - export MACOSX_DEPLOYMENT_TARGET=10.8 - export CFLAGS="$CFLAGS -stdlib=libc++" - export CXXFLAGS="$CXXFLAGS -stdlib=libc++" - fi - - if [ ! -d snappy-$SNAPPY_VSN ]; then - tar -xzf snappy-$SNAPPY_VSN.tar.gz - (cd snappy-$SNAPPY_VSN && ./configure --disable-shared --prefix=$BASEDIR/system --libdir=$BASEDIR/system/lib --with-pic) - fi - - if [ ! -f system/lib/libsnappy.a ]; then - (cd snappy-$SNAPPY_VSN && $MAKE && $MAKE install) - fi - - - export LDFLAGS="$LDFLAGS -L$BASEDIR/system/lib" - export LD_LIBRARY_PATH="$BASEDIR/system/lib:$LD_LIBRARY_PATH" - export LEVELDB_VSN="$LEVELDB_VSN" - - if [ ! -d leveldb ]; then - git clone https://github.com/basho/leveldb - (cd leveldb && git checkout $LEVELDB_VSN) - (cd leveldb && git submodule update --init) - fi - - # hack issue where high level make is running -j 4 - # and causes build errors in leveldb - export MAKEFLAGS= - - (cd leveldb && $MAKE -j 3 all) - (cd leveldb && $MAKE -j 3 tools) - (cp leveldb/perf_dump leveldb/sst_rewrite leveldb/sst_scan leveldb/leveldb_repair ../priv) - - ;; -esac diff --git a/c_src/snappy-1.0.4.tar.gz b/c_src/snappy-1.0.4.tar.gz deleted file mode 100644 index a34852f2..00000000 Binary files a/c_src/snappy-1.0.4.tar.gz and /dev/null differ diff --git a/rebar.config b/rebar.config index 41d712bc..10b4612e 100644 --- a/rebar.config +++ b/rebar.config @@ -30,7 +30,7 @@ {"DRV_LDFLAGS", "$DRV_LDFLAGS c_src/leveldb/libleveldb.a c_src/system/lib/libsnappy.a -lstdc++"} ]}. -{pre_hooks, [{'get-deps', "c_src/build_deps.sh get-deps"}, - {compile, "c_src/build_deps.sh"}]}. +{pre_hooks, [{'get-deps', "make -C c_src get-deps"}, + {compile, "make -C c_src compile"}]}. -{post_hooks, [{clean, "c_src/build_deps.sh clean"}]}. +{post_hooks, [{clean, "make -C c_src clean"}]}. diff --git a/tools.mk b/tools.mk deleted file mode 100644 index 07dfdd7f..00000000 --- a/tools.mk +++ /dev/null @@ -1,69 +0,0 @@ -REBAR ?= ./rebar - -compile-no-deps: - ${REBAR} compile skip_deps=true - -test: compile - ${REBAR} eunit skip_deps=true - -docs: - ${REBAR} doc skip_deps=true - -xref: compile - ${REBAR} xref skip_deps=true - -PLT ?= $(HOME)/.combo_dialyzer_plt -LOCAL_PLT = .local_dialyzer_plt -DIALYZER_FLAGS ?= -Wunmatched_returns - -${PLT}: compile - @if [ -f $(PLT) ]; then \ - dialyzer --check_plt --plt $(PLT) --apps $(DIALYZER_APPS) && \ - dialyzer --add_to_plt --plt $(PLT) --output_plt $(PLT) --apps $(DIALYZER_APPS) ; test $$? -ne 1; \ - else \ - dialyzer --build_plt --output_plt $(PLT) --apps $(DIALYZER_APPS); test $$? -ne 1; \ - fi - -${LOCAL_PLT}: compile - @if [ -d deps ]; then \ - if [ -f $(LOCAL_PLT) ]; then \ - dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin && \ - dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1; \ - else \ - dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1; \ - fi \ - fi - -dialyzer-run: - @echo "==> $(shell basename $(shell pwd)) (dialyzer)" - @if [ -f $(LOCAL_PLT) ]; then \ - PLTS="$(PLT) $(LOCAL_PLT)"; \ - else \ - PLTS=$(PLT); \ - fi; \ - if [ -f dialyzer.ignore-warnings ]; then \ - if [ $$(grep -cvE '[^[:space:]]' dialyzer.ignore-warnings) -ne 0 ]; then \ - echo "ERROR: dialyzer.ignore-warnings contains a blank/empty line, this will match all messages!"; \ - exit 1; \ - fi; \ - dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -c ebin > dialyzer_warnings ; \ - egrep -v "^\s*(done|Checking|Proceeding|Compiling)" dialyzer_warnings | grep -F -f dialyzer.ignore-warnings -v > dialyzer_unhandled_warnings ; \ - cat dialyzer_unhandled_warnings ; \ - [ $$(cat dialyzer_unhandled_warnings | wc -l) -eq 0 ] ; \ - else \ - dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -c ebin; \ - fi - -dialyzer-quick: compile-no-deps dialyzer-run - -dialyzer: ${PLT} ${LOCAL_PLT} dialyzer-run - -cleanplt: - @echo - @echo "Are you sure? It takes several minutes to re-build." - @echo Deleting $(PLT) and $(LOCAL_PLT) in 5 seconds. - @echo - sleep 5 - rm $(PLT) - rm $(LOCAL_PLT) -