Skip to content

Commit

Permalink
Merge pull request #267 from basho/mas-i384-backport
Browse files Browse the repository at this point in the history
Backport changes to upgrade snappy
  • Loading branch information
martinsumner authored Dec 7, 2022
2 parents b482410 + 6ef9202 commit edfd392
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 185 deletions.
Binary file removed .eqc-info
Binary file not shown.
8 changes: 3 additions & 5 deletions .github/workflows/erlang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ c_src/system
_build
.DS_Store
rebar.lock
snappy-*.tar.gz
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -11,6 +16,7 @@ cover: test
$(REBAR) cover

test: compile
$(MAKE) -C c_src test
$(REBAR) as test do eunit

dialyzer:
Expand Down
50 changes: 50 additions & 0 deletions c_src/Makefile
Original file line number Diff line number Diff line change
@@ -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
106 changes: 0 additions & 106 deletions c_src/build_deps.sh

This file was deleted.

Binary file removed c_src/snappy-1.0.4.tar.gz
Binary file not shown.
6 changes: 3 additions & 3 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]}.
69 changes: 0 additions & 69 deletions tools.mk

This file was deleted.

0 comments on commit edfd392

Please sign in to comment.