Skip to content

Commit 6ef9202

Browse files
committed
Backport changes to upgrade snappy
1 parent b482410 commit 6ef9202

File tree

9 files changed

+65
-185
lines changed

9 files changed

+65
-185
lines changed

.eqc-info

-5.74 KB
Binary file not shown.

.github/workflows/erlang.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v2
2121
- name: Compile
22-
run: ./rebar3 compile
23-
- name: Run xref and dialyzer
24-
run: ./rebar3 do xref, dialyzer
25-
- name: Run eunit
26-
run: ./rebar3 do eunit
22+
run: apt-get update && apt-get install -y cmake && make
23+
- name: Run tests
24+
run: apt-get update && apt-get install -y cmake libc6-dev && make check

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ c_src/system
1414
_build
1515
.DS_Store
1616
rebar.lock
17+
snappy-*.tar.gz

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
.PHONY: compile rel cover test dialyzer
1+
.PHONY: compile rel cover test dialyzer get-deps
22
REBAR=./rebar3
33

4-
compile:
4+
all: compile
5+
6+
get-deps:
7+
$(REBAR) get-deps
8+
9+
compile: get-deps
510
$(REBAR) compile
611

712
clean:
@@ -11,6 +16,7 @@ cover: test
1116
$(REBAR) cover
1217

1318
test: compile
19+
$(MAKE) -C c_src test
1420
$(REBAR) as test do eunit
1521

1622
dialyzer:

c_src/Makefile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
LEVELDB_VSN ?= "2.0.38"
2+
SNAPPY_VSN ?= "1.1.9"
3+
BASEDIR = $(shell pwd)
4+
5+
LDFLAGS := $(LDFLAGS) -L$(BASEDIR)/system/lib
6+
LD_LIBRARY_PATH := $(BASEDIR)/system/lib:$(LD_LIBRARY_PATH)
7+
CFLAGS := $(CFLAGS) -I $(BASEDIR)/system/include -I. -I $(BASEDIR)/leveldb/include -fPIC
8+
CXXFLAGS := $(CXXFLAGS) -I $(BASEDIR)/system/include -I. -I $(BASEDIR)/leveldb/include -fPIC
9+
10+
get-deps:
11+
if [ ! -r snappy-$(SNAPPY_VSN).tar.gz ]; then \
12+
wget -O snappy-$(SNAPPY_VSN).tar.gz https://github.com/google/snappy/archive/refs/tags/$(SNAPPY_VSN).tar.gz; \
13+
fi
14+
if [ ! -d leveldb ]; then \
15+
git clone https://github.com/basho/leveldb && \
16+
(cd leveldb && git checkout $(LEVELDB_VSN)) && \
17+
(cd leveldb && git submodule update --init); \
18+
fi
19+
20+
compile: get-deps snappy ldb
21+
cp leveldb/perf_dump leveldb/sst_rewrite leveldb/sst_scan leveldb/leveldb_repair ../priv
22+
23+
ldb:
24+
$(MAKE) LDFLAGS="$(LDFLAGS) -lsnappy" LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)" -C leveldb all
25+
$(MAKE) LDFLAGS="$(LDFLAGS) -lsnappy" LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)" -C leveldb tools
26+
27+
snappy: system/lib/libsnappy.a
28+
29+
system/lib/libsnappy.a:
30+
tar -xzf snappy-$(SNAPPY_VSN).tar.gz && \
31+
(cd snappy-$(SNAPPY_VSN) && \
32+
git submodule update --init && \
33+
if [ -r autogen.sh ]; then \
34+
./autogen.sh && ./configure --prefix=$(BASEDIR)/system && make && make install; \
35+
else \
36+
mkdir build && cd build && \
37+
mkdir -p $(BASEDIR)/system && \
38+
cmake -D SNAPPY_BUILD_TESTS=0 -D SNAPPY_BUILD_BENCHMARKS=0 \
39+
-D CMAKE_INSTALL_PREFIX=$(BASEDIR)/system \
40+
..; \
41+
fi && \
42+
make && make install)
43+
mv system/lib64 system/lib || true
44+
45+
clean:
46+
$(MAKE) -C leveldb clean
47+
rm -rf system snappy-$(SNAPPY_VSN)/build
48+
49+
test: compile
50+
$(MAKE) CXXFLAGS="$(CXXFLAGS) -Wno-narrowing" LDFLAGS="$(LDFLAGS) -lsnappy -lpthread" LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)" -C leveldb test

c_src/build_deps.sh

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

c_src/snappy-1.0.4.tar.gz

-1.6 MB
Binary file not shown.

rebar.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
{"DRV_LDFLAGS", "$DRV_LDFLAGS c_src/leveldb/libleveldb.a c_src/system/lib/libsnappy.a -lstdc++"}
3131
]}.
3232

33-
{pre_hooks, [{'get-deps', "c_src/build_deps.sh get-deps"},
34-
{compile, "c_src/build_deps.sh"}]}.
33+
{pre_hooks, [{'get-deps', "make -C c_src get-deps"},
34+
{compile, "make -C c_src compile"}]}.
3535

36-
{post_hooks, [{clean, "c_src/build_deps.sh clean"}]}.
36+
{post_hooks, [{clean, "make -C c_src clean"}]}.

tools.mk

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

0 commit comments

Comments
 (0)