Skip to content

Commit

Permalink
dragonboat: added preliminary support for FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
lni committed Sep 24, 2019
1 parent 54fa282 commit 017284e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 21 deletions.
51 changes: 30 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Dragonboat is known to work on -
# Linux AMD64, Linux ARM64, MacOS and FreeBSD AMD64
# only Linux AMD64 is officially supported
OS := $(shell uname)
# the location of this Makefile
PKGROOT=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
Expand All @@ -32,25 +35,17 @@ GOCMD=go
LOGDB_TAG=dragonboat_no_rocksdb
else ifeq ($(DRAGONBOAT_LOGDB),)
$(info using rocksdb based log storage)
# set the variables below to tell the Makefile where to find
# rocksdb libs and includes, e.g. /usr/local/lib and /usr/local/include
# tested rocksdb version -
# rocksdb 5.13.x
# very briefly tested -
# rocksdb 5.15.10, 5.16.6, 5.17.2 and 6.0.2
ROCKSDB_MAJOR_VER=5
ROCKSDB_MINOR_VER=13
ROCKSDB_PATCH_VER=4
ROCKSDB_VER ?= $(ROCKSDB_MAJOR_VER).$(ROCKSDB_MINOR_VER).$(ROCKSDB_PATCH_VER)

ifeq ($(OS),Darwin)
ROCKSDB_SO_FILE=librocksdb.$(ROCKSDB_MAJOR_VER).dylib
ROCKSDB_SO_FILE=librocksdb.dylib
else ifeq ($(OS),Linux)
ROCKSDB_SO_FILE=librocksdb.so.$(ROCKSDB_MAJOR_VER)
ROCKSDB_SO_FILE=librocksdb.so
else ifeq ($(OS),FreeBSD)
ROCKSDB_SO_FILE=librocksdb.so
else
$(error OS type $(OS) not supported)
endif

# RocksDB version 5 or 6 are required
ROCKSDB_INC_PATH ?=
ROCKSDB_LIB_PATH ?=
# figure out where is the rocksdb installation
Expand All @@ -74,6 +69,7 @@ ifneq ($(wildcard /usr/local/lib/$(ROCKSDB_SO_FILE)),)
ifneq ($(wildcard /usr/local/include/rocksdb/c.h),)
$(info rocksdb lib found at /usr/local/lib/$(ROCKSDB_SO_FILE))
ROCKSDB_LIB_PATH=/usr/local/lib
ROCKSDB_INC_PATH=/usr/local/include
endif
endif
endif
Expand All @@ -89,11 +85,11 @@ CDEPS_LDFLAGS=-L$(ROCKSDB_LIB_PATH) -lrocksdb
endif

ifneq ($(ROCKSDB_INC_PATH),)
CGO_CXXFLAGS=CGO_CFLAGS="-I$(ROCKSDB_INC_PATH)"
CGO_CFLAGS=CGO_CFLAGS="-I$(ROCKSDB_INC_PATH)"
endif

CGO_LDFLAGS=CGO_LDFLAGS="$(CDEPS_LDFLAGS)"
GOCMD=$(CGO_LDFLAGS) $(CGO_CXXFLAGS) go
GOCMD=$(CGO_LDFLAGS) $(CGO_CFLAGS) go
else
$(error LOGDB type $(DRAGONBOAT_LOGDB) not supported)
endif
Expand Down Expand Up @@ -161,6 +157,19 @@ rebuild-all: clean unit-test-bin
# download and install rocksdb
###############################################################################
LIBCONF_PATH=/etc/ld.so.conf.d/usr_local_lib.conf
# set the variables below to tell the Makefile which version of rocksdb you
# want to install. rocksdb v5.13.4 is the version we used in production, it is
# used here as the default, feel free to change to the version number you like
#
# tested rocksdb version -
# rocksdb 5.13.x
# very briefly tested -
# rocksdb 5.15.10, 5.16.6, 5.17.2 and 6.0.2
ROCKSDB_MAJOR_VER=5
ROCKSDB_MINOR_VER=13
ROCKSDB_PATCH_VER=4
ROCKSDB_VER ?= $(ROCKSDB_MAJOR_VER).$(ROCKSDB_MINOR_VER).$(ROCKSDB_PATCH_VER)

RDBTMPDIR=$(PKGROOT)/build/rocksdbtmp
RDBURL=https://github.com/facebook/rocksdb/archive/v$(ROCKSDB_VER).tar.gz
build-rocksdb: get-rocksdb make-rocksdb
Expand Down Expand Up @@ -336,9 +345,8 @@ snapshot-benchmark-test:
###############################################################################
# build slow tests
###############################################################################
# build slow tests, this is invoked for every push
# we can't afford to run all these tests that are known to be slow, but we can
# check whether the push fails the build
# build slow tests, we can't afford to run all these tests that are known to be
# slow, but we can check whether the push fails the build
slow-multiraft: TESTTAGVALS+=$(MULTIRAFT_SLOW_TEST_BUILDTAGS)
slow-multiraft:
$(GOTEST) $(BUILD_TEST_ONLY) $(PKGNAME)
Expand All @@ -361,6 +369,8 @@ ifeq ($(OS),Darwin)
SANITIZER_FLAGS ?= -fsanitize=address -fsanitize=undefined
else ifeq ($(OS),Linux)
SANITIZER_FLAGS ?= -fsanitize=address -fsanitize=leak
else ifeq ($(OS),FreeBSD)
SANITIZER_FLAGS ?= -fsanitize=address -fsanitize=leak
else
$(error OS type $(OS) not supported)
endif
Expand Down Expand Up @@ -449,11 +459,10 @@ PLUGIN_CPP_EXAMPLE_BIN=dragonboat-cpp-plugin-example.so
ifeq ($(OS),Darwin)
CPPTEST_LDFLAGS=-bundle -undefined dynamic_lookup \
-Wl,-install_name,$(PLUGIN_CPP_EXAMPLE_BIN)
CPPKVTEST_LDFLAGS=-bundle -undefined dynamic_lookup \
-Wl,-install_name,$(PLUGIN_CPP_KVTEST_BIN)
else ifeq ($(OS),Linux)
CPPTEST_LDFLAGS=-shared -Wl,-soname,$(PLUGIN_CPP_EXAMPLE_BIN)
CPPKVTEST_LDFLAGS=-shared -Wl,-soname,$(PLUGIN_CPP_KVTEST_BIN)
else ifeq ($(OS),FreeBSD)
CPPTEST_LDFLAGS=-shared -Wl,-soname,$(PLUGIN_CPP_EXAMPLE_BIN)
else
$(error OS type $(OS) not supported)
endif
Expand Down
19 changes: 19 additions & 0 deletions internal/logdb/kv/rocksdb/kv_rocksdb_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2017-2019 Lei Ni ([email protected]) and other Dragonboat authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package rocksdb

func directIOSupported(dir string) bool {
return false
}

0 comments on commit 017284e

Please sign in to comment.