Build against the rocksdb of the distribution
Like collocatordb, which no longer needs a rocksdb 5.11 built from source.
The build asked for librocksdb.a unconditionally, which distributions that
package rocksdb do not necessarily ship; only a static dereko2vec really needs
it, otherwise any rocksdb will do. CI installs librocksdb-dev instead of
building rocksdb twice.
ccache is guarded the same way as in derekovecs: it only makes the build
faster, so a missing ccache must not stop the pipeline at --show-stats.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Change-Id: I17ca8cfb3b092ccc646db3ff84c88f2c4391f068
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 217eccf..5ea23b7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -31,35 +31,20 @@
- start_section install_linux_packages "Installing missing Linux packages"
- mkdir -pv $APT_CACHE_DIR ccache
- - apt-get update && apt-get -o dir::cache::archives="$APT_CACHE_DIR" -y install ccache cmake libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev libomp-dev
- - ln -s $(which ccache) /usr/local/sbin/gcc
- - ln -s $(which ccache) /usr/local/sbin/g++
+ - apt-get update && apt-get -o dir::cache::archives="$APT_CACHE_DIR" -y install ccache cmake librocksdb-dev libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev libomp-dev
+ # ccache only makes the build faster, it must never be able to make it fail,
+ # so everything that uses it is guarded and CCACHE_OPTS stays empty without it
+ - if CCACHE=$(command -v ccache); then ln -sf "$CCACHE" /usr/local/sbin/gcc && ln -sf "$CCACHE" /usr/local/sbin/g++ && CCACHE_OPTS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"; else echo "ccache is not available - building without it"; CCACHE_OPTS=""; fi
- end_section install_linux_packages
- - start_section install_rocksdb_static "Building and installing rocksdb-static"
- - git clone --branch 5.11.fb https://github.com/kupietz/rocksdb.git
- - cd rocksdb
- - export PROCS=$(nproc)
- - make -j $PROCS static_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
- - ccache --show-stats
- - make install-static DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
- - end_section install_rocksdb_static
-
- - start_section install_rocksdb_shared "Building and installing rocksdb-shared"
- - make -j $PROCS shared_lib DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
- - make install-shared DISABLE_WARNING_AS_ERROR=1 WARNING_FLAGS=-w
- - ldconfig
- - cd ..
- - end_section rocksdb_shared
-
- start_section install_collocatordb "Building and installing collocatordb"
- git clone "https://korap.ids-mannheim.de/gerrit/ids-kl/collocatordb"
- cd collocatordb
- mkdir -p build
- cd build
- - cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache ..
+ - cmake $CCACHE_OPTS ..
- make
- - ccache --show-stats
+ - command -v ccache > /dev/null && ccache --show-stats || true
- make install # && ctest --extra-verbose
- ldconfig
- end_section install_collocatordb
@@ -70,9 +55,9 @@
- pwd
- mkdir build
- cd build
- - cmake -DSTATIC_DEREKO2VEC=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache ..
- - make || (cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache .. && make)
- - ccache --show-stats
+ - cmake -DSTATIC_DEREKO2VEC=ON $CCACHE_OPTS ..
+ - make || (cmake $CCACHE_OPTS .. && make)
+ - command -v ccache > /dev/null && ccache --show-stats || true
- ctest --extra-verbose
- end_section build_dereko2vec
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3baa2d4..f6faee7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,10 +19,17 @@
message(FATAL_ERROR "No libcollocatordb_static.a found. Please install from https://korap.ids-mannheim.de/gerrit/plugins/gitiles/private/collocatordb")
endif ()
-find_library(ROCKSDB librocksdb.a REQUIRED)
-if (NOT ROCKSDB)
- message(FATAL_ERROR "No librocksdb.a found. Please install like suggested here https://korap.ids-mannheim.de/gerrit/plugins/gitiles/private/collocatordb#install-rocksdb-and-prerequisites")
+# No version pin, so that the rocksdb of the distribution can be used. A static
+# build needs the static library, otherwise a shared one will do as well.
+if (STATIC_DEREKO2VEC)
+ find_library(ROCKSDB librocksdb.a REQUIRED)
+else ()
+ find_library(ROCKSDB NAMES rocksdb REQUIRED)
endif ()
+if (NOT ROCKSDB)
+ message(FATAL_ERROR "No rocksdb found. Install the rocksdb development package of your distribution, e.g. librocksdb-dev or rocksdb-devel.")
+endif ()
+message(STATUS "Using RocksDB library ${ROCKSDB}")
file(GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/src/*.c)
foreach (mysourcefile ${APP_SOURCES})