Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

reenable building of mongo c/cxx drivers #7218

Merged
merged 8 commits into from
Apr 26, 2019
20 changes: 10 additions & 10 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ steps:
ln -s "$(pwd)" /data/job
cd /data/job
echo "+++ Building :hammer:"
./scripts/eosio_build.sh -y -P
./scripts/eosio_build.sh -y -P -m
echo "--- Compressing build directory :compression:"
tar -pczf build.tar.gz build
if [[ ! -f build.tar.gz ]]; then echo 'ERROR: No build.tar.gz artifact found!' && exit 1; fi
Expand All @@ -60,7 +60,7 @@ steps:
- command: | # Amazon Linux 2 Build
echo "+++ :hammer: Building"
./scripts/eosio_build.sh -y -P
./scripts/eosio_build.sh -y -P -m
echo "--- :compression: Compressing build directory"
tar -pczf build.tar.gz build
if [[ ! -f build.tar.gz ]]; then echo 'ERROR: No build.tar.gz artifact found!' && exit 1; fi
Expand All @@ -83,7 +83,7 @@ steps:
- command: | # CentOS 7 Build
echo "+++ :hammer: Building"
./scripts/eosio_build.sh -y -P
./scripts/eosio_build.sh -y -P -m
echo "--- :compression: Compressing build directory"
tar -pczf build.tar.gz build
if [[ ! -f build.tar.gz ]]; then echo 'ERROR: No build.tar.gz artifact found!' && exit 1; fi
Expand All @@ -106,7 +106,7 @@ steps:
- command: | # Ubuntu 16.04 Build
echo "+++ :hammer: Building"
./scripts/eosio_build.sh -y -P
./scripts/eosio_build.sh -y -P -m
echo "--- :compression: Compressing build directory"
tar -pczf build.tar.gz build
if [[ ! -f build.tar.gz ]]; then echo 'ERROR: No build.tar.gz artifact found!' && exit 1; fi
Expand All @@ -129,7 +129,7 @@ steps:
- command: | # Ubuntu 18.04 Build
echo "+++ :hammer: Building"
./scripts/eosio_build.sh -y -P
./scripts/eosio_build.sh -y -P -m
echo "--- :compression: Compressing build directory"
tar -pczf build.tar.gz build
if [[ ! -f build.tar.gz ]]; then echo 'ERROR: No build.tar.gz artifact found!' && exit 1; fi
Expand Down Expand Up @@ -190,7 +190,7 @@ steps:
region: "us-west-2"
docker#v2.1.0:
debug: true
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:amazonlinux2_2-3"
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:amazonlinux2_2-2"
propagate-environment: true
workdir: /data/job
timeout: 60
Expand Down Expand Up @@ -233,7 +233,7 @@ steps:
region: "us-west-2"
docker#v2.1.0:
debug: true
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:centos7_2-3"
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:centos7_2-2"
propagate-environment: true
workdir: /data/job
timeout: 60
Expand Down Expand Up @@ -276,7 +276,7 @@ steps:
region: "us-west-2"
docker#v2.1.0:
debug: true
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu16_2-3"
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu16_2-2"
propagate-environment: true
workdir: /data/job
timeout: 60
Expand Down Expand Up @@ -319,7 +319,7 @@ steps:
region: "us-west-2"
docker#v2.1.0:
debug: true
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu18_2-3"
image: "436617320021.dkr.ecr.us-west-2.amazonaws.com/ci:ubuntu18_2-2"
propagate-environment: true
workdir: /data/job
timeout: 60
Expand Down Expand Up @@ -382,7 +382,7 @@ steps:
./scripts/serial-test.sh
label: ":darwin: Mojave NP Tests"
agents:
- "role=tester-v2-2"
- "role=tester-v2-1"
- "os=mojave"
timeout: 60
Expand Down
42 changes: 10 additions & 32 deletions plugins/mongo_db_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,22 @@ if(BUILD_MONGO_DB_PLUGIN)

if (libmongoc-1.0_FOUND)

# EOS has no direct dependencies on libmongoc but its shared libraries
# will need to be present at runtime for the C++ libraries we use:
# libbsoncxx & libmongocxx (both from github.com/mongodb/mongo-cxx-driver)

# The *.cmake package files provided by mongo-cxx-driver don't give us the
# absolute path to the libraries, which is needed whenever they are not
# installed in system-known locations. CMake requires the absolute paths
# in target_link_libraries() since we are builiding an archive and the
# link step for all executables using this archive must include the
# mongo-cxx-driver libraries libmongocxx and libbsoncxx.

find_package(libbsoncxx-static REQUIRED)
message(STATUS "Found bsoncxx headers: ${LIBBSONCXX_STATIC_INCLUDE_DIRS}")
find_library(EOS_LIBBSONCXX "libbsoncxx-static${CMAKE_STATIC_LIBRARY_SUFFIX}" PATHS ${LIBBSONCXX_STATIC_LIBRARY_DIRS})
larryk85 marked this conversation as resolved.
Show resolved Hide resolved

# mongo-cxx-driver 3.2 release altered LIBBSONCXX_LIBRARIES semantics. Instead of library names,
# it now hold library paths.
if((LIBBSONCXX_STATIC_VERSION_MAJOR LESS 3) OR ((LIBBSONCXX_STATIC_VERSION_MAJOR EQUAL 3) AND (LIBBSONCXX_STATIC_VERSION_MINOR LESS 2)))
find_library(EOS_LIBBSONCXX ${LIBBSONCXX_STATIC_LIBRARIES}
PATHS ${LIBBSONCXX_STATIC_LIBRARY_DIRS} NO_DEFAULT_PATH)
else()
set(EOS_LIBBSONCXX ${LIBBSONCXX_STATIC_LIBRARIES})
endif()
find_package(libmongocxx-static REQUIRED)
find_library(EOS_LIBMONGOCXX "libmongocxx-static${CMAKE_STATIC_LIBRARY_SUFFIX}" PATHS ${LIBMONGOCXX_STATIC_LIBRARY_DIRS})
larryk85 marked this conversation as resolved.
Show resolved Hide resolved

message(STATUS "Found bsoncxx library: ${EOS_LIBBSONCXX}")
find_package(libmongoc-static-1.0 REQUIRED)
find_library(EOS_LIBMONGOC "libmongoc-static-1.0${CMAKE_STATIC_LIBRARY_SUFFIX}" PATHS ${LIBMONGOC_STATIC_LIBRARY_DIRS})
larryk85 marked this conversation as resolved.
Show resolved Hide resolved

find_package(libmongocxx-static REQUIRED)
message(STATUS "Found mongocxx headers: ${LIBMONGOCXX_STATIC_INCLUDE_DIRS}")
find_package(libbson-static-1.0 REQUIRED)
find_library(EOS_LIBBSONC "libbson-static-1.0${CMAKE_STATIC_LIBRARY_SUFFIX}" PATHS ${LIBBSON_STATIC_LIBRARY_DIRS})
larryk85 marked this conversation as resolved.
Show resolved Hide resolved

# mongo-cxx-driver 3.2 release altered LIBBSONCXX_LIBRARIES semantics. Instead of library names,
# it now hold library paths.
if((LIBMONGOCXX_STATIC_VERSION_MAJOR LESS 3) OR ((LIBMONGOCXX_STATIC_VERSION_MAJOR EQUAL 3) AND (LIBMONGOCXX_STATIC_VERSION_MINOR LESS 2)))
find_library(EOS_LIBMONGOCXX ${LIBMONGOCXX_STATIC_LIBRARIES}
PATHS ${LIBMONGOCXX_STATIC_LIBRARY_DIRS} NO_DEFAULT_PATH)
else()
set(EOS_LIBMONGOCXX ${LIBMONGOCXX_STATIC_LIBRARIES})
if(NOT EOS_LIBBSONCXX OR NOT EOS_LIBMONGOCXX OR NOT EOS_LIBMONGOC OR NOT EOS_LIBBSONC)
message(FATAL_ERROR "Could not find one or more mongo driver static libraries")
endif()

message(STATUS "Found mongocxx library: ${EOS_LIBMONGOCXX}")
else()
message("Could NOT find MongoDB. mongo_db_plugin with MongoDB support will not be included.")
return()
Expand All @@ -64,7 +42,7 @@ if(BUILD_MONGO_DB_PLUGIN)

target_link_libraries(mongo_db_plugin
PUBLIC chain_plugin eosio_chain appbase
${EOS_LIBMONGOCXX} ${EOS_LIBBSONCXX}
${EOS_LIBMONGOCXX} ${EOS_LIBBSONCXX} ${EOS_LIBMONGOC} ${EOS_LIBBSONC} resolv
)

else()
Expand Down
2 changes: 1 addition & 1 deletion scripts/eosio_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ if [ "$ARCH" == "Darwin" ]; then
export OS_NAME=MacOSX
# opt/gettext: cleos requires Intl, which requires gettext; it's keg only though and we don't want to force linking: https://github.com/EOSIO/eos/issues/2240#issuecomment-396309884
# HOME/lib/cmake: mongo_db_plugin.cpp:25:10: fatal error: 'bsoncxx/builder/basic/kvp.hpp' file not found
LOCAL_CMAKE_FLAGS="-DCMAKE_PREFIX_PATH=/usr/local/opt/gettext;$HOME/lib/cmake ${LOCAL_CMAKE_FLAGS}"
LOCAL_CMAKE_FLAGS="-DCMAKE_PREFIX_PATH=/usr/local/opt/gettext;$PREFIX ${LOCAL_CMAKE_FLAGS}"
FILE="${REPO_ROOT}/scripts/eosio_build_darwin.sh"
OPENSSL_ROOT_DIR=/usr/local/opt/openssl
fi
Expand Down
144 changes: 69 additions & 75 deletions scripts/eosio_build_amazon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ DISK_AVAIL_KB=$( df . | tail -1 | awk '{print $4}' )
DISK_TOTAL=$(( DISK_TOTAL_KB / 1048576 ))
DISK_AVAIL=$(( DISK_AVAIL_KB / 1048576 ))

if [ $BUILD_CLANG8 ]; then
PINNED_TOOLCHAIN=-DCMAKE_TOOLCHAIN_FILE=$BUILD_DIR/pinned_toolchain.cmake
fi

DEP_ARRAY=(
git procps-ng util-linux gcc gcc-c++ autoconf automake libtool make bzip2 \
bzip2-devel openssl-devel gmp-devel libstdc++ libcurl-devel libusbx-devel \
Expand Down Expand Up @@ -110,18 +114,6 @@ fi

printf "\\n"

### clean up force build before starting
if [ $FORCE_BUILD ];then
rm -rf \
${SRC_LOCATION}/cmake-$CMAKE_VERSION \
${SRC_LOCATION}/llvm ${OPT_LOCATION}/llvm4 \
${TMP_LOCATION}/clang8 ${OPT_LOCATION}/clang8 \
${SRC_LOCATION}/zlib ${OPT_LOCATION}/zlib \
${SRC_LOCATION}/boost \
${SRC_LOCATION}/mongodb-linux-x86_64-amazon-$MONGODB_VERSION \
${SRC_LOCATION}/mongo-c-driver-$MONGO_C_DRIVER_VERSION \
${SRC_LOCATION}/mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION
fi

printf "Checking CMAKE installation...\\n"
if [ ! -e $CMAKE ] || [ $FORCE_BUILD ]; then
Expand All @@ -144,8 +136,7 @@ if [ $? -ne 0 ]; then exit -1; fi

printf "\\n"


if [ $PIN_COMPILER ]; then
if $PIN_COMPILER; then
printf "Checking Clang 8 support...\\n"
if [ ! -d $CLANG8_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing Clang 8...\\n"
Expand Down Expand Up @@ -257,67 +248,6 @@ else

printf "\\n"

if [ $BUILD_MONGO ]; then
printf "Checking MongoDB installation...\\n"
if [ ! -d $MONGODB_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB into ${MONGODB_ROOT}...\\n"
curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& tar -xzf mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& mv $SRC_LOCATION/mongodb-linux-x86_64-amazon-$MONGODB_VERSION $MONGODB_ROOT \
&& touch $MONGODB_LOG_LOCATION/mongod.log \
&& rm -f mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \
&& mkdir -p $MONGODB_DATA_LOCATION \
&& rm -rf $MONGODB_LINK_LOCATION \
&& rm -rf $BIN_LOCATION/mongod \
&& ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \
&& ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \
|| exit 1
printf " - MongoDB successfully installed @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n"
else
printf " - MongoDB found with correct version @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "Checking MongoDB C driver installation...\\n"
if [ ! -d $MONGO_C_DRIVER_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB C driver...\\n"
curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
&& tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
&& cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \
&& mkdir -p cmake-build \
&& cd cmake-build \
&& $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON .. \
&& make -j"${JOBS}" \
&& make install \
&& cd ../.. \
&& rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
|| exit 1
printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n"
else
printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "Checking MongoDB C++ driver installation...\\n"
if [ ! -d $MONGO_CXX_DRIVER_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB C++ driver...\\n"
curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
&& tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \
&& cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION/build \
&& $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX .. \
&& make -j"${JOBS}" VERBOSE=1 \
&& make install \
&& cd ../.. \
&& rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
|| exit 1
printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
else
printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi

printf "\\n"
fi

printf "Checking LLVM 4 support...\\n"
if [ ! -d $LLVM_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing LLVM 4...\\n"
Expand All @@ -341,6 +271,70 @@ else
printf "\\n"
fi

if [ $BUILD_MONGO ]; then
printf "Checking MongoDB installation...\\n"
if [ ! -d $MONGODB_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB into ${MONGODB_ROOT}...\\n"
curl -OL https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& tar -xzf mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& mv $SRC_LOCATION/mongodb-linux-x86_64-amazon-$MONGODB_VERSION $MONGODB_ROOT \
&& touch $MONGODB_LOG_LOCATION/mongod.log \
&& rm -f mongodb-linux-x86_64-amazon-$MONGODB_VERSION.tgz \
&& cp -f $REPO_ROOT/scripts/mongod.conf $MONGODB_CONF \
&& mkdir -p $MONGODB_DATA_LOCATION \
&& rm -rf $MONGODB_LINK_LOCATION \
&& rm -rf $BIN_LOCATION/mongod \
&& ln -s $MONGODB_ROOT $MONGODB_LINK_LOCATION \
&& ln -s $MONGODB_LINK_LOCATION/bin/mongod $BIN_LOCATION/mongod \
|| exit 1
printf " - MongoDB successfully installed @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n"
else
printf " - MongoDB found with correct version @ ${MONGODB_ROOT} (Symlinked to ${MONGODB_LINK_LOCATION}).\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "Checking MongoDB C driver installation...\\n"
if [ ! -d $MONGO_C_DRIVER_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB C driver...\\n"
curl -LO https://github.com/mongodb/mongo-c-driver/releases/download/$MONGO_C_DRIVER_VERSION/mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
&& tar -xzf mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
&& cd mongo-c-driver-$MONGO_C_DRIVER_VERSION \
&& mkdir -p cmake-build \
&& cd cmake-build \
&& $CMAKE -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX -DENABLE_BSON=ON -DENABLE_SSL=OPENSSL -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF -DENABLE_STATIC=ON -DENABLE_ICU=OFF $PINNED_TOOLCHAIN .. \
&& make -j"${JOBS}" \
&& make install \
&& cd ../.. \
&& rm mongo-c-driver-$MONGO_C_DRIVER_VERSION.tar.gz \
|| exit 1
printf " - MongoDB C driver successfully installed @ ${MONGO_C_DRIVER_ROOT}.\\n"
else
printf " - MongoDB C driver found with correct version @ ${MONGO_C_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi
printf "Checking MongoDB C++ driver installation...\\n"
if [ ! -d $MONGO_CXX_DRIVER_ROOT ] || [ $FORCE_BUILD ]; then
printf "Installing MongoDB C++ driver...\\n"
curl -L https://github.com/mongodb/mongo-cxx-driver/archive/r$MONGO_CXX_DRIVER_VERSION.tar.gz -o mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
&& tar -xzf mongo-cxx-driver-r${MONGO_CXX_DRIVER_VERSION}.tar.gz \
&& cd mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION \
&& sed -i 's/"maxAwaitTimeMS", count/"maxAwaitTimeMS", static_cast<int64_t>(count)/' src/mongocxx/options/change_stream.cpp \
&& sed -i 's/add_subdirectory(test)//' src/mongocxx/CMakeLists.txt src/bsoncxx/CMakeLists.txt \
&& cd build \
&& $CMAKE -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX $PINNED_TOOLCHAIN .. \
&& make -j"${JOBS}" VERBOSE=1 \
&& make install \
&& cd ../.. \
&& rm -f mongo-cxx-driver-r$MONGO_CXX_DRIVER_VERSION.tar.gz \
|| exit 1
printf " - MongoDB C++ driver successfully installed @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
else
printf " - MongoDB C++ driver found with correct version @ ${MONGO_CXX_DRIVER_ROOT}.\\n"
fi
if [ $? -ne 0 ]; then exit -1; fi

printf "\\n"
fi

function print_instructions() {
return 0
}
Loading